与APP对接OTA固件升级
This commit is contained in:
@@ -110,11 +110,15 @@ void app_thread(void* arg)
|
||||
strcpy(sertrf_stauct.wifi_sta_ssid, g_cfg_app->app_config_wifi_para.wifi_sta_ssid);
|
||||
strcpy(sertrf_stauct.wifi_sta_password, g_cfg_app->app_config_wifi_para.wifi_sta_password);
|
||||
|
||||
resend_send_data(&sertrf.resend_device, RESEND_CMD_GET_PARAM, &sertrf_stauct, sizeof(sertrf_stauct_t), 100);
|
||||
resend_send_data(&sertrf.resend_device, RESEND_CMD_GET_PARAM, &sertrf_stauct, sizeof(sertrf_stauct_t), 1000);
|
||||
|
||||
sertrf.resend_device.handle_flag = 0;//标志位清零
|
||||
break;
|
||||
case 1:
|
||||
case RESEND_CMD_OTA_GET_PARAM:
|
||||
printf("RESEND_CMD_OTA_GET_PARAM\r\n");
|
||||
ota_parm_t ota_parm;
|
||||
resend_send_data(&sertrf.resend_device, RESEND_CMD_OTA_GET_PARAM, &ota_parm, sizeof(ota_parm_t), 1000);
|
||||
sertrf.resend_device.handle_flag = 0;//标志位清零
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -166,6 +170,8 @@ void task_thread(void* arg)
|
||||
case PROTOCOL_STATUS_ANALYSIS_ERROR:
|
||||
rgb_color_change(1, RGB_COLOR_RAD);
|
||||
break;
|
||||
case PROTOCOL_STATUS_IN_OTA:
|
||||
rgb_color_change(1, RGB_COLOR_BLUE);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -297,28 +303,51 @@ void resend_user_parse(void *resend_device)
|
||||
os_thread_sleep(1000);
|
||||
esp_restart();
|
||||
break;
|
||||
case RESEND_CMD_OTA_GET_PARAM:
|
||||
{
|
||||
if(sizeof(ota_parm_t) != resend_parse->rx_frame.len)
|
||||
{
|
||||
printf("RESEND_CMD_OTA_GET_PARAM len error\r\n");
|
||||
}
|
||||
ota_parm_t* ota_parm = (ota_parm_t*)resend_parse->rx_frame.payload;
|
||||
printf("RESEND_CMD_OTA_GET_PARAM %d\n", ota_parm->ota_file_size);
|
||||
resend_send_cmd(resend_device, RESEND_CMD_ACK, 0);
|
||||
}
|
||||
break;
|
||||
case RESEND_CMD_OTA_START:
|
||||
{
|
||||
if(!sertrf.resend_device.status.resend_flag)
|
||||
otau_init(&sertrf.otau);
|
||||
|
||||
protocol_set_message_status(MESSAGE_OTA);
|
||||
// if(!sertrf.resend_device.status.resend_flag)
|
||||
otau_init(&sertrf.otau);
|
||||
resend_send_cmd(resend_device, RESEND_CMD_ACK, 0);
|
||||
}
|
||||
break;
|
||||
case RESEND_CMD_OTA_DATA:
|
||||
{
|
||||
if(!sertrf.resend_device.status.resend_flag)
|
||||
|
||||
memcpy(sertrf.otau.ota_buff + sertrf.otau.ota_data_cnt, sertrf.resend_device.rx_frame.payload, sertrf.resend_device.rx_frame.len);
|
||||
|
||||
sertrf.otau.ota_data_cnt += sertrf.resend_device.rx_frame.len;
|
||||
// if(!sertrf.resend_device.status.resend_flag)
|
||||
if(sertrf.otau.ota_data_cnt >= 20480 )
|
||||
{
|
||||
SYS_LOG_DBG("KUYI_CMD_OTA_DATA");
|
||||
otau_write(&sertrf.otau, sertrf.resend_device.rx_frame.payload, sertrf.resend_device.rx_frame.len);
|
||||
SYS_LOG_DBG("KUYI_CMD_OTA_DATA %d\n", sertrf.resend_device.rx_frame.seq);
|
||||
otau_write(&sertrf.otau, sertrf.otau.ota_buff, sertrf.otau.ota_data_cnt);
|
||||
sertrf.otau.ota_data_cnt = 0;
|
||||
}
|
||||
|
||||
resend_send_cmd(resend_device, RESEND_CMD_ACK, 0);
|
||||
}
|
||||
break;
|
||||
case RESEND_CMD_OTA_END:
|
||||
{
|
||||
if(!sertrf.resend_device.status.resend_flag)
|
||||
otau_end(&sertrf.otau);
|
||||
if(sertrf.otau.ota_data_cnt > 0)
|
||||
{
|
||||
otau_write(&sertrf.otau, sertrf.otau.ota_buff, sertrf.otau.ota_data_cnt);
|
||||
sertrf.otau.ota_data_cnt = 0;
|
||||
}
|
||||
// if(!sertrf.resend_device.status.resend_flag)
|
||||
otau_end(&sertrf.otau);
|
||||
resend_send_cmd(resend_device, RESEND_CMD_ACK, 0);
|
||||
os_thread_sleep(2);
|
||||
esp_restart();
|
||||
|
||||
Reference in New Issue
Block a user