Question on OTA callback (ota_cb_func)
Posted: Sun Aug 16, 2020 11:03 am
Hi,
I'm trying to add callback to the OTA function in the switch example:
And my callback function:
Admittedly, there is very little information documented. I'm really just stabbing in the dark.
When I tried to update OTA, clearly it wouldn't work:
Is there an example callback implementation, or some additional documentation? I'd appreciate it if you can point me to the relevant information.
I'm trying to add callback to the OTA function in the switch example:
- /* Enable OTA */
- esp_rmaker_ota_config_t ota_config = {
- .ota_cb = &ota_cb_func,
- .server_cert = ESP_RMAKER_OTA_DEFAULT_SERVER_CERT,
- };
And my callback function:
- esp_err_t ota_cb_func(esp_rmaker_ota_handle_t handle, esp_rmaker_ota_data_t *ota_data)
- {
- ota_status_t status = OTA_STATUS_IN_PROGRESS;
- char info[1024]="test";
- ESP_LOGW(TAG, "OTA URL: %s\r\n", ota_data->url);
- ESP_LOGW(TAG, "OTA Filesize: %d\r\n", ota_data->filesize);
- ESP_LOGW(TAG, "OTA Status: %d\r\n", status);
- esp_err_t err = esp_rmaker_ota_report_status(handle, status, info); // reports to OTA server
- return err;
- }
Admittedly, there is very little information documented. I'm really just stabbing in the dark.
When I tried to update OTA, clearly it wouldn't work:
- I (5314) app_wifi: Connected with IP Address:192.168.43.42
- I (5314) esp_netif_handlers: sta ip: 192.168.43.42, mask: 255.255.255.0, gw: 192.168.43.70
- I (5314) esp_rmaker_mqtt: Connecting to a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com
- I (5324) esp_rmaker_mqtt: Waiting for MQTT connection. This may take time.
- I (10204) esp_rmaker_mqtt: MQTT Connected
- I (10204) esp_rmaker_node_config: Reporting Node Configuration
- I (10214) esp_rmaker_param: Reporting params: {"Switch":{"name":"Switch","power":true},"ota":{"status":"","info":"","url":""}}
- I (75124) esp_rmaker_param: Received params: {"ota": {"url": "https://esp-rainmaker-ota-315787942180-prod.s3.amazonaws.com/users/c92eda40-6e1d-4762-8f70-a23bc0eb3d5c/firmwareimages/Oba-4qSGR/c%3A%5Cmsys32%5Chome%5Cy.tan%5Cesp%5Cesp-rainmaker%5Ccli%5C..%5Cexamples%5Cswitch%5Cswitch_ota.bin?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAUTBTNTESLTL6K3EK%2F20200816%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200816T105153Z&X-Amz-Expires=86400&X-Amz-Security-Token=FwoGZXIvYXdzEAwaDHzxdypQ84o7NS1gfyK3Afi%2BWy8BFmPXnW%2BHwQyLffp2qHQITsMnT%2BVtWdzTXOr6UC8sh3k64Dcxc3dBBv3i%2Fq%2FNT7tr8QxjxLzh%2FFQzxnOh1AQij7XBH0Var7Qio9iPSnpofvBupA1TnNRoJ9LRrFUqhHHKIsc7G6Z8zvpSMPxFPNz0bOFiu6i8dbqi2Pxkx7ipqt1l7jrdWAGbxB0gUM%2BIa2%2F7Ac4xHt9wt4fvfFmlCCzFoDlSAVmOTs%2FOBCUH5B%2FQa92DWyjJn%2BT5BTIt7%2Fh%2BBsFyt4x%2FkHJJIwlmq21hSkjne7JS%2Fb5T09QiL7ZwI8x5HAGPkCKsUaMI&X-Amz-SignedHeaders=host&X-Amz-Signature=1d5e54dd6b9877cbf11dc75aa64a0c8b8705ba6bbbf8dab00f153522253a60d9"}}
- I (75204) esp_rmaker_ota_using_params: Received value = https://esp-rainmaker-ota-315787942180-prod.s3.amazonaws.com/users/c92eda40-6e1d-4762-8f70-a23bc0eb3d5c/firmwareimages/Oba-4qSGR/c%3A%5Cmsys32%5Chome%5Cy.tan%5Cesp%5Cesp-rainmaker%5Ccli%5C..%5Cexamples%5Cswitch%5Cswitch_ota.bin?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAUTBTNTESLTL6K3EK%2F20200816%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200816T105153Z&X-Amz-Expires=86400&X-Amz-Security-Token=FwoGZXIvYXdzEAwaDHzxdypQ84o7NS1gfyK3Afi%2BWy8BFmPXnW%2BHwQyLffp2qHQITsMnT%2BVtWdzTXOr6UC8sh3k64Dcxc3dBBv3i%2Fq%2FNT7tr8QxjxLzh%2FFQzxnOh1AQij7XBH0Var7Qio9iPSnpofvBupA1TnNRoJ9LRrFUqhHHKIsc7G6Z8zvpSMPxFPNz0bOFiu6i8dbqi2Pxkx7ipqt1l7jrdWAGbxB0gUM%2BIa2%2F7Ac4xHt9wt4fvfFmlCCzFoDlSAVmOTs%2FOBCUH5B%2FQa92DWyjJn%2BT5BTIt7%2Fh%2BBsFyt4x%2FkHJJIwlmq21hSkjne7JS%2Fb5T09QiL7ZwI8x5HAGPkCKsUaMI&X-Amz-SignedHeaders=host&X-Amz-Signature=1d5e54dd6b9877cbf11dc75aa64a0c8b8705ba6bbbf8dab00f153522253a60d9 for ota - url
- W (76224) app_main: OTA URL: https://esp-rainmaker-ota-315787942180-prod.s3.amazonaws.com/users/c92eda40-6e1d-4762-8f70-a23bc0eb3d5c/firmwareimages/Oba-4qSGR/c%3A%5Cmsys32%5Chome%5Cy.tan%5Cesp%5Cesp-rainmaker%5Ccli%5C..%5Cexamples%5Cswitch%5Cswitch_ota.bin?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAUTBTNTESLTL6K3EK%2F20200816%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200816T105153Z&X-Amz-Expires=86400&X-Amz-Security-Token=FwoGZXIvYXdzEAwaDHzxdypQ84o7NS1gfyK3Afi%2BWy8BFmPXnW%2BHwQyLffp2qHQITsMnT%2BVtWdzTXOr6UC8sh3k64Dcxc3dBBv3i%2Fq%2FNT7tr8QxjxLzh%2FFQzxnOh1AQij7XBH0Var7Qio9iPSnpofvBupA1TnNRoJ9LRrFUqhHHKIsc7G6Z8zvpSMPxFPNz0bOFiu6i8dbqi2Pxkx7ipqt1l7jrdWAGbxB0gUM%2BIa2%2F7Ac4xHt9wt4fvfFmlCCzFoDlSAVmOTs%2FOBCUH5B%2FQa92DWyjJn%2BT5BTIt7%2Fh%2BBsFyt4x%2FkHJJIwlmq21hSkjne7JS%2Fb5T09QiL7ZwI8x5HAGPkCKsUaMI&X-Amz-SignedHeaders=host&X-Amz-Signature=1d5e54dd6b9877cbf11dc75aa64a0c8b8705ba6bbbf8dab00f153522253a60d9
- W (76294) app_main: OTA Filesize: 0
- W (76294) app_main: OTA Status: 1
- I (76304) esp_rmaker_param: Reporting params: {"ota":{"info":"test"}}
- I (76314) esp_rmaker_param: Reporting params: {"ota":{"status":"in-progress"}}