Problem running FreeRTOS BLE demo app on Nordic nRF52840-DK with Android

HansW121 wrote on September 23, 2019:

HI

I am trying to run the BLE FreeRTOS demo with the Nordic nRF52840-DK reference HW and the Android phone.

https://docs.aws.amazon.com/freertos/latest/userguide/ble-demo.html#ble-demo-mqtt

Running the Nordic code I get the following output:

0 0 [iot_thread] [INFO ][DEMO][0] ---------STARTING DEMO---------

The RAM must start at 200046f8, it’s size must be 3b908
1 0 [iot_thread] [INFO ][INIT][0] SDK successfully initialized.
2 2 [iot_thread] [INFO ][DEMO][20] No networks connected for the demo. Waiting for a network connection.
3 10957 [BLE] [ERROR][BLE_HAL][109570] sd_ble_gattc_exchange_mtu_request() on connection 0x0 returned busy, will retry.
4 10957 [BLE] [INFO ][DEMO][109570] BLE Connected to remote device, connId = 0

5 10957 [iot_thread] [INFO ][DEMO][109570] Successfully initialized the demo. Network type for the demo: 2
6 10957 [iot_thread] [INFO ][MQTT][109570] MQTT library successfully initialized.
7 10957 [iot_thread] [INFO ][DEMO][109570] MQTT demo client identifier is ADI_BLE_Demo_Thing (length 18).
8 10998 [InputTask] Numeric comparison:328071
9 10998 [InputTask] Press ‘y’ to confirm
y
10 13957 [iot_thread] [ERROR][NET_BLE][139570] Failed to create BLE network connection after 30000 milliseconds.
11 13957 [iot_thread] [ERROR][MQTT][139570] Failed to establish new MQTT connection, error NETWORK ERROR.
12 13957 [iot_thread] [ERROR][DEMO][139570] MQTT CONNECT returned error NETWORK ERROR.
13 13957 [iot_thread] [INFO ][MQTT][139570] MQTT library cleanup done.
14 13957 [iot_thread] [ERROR][DEMO][139570] Error running demo.
15 13957 [iot_thread] [INFO ][INIT][139570] SDK cleanup done.
16 13957 [iot_thread] [INFO ][DEMO][139570] -------DEMO FINISHED-------

17 13995 [BLE] [ERROR][BLE_HAL][139950] Failed to secure connection. Disconnecting.
18 13997 [BLE] [INFO ][DEMO][139970] BLE disconnected with remote device, connId = 0

19 13997 [BLE] [ERROR][DEMO][139970] Failed to create subscription task for network: 2, state: 1, error:
20 31967 [BLE] [ERROR][BLE_HAL][319670] UNKNOWN BLE EVENT 38.

Running the app on android I get the following output:

C:\Users\hans_\backup\AWS\Nordic\amazon-freertos-ble-android-sdk-master\amazon-freertos-ble-android-sdk-master\app>gradlew installDebug

02:20:22 V/ddms: execute: running am get-config
02:20:24 V/ddms: execute ‘am get-config’ on ‘42001d8dc23283b3’ : EOF hit. Read: -1
02:20:24 V/ddms: execute: returning
Installing APK ‘app-debug.apk’ on ‘SAMSUNG-SM-J320A - 6.0.1’ for app:debug
02:20:24 D/app-debug.apk: Uploading app-debug.apk onto device ‘42001d8dc23283b3’
02:20:24 D/Device: Uploading file onto device ‘42001d8dc23283b3’
02:20:24 D/ddms: Reading file permision of C:\Users\hans_\backup\AWS\Nordic\amazon-freertos-ble-android-sdk-master\amazon-freertos-ble-android-sdk-master\app\build\outputs\apk\debug\app-debug.apk as: rwx------
02:20:25 V/ddms: execute: running pm install -r -t “/data/local/tmp/app-debug.apk”
02:20:40 V/ddms: execute ‘pm install -r -t “/data/local/tmp/app-debug.apk”’ on ‘42001d8dc23283b3’ : EOF hit. Read: -1
02:20:40 V/ddms: execute: returning
02:20:40 V/ddms: execute: running rm “/data/local/tmp/app-debug.apk”
02:20:40 V/ddms: execute ‘rm “/data/local/tmp/app-debug.apk”’ on ‘42001d8dc23283b3’ : EOF hit. Read: -1
02:20:40 V/ddms: execute: returning
Installed on 1 device.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use ‘–warning-mode all’ to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 22s
27 actionable tasks: 1 executed, 26 up-to-date
C:\Users\hans_\backup\AWS\Nordic\amazon-freertos-ble-android-sdk-master\amazon-freertos-ble-android-sdk-master\app>

I try to pair the nRF5 bluetooth device on my android but it does not seem like that succeeds. When the Segger Studio serial terminal emulator asks for the bluetooth connection

8 2904 [InputTask] Numeric comparison:614809
9 2904 [InputTask] Press ‘y’ to confirm"Press ‘y’ to confirm

I try to type in the ‘y’ character, but it does not seem to have any effect.

I am not really sure what is going wrong? Does anyone have an idea on this?
Thanks.

ravishankar-AWS wrote on September 25, 2019:

Hi @HansW121

Thanks for trying the demo. Segger Studio serial terminal emulator does not support input terminal so, you cant type in y/n from the terminal.

Could you trying opening terminal such as “Tera Term” or “Putty” at the same time of running the application and press y/n from this ?

Let us know how it goes.

Edited by: ravishankar-AWS on Sep 25, 2019 2:59 PM

TimLai wrote on September 26, 2019:

Hi all,
I have the same question!
It’s my log on Putty below:

0 0 [iot_thread] [INFO ][DEMO][0] ---------STARTING DEMO---------

1 0 [iot_thread] [INFO ][INIT][0] SDK successfully initialized.
2 2 [iot_thread] [INFO ][DEMO][20] No networks connected for the demo. Waiting f or a network connection.
3 4138 [BLE] [ERROR][BLE_HAL][41380] sd_ble_gattc_exchange_mtu_request() on conn ection 0x0 returned busy, will retry.
4 4138 [BLE] [INFO ][DEMO][41380] BLE Connected to remote device, connId = 0

5 4138 [iot_thread] [INFO ][DEMO][41380] Successfully initialized the demo. Netw ork type for the demo: 2
6 4138 [iot_thread] [INFO ][MQTT][41380] MQTT library successfully initialized.
7 4138 [iot_thread] [INFO ][DEMO][41380] MQTT demo client identifier is nRF52840 DK-01 (length 13).
8 4188 [InputTask] Numeric comparison:747144
9 4188 [InputTask] Press ‘y’ to conf irm
y10 4511 [InputTask] Key accepted
11 7139 [iot_thread] [ERROR][NET_BLE][71390] Failed to create BLE network connection after 30000 milliseconds.
12 7139 [iot_thread] [ERROR][MQTT][71390] Failed to establish new MQTT connection, error NETWORK ERROR.
13 7139 [iot_thread] [ERROR][DEMO][71390] MQTT CONNECT returned error NETWORK ERROR.
14 7139 [iot_thread] [INFO ][MQTT][71390] MQTT library cleanup done.
15 7139 [iot_thread] [ERROR][DEMO][71390] Error running demo.
16 7139 [iot_thread] [INFO ][INIT][71390] SDK cleanup done.
17 7139 [iot_thread] [INFO ][DEMO][71390] -------DEMO FINISHED-------

18 7185 [BLE] [ERROR][BLE_HAL][71850] Failed to secure connection. Disconnecting.
19 7191 [BLE] [INFO ][DEMO][71910] BLE disconnected with remote device, connId = 0

20 7191 [BLE] [ERROR][DEMO][71910] Failed to create subscription task for network: 2, state: 1, error:

When I press ‘y’ on Putty I get ‘[InputTask] Key accepted’.
but Android APP UI does not show ‘Bluetooth Pairing request’

[https://drive.google.com/file/d/1_6CLLT1ItfRUGdbXGOZyYaLn8UIlhhNi/view?usp=sharing https://drive.google.com/file/d/1LILoTwLoDLaXOAF52ig8ox1HIwQQte0D/view?usp=sharing]

ravishankar-AWS wrote on September 26, 2019:

Could you provide following details ?

  1. Which version of Android do you use on phone?
  2. Which version of FreeRTOS mobile SDK and which version of Amazon FreeRTOS do you run ?

Additionally could you post the logs on the Android device ?

Also please check if there is a stale bond created on the phone. To check this Close the App, Goto Settings->Connected Devices->Previously connected-devices. Check for the FreeRTOS device name in the list. Click on “Settings” button on right side and delete the bond.
Rerun the demo on both device and phone and reinitiate the paring procedure.

Please post with above the information if the issue still prevails.