static void ota_finished_callback(void *arg) { upgrade_server_info *pUpdate = (upgrade_server_info *)arg; if (pUpdate->upgrade_flag == true) { system_upgrade_reboot(); } else { } }
//OTA reboot function void ICACHE_FLASH_ATTR debug_OtaReboot() { #if ESP_MESH_SUPPORT ESP_DBG("deinit for OTA\r\n"); espconn_mesh_disable(NULL); wifi_station_disconnect(); wifi_set_opmode(NULL_MODE); #endif user_esp_clr_upgrade_finish_flag();//clear flag and reboot system_upgrade_flag_set(UPGRADE_FLAG_FINISH); ESP_DBG("call system upgrade reboot...\r\n"); system_upgrade_reboot(); }
static void ICACHE_FLASH_ATTR ota_finished_callback(void *arg) { struct upgrade_server_info *update = arg; if (update->upgrade_flag == true) { DBG_MSG("[OTA]success; rebooting!\r\n"); system_upgrade_reboot(); } else { DBG_MSG("[OTA]failed! %d - %d\r\n", update->upgrade_flag, system_upgrade_flag_check()); } os_free(update->pespconn); os_free(update->url); os_free(update); }
// Handle request to reboot into the new firmware int ICACHE_FLASH_ATTR cgiRebootFirmware(HttpdConnData *connData) { if (connData->conn==NULL) { //Connection aborted. Clean up. return HTTPD_CGI_DONE; } // TODO: sanity-check that the 'next' partition actually contains something that looks like // valid firmware // This should probably be forked into a separate task that waits a second to let the // current HTTP request finish... system_upgrade_flag_set(UPGRADE_FLAG_FINISH); system_upgrade_reboot(); httpdStartResponse(connData, 200); httpdEndHeaders(connData); return HTTPD_CGI_DONE; }
/****************************************************************************** * FunctionName : user_esp_platform_upgrade_cb * Description : Processing the downloaded data from the server * Parameters : pespconn -- the espconn used to connetion with the host * Returns : none *******************************************************************************/ LOCAL void ICACHE_FLASH_ATTR at_upDate_rsp(void *arg) { struct upgrade_server_info *server = arg; // struct espconn *pespconn = server->pespconn; // uint8 *pbuf = NULL; // char *action = NULL; // char temp[32]; // if(pespconn->proto.tcp != NULL) // { // os_free(pespconn->proto.tcp); // } // os_free(pespconn); if(server->upgrade_flag == true) { // pbuf = (char *) os_zalloc(2048); // ESP_DBG("user_esp_platform_upgarde_successfully\n"); os_printf("device_upgrade_success\r\n"); // action = "device_upgrade_success"; at_backOk; system_upgrade_reboot(); // os_sprintf(pbuf, UPGRADE_FRAME, // devkey, action, // server->pre_version, // server->upgrade_version); // ESP_DBG(pbuf); // espconn_sent(pespconn, pbuf, os_strlen(pbuf)); // if(pbuf != NULL) // { // os_free(pbuf); // pbuf = NULL; // } } else { // ESP_DBG("user_esp_platform_upgrade_failed\n"); os_printf("device_upgrade_failed\r\n"); // action = "device_upgrade_failed"; // os_sprintf(pbuf, UPGRADE_FRAME, devkey, action); // ESP_DBG(pbuf); // os_sprintf(temp, at_backTeError, 1); // uart0_sendStr(at_backTeError"1\r\n"); at_backError; // espconn_sent(pespconn, pbuf, os_strlen(pbuf)); // if(pbuf != NULL) // { // os_free(pbuf); // pbuf = NULL; // } } os_free(server->url); server->url = NULL; os_free(server); server = NULL; // espconn_disconnect(pespconn); specialAtState = TRUE; at_state = at_statIdle; }
int esp_ota_upgrade(void) { os_printf("esp_ota_upgrade \n"); system_upgrade_reboot(); return 0; }