Closed rrivadeneira-rsc closed 4 years ago
Hello, @rrivadeneira-rsc . As a first trouble-shooting step, will your OTA update succeed if you configure the ESP32 device to connect via WiFi?
Hello @rrivadeneira-rsc. I tried the OTA demo configuring my ESP32 to connect via WiFi. The few OTA Jobs I had created previously to test the proxy were taken by the ESP32 device and completed (jobs failed because I had my old thing name for the firmware loaded via OTA). I then created another OTA Job with this firmware and incremented the version - that OTA Job was successful.
Here are the steps I took to configure my setup:
For the sake of troubleshooting, I'll get the right thing name into the firmware that has only BLE enabled and connect via the proxy to see if the OTA succeeds under the firmware that has WiFi enabled.
I have tried what I mentioned below:
3 4022 [iot_thread] [INFO ][DEMO][40220] State: RequestingJob Received: 0 Queued: 0 Processed: 0 Dropped: 0
34 4122 [iot_thread] [INFO ][DEMO][41220] State: WaitingForJob Received: 0 Queued: 0 Processed: 0 Dropped: 0
(...)
46 5322 [iot_thread] [INFO ][DEMO][53220] State: WaitingForJob Received: 0 Queued: 0 Processed: 0 Dropped: 0 47 5422 [iot_thread] [INFO ][DEMO][54220] State: WaitingForJob Received: 0 Queued: 0 Processed: 0 Dropped: 0
48 5424 [Tmr Svc] [prvSelfTestTimer_Callback] Self test failed to complete within 16000ms ets Jun 8 2016 00:22:57
For further reference, these are the topics the device is subscribing to for the jobs and how it is connecting as:
Firmware with WiFi enabled:
8 270 [iot_thread] [INFO ][DEMO][2700] MQTT demo client identifier is esp32-ble (length 9). 20 726 [OTA Agent Task] [prvSubscribeToJobNotificationTopics] OK: $aws/things/esp32-ble/jobs/$next/get/accepted 24 735 [OTA Agent Task] [prvSubscribeToJobNotificationTopics] OK: $aws/things/esp32-ble/jobs/notify-next
Firmware with BLE enabled:
11 3597 [iot_thread] [INFO ][DEMO][35970] MQTT demo client identifier is esp32-ble (length 9). 22 3888 [OTA Agent Task] [prvSubscribeToJobNotificationTopics] OK: $aws/things/esp32-ble/jobs/$next/get/accepted 27 3951 [OTA Agent Task] [prvSubscribeToJobNotificationTopics] OK: $aws/things/esp32-ble/jobs/notify-next
Hi @rrivadeneira-rsc. Thank you for your patience. This issue has been forwarded to the OTA team, and we are currently looking for a fix.
@rrivadeneira-rsc
I tried to reproduce your scenario but couldn't. I tried with steps as follows:
Setup:
OTA:
Test was done using FreeRTOS release 202007.00- 4e8219e and Android SDK 1.2.0-acfb4bc.
Could you check if the steps you executed were same ? Also what BLE pairing is enabled between mobile app and the device ? Please note that you don't need to detach the certificates from the thing for the mqtt proxy to work.
@ravibhagavandas thank you for trying this! I appreciate the thorough test.
I see there are differences between our setups. From the guide you provided, there is this step under "To set up AWS IoT" that I also saw on the guide I was using:
- If you are connecting your microcontroller to the cloud through a mobile device, choose Create thing without certificate. Because the Mobile SDKs use Amazon Cognito for device authentication, you do not need to create a device certificate for demos that use Bluetooth Low Energy. If you are connecting your microcontroller to the cloud directly over Wi-Fi, choose Create certificate, choose Activate, and then download the thing's certificate, public key, and private key.
Thus, I did not configure a certificate or private key for the device's client credentials, nor I attached a certificate to the thing created on AWS for the OTA demo using BLE. What I was expecting is that when I sent the OTA Jib to my thing on AWS, is that the proxy connected would take that update and run it to my device, but it is not doing that. So, the setup and OTA I was expecting to test is the following: Setup:
OTA:
Additionally, I tried the same steps on your OTA section, as I explained above, but with the difference that I detached the certificate before connecting the device via BLE, so as to replicate my setup with the OTA demo with BLE configured above. My steps to run the OTA demo over WiFi and trying to update with the OTA demo that uses BLE were the following: Setup:
OTA:
To test the OTA demo with WiFi, I understand that I do need to provide a certificate and private key on my device configuration, as well as attach that certificate to my thing on AWS for it to connect successfully. However, I am looking for the case where both firmware applications are configured to run the OTA demo with BLE and where, as the guide said, I do not need certificates attached to my thing created. So that when I connect my mobile app with my device, an OTA job is taken and runs as expected, completes download, and then when the new image boots up for self-test, the mobile app and device connect, and the demo will find that pending job and complete self-test. self-test succeeds and takes the new imagine I get to once again connect my mobile app with my device and complete the self-test.
Would you be able to check if my steps give you the same result or you are able to run the OTA Job successfully?
I was using FreeRTOS version: 202007.00-86-g549f7d17f and, Android SDK mobile app version: v1.1.0-10-ge5a23e5
Let me know if I should be doing something different. Thank you so much again for your time!
@rrivadeneira-rsc
I think this could be the issue:
In the blog post which you are referring to, under step 3 of AWS Cognito Configuration the policy for authenticate cognito identity is missing permissions iot:Receive
which allows receiving packets via cognito in self test mode. I followed the same step from this doc, which adds that permission, so I was not getting that error.For testing, I removed the permission from my cognito authenticated identity policy and I was able to reproduce the same behavior.
Could you add the permission by following these steps and check ?
"iot:Receive"
under "Action" : [
list.@ravibhagavandas - I see! That makes a lot of sense. I will make sure to note that.
I have added the iot:Receive
permission to my policy for my cognito identity. I flashed the OTA demo configured for BLE and issued an OTA Job with also the OTA demo configured for BLE (just a version up) - OTA Job succeeded as expected. Thank you so much for your help with this!
Closing this issue as it has been resolved. Thank you for your patience! Please feel free to reach out again anytime.
Describe the bug I have tried to following guide to perform OTA updates using BLE + MQTT Proxy through the pass-through example app and FreeRTOS OTA Demo. However, it does not seem that the OTA Job created makes it through the device's demo queue (device is in WaitingForJob state) as expected.
One thing to note is that I'm not using the provided OTA script ran through python, as I already have my own setup. I have my code-signing profile, OTA service role and policies, and IAM user and policies. Instead, I am using the Create Job (Create OTA update job) wizard that creates it with the firmware file I provide.
Is the issue that the MQTT Proxy is not telling the device there is a job in the queue? Am I missing additional steps? Please advice.
System information
git describe --tags
to find it) -202007.00-86-g549f7d17f
Code to reproduce the bug
.Expected behavior From this guide, I would expect the job to go through the device's demo queue and start the OTA update process.
Screenshots or console output I am seeing the job successfully created on AWS in the state of QUEUED. Additionally, I see the notify and notify-next appropriate topics (
$aws/things/esp32-ble/jobs/notify
and$aws/things/esp32-ble/jobs/notify-next
) populate with my create job information. For instanceAnd device has started the demo, connected to the broker, but still on a WaitingForJob state, as well as it does not show any change on the received, queue, processed or dropped items
To reproduce Follow through this guide, but instead create the OTA Job through the Create Job wizard on AWS. In short:
State: WaitingForJob Received: 0 Queued: 0 Processed: 0 Dropped: 0
Code to reproduce the bug FreeRTOS OTA demo as is (with the changes depicted above to enable BLE only, get the broker to connect to, thing name to match what was created on IoT, and add the code-signed certificate) and the Android FreeRTOS SDK app with the appropriate Cognito and IoT Policy information to set up the MQTT Proxy.
Additional context Again, I am not using the start_ota.py script, because I already have the information I need to go through the FreeRTOS OTA job creation process in AWS. Let me know if there is a step I am missing to successfully test this demo/example.
Thank you!