|
因为我也要保存当前状态,所以今晚又测试了一下,既然可以了,真是莫明其妙,不知问题出在哪?请高手解答一下。
下面代码给你参考一下:
gizwits_product.c
/** 用户区当前设备状态结构体*/
extern dataPoint_t currentDataPoint;
[url=]/**@name[/url] Gizwits 用户API接口
* @{
*/
/**
* @brief 事件处理接口
* 说明:
* 1.用户可以对WiFi模组状态的变化进行自定义的处理
* 2.用户可以在该函数内添加数据点事件处理逻辑,如调用相关硬件外设的操作接口
* @param[in] info : 事件队列
* @param[in] data : 协议数据
* @param[in] len : 协议数据长度
* @return NULL
* @ref gizwits_protocol.h
*/
int8_t ICACHE_FLASH_ATTR gizwitsEventProcess(eventInfo_t *info, uint8_t *data, uint32_t len)
{
uint8_t i = 0;
dataPoint_t *dataPointPtr = (dataPoint_t *)data;
moduleStatusInfo_t *wifiData = (moduleStatusInfo_t *)data;
if((NULL == info) || (NULL == data))
{
return -1;
}
for(i=0; i<info->num; i++)
{
switch(info->event)
{
case EVENT_SOCKET_ONOFF_A:
currentDataPoint.valuesocket_OnOff_a = dataPointPtr->valuesocket_OnOff_a;
os_printf("Evt: EVENT_SOCKET_ONOFF_A %d \n", currentDataPoint.valuesocket_OnOff_a);
if(0x01 == currentDataPoint.valuesocket_OnOff_a)
{
//user handle
}
break;
case EVENT_TIMING_START:
currentDataPoint.valuetiming_start = dataPointPtr->valuetiming_start;
os_printf("Evt: EVENT_TIMING_START %d \n", currentDataPoint.valuetiming_start);
if(0x01 == currentDataPoint.valuetiming_start)
{
//user handle
}
break;
case EVENT_TIMED_TASK:
currentDataPoint.valuetimed_task = dataPointPtr->valuetimed_task;
os_printf("Evt: EVENT_TIMED_TASK %d\n", currentDataPoint.valuetimed_task);
switch(currentDataPoint.valuetimed_task)
{
case TIMED_TASK_VALUE0:
//user handle
break;
case EVENT_TIMING_HOUR:
currentDataPoint.valuetiming_hour = dataPointPtr->valuetiming_hour;
os_printf("Evt:EVENT_TIMING_HOUR %d\n",currentDataPoint.valuetiming_hour);
//user handle
}
break;
case EVENT_TIMING_MINUTE:
currentDataPoint.valuetiming_minute = dataPointPtr->valuetiming_minute;
os_printf("Evt:EVENT_TIMING_MINUTE %d\n",currentDataPoint.valuetiming_minute);
//user handle
}
break;
case WIFI_SOFTAP:
break;
case WIFI_AIRLINK:
break;
case WIFI_STATION:
break;
case WIFI_CON_ROUTER:
break;
case WIFI_DISCON_ROUTER:
break;
case WIFI_CON_M2M:
break;
case WIFI_DISCON_M2M:
break;
case WIFI_RSSI:
os_printf("RSSI %d\n", wifiData->rssi);
break;
case TRANSPARENT_DATA:
os_printf("TRANSPARENT_DATA \n");
//user handle , Fetch data from [data] , size is [len]
break;
default:
break;
}
}
system_os_post(USER_TASK_PRIO_0, SIG_UPGRADE_DATA, 0);
system_param_save_with_protect(0x7D, (uint32 *)¤tDataPoint, sizeof(currentDataPoint));
os_printf("### save timing ### \n");
return 0;
}
读函数:(临时位置)
user_main.c
/** 用户区当前设备状态结构体*/
dataPoint_t currentDataPoint;
dataPoint_t currentDataPoint_my; //新定义一个结构体保存从flash读出的数据
void ICACHE_FLASH_ATTR userTimerFunc(void)
{
system_param_load(0x7D, 0, (uint32 *)¤tDataPoint_my,sizeof(currentDataPoint_my));
os_printf("### timing : %d \n",currentDataPoint_my.valuetiming_minute);
system_os_post(USER_TASK_PRIO_0, SIG_UPGRADE_DATA, 0);
}
|
|