微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI WIFI设计交流 > Edits_for_OTA.zip 下载链接?

Edits_for_OTA.zip 下载链接?

时间:10-02 整理:3721RD 点击:

TI工程师,你好:

就是我看那个文档里面有提及一个OTA的修改的压缩包,但是我网站搜索了一下,却没有看到相关的内容?

可不可以给我发送一个下载链接,我下载一下

(Edits_for_OTA.zip )file 代码如下:

Include Section (To be added after osi.h)
Global/Define Section
12
#include "flc_api.h"
#include "ota_api.h"

#define OTA_SERVER_NAME "api.dropbox.com"
#define OTA_SERVER_IP_ADDRESS 0x00000000
#define OTA_SERVER_SECURED 1
#define OTA_SERVER_REST_UPDATE_CHK "/1/metadata/auto/" // returns files/folder list
#define OTA_SERVER_REST_RSRC_METADATA "/1/media/auto" // returns A url that serves the media directly
#define OTA_SERVER_REST_HDR "Authorization: Bearer "
#define OTA_SERVER_REST_HDR_VAL "<access_token>"
#define LOG_SERVER_NAME "api‐content.dropbox.com"
#define OTA_SERVER_REST_FILES_PUT "/1/files_put/auto/"
#define OTA_VENDOR_STRING "VId_PId_VerId"
static OtaOptServerInfo_t g_otaOptServerInfo;
? ?
Function Prototypes
Local Variables (To be added to GetWeatherTask() Function
OTA Initialization (To be added to GetWeatherTask() function after GPIO_IF_LedOn(MCU_GREEN_LED_GPIO) function
call)
OTA main construct/logic (To be added to GetWeatherTask() function after lRetVal =
Network_IF_GetHostIP((char*)g_ServerAddress, &ulDestinationIP);)
12
13
static OtaOptServerInfo_t g_otaOptServerInfo;
static void *pvOtaApp;
12
int OTAServerInfoSet(void **pvOtaApp, char *vendorStr);
static void RebootMCU();
1234
long OptionLen;
unsigned char OptionVal;
int SetCommitInt;
unsigned char ucVendorStr[20];
12345678
//
// Initialize OTA
//
pvOtaApp = sl_extLib_OtaInit(RUN_MODE_NONE_OS | RUN_MODE_BLOCKING,0);
strcpy((char *)ucVendorStr, OTA_VENDOR_STRING);
OTAServerInfoSet(&pvOtaApp, (char *)ucVendorStr);

//
// Check if this image is booted in test mode
//
sl_extLib_OtaGet(pvOtaApp, EXTLIB_OTA_GET_OPT_IS_PENDING_COMMIT, &OptionLen, (_u8 *)&OptionVal);
UART_PRINT("EXTLIB_OTA_GET_OPT_IS_PENDING_COMMIT? %d \n\r", OptionVal);
if (OptionVal == true) {
UART_PRINT("OTA: PENDING COMMIT & WLAN OK ==> PERFORM COMMIT \n\r");
SetCommitInt = OTA_ACTION_IMAGE_COMMITED;
sl_extLib_OtaSet(pvOtaApp, EXTLIB_OTA_SET_OPT_IMAGE_COMMIT, sizeof(int), (_u8 *)&SetCommitInt);
}e
lse {
UART_PRINT("Starting OTA\n\r");
lRetVal = 0;
while (!lRetVal) {
lRetVal = sl_extLib_OtaRun(pvOtaApp);
} U
ART_PRINT("OTA run = %d\n\r", lRetVal);
if (lRetVal < 0) {
UART_PRINT("OTA: Error with OTA server\n\r");
} e
lse if (lRetVal == RUN_STAT_NO_UPDATES) {
? ? ? ?
Banner Display (Replace “DisplayBanner(APP_NAME);” with the new code)
New Functions (Added at the end of “main.c”)

else if (lRetVal == RUN_STAT_NO_UPDATES) {
UART_PRINT("OTA: RUN_STAT_NO_UPDATES\n\r");
}e
lse if (lRetVal && RUN_STAT_DOWNLOAD_DONE) {
// Set OTA File for testing
lRetVal = sl_extLib_OtaSet(pvOtaApp, EXTLIB_OTA_SET_OPT_IMAGE_TEST, sizeof(int), (_u8 *)&SetCommitInt);
UART_PRINT("OTA: NEW IMAGE DOWNLOAD COMPLETE\n\r");
UART_PRINT("Rebooting...\n\r");
RebootMCU();
}
}
1 DisplayBanner(OTA_VENDOR_STRING);

//! Sets the OTA server info and vendor ID
//!
//! \param pvOtaApp pointer to OtaApp handler
//! \param ucVendorStr vendor string
//! \param pfnOTACallBack is pointer to callback function
//!
//! This function sets the OTA server info and vendor ID.
//!
//! \return None.
//
//****************************************************************************
int OTAServerInfoSet(void **pvOtaApp, char *vendorStr)
{
unsigned char macAddressLen = SL_MAC_ADDR_LEN;
//
// Set OTA server info
//
g_otaOptServerInfo.ip_address = OTA_SERVER_IP_ADDRESS;
g_otaOptServerInfo.secured_connection = OTA_SERVER_SECURED;
strcpy((char *)g_otaOptServerInfo.server_domain, OTA_SERVER_NAME);
strcpy((char *)g_otaOptServerInfo.rest_update_chk, OTA_SERVER_REST_UPDATE_CHK);
strcpy((char *)g_otaOptServerInfo.rest_rsrc_metadata, OTA_SERVER_REST_RSRC_METADATA);
strcpy((char *)g_otaOptServerInfo.rest_hdr, OTA_SERVER_REST_HDR);
strcpy((char *)g_otaOptServerInfo.rest_hdr_val, OTA_SERVER_REST_HDR_VAL);
strcpy((char *)g_otaOptServerInfo.log_server_name, LOG_SERVER_NAME);
strcpy((char *)g_otaOptServerInfo.rest_files_put, OTA_SERVER_REST_FILES_PUT);
sl_NetCfgGet(SL_MAC_ADDRESS_GET, NULL, &macAddressLen, (_u8 *)g_otaOptServerInfo.log_mac_address);
//
// Set OTA server Info
//
sl_extLib_OtaSet(*pvOtaApp, EXTLIB_OTA_SET_OPT_SERVER_INFO,
sizeof(g_otaOptServerInfo), (_u8 *)&g_otaOptServerInfo);
//
// Set vendor ID.
//
sl_extLib_OtaSet(*pvOtaApp, EXTLIB_OTA_SET_OPT_VENDOR_ID, strlen(vendorStr),
(_u8 *)vendorStr);

//
// Return ok status
//
return RUN_STAT_OK;
} /
/****************************************************************************
//
//! Reboot the MCU by requesting hibernate for a short duration
//!
//! \return None
//
//****************************************************************************
static void RebootMCU()
{
//
// Configure hibernate RTC wakeup
//
PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
//
// Delay loop
//
MAP_UtilsDelay(8000000);
//
// Set wake up time
//
PRCMHibernateIntervalSet(330);
//
// Request hibernate
//
PRCMHibernateEnter();
//
// Control should never reach here
//
while(1)
{ }
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top