Unverified Commit c8da793c authored by Sanket Wadekar's avatar Sanket Wadekar Committed by GitHub

Fixes to Rainmaker OTA Issues (#7324)

* Added OTA Event Handlers

* Overrided verifyRollbackLater Method
Co-authored-by: default avatarRodrigo Garcia <rodrigo.garcia@espressif.com>
parent e01f175d
......@@ -6,6 +6,8 @@
bool wifiLowLevelInit(bool persistent);
static esp_err_t err;
extern "C" bool verifyRollbackLater() { return true; }
static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
{
if (event_base == RMAKER_EVENT) {
......@@ -25,6 +27,33 @@ static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_
default:
log_i("Unhandled RainMaker Event:");
}
} else if (event_base == RMAKER_OTA_EVENT) {
if(event_data == NULL){
event_data = (void*)"";
}
switch(event_id) {
case RMAKER_OTA_EVENT_STARTING:
log_i("Starting OTA : %s", (char*)event_data);
break;
case RMAKER_OTA_EVENT_IN_PROGRESS:
log_i("OTA in progress : %s", (char*)event_data);
break;
case RMAKER_OTA_EVENT_SUCCESSFUL:
log_i("OTA Successful : %s", (char*)event_data);
break;
case RMAKER_OTA_EVENT_FAILED:
log_i("OTA Failed : %s", (char*)event_data);
break;
case RMAKER_OTA_EVENT_DELAYED:
log_i("OTA Delayed : %s", (char*)event_data);
break;
case RMAKER_OTA_EVENT_REJECTED:
log_i("OTA Rejected : %s", (char*)event_data);
break;
default:
log_i("Unhandled OTA Event");
break;
}
}
}
......@@ -39,6 +68,7 @@ Node RMakerClass::initNode(const char *name, const char *type)
Node node;
esp_rmaker_node_t *rnode = NULL;
esp_event_handler_register(RMAKER_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL);
esp_event_handler_register(RMAKER_OTA_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL);
rnode = esp_rmaker_node_init(&rainmaker_cfg, name, type);
if (!rnode){
log_e("Node init failed");
......@@ -104,9 +134,11 @@ esp_err_t RMakerClass::enableTZService()
esp_err_t RMakerClass::enableOTA(ota_type_t type, const char *cert)
{
esp_rmaker_ota_config_t ota_config;
ota_config.server_cert = cert;
ota_config.ota_cb = NULL;
esp_rmaker_ota_config_t ota_config = {
.ota_cb = NULL,
.ota_diag = NULL,
.server_cert = cert,
};
err = esp_rmaker_ota_enable(&ota_config, type);
if(err != ESP_OK) {
log_e("OTA enable failed");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment