Issue3:Linux Gateway App v1.0.1中ota state machine的执行逻辑是怎样的?
Hi all,
问题如标题,想弄明白ota状态机的逻辑切换,case2到case3,以及case4到case5是怎么过渡的,请教TI工程师以及同仁指导,感谢!
代码定位:ota_engine.c 大概75行左右(我的代码有改动),void ota_enable_state_machine(bool timed_out, void * arg)
void ota_enable_state_machine(bool timed_out, void * arg)
{
static int state = 0;
static int current_ota_file_index;
bool rerun_state_machine = true;
if ((arg == NULL) && (state != 0))
{
printf("OTA-Enable already in progress");
return;
}
if (si_is_server_ready(SI_SERVER_ID_OTA) == false)
{
printf("ota_enable_state_machine: ERROR: OTA server not connected");
state = 6;
}
else if ((!timed_out) || (state == 0))
{
state++;
}
while (rerun_state_machine)
{
printf("OTA-Enable state %d\n", state);
rerun_state_machine = false;
switch (state)
{
case 1:
if (si_register_idle_callback(ota_enable_state_machine, NOT_NULL) == 0)
{
if (si_is_waiting_for_confirmation() == false)
{
state++;
rerun_state_machine = true;
}
}
else
{
state = 0;
printf("WARNING: OTA-Enable state machine cannot be initialized at this time");
}
break;
case 2:
enable_ota_upgrade(); //OTA enable 3:OTA_UPDATE_ENABLE_REQ 4:OTA_UPDATE_ENABLE_CNF
break;
case 3:
ota_register("./sample_app_ota.cfg");
current_ota_file_index = 0;
state++;
rerun_state_machine = true;
break;
case 4:
//if(DeviceList_Router[0] == router_of_config[i])
register_single_file(current_ota_file_index); //OTA register 2: IMAGE_REGISTERATION_REQ 0:ZIGBEE_GENERIC_CNF
//printf("router_of_config[%d] = %Lx\n", i, router_of_config[i]);
//printf("DeviceList_Router[0] = %Lx\n", DeviceList_Router[0]);
break;
case 5:
current_ota_file_index++;
if (current_ota_file_index < upgrade_num_files)
{
state--;
}
else
{
state++;
}
rerun_state_machine = true;
break;
case 6:
si_unregister_idle_callback();
state = 0;
break;
default:
break;
}
}
}
正常执行ota更新,log信息如下:
TI的工程师不能支持一下吗?每次发帖,基本上石沉大海,杳无音讯。@vv
这几个过程切换的时候,有没有对比过空中数据包发送情况,在OTA过程的前是需要进项一些数据交互的。