aws / amazon-freertos-ble-android-sdk

Android SDK for FreeRTOS Bluetooth Devices.
Apache License 2.0
49 stars 41 forks source link

ESP32 wifi provisioning #44

Closed sherindeena closed 3 years ago

sherindeena commented 3 years ago

I am using ESP32 DevkitC as IoT thing. Also, I am using the app from amazon-freertos-ble-android-sdk/app at master · aws/amazon-freertos-ble-android-sdk (github.com). My intention is to do WiFi provisioning of ESP32 using BLE. The android app lists the ESP32 device. And it prompts for bluetooth pairing as well. But after that I am not able to see the next options to do network config. I am using Android version 9 on the phone. Attaching the screenshot of the android app.

In android studio I could see this error in logcat: 2021-06-23 17:34:43.253 911-1084/software.amazon.freertos.demo D/com.amazonaws.request: Received error response: com.amazonaws.services.iot.model.InvalidRequestException: Empty Target (Service: null; Status Code: 400; Error Code: InvalidRequestException; Request ID: 94c40124-4070-423c-a250-522e47d30f41) 2021-06-23 17:34:43.256 911-1084/software.amazon.freertos.demo E/AuthActivity: Exception caught: com.amazonaws.services.iot.model.InvalidRequestException: Empty Target (Service: AWSIot; Status Code: 400; Error Code: InvalidRequestException; Request ID: 94c40124-4070-423c-a250-522e47d30f41) at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:730) at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:405) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212) at com.amazonaws.services.iot.AWSIotClient.invoke(AWSIotClient.java:9226) at com.amazonaws.services.iot.AWSIotClient.attachPolicy(AWSIotClient.java:589) at software.amazon.freertos.demo.AuthenticatorActivity.signinsuccessful(AuthenticatorActivity.java:116) at software.amazon.freertos.demo.AuthenticatorActivity.access$000(AuthenticatorActivity.java:24) at software.amazon.freertos.demo.AuthenticatorActivity$2.run(AuthenticatorActivity.java:68) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.os.HandlerThread.run(HandlerThread.java:65) 2021-06-23 17:34:43.300 911-967/software.amazon.freertos.demo D/AWS4Signer: AWS4 Canonical Request: '"PUT /target-policies/mypolicy

Also attaching full logcat. app_screen logcat.txt

ravibhagavandas commented 3 years ago

Hi @sherindeena

Did you enable WiFi provisioning demo on ESP32 device by setting the flag #define IOT_BLE_ENABLE_WIFI_PROVISIONING ( 1 ) in iot_ble_config.h as described here: https://docs.aws.amazon.com/freertos/latest/userguide/ble-demo.html#ble-demo-wifi

Also, from the error logs in android logcat it seems it fails to attach policy for cognito correctly. Did you make sure to create the IoT policy and configure the policy name in file DemConstants.java? Detailed steps for this can be found under section To configure the Android SDK demo application here.

ravibhagavandas commented 3 years ago

Hi @sherindeena

Is your problem resolved? Can this issue be closed?

ravibhagavandas commented 3 years ago

I will close this issue due to inactivity. Please open a new issue if you have any questions.