main/ims_ota.c
/*
 * A task to perform OTA update and restart on success. On fail, return to normal program
 */
A task to perform OTA update and restart on success. On fail, return to normal program
A task to perform OTA update and restart on success . On fail return to normal program
void ota_start_task ( void *pvParameter ){
    globalPtrs = (globalptrs_t *) pvParameter;
    int res = ota_run();
	if( res == SUCCESS ){
		ESP_LOGI(TAG, "OTA successful");
		xEventGroupClearBits( globalPtrs->system_event_group, FW_UPDATING); 
		xEventGroupSetBits( globalPtrs->system_event_group, FW_UPDATE_SUCCESS );
		esp_restart();
	}
	else if( res == CRITICAL_FAIL ){
		ESP_LOGE(TAG, "OTA critical fail");
		xEventGroupClearBits( globalPtrs->system_event_group, FW_UPDATING); 
		xEventGroupSetBits( globalPtrs->system_event_group, FW_UPDATE_CRITICAL_FAIL );
		esp_restart();
	}
	else {
		ESP_LOGE(TAG, "OTA fail");
		xEventGroupClearBits( globalPtrs->system_event_group, FW_UPDATING); 
		xEventGroupSetBits( globalPtrs->system_event_group, FW_UPDATE_FAIL );
		esp_restart();	
	}
	(void)vTaskDelete(NULL);
}
void ota_start_task ( void * pvParameter ) { globalPtrs = ( globalptrs_t * ) pvParameter ; int res = ota_run ( ) ; if ( res == SUCCESS ) { ESP_LOGI ( TAG , " " ) ; xEventGroupClearBits ( globalPtrs -> system_event_group , FW_UPDATING ) ; xEventGroupSetBits ( globalPtrs -> system_event_group , FW_UPDATE_SUCCESS ) ; esp_restart ( ) ; } else if ( res == CRITICAL_FAIL ) { ESP_LOGE ( TAG , " " ) ; xEventGroupClearBits ( globalPtrs -> system_event_group , FW_UPDATING ) ; xEventGroupSetBits ( globalPtrs -> system_event_group , FW_UPDATE_CRITICAL_FAIL ) ; esp_restart ( ) ; } else { ESP_LOGE ( TAG , " " ) ; xEventGroupClearBits ( globalPtrs -> system_event_group , FW_UPDATING ) ; xEventGroupSetBits ( globalPtrs -> system_event_group , FW_UPDATE_FAIL ) ; esp_restart ( ) ; } ( void ) vTaskDelete ( NULL ) ; }
A task to perform OTA update and restart on success.
A task to perform OTA update and restart on success .
//start OTA //inform other tasks that update was successful //inform other tasks that update failed //inform other tasks that update failed //TODO: do not restart on non-critical fail such as no connection. Implement later if gui used instead of web interface