Skip to content
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

Fixes to Rainmaker OTA Issues #7324

Merged
merged 3 commits into from
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions libraries/RainMaker/src/RMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
}
}

Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down