Commit e31877dc authored by limm's avatar limm

V1.1

parent 4f207db8
......@@ -101,7 +101,7 @@ extern "C" {
#endif
#define ZCL_GROUP_SUPPORT 1
#define ZCL_SCENE_SUPPORT 1
#define ZCL_OTA_SUPPORT 1
#define ZCL_OTA_SUPPORT 0
#define ZCL_PRIVATE_CLUSTER_FCC0_SUPPORT 1
#if TOUCHLINK_SUPPORT
#define ZCL_ZLL_COMMISSIONING_SUPPORT 1
......
This diff is collapsed.
......@@ -305,7 +305,11 @@ void kLedOptTrigger(uint8_t id, uint32_t duration_on_ms, uint32_t duration_off_m
g_stLedCtrller[led_index].offDuration = duration_off_ms/ TICK_LOOP_NMS;
g_stLedCtrller[led_index].start = start;
g_stLedCtrller[led_index].end = end;
if(end == LED_IGNORE)
g_stLedCtrller[led_index].end = LED_OFF;
else
g_stLedCtrller[led_index].end = end;
if( g_stLedCtrller[led_index].start == LED_ON ) {
kLedDriverhandler(led_index, LED_ON);
......
......@@ -202,11 +202,6 @@ void Update_Local_Attribute_Info(void)
Rewrite_ManufactureName();
}
typedef struct{
zcl_basicAttr_t basicAttrs_temp;
zcl_identifyAttr_t identifyAttrs_temp;
......
......@@ -19,7 +19,6 @@ typedef enum{ EOOC_OFF = 0, EOOC_ON, EOOC_TOGGLE, EOOC_UNKNOW }OnOffCtrlEnum;
#define ZCL_ONOFF_STATUS_OFF 0x00
#define ZCL_ONOFF_STATUS_ON 0x01
typedef struct tag_zcl_report_table{
uint8_t endpoint;
uint16_t cluster;
......
......@@ -56,7 +56,7 @@ uint16_t kCmdGetMsgCrc16Value( uint8_t* msg, uint8_t len)
/* DESP: remap opcode, arg direction 0: FCC0->AA55 1:AA55->FCC0
* Auth:
* */
uint16_t kCmdOpcodeRemap(uint16_t Opcode, uint8_t direction)
static uint16_t kCmdOpcodeRemap(uint16_t Opcode, uint8_t direction)
{
for (uint8_t i = 0; i < (sizeof(opcodeReampTable)/(2*sizeof(uint16_t))); i++ ) {
if (opcodeReampTable[i][0] == Opcode) {
......@@ -66,7 +66,6 @@ uint16_t kCmdOpcodeRemap(uint16_t Opcode, uint8_t direction)
return 0xFFFF;
}
kk_err_t kCmdGeneralMsgPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st *pDataOut)
{
//UMsgNodeSt uMsgNode = {0};
......@@ -144,7 +143,7 @@ kk_err_t kCmdGeneralMsgPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st
//check install code length 20200725
uint8_t length = data.u8ARG[0];
if (length != 16) {
if (length != 16) {//如果不是16位的数据就不做任何改变,只回复
send_buf.u8ARG[0] = ERR_FORMAT;
send_buf.u8ARG[1] = data.u8ARG[0];
memcpy(&send_buf.u8ARG[2], &data.u8ARG[1], length);
......@@ -247,9 +246,9 @@ kk_err_t kCmdGeneralMsgPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st
memset(buffer, 0, 33);
uint8_t *data = ISN_TOKEN_GET();
iKonkeAfSelfPrint("len %x\r\n",data[0]);
iKonkeAfSelfPrintBuffer(data+1,32);
length = data[0];
iKonkeAfSelfPrint("read ISN len %x\r\n",data[0]);
iKonkeAfSelfPrintBuffer(data+1,32);
memcpy(buffer,data,length +1);
if(length > 32) {
......@@ -268,7 +267,7 @@ kk_err_t kCmdGeneralMsgPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st
{
uint8_t mac_length = 0x00;
addrExt_t addr,local_addr;
flash_read(CFG_MAC_ADDRESS,8,(uint8_t*)local_addr);
zb_getLocalExtAddr(local_addr);
mac_length = data.u8ARG[0];
if (mac_length != 8) {
......@@ -293,8 +292,7 @@ kk_err_t kCmdGeneralMsgPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st
case (UART_MSG_READ_MAC_CODE_OPCODE)://ok
{
addrExt_t addr;
flash_read(CFG_MAC_ADDRESS,8,(uint8_t*)addr);
// zb_getLocalExtAddr(addr);
zb_getLocalExtAddr(addr);
send_buf.u8ARG[0] = 0x00;
send_buf.u8ARG[1] = 0x08;
......@@ -424,61 +422,6 @@ kk_err_t kCmdGeneralMsgPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st
reply_control_field = Z_TO_H_NO_ACK;
break;
}
// case (UART_MSG_READ_DEVICE_SNAP_OPCODE):
// {
// uint8_t tmp_value = 0;
// uint8_t send_length = 0;
//
// send_buf.u8ARG[send_length++] = ERR_OK;
// emberAfReadAttribute(1, ZCL_BASIC_CLUSTER_ID, ZCL_STACK_VERSION_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
// &tmp_value, 1, NULL);
// send_buf.u8ARG[send_length++] = tmp_value;
//
// EmberEUI64 localEui64;
// EmberNodeType nodeTypeResult = 0xFF;
// EmberNetworkParameters networkParams;
// emberAfGetEui64(localEui64);
// SWAP_EUI64((uint8_t *)&localEui64);
//
// if(emberAfNetworkState() == EMBER_JOINED_NETWORK) {
// emberAfGetNetworkParameters(&nodeTypeResult, &networkParams);
// send_buf.u8ARG[send_length++] = HI_UINT16(networkParams.panId);
// send_buf.u8ARG[send_length++] = LO_UINT16(networkParams.panId);
// send_buf.u8ARG[send_length++] = HI_UINT16(emberAfGetNodeId());
// send_buf.u8ARG[send_length++] = LO_UINT16(emberAfGetNodeId());
// memcpy(&send_buf.u8ARG[send_length], localEui64, 8);
// send_length = send_length + 8;
// send_buf.u8ARG[send_length++] = networkParams.radioChannel;
// send_buf.u8ARG[send_length++] = networkParams.radioTxPower;
// } else {
// emberAfGetNetworkParameters(&nodeTypeResult, &networkParams);
// send_buf.u8ARG[send_length++] = 0xff;
// send_buf.u8ARG[send_length++] = 0xff;
// send_buf.u8ARG[send_length++] = 0xff;
// send_buf.u8ARG[send_length++] = 0xff;
// memcpy(&send_buf.u8ARG[send_length], localEui64, 8);
// send_length = send_length + 8;
// send_buf.u8ARG[send_length++] = 0xff;
// send_buf.u8ARG[send_length++] = 0xff;
// }
// //SV
// emberAfReadAttribute(1, ZCL_BASIC_CLUSTER_ID, ZCL_APPLICATION_VERSION_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
// &tmp_value, 1, NULL);
// send_buf.u8ARG[send_length++] = tmp_value;
// //HV
// emberAfReadAttribute(1, ZCL_BASIC_CLUSTER_ID, ZCL_HW_VERSION_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
// &tmp_value, 1, NULL);
// send_buf.u8ARG[send_length++] = tmp_value;
// memset(&send_buf.u8ARG[send_length], 0xff, 4);
// send_length = send_length + 4;
// send_buf.u8ARG[send_length++] = emberAfNetworkState();
//
// send_buf.u8ArgLen = send_length;
// //send_buf.u8Datalen = send_length + 3;
// reply_control_field = Z_TO_H_NO_ACK;
//
// break;
// }
//nwk operation request
case (UART_MSG_QUERY_NWK_STATUS_REQUEST_OPCODE)://ok
{
......
......@@ -34,7 +34,6 @@ typedef struct{
}MsgFrameworkFormat_st;
kk_err_t kCmdGeneralMsgPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st *pDataOut);
uint16_t kCmdOpcodeRemap(uint16_t Opcode, uint8_t direction);
uint16_t kCmdGetMsgCrc16Value( uint8_t* msg, uint8_t len);
uint8_t kCmdMsgDataSentByPort(uint8_t u8Control_Field, DataField_st data, bool isGetResult, ComPortEm port);
......
......@@ -42,11 +42,15 @@ typedef enum{
FTS_AGING_4HOU_START,
FTS_AGING_4HOU,
FTS_AGING_DONE,
FTS_AGING_FORCE_EXIT,
FTS_AGING_WAITING,
FTS_AGING_FORCE_REBOOT,
FTS_AGING_FIRST_LONG_PRESSED,
FTS_AGING_WAITING_SECOND_PRESS
FTS_FORCE_EXIT,
FTS_WAITING_RELEASED,//waiting key released
FTS_FORCE_REBOOT,
FTS_FIRST_LONG_PRESSED,
FTS_WAITING_SECOND_PRESS,
FTS_SINGLE_BOARD_TEST,
FTS_FULL_DEVICE_TEST,
FTS_SINGLE_BOARD_TEST_DONE,
FTS_FULL_DEVICE_TEST_DONE,
}FactoryTestStatusEnum;
typedef struct{
......@@ -74,7 +78,14 @@ void kSetAgingMaxTime(uint16_t value);
//获取当前产测状态
FactoryTestStatusEnum kGetFactoryTestStatus(void);
//void kGetFactoryTestBtnAction(uint8_t btn_id, BtnActionEnum action);
void kFactoryTestInit(pFactoryTestPollCallback callback, FactoryTestConfSt conf_list[], uint8_t btn_num);
void kFactoryTestInit(pFactoryTestPollCallback callback, FactoryTestConfSt conf_list[], uint8_t btn_num,uint8_t led_id);
void kSetNetworkSteeringInfo(uint8_t channel, uint16_t PanId);
bool kCmdNetworkSteeringinfoCheck(uint8_t channel, uint16_t panid);
//Auth: han_frc.20220105.
void kSetAgingTestDone(void);
kk_err_t kkFactoryMsgInComingPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st *pDataOut);
#endif
......
......@@ -8,7 +8,7 @@
#include "ikk-debug.h"
#include "ikk-token.h"
#include "ikk-network.h"
#include "ikk-factory-test.h"
static bool gInterPanEnabled; // 1:enable
static uint16_t gInterPanID = 0x1111; // 1:enable
......@@ -16,12 +16,10 @@ static uint8_t g_interpanChannel = 20;
pInterPanMsgIncomingCallback gInterPanMsgIncomingCallback;
static ev_timer_event_t *Interpan_timerEvt = NULL;
static ev_timer_event_t *Interpan_DelaySendEvt = NULL;
static INCOM_MESSAGE_INFO sIncomingMessageInfo = {0};
static s32 kInterPanEventHandler(void);
static s32 kInterPanDelaySendTestDataEventHandler(void );
/**
* @brief Definition for Incoming cluster / Sever Cluster
......@@ -104,8 +102,7 @@ void kInterPanEnable(uint8_t channel)
{
rf_setChannel(channel);
printf("kInterPanEnable enable,Regesiter Interpan Func,network = %d\r\n!!\r\n",kNwkGetCurrentStatus());
if (kNwkGetCurrentStatus() == ENS_LEAVED) {
if (!zb_isDeviceJoinedNwk()) {
af_endpointRegister(INTERPAN_ENDPOINT, (af_simple_descriptor_t *)&kInterpanSimpleDesc, afInterpan_rx_handler, afInterpan_dataSendConfirm);
}
else{
......@@ -128,19 +125,17 @@ void kInterpanDisable(void)
void kInterPanMoudleInit(pInterPanMsgIncomingCallback pfunc_incoming)
{
bool interPanEnabledFlg = kGetInterpanEnableFlg();
if (interPanEnabledFlg) {
gInterPanEnabled = true;
if (kGetFactoryTestStatus() == FTS_NORMAL) {
gInterPanEnabled = false;
af_endpointUnregister(INTERPAN_ENDPOINT);
printf("kInterPanEnable disable\r\n!!\r\n");
}
if (gInterPanEnabled == true) {
else{
gInterPanEnabled = true;
printf("kInterPanEnable enable\r\n!!\r\n");
kInterPanEnable(INTERPAN_CHANNEL);
if(Interpan_timerEvt){
TL_ZB_TIMER_CANCEL(&Interpan_timerEvt);
}
Interpan_timerEvt = TL_ZB_TIMER_SCHEDULE(kInterPanEventHandler, NULL, INTERPAN_AUTO_OFF_TIME);
if (kNwkGetCurrentStatus() == ENS_LEAVED) {
if (!zb_isDeviceJoinedNwk()) {
if(Interpan_DelaySendEvt)
TL_ZB_TIMER_CANCEL(&Interpan_DelaySendEvt);
......@@ -211,17 +206,6 @@ static s32 kInterPanDelaySendTestDataEventHandler(void )
sSend_Count = 0;
return -1;
}
static s32 kInterPanEventHandler(void)
{
iKonkeAfSelfPrint("kInterPanEventHandler\r\n");
if (gInterPanEnabled ==true) {
af_endpointUnregister(INTERPAN_ENDPOINT);
kInterPanSetEnableStatus(false);
}
return -1;
}
kk_err_t kInterPanSend(UMsgNodeSt *pMsgNode)
{
......
......@@ -12,7 +12,6 @@ extern const af_simple_descriptor_t kInterpanSimpleDesc;
#define INTERPAN_EVENT_INIT 0x00 // interPan Event
#define INTERPAN_EVENT_OFF 0x01 //
#define INTERPAN_AUTO_OFF_TIME (10 * 60 * 1000)
#define INTERPAN_DELAY_SEND_INTERVAL (3 * 1000)
#define INTERPAN_DELAY_SEND_TIMES (2)
#define INTERPAN_CHANNEL 20
......@@ -38,5 +37,7 @@ kk_err_t kInterPanSend(UMsgNodeSt *pMsgNode);
void kInterpan_Init(void);
bool kInterPanSetEnableStatus(uint8_t enable);
bool kInterPanGetEnableStatus(void);
void kInterPanMoudleInit(pInterPanMsgIncomingCallback pfunc_incoming);
#endif /* _SAMPLE_LIGHT_H_ */
......@@ -86,6 +86,8 @@
#define UART_MSG_QUERY_SWITCH_ONOFF_OPCODE 0xED06
#define UART_MSG_ENTER_FACTORY_TEST_OPCODE 0xED14
#define UART_MSG_ONOFF_SWITCH_OPCODE 0xED15
#define UART_MSG_QUERY_FACTORY_STATE_OPCODE 0xED16
#define UART_MSG_LED_GROUP_CONTROL_OPCODE 0xED17
#define UART_MSG_GPIO_TEST_OPCODE 0xED10
#define UART_MSG_READ_RSSI_REQUEST_OPCODE 0xED12
......@@ -172,6 +174,7 @@ typedef enum {
ERR_WRITE_FAILED=0x04,
ERR_READ_WRITE_TIMEOUT=0x05,
ERR_NOT_EXIST=0x06,
ERR_EXEC_FAILED=0xe0,
ERR_UNKNOW=0xFF,
}ERR_RET_E;
typedef enum { Z3D_COORDINATOR = 0, Z3D_ROUTER, Z3D_ENDDEVICE }Z3DevTypeEm;
......
......@@ -400,7 +400,8 @@ void kNwkFactoryReset(bool is_nwk_indicator)
//led can blink when network leaved
if (is_nwk_indicator == true){
zb_factoryReset();
if(zb_isDeviceJoinedNwk())
zb_factoryReset();
g_KeyPressCauasLeave = true;
//add by maozj 20200407 for reset count down after network leaved
g_u32NwkExitCountDownCounter = MS2COUNT(LED_FAST_BLINK_CONTINUE_TIME_MS);
......@@ -444,7 +445,7 @@ void NetworkLeaveHandler(nlme_leave_cnf_t *pLeaveCnf)
NwkStatusEnum kNwkGetCurrentStatus(void )
{
NwkStatusEnum status;
if(zb_isDeviceJoinedNwk()){
if(zb_isDeviceJoinedNwk() ||(kInterPanGetEnableStatus())){
status = ENS_ONLINE;
g_bIsNwkJoiningFlg = false;
}
......
......@@ -6,6 +6,10 @@
#include "ikk-config.h"
#include "ikk-token.h"
#include "../../../../zigbee/zcl/zcl_include.h"
#include "ikk-command.h"
#include "../driver/ikk-uart.h"
#include "ikk-factory-test.h"
// FCC0-0000
#pragma pack(1)
typedef struct tag_private_clsFCC0_attr0000_frame_st {
......@@ -27,55 +31,7 @@ pFUNC_OPTDATA_MESSAGE_CALLBACK g_pOptDataIncomingMessageCallback = NULL;
extern bool Get_Model_ID(uint8_t *ModeID);
extern _CODE_ZCL_ zclReadCmd_t *zcl_parseInReadCmd(zclIncoming_t *pCmd);
extern _CODE_ZCL_ status_t zcl_readRsp(u8 srcEp, epInfo_t *pDstEpInfo, u16 clusterId, u16 manuCode, u8 disableDefaultRsp, u8 direction, u8 seqNo, zclReadRspCmd_t *readRspCmd);
//_CODE_ZCL_ static status_t zcl_Private_cmdHandler(zclIncoming_t *pInMsg);
//
//
//
//
//_CODE_ZCL_ status_t zcl_private_fcc0_register(u8 endpoint, u16 manuCode, u8 attrNum, const zclAttrInfo_t attrTbl[], cluster_forAppCb_t cb)
//{
// return zcl_registerCluster(endpoint, ZCL_CLUSTER_PRIVATE_FCC0, manuCode, attrNum, attrTbl, zcl_Private_cmdHandler, cb);
//}
//
//_CODE_ZCL_ static status_t zcl_private_clientCmdHandler(zclIncoming_t *pInMsg)
//{
// u8 status = ZCL_STA_SUCCESS;
// apsdeDataInd_t *pApsdeInd = (apsdeDataInd_t*)pInMsg->msg;
// iKonkeAfSelfPrint("#############zcl_private_clientCmdHandler ,command id =%x!!!!!!!\r\n",pInMsg->hdr.cmd);
//// switch(pInMsg->hdr.cmd)
//// {
//// case ZCL_CMD_BASIC_RESET_FAC_DEFAULT:
//// if(pInMsg->clusterAppCb){
//// zclIncomingAddrInfo_t addrInfo;
//// addrInfo.dirCluster = pInMsg->hdr.frmCtrl.bf.dir;
//// addrInfo.profileId = pApsdeInd->indInfo.profile_id;
//// addrInfo.srcAddr = pApsdeInd->indInfo.src_short_addr;
//// addrInfo.dstAddr = pApsdeInd->indInfo.dst_addr;
//// addrInfo.srcEp = pApsdeInd->indInfo.src_ep;
//// addrInfo.dstEp = pApsdeInd->indInfo.dst_ep;
////
//// status = pInMsg->clusterAppCb(&addrInfo, ZCL_CMD_BASIC_RESET_FAC_DEFAULT, NULL);
//// }else{
//// status = ZCL_STA_FAILURE;
//// }
//// break;
//// default:
//// status = ZCL_STA_UNSUP_CLUSTER_COMMAND;
//// break;
//// }
//
// return status;
//}
//
//_CODE_ZCL_ static status_t zcl_Private_cmdHandler(zclIncoming_t *pInMsg)
//{
// if(pInMsg->hdr.frmCtrl.bf.dir == ZCL_FRAME_CLIENT_SERVER_DIR){
// return zcl_private_clientCmdHandler(pInMsg);
// }else{
// return ZCL_STA_UNSUP_CLUSTER_COMMAND;
// }
//}
//
uint8_t kOptTunnelChunkRead(uint8_t endpoint,
uint16_t clusterId,
uint16_t attributeId,
......@@ -271,7 +227,29 @@ kk_err_t kOptTunnelMessageIncoming(OptMethodEm method,zclIncoming_t *pCmd)
// {
if( length >= 7 ) {
iKonkeAfSelfPrint("\r\n########################OPTDATA WRITE,g_tmp_length = %d\r\n",g_tmp_length);
if( g_pOptDataIncomingMessageCallback ) {
extern kk_err_t kCmdGeneralMsgPaser(UMsgNodeSt *pMsgNode, ComPortEm port, DataField_st *pDataOut);
UMsgNodeSt msgNode;
DataField_st dataOut;
// length pid ch opcode arg
memcpy(msgNode.buffer, &g_tmp_buffer[0], g_tmp_length);
msgNode.length = g_tmp_length;
if (kCmdGeneralMsgPaser(&msgNode, ECOM_PORT_FCC0, &dataOut) == KET_OK) {
iKonkeAfSelfPrint("length(%d)\r\n" , dataOut.u8Datalen);
iKonkeAfSelfPrintBuffer(dataOut.u8ARG, dataOut.u8Datalen);
g_tmp_length = dataOut.u8Datalen + 7;
g_tmp_buffer[0] = g_tmp_length - 1;
memcpy(&g_tmp_buffer[7], dataOut.u8ARG, dataOut.u8Datalen);
kOptTunnelMessageWriteResponse(pCmd, g_tmp_buffer);
} else if (kkFactoryMsgInComingPaser(&msgNode, ECOM_PORT_FCC0, &dataOut) == KET_OK) {
iKonkeAfSelfPrint("length(%d)\r\n" , dataOut.u8Datalen);
iKonkeAfSelfPrintBuffer(dataOut.u8ARG, dataOut.u8Datalen);
g_tmp_length = dataOut.u8Datalen + 7;
g_tmp_buffer[0] = g_tmp_length - 1;
memcpy(&g_tmp_buffer[7], dataOut.u8ARG, dataOut.u8Datalen);
kOptTunnelMessageWriteResponse(pCmd, g_tmp_buffer);
}
else if( g_pOptDataIncomingMessageCallback ) {
g_tmp_length = g_tmp_length - 6;
if(KET_NO_RESPONSE == g_pOptDataIncomingMessageCallback(g_tmp_buffer[5], g_tmp_buffer[6], g_tmp_buffer + 7, &g_tmp_length)){
return KET_NO_RESPONSE;
......
//#include "app/framework/plugin/network-steering/network-steering.h"
//#include "app/framework/plugin/network-steering/network-steering-internal.h"
#include "ikk-ota.h"
#include "ikk-debug.h"
#include "../driver/ikk-led.h"
#define LED_SLOW_BLINK_ON_TIME_MS 800
#define LED_SLOW_BLINK_OFF_TIME_MS 800
#define LED_FAST_BLINK_ON_TIME_MS 200
#define LED_FAST_BLINK_OFF_TIME_MS 200
#define LED_SLOW_BLINK_CONTINUE_TIME_MS (60 * 1000)
#define LED_FAST_BLINK_CONTINUE_TIME_MS (5 * 1000)
static OTAStatusEnum g_eOTAStatus = OTA_NORMAL;
static uint8_t g_u8OtaLedId = LED_UNKNOW_ID;
pOTACallback g_pOTACallback = NULL;
static void kOTAMoudleOptCallback(OTAStatusEnum status);
//__no_init OTAGpioStatusST g_stOTAGpioStatus @ 0x2000FFF0;
static OTAGpioStatusST g_stOTAGpioStatus;
OTAStatusEnum kGetOTAStatus(void)
{
return g_eOTAStatus;
}
void kSetOTAStatus(OTAStatusEnum status)
{
g_eOTAStatus = status;
}
void kOTAMoudleInit(pOTACallback callback, uint8_t led_id)
{
g_pOTACallback = callback;
g_u8OtaLedId = led_id;
}
void kOTAMoudleCallback(OTAStatusEnum status)
{
//校验成功或失败保存gpio状态,待bootloader中恢复
if (status == OTA_VERITY_SUCCEED || status == OTA_FAILED){
iKonkeAfSelfPrint("OTA GPIO KEEP status(%d)\r\n", g_eOTAStatus);
}
if (g_pOTACallback){
g_pOTACallback(status);
}else {
if (g_u8OtaLedId != LED_UNKNOW_ID){
kOTAMoudleOptCallback(status);
}
}
}
static void kOTAMoudleOptCallback(OTAStatusEnum status)
{
iKonkeAfSelfPrint("##############kOTAMoudleUserCallback status(%d)##################\r\n", status);
static bool flg = false;//防止网关断电后,ota失败后会间隔快闪
switch(status)
{
case OTA_NORMAL:
break;
case OTA_START:
kLedOptTrigger(g_u8OtaLedId, 2 * LED_FAST_BLINK_ON_TIME_MS, 14 * LED_FAST_BLINK_ON_TIME_MS,\
OTA_UPGRADE__CONTINUE_MAX_TIME_MS /(2 * LED_FAST_BLINK_ON_TIME_MS + 14 * LED_FAST_BLINK_ON_TIME_MS), LED_ON, LED_ON);
g_eOTAStatus = OTA_START;
flg = false;
break;
case OTA_DOWNLOAD_DONE:
{
g_eOTAStatus = OTA_DOWNLOAD_DONE;
break;
}
case OTA_VERITY_SUCCEED:
//校验成功,记录继电器状态
//常亮5S
kLedOptTrigger(g_u8OtaLedId, 25 * LED_FAST_BLINK_ON_TIME_MS, LED_FAST_BLINK_ON_TIME_MS, 1, LED_ON, LED_ON);
g_eOTAStatus = OTA_NORMAL;
break;
case OTA_FAILED:
if (flg != true){
kLedOptTrigger(g_u8OtaLedId, LED_FAST_BLINK_ON_TIME_MS, LED_FAST_BLINK_ON_TIME_MS,\
LED_FAST_BLINK_CONTINUE_TIME_MS /(LED_FAST_BLINK_ON_TIME_MS + LED_FAST_BLINK_ON_TIME_MS), LED_ON, LED_ON);
g_eOTAStatus = OTA_NORMAL;
}
flg = true;
break;
default:
iKonkeAfSelfPrint("##############Err: OTA status is not exist\r\n");
break;
}
}
#ifndef __IKONKE_MODULE_OTA_H_______________________
#define __IKONKE_MODULE_OTA_H_______________________
#include "tl_common.h"
#define OTA_UPGRADE__CONTINUE_MAX_TIME_MS (16*60*1000)
#define OTA_GPIO_RESTORE_MAXN 8
typedef enum{OTA_NORMAL=0, OTA_START,OTA_DOWNLOAD_DONE, OTA_VERITY_SUCCEED, OTA_FAILED}OTAStatusEnum;
typedef enum{OTA_GPIO_OFF=0, OAT_GPIO_ON}OTAGpioEnum;
#pragma pack(1) //按1字节对齐
typedef struct {
uint32_t pin;
bool bStatus; // on/off
}OTAGpioListSt;
#pragma pack() //取消自定义字节对齐方式
#pragma pack(1) //按1字节对齐
typedef struct {
bool bIsValid;
uint8_t gpioNum;
OTAGpioListSt gpio[OTA_GPIO_RESTORE_MAXN];
}OTAGpioStatusST;
#pragma pack() //取消自定义字节对齐方式
//OTA操作函数,一般操作用来操作led
typedef void (*pOTACallback)(OTAStatusEnum status);
//获取当前产测状态
OTAStatusEnum kGetOTAStatus(void);
void kSetOTAStatus(OTAStatusEnum status);
void kOTAMoudleInit(pOTACallback callback, uint8_t led_id);
void kOTAMoudleCallback(OTAStatusEnum status);
#endif
......@@ -288,7 +288,11 @@ uint8_t General_Custom_Token_Save(uint8_t item,uint8_t *buff,uint8_t len)
//same data ,not need rewrite!
return 0;
}else if(All_Same_Data((uint8_t*)&sOptunnel_Token_temp.modeid,0xff,32)){
flash_write(TOKEN_USER_LOCATION+MODEL_ID_LOC_OFFSET,len,buff);
//Auth: han_frc.20220105.
u8 modelid_buff[35]={0};
modelid_buff[0] = len;
memcpy(modelid_buff+1,buff,len);
flash_write(TOKEN_USER_LOCATION+MODEL_ID_LOC_OFFSET,len+1,modelid_buff);
return 0;
}else{
sOptunnel_Token_temp.modeid.modeid_len = len;
......@@ -309,7 +313,11 @@ uint8_t General_Custom_Token_Save(uint8_t item,uint8_t *buff,uint8_t len)
//same data ,not need rewrite!
return 0;
}else if(All_Same_Data((uint8_t*)&sOptunnel_Token_temp.cmei,0xff,32)){
flash_write(TOKEN_USER_LOCATION+CMEI_LOC_OFFSET,len,buff);
//Auth: han_frc.20220105.
u8 cmei_buff[35]={0};
cmei_buff[0] = len;
memcpy(cmei_buff+1,buff,len);
flash_write(TOKEN_USER_LOCATION+CMEI_LOC_OFFSET,len+1,cmei_buff);
return 0;
}else{
sOptunnel_Token_temp.cmei.cmei_len = len;
......@@ -330,7 +338,11 @@ uint8_t General_Custom_Token_Save(uint8_t item,uint8_t *buff,uint8_t len)
//same data ,not need rewrite!
return 0;
}else if(All_Same_Data((uint8_t*)&sOptunnel_Token_temp.isn,0xff,32)){
flash_write(TOKEN_USER_LOCATION+ISN_LOC_OFFSET,len,buff);
//Auth: han_frc.20220105.
u8 isn_buff[35]={0};
isn_buff[0] = len;
memcpy(isn_buff+1,buff,len);
flash_write(TOKEN_USER_LOCATION+ISN_LOC_OFFSET,len+1,isn_buff);
return 0;
}else{
sOptunnel_Token_temp.isn.isn_len = len;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment