-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] OTA Job notification isn't received #117
Comments
Are you saying that your subscribe calls fails? Or the subscribe succeeds and you do not get a notification? |
Thank you for your response, Actually I thought I was subscribed but since I don't get the notification I tried to add the subscription manually. That's why I think I'm missing something. |
@Fienberber, the demo doesn't actively subscribe to the MQTT topic. See the jobs docs on AWS. Clients are sent the messages from the broker even when they are not subscribed to it. To that end, the demos 'inject' an OTA handler which handles unsolicited publishes. Thus, any topics not handled by coreMQTT-Agent (or manager) will be passed on to the OTA handler which verifies whether the job topic matches with what is expected and processes it. You should not need to process the OTA events yourself. The OTA task should do that on its own by calling Thanks |
Hi @AniruddhaKanhere thank you for you response. I enabled every level of logs for MQTT in the menuconfig. But I see no publish when I create a remote job on the AWS control panel. The OTA handler doesn't get anything either. The task seem to running since it works properly at startup. Or am I mistaken ? |
Can you try to add a log here to dump |
Hi @Fienberber , |
@fjuliofontes why do you need to call the Can you please add a breakpoint there and check whether that line is hit and the step through to figure out why isn't that message sent/processed? |
Also, can you try creating the job before running the code on the device? @Fienberber and @fjuliofontes can you both please try the above? |
I'm not actually calling, it's during bootup that the function get's called. I was just pointing that it's the only way for the job to start, rebooting. |
Thank you, as I described above the OTA will start at bootup if the job is already created. By the way, the compiler was giving a warning about a falling-through on this line and I've added a break there. Best regards, |
Hello @AniruddhaKanhere thank you for your response.
As @fjuliofontes said, if the Job was created before the software start, it will work. At init the OTA is polled once. The issue happen when the software is running and a job is send from AWS.
I've added the log, I've already done it, and didn't saw anything anormal. Software startup
I can try other things if necessary. |
@Fienberber, thank you for that debug log. Can you try to add the following line here: switch( recvEventId )
{
+ case OtaAgentEventStart:
case OtaAgentEventRequestJobDocument:
ESP_LOGI( TAG, "Request Job Document event Received \n" );
requestJobDocumentHandler();
otaAgentState = OtaAgentStateRequestingJob;
break; I think that would fix the issue as the OTA task calls the |
@AniruddhaKanhere thank you for your response. Unfortunately, it doesn't change anything. The |
@Fienberber, I am not sure why doesn't these lines do not call Can you please put a breakpoint there? The As far as topic subscription is considered, the Jobs topic is a special topic to which IoT core publishes even without subscription as I highlighted above here. Thanks for your patience. |
@AniruddhaKanhere tank you for your response. I've put a break point, actually it loops only 3 times, It it waiting for an event here. The two previous events are : But then it is just waiting for an event it never gets... I don't know if it's expected but when |
Ah! I see the issue now. Can you please make the following change here? /* Temp buffer.*/
uint8_t buff[ sizeof( OtaEventMsg_t ) ];
- retVal = xQueueReceive( otaEventQueue, &buff, portMAX_DELAY );
+ retVal = xQueueReceive( otaEventQueue, &buff, 10000 );
if( retVal == pdTRUE ) The above should allow the loop to break in absence of any event. That way, when the OTA job is started, the device will ping IoT core. Thank you for your patience as we try to figure out the core issue. Thanks! |
Hi @AniruddhaKanhere, thank you, It did the trick ! I want to keep using the 202406.01-LTS-release so I made some quick modification to the example static OtaEvent_t lastRecvEventIdBeforeSuspend = OtaAgentEventStart;
OtaEventMsg_t nextEvent = { 0 };
- OtaReceiveEvent_FreeRTOS( &recvEvent );
+ {
+ EventGroupHandle_t eventGroup = xEventGroupCreate();
+ BlockingTaskParams taskParams = {
+ .eventGroup = eventGroup,
+ .recvEvent = &recvEvent
+ };
+ TaskHandle_t blockingTaskHandle;
+ // Create the blocking task
+ xTaskCreate(OtaReceiveEvent_FreeRTOS_InTask, "OtaReceiveEvent_FreeRTOS_InTask", otaconfigOTA_TASK_STACK_SIZE, &taskParams, otaconfigOTA_TASK_PRIORITY, &blockingTaskHandle);
+
+ // Wait for completion or timeout
+ EventBits_t result = xEventGroupWaitBits(eventGroup, TASK_COMPLETED_BIT, pdTRUE, pdFALSE, pdMS_TO_TICKS(TIMEOUT_MS));
+
+ if (result & TASK_COMPLETED_BIT) {
+ // Blocking function completed in time
+ } else {
+ // Timeout occurred, handle error
+ ESP_LOGI( TAG, "No events during timeout, ping IoT core." );
+ vTaskDelete(blockingTaskHandle);
+ }
+
+ // Ensure cleanup of the event group after usage
+ vEventGroupDelete(eventGroup);
+ }
recvEventId = recvEvent.eventId; In addition to // Structure to pass multiple parameters to the blocking task
typedef struct {
EventGroupHandle_t eventGroup;
OtaEventMsg_t * recvEvent;
} BlockingTaskParams;
void OtaReceiveEvent_FreeRTOS_InTask(void *params) {
BlockingTaskParams *taskParams = (BlockingTaskParams *)params;
EventGroupHandle_t eventGroup = taskParams->eventGroup;
// Call of the blocking when no events function
OtaReceiveEvent_FreeRTOS( taskParams->recvEvent );
// If function returns before timeout, signal completion
xEventGroupSetBits(eventGroup, TASK_COMPLETED_BIT);
vTaskDelete(NULL); // Delete this task when done
} |
@Fienberber, your solution works indeed. But do note that creating a deleting a task is very resource intensive. That is why I suggested that you make the change xQueueReceive() call instead. We are working on adding this change in the upstream repo. Thank you for your patience. |
@AniruddhaKanhere The changes you mentioned did not work. The timeout prints the following message. |
@jvasanthan, my above suggested changes are to be used with the previous changes mentioned here. When both of these changes are made, then only OTA works. Let me know if that helps |
@AniruddhaKanhere after making those 2 changes, it works. Thankyou. |
I'm migrating from to the esp-aws-iot [202406.01-LTS] from [202210.01-LTS].
The previous integration was working properly so I know this is not an AWS issue.
Using the OTA example, I can start OTA's using polling. Using the
requestJobDocumentHandler();
by sending an event atOtaAgentEventRequestJobDocument
.But previously I was subscribed to
$aws/things/+/jobs/#
, which notified when OTA where available.I don't want to use polling to start an OTA. But I don't achieve subscription to the jobs topic.
I think I'm missing a critical part of the example. Because it seems like it doesn't subscribe to the
$aws/things/+/jobs/#
topic.The text was updated successfully, but these errors were encountered: