Hi all,
Im' tryint to acheive a aws fota firmware update on my custom nRF9151 board but I'm stuck. Here is my setup and what working
- Custom board build with a nRF9151 -> work
- Use MQTT over AWS with my custom board publich, receive -> work (using softsim onomondo)
With this setup I'm able to connect to LTE and to AWS iot core and send receive MQTT messages. I have a specific policy in aws for my things, and it's working.
So now here what I've try, in my prj.conf I've added :
CONFIG_DOWNLOAD_CLIENT=y CONFIG_DFU_TARGET=y CONFIG_FOTA_DOWNLOAD=y CONFIG_AWS_FOTA=y CONFIG_AWS_FOTA_PAYLOAD_SIZE=1350
Coming from nrf doc and some thread. in my main I've added
static void aws_iot_event_handler(const struct aws_iot_evt *const evt)
{
switch (evt->type) {
case AWS_IOT_EVT_CONNECTING:
LOG_INF("AWS_IOT_EVT_CONNECTING");
break;
case AWS_IOT_EVT_CONNECTED:
LOG_INF("AWS_IOT_EVT_CONNECTED");
on_aws_iot_evt_connected(evt);
break;
case AWS_IOT_EVT_DISCONNECTED:
LOG_INF("AWS_IOT_EVT_DISCONNECTED");
on_aws_iot_evt_disconnected();
break;
case AWS_IOT_EVT_DATA_RECEIVED:
LOG_INF("AWS_IOT_EVT_DATA_RECEIVED");
handle_received_topic(evt);
break;
case AWS_IOT_EVT_PUBACK:
LOG_INF("AWS_IOT_EVT_PUBACK, message ID: %d", evt->data.message_id);
break;
case AWS_IOT_EVT_PINGRESP:
LOG_INF("AWS_IOT_EVT_PINGRESP");
break;
case AWS_IOT_EVT_FOTA_START:
LOG_INF("AWS_IOT_EVT_FOTA_START");
break;
case AWS_IOT_EVT_FOTA_ERASE_PENDING:
LOG_INF("AWS_IOT_EVT_FOTA_ERASE_PENDING");
break;
case AWS_IOT_EVT_FOTA_ERASE_DONE:
LOG_INF("AWS_FOTA_EVT_ERASE_DONE");
break;
case AWS_IOT_EVT_FOTA_DONE:
LOG_INF("AWS_IOT_EVT_FOTA_DONE");
on_aws_iot_evt_fota_done(evt);
break;
case AWS_IOT_EVT_FOTA_DL_PROGRESS:
LOG_INF("AWS_IOT_EVT_FOTA_DL_PROGRESS, (%d%%)", evt->data.fota_progress);
break;
case AWS_IOT_EVT_ERROR:
LOG_INF("AWS_IOT_EVT_ERROR, %d", evt->data.err);
FATAL_ERROR();
break;
case AWS_IOT_EVT_FOTA_ERROR:
LOG_INF("AWS_IOT_EVT_FOTA_ERROR");
break;
default:
LOG_INF("Unknown AWS IoT event type: %d", evt->type);
break;
}
}
and
static void on_aws_iot_evt_fota_done(const struct aws_iot_evt *const evt)
{
int err;
/* Tear down MQTT connection. */
(void)aws_iot_disconnect();
(void)k_work_cancel_delayable(&connect_work);
/* If modem FOTA has been carried out, the modem needs to be reinitialized.
* This is carried out by bringing the network interface down/up.
*/
if (evt->data.image & DFU_TARGET_IMAGE_TYPE_ANY_MODEM) {
LOG_INF("Modem FOTA done, reinitializing the modem");
} else if (evt->data.image & DFU_TARGET_IMAGE_TYPE_ANY_APPLICATION) {
LOG_INF("Application FOTA done, rebooting");
IF_ENABLED(CONFIG_REBOOT, (sys_reboot(0)));
} else {
LOG_INF("Unexpected FOTA image type");
}
}
I'm able to build and flash firmware on my board, but with all these setting, I can no longer connect to aws, as soon as I got AWS_IOT_EVT_CONNECTED I got and AWS_IOT_EVT_DISCONNECTED few seconds later, should I add some speficic configuration in my policy ?
EDIT: it's seem when I try to use FOTO config I got an: Timed out waiting for subscription acknowledgments in aws_iot_connect() function, her eis my job if it's usefull
{
"operation": "app_fw_update",
"fwversion": "v1.0.2",
"size": 242388, ->zephyr.bin size
"location": {
"protocol": "protocol",
"host": "my-bucket.s3.XXXXXXXXXX.amazonaws.com",
"path": "zephyr.bin"
}
}
Just to be sure, aws fota with nrf some specific topics or not ? for example $aws/fota/something ? and should fota use shadow ? Because I've a restricted policie, I don't use shadow and I allow only some specific topics for my thing
Ok find it I have to allow $aws/things/name/jobs topics
Thanks