1. Version change to 4
2. Add user GPIO configure support
This commit is contained in:
parent
d9ade40e82
commit
ecc6ac6685
|
@ -14,6 +14,7 @@
|
|||
|
||||
#define GLOBAL_TAGS "NETEASEIOTGLOBALCONFIGURETAG"
|
||||
#define NE_PRODUCT_ID_LEN 4
|
||||
#define DEBUG_USER_CFG (0)
|
||||
|
||||
static PUSER_CONFIG g_pUserCfg = NULL;
|
||||
|
||||
|
@ -285,13 +286,17 @@ PUSER_CONFIG CreateDefaultUserCfg(void)
|
|||
usrCfg.UART[1].Parity = USART_Parity_None;
|
||||
usrCfg.UART[1].FlowCtrl = USART_HardwareFlowControl_None;
|
||||
usrCfg.UART[0].Baud = 115200;
|
||||
usrCfg.UART[0].DataBits = 8;
|
||||
usrCfg.UART[0].DataBits = 3;
|
||||
usrCfg.UART[0].StopBits = 1;
|
||||
usrCfg.UART[0].FlowCtrl = 3;
|
||||
usrCfg.UART[0].Parity = 2;
|
||||
usrCfg.UART[0].FlowCtrl = 0;
|
||||
usrCfg.UART[1].Baud = 115200;
|
||||
usrCfg.UART[1].DataBits = 8;
|
||||
usrCfg.UART[1].DataBits = 3;
|
||||
usrCfg.UART[1].StopBits = 1;
|
||||
usrCfg.UART[2].Parity = 2;
|
||||
usrCfg.UART[1].FlowCtrl = 0;
|
||||
usrCfg.GPIO.iSize = 0;
|
||||
usrCfg.GPIO.pGpioCfg = NULL;
|
||||
|
||||
return &usrCfg;
|
||||
}
|
||||
|
@ -409,8 +414,9 @@ int CfgReadUserCfgFromFlash(void)
|
|||
|
||||
memset(pUserCfg, 0, SECTOR_SIZE);
|
||||
ret = CfgDecrypto(pUserCfg, pBase64Buf, i);
|
||||
//LOG_EX(LOG_Debug, "User Cfg Decode(%d): \n%s\n\n", ret, pUserCfg);
|
||||
|
||||
#if DEBUG_USER_CFG
|
||||
LOG_EX(LOG_Debug, "User Cfg Decode(%d): \n%s\n\n", ret, pUserCfg);
|
||||
#endif
|
||||
//IHW_LOG_BUF(LOG_Debug, "Json", (unsigned char*)pBase64Buf, strlen(pBase64Buf));
|
||||
|
||||
pCfgInfo = (PUSER_CONFIG)Json2Struct(pUserCfg, JE_USER_CFG, CRYPTO_NONE, &i);
|
||||
|
@ -424,6 +430,11 @@ int CfgReadUserCfgFromFlash(void)
|
|||
free(pCfgInfo);
|
||||
}
|
||||
|
||||
if(pCfgInfo->GPIO.iSize > 0 && pCfgInfo->GPIO.pGpioCfg)
|
||||
{
|
||||
free(pCfgInfo->GPIO.pGpioCfg);
|
||||
}
|
||||
|
||||
free(pUserCfg);
|
||||
free(pBase64Buf);
|
||||
|
||||
|
@ -485,10 +496,12 @@ void CfgInitEnv(void)
|
|||
{
|
||||
g_pUserCfg = CreateDefaultUserCfg();
|
||||
|
||||
#if !DEBUG_USER_CFG
|
||||
if(CfgReadUserCfgFromFlash() != ERR_OK)
|
||||
{
|
||||
UserCfgSaveToFlash();
|
||||
}
|
||||
#endif
|
||||
|
||||
if(CfgReadFromFlash() == ERR_OK)
|
||||
{
|
||||
|
@ -511,6 +524,10 @@ void CfgInitEnv(void)
|
|||
void ShowCfgConfigure(void)
|
||||
{
|
||||
LOG_EX(LOG_Debug, "Read user configure at Nand Flash address: 0x%04X000\n", PARAM_SAVE_USERCFG);
|
||||
|
||||
#if DEBUG_USER_CFG
|
||||
CfgReadUserCfgFromFlash();
|
||||
#endif
|
||||
__dumpUserConfig(g_pUserCfg);
|
||||
__dumpGlobalCfg();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#define SERVER_USED ONLINE_PUBLISH
|
||||
|
||||
#define FIRMWARE_VERSION "00000003"
|
||||
#define FIRMWARE_VERSION "00000004"
|
||||
#define FIRMWARE_VERSION_MCU "00000002"
|
||||
#define USER_CFG_VERSION (0)
|
||||
|
||||
|
@ -197,6 +197,21 @@ typedef struct
|
|||
int FlowCtrl;
|
||||
} UART_CFG, *PUART_CFG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int Id;
|
||||
int Func;
|
||||
int Dir;
|
||||
int PullUp;
|
||||
int Interrupt;
|
||||
} GPIO_ITEM, *PGPIO_ITEM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int iSize;
|
||||
PGPIO_ITEM pGpioCfg;
|
||||
} GPIO_CFG, *PGPIO_CFG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int UsedDefault;
|
||||
|
@ -207,6 +222,7 @@ typedef struct
|
|||
SOFTAP_CONFIG SoftAP;
|
||||
WIFIAP_CONFIG WifiAP;
|
||||
UART_CFG UART[2];
|
||||
GPIO_CFG GPIO;
|
||||
} USER_CONFIG, *PUSER_CONFIG;
|
||||
|
||||
typedef struct
|
||||
|
|
Loading…
Reference in New Issue