1:imageBlockResponseParse服務器
{ui
塊請求應答spa
emberAfOtaStorageFinishDownloadCallback(offset); //完成下載
continueImageVerification(EMBER_AF_IMAGE_UNKNOWN); 、、映象的狀態,爲不知道it
}io
2:下載
recordUpgradeStatus(BOOTLOAD_STATE_VERIFY_IMAGE); 、、覈對映象請求
customVerifyStatus = NEW_CUSTOM_VERIFY; //新的映象存在
setTimer(EMBER_AF_PLUGIN_OTA_CLIENT_VERIFY_DELAY_MS)im
continueImageVerification(EMBER_AF_IMAGE_VERIFY_IN_PROGRESS);不停的核對映象ember
3:覈對成功static
downloadAndVerifyFinish(EMBER_AF_OTA_DOWNLOAD_AND_VERIFY_SUCCESS) 覈對成功
askServerToRunUpgrade(START_NEW_TIMER);
請求服務器去升級,發送升級結束,若是沒回,就強制升級
4:網關回了何時升級
waitTime=500;// ZGM
setTimer(waitTime);
emberAfCoreFlush();
otaPrintln("Countdown to upgrade: %d ms", waitTime);
emberAfCoreFlush();
recordUpgradeStatus(BOOTLOAD_STATE_COUNTDOWN_TO_UPGRADE); 500毫秒以後去升級
5:
case BOOTLOAD_STATE_COUNTDOWN_TO_UPGRADE:
runUpgrade(); 時間到升級
emberAfOtaClientBootloadCallback(¤tDownloadFile);
6:最終升級的地方
uint8_t emberAfOtaBootloadCallback(const EmberAfOtaImageId* id,uint16_t ncpUpgradeTagId)
{
halAppBootloaderInstallNewImage(); 升級文件,須要等1分鐘左右
emberAfCorePrintln("Bootloading failed!");
// If we got here, it is a failure.
return 1;
}
2:
static void otaClientTick(void)
{
switch (currentBootloadState) {
case BOOTLOAD_STATE_DOWNLOAD:
continueImageDownload();
break;
case BOOTLOAD_STATE_VERIFY_IMAGE:
continueImageVerification(EMBER_AF_IMAGE_VERIFY_IN_PROGRESS);
break;
case BOOTLOAD_STATE_WAITING_FOR_UPGRADE_MESSAGE:
askServerToRunUpgrade(TIMEOUT_REACHED);
break;
case BOOTLOAD_STATE_COUNTDOWN_TO_UPGRADE:
runUpgrade();
case BOOTLOAD_STATE_UPGRADE_VIA_OUT_OF_BAND:
// Does nothing right now after timeout
default:
// Do nothing. Invalid state
break;
}
}
2: