Code Monkey home page Code Monkey logo

Comments (7)

ravibhagavandas avatar ravibhagavandas commented on September 25, 2024

@massi-ang

I tested this with FreeRTOS master branch (latest code) and amazon-freertos-ble-ios-sdk version 1.1.0 on IOS version 13.3.1, but couldn't reproduce the issue.

Could you provide the following information ?

  1. FreeRTOS version or commit ID
  2. amazon-freertos-ble-ios-sdk version
  3. Version of IOS running on your device.

Also, if possible, could you send the app side logs ( by clicking on the Debug button at the top right corner ) and the device side logs ?

from amazon-freertos-ble-ios-sdk.

roberthartman avatar roberthartman commented on September 25, 2024

@ravibhagavandas I am seeing this same issue.

I have to say I am not clear what version of Amazon FreeRTOS is running on the embedded side. It's an ESP32 AmazonFreeRTOS demo that I got running. It is using BLE PIN pairing.

On the iOS side I have iOS 13.2.2, and I'm using the latest SDK version, which currently is v1.1.0.

If I attempt to list networks as soon as I connect, AmazonFreeRTOSManager.listNetworks() fails in the check for the NetworkConfig service/RXNetworkMessage characteristic. I tried putting a delay in my code, after connecting but before calling listNetworks(), and then the failure occurs when listNetworks() calls writeValueToRXMessage(), in the check for whether the mtu is nil: "Mtu unknown".

This is the app output in the former case, where I call listNetworks() immediately after connection:

2020-04-07 07:54:49.505663-0400 uvc[6793:1761847] [AFR][Central] afrCentralManagerDidDiscoverPeripheral: ED9863C5-7496-A775-A816-09F00100017E
UvcProvisioningManager.swift connect(device:) line: 119: Connecting
UvcProvisioningManager.swift subscribeToAfrListener() line: 58: .connected to XARTMAN-ESP32
2020-04-07 07:54:54.728336-0400 uvc[6793:1761847] [AFR][ED9863C5-7496-A775-A816-09F00100017E] afrCentralManagerDidConnectPeripheral
UvcProvisioningManager.swift getNetworks(device:) line: 132: Getting networks
2020-04-07 07:54:54.733464-0400 uvc[6793:1761847] [AFR][ED9863C5-7496-A775-A816-09F00100017E][NETWORK] ↓ ListNetworkReq(maxNetworks: 15, timeout: 30)
2020-04-07 07:54:54.744093-0400 uvc[6793:1761847] [AFR][ED9863C5-7496-A775-A816-09F00100017E][NETWORK][ERROR] NetworkConfig service or RXNetworkMessage characteristic doesn't exist
2020-04-07 07:54:55.145013-0400 uvc[6793:1761847] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get afrVersion
2020-04-07 07:54:55.146024-0400 uvc[6793:1761847] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get brokerEndpoint
2020-04-07 07:54:55.146549-0400 uvc[6793:1761847] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get mtu
2020-04-07 07:54:55.147064-0400 uvc[6793:1761847] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get afrPlatform
2020-04-07 07:54:55.147544-0400 uvc[6793:1761847] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get afrDevId

This is the app output in the latter case, where I delay prior to listNetworks():

2020-04-07 07:42:59.106847-0400 uvc[6781:1758957] [AFR][Central] afrCentralManagerDidDiscoverPeripheral: ED9863C5-7496-A775-A816-09F00100017E
UvcProvisioningManager.swift connect(device:) line: 119: Connecting
UvcProvisioningManager.swift subscribeToAfrListener() line: 58: .connected to XARTMAN-ESP32
2020-04-07 07:43:04.349937-0400 uvc[6781:1758957] [AFR][ED9863C5-7496-A775-A816-09F00100017E] afrCentralManagerDidConnectPeripheral
2020-04-07 07:43:04.769881-0400 uvc[6781:1758957] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get afrVersion
2020-04-07 07:43:04.770874-0400 uvc[6781:1758957] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get brokerEndpoint
2020-04-07 07:43:04.771379-0400 uvc[6781:1758957] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get mtu
2020-04-07 07:43:04.771885-0400 uvc[6781:1758957] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get afrPlatform
2020-04-07 07:43:04.772391-0400 uvc[6781:1758957] [AFR][ED9863C5-7496-A775-A816-09F00100017E] ↓ get afrDevId
UvcProvisioningManager.swift getNetworks(device:) line: 132: Getting networks
2020-04-07 07:43:08.665462-0400 uvc[6781:1758957] [AFR][ED9863C5-7496-A775-A816-09F00100017E][NETWORK] ↓ ListNetworkReq(maxNetworks: 15, timeout: 30)
2020-04-07 07:43:08.677471-0400 uvc[6781:1758957] [AFR][ED9863C5-7496-A775-A816-09F00100017E][ERROR] Mtu unknown

from amazon-freertos-ble-ios-sdk.

massi-ang avatar massi-ang commented on September 25, 2024

@roberthartman
The issue is because ESP32 stores a limited number of bonds using a temporary identifier from the phone. This identifier is rotated every X minutes, and when all the slots are occupied you'll not be able to do a correct pairing with the phone and the issue will appear.

You can do few things to solve this:

  1. use the esp tool to erase the flash on the ESP32 and then reflash the firmware. This is needed as simply reflashing the firmware does not erase the bonding data.
  2. change the configuration to not use secure parameters, so that you'll not be required to pair the ESP32 with the phone. You can do this by changing the code in https://github.com/aws/amazon-freertos/blob/master/libraries/c_sdk/standard/ble/include/iot_ble_config_defaults.h#L172 as follow:
#ifndef IOT_BLE_ENABLE_BONDING
    #define IOT_BLE_ENABLE_BONDING    ( 0)
#endif

/**
 * @brief The flag to enable secure connection for the device.
 *
 * By default secure connection will be enable on all device.
 */
#ifndef IOT_BLE_ENABLE_SECURE_CONNECTION
    #define IOT_BLE_ENABLE_SECURE_CONNECTION    ( 0 )
#endif

/* Config if set, requires encryption to access services and characteristics */

/**
 * @brief Configuration to force encryption to access all characteristics of services.
 */
#ifndef IOT_BLE_ENCRYPTION_REQUIRED
    #define IOT_BLE_ENCRYPTION_REQUIRED    ( 0 )
#endif

from amazon-freertos-ble-ios-sdk.

roberthartman avatar roberthartman commented on September 25, 2024

@massi-ang thanks. I had previously tried to get Just Works pairing working on the ESP32, but without luck. If you happen to know the settings required for that, that would be really helpful, because the eventual production HW will be using Just Works.

I will also try what you suggest with turning off pairing/bonding altogether.

I have used the ESP IDF tools to erase_flash on the board, but I don't recall reconnecting working for a little while afterwards, though maybe I wasn't paying attention. I'll post here once I circle back to this.

from amazon-freertos-ble-ios-sdk.

ravibhagavandas avatar ravibhagavandas commented on September 25, 2024

@massi-ang Thank you for updates on the issue.

While as you suggested, setting
#define IOT_BLE_ENABLE_BONDING ( 0) will turn off the bonding, whereas setting #define IOT_BLE_ENCRYPTION_REQUIRED ( 0 ) will lead to an open unencrypted connection.

The right set of overrides to enable just works pairing is

#define IOT_BLE_ENABLE_NUMERIC_COMPARISON        ( 0 )
#define IOT_BLE_ENABLE_SECURE_CONNECTION         ( 0 )
#define IOT_BLE_INPUT_OUTPUT                     ( eBTIONone )

You can see more details about different modes here.

Also, I recommend you to override these configurations in the demo specific configuration file iot_ble_config.h

from amazon-freertos-ble-ios-sdk.

massi-ang avatar massi-ang commented on September 25, 2024

My understanding is that in order to have an encrypted connection, you need to enable bonding which will cause the issue with the ESP32.

As for the Just Works setup, thanks for providing the correct solution.

from amazon-freertos-ble-ios-sdk.

kstribrnAmzn avatar kstribrnAmzn commented on September 25, 2024

I'm closing this issue as there hasn't been activity in the past two years. Feel free to reopen if an issue persists.

from amazon-freertos-ble-ios-sdk.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.