Issues with Android RTOS SDK

ISSUE 1: I am having an issue where my bluetooth connection does not appear to be clearing and preventing me from making another connection so I can get a list of SSID’s. This is an issue with the amazon-freertos-ble-android-sdk. I am attaching my code in a gist below so you can see the React Native calls as well as where it makes it into the calls for the native modules.

ISSUE 2: I am also having an issue where the connect to wifi is taking time, it is located in the code below as well.

Code:

Look at the following lines to follow what it is doing for the first (included WifiProvisioningNative.ts as reference):
Issue 1:
ConnectToWifi.tsx. line 54 and 91
WifiProvisioningNative.java. line 246

Issue 2:
ConnectToWifi.tsx. line 72 then lines 146-159 depending on the event emitted
WifiProvisioningNative.java: line 158+

Let me know what other info I can provide but I would prefer either a video conference call or a chat to go over what could be the issue.

Hi,

Could you provide more information on following:

  1. Board used as the BLE peripheral.
  2. Version or commit iD of FreeRTOS android BLE SDK you are running.
  3. Version of FreeRTOS running.

ISSUE 1
I was not able reproduce this behavior on the latest FreeRTOS android SDK app and FreeRTOS latest master on an ESP32 platform. Could you provide steps to reproduce the issue ?

The disconnect you mentioned, was it a peripheral initiated disconnect or you disconnected from the app? I can see from your application code that for peripheral initiated disconnects, the DISCONNECT callback will be invoked at WifiProvisioningNative.java line 234, but no action is performed as part of it. So the bluetooth device object will continue to be in reconnect mode as the autoreconnect flag is set to true.

For user initiated disconnects: mAmazonFreeRTOSManager.disconnectFromDevice(mDevice); at line 249 will disconnect from peripheral and also set autoreconnect mode to false since its user initiated termination. Its good to set mDevice = null after that to avoid the disconnected object from reused.

At WifiProvisioningNative.java line 161 you update mDevice to a bluetooth device based on mac address passed into the function. So the mDevice could be changed at this point, if there are multiple devices, then you may not be disconnecting the right device form disconnectAppliances().

ISSUE 2: I am also having an issue where the connect to wifi is taking time, it is located in the code below as well.

What point of the connect network flow is taking time? Is it time from a save network request is sent to device and save network response is received on app ? What’s approximate time taken ? Since the connect network also waits for receiving an IP address on device, it can take ~30 seconds to receive the response. Could you also share the peripheral logs when request was sent ?

Thanks.

Hello,

  1. Board used as the BLE peripheral.
    • we are using a ESP32
  2. Version or commit iD of FreeRTOS android BLE SDK you are running.
    • aws-iot-device-sdk-v2 v1.2.1 which looks like the latest
  3. Version of FreeRTOS running.
    • amazon freertos release (July 2020) - ESP-IDF release/v3.3.2

So with the disconnect and connect issue should I just set autoReconnect to false? I think that will cause me issues then if during the scan for wifi networks it disconnects I will have to force them to reconnect. I am disconnecting using the app when I am done with connecting to wifi. I guess what is your suggestion for the correct way to connect and disconnect, I will make those changes and test to see if the issue stops. What action should I be taking in the disconnect because when I did that it was called over and over again so I did not have enough trust to use it.

For Issue 2, I am seeing the scan for wifi taking about 20+ seconds on both my app as well as the AWS test app in android. I guess if this is just what it takes we will have to live with it but just wanted to see if from any of my code I was maybe doing something incorrect.

When I set this all up I had to basically just look at the code in the SDK as the documentation is pretty much no help, it just says here are 4 methods but no explanation of how to interact with it or what the best practices are for use. If there is something I am missing or a better way to get the list of SSID’s I am all for changing it.

Let me know if any of this helps and if you have any suggestions or tips to make this work better. For now I will set the auto reconnect on line 241 to be false.

John

Hello,

As an update I tried setting mDevice to null in the mAmazonFreeRTOSManager.disconnectFromDevice(mDevice); and that did not seem to have any effect, it just seems like something with RTOS is holding on to a connection the second time I ask for the list of SSID’s, if I kill the app it all works fine again.

Let me know if you have any other ideas of what it could be as well as if there is any way to speed up getting the list of SSID’s.

John

So with the disconnect and connect issue should I just set autoReconnect to false?

Setting autoReconnect to false will not let the app reconnect in case RTOS device disconnects from app, for example a WiFi network is connected and FreeRTOS device disconnects from Bluetooth. So autoReconnect is nice to have in cases where app needs to connect again.
But please note that the app won’t reconnect even if in autoReconnect mode and user manually disconnects from the device through the app.

So I would like to know if its the FreeRTOS device which disconnected from app and app is executing an auto-reconnect in background. If so the second connection attempt from user, will not do anything as an auto reconnect is already ongoing in background. Could you also post the FreeRTOS device side logs at the time of the issue?

I am seeing the scan for wifi taking about 20+ seconds on both my app as well as the AWS test app in android

Could you post the FreeRTOS device side logs for this issue as well?