|
准备做个esp8266 soc的四路定时开关 四路定时互不影响 可以同时定时 最好加入周一到周七自由选择,下面三个文件应该如何修改gizwits_product.h
- #ifndef _GIZWITS_PRODUCT_H_
- #define _GIZWITS_PRODUCT_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "gizwits_protocol.h"
- #include "GAgent_soc.h"
- #define ON 1
- #define OFF 0
- extern bool STA[5];
- extern uint32_t time_data[5];//用于存储定时数据
- extern _tm ntptimeStr;
- /**
- * MCU software version number
- */
- #define SOFTWARE_VERSION "03030000"
- /**
- * MCU hardware version number
- */
- #define HARDWARE_VERSION "03000001"
- /**
- * Gagent minor version number for OTA upgrade
- * OTA hardware version number: 00ESP826
- * OTA software version number: 040206xx // "xx" is version number defaults to "25", consistent with the Gagent library version
- */
- #define SDK_VERSION "25"
- #ifndef SOFTWARE_VERSION
- #error "no define SOFTWARE_VERSION"
- #endif
- #ifndef HARDWARE_VERSION
- #error "no define HARDWARE_VERSION"
- #endif
- /** User area The current device state structure */
- extern dataPoint_t currentDataPoint;
- /** User area data point initialization */
- void userInit(void);
- /** User area device status detection */
- void userHandle(void);
- void getntpTimerFunc(void);
- /** User zone event handling */
- int8_t gizwitsEventProcess(eventInfo_t * info, uint8_t * data, uint32_t len);
- #ifdef __cplusplus
- }
- #endif
复制代码 gizwits_product.c
- #include <stdio.h>
- #include <string.h>
- #include "gizwits_product.h"
- #include "driver/hal_key.h"
- /*
- LOCAL os_timer_t time_low_sz; ///< 用户定时器结构
- //关闭定时器
- //参数一:要关闭的定时器
- os_timer_disarm(&time_low_sz);
- //设置定时器
- //参数一:要设置的定时器;参数二:定时器到时间要执行的回调函数;参数三:回调函数的参数
- os_timer_setfn(&time_low_sz, (os_timer_func_t *)time_low, NULL);
- //使能(启动)定时器
- //参数一:要使能的定时器;参数二:定时时间(单位:ms);参数三:是否重复执行,即执行完1次
- os_timer_arm(&time_low_sz, 1000, 1);
- //倒计时函数
- void ICACHE_FLASH_ATTR time_low(void)
- {
- currentDataPoint.valuecountdown = time_data[2];//上报当前剩余时间
- }
- */
- /** 用户区域当前设备状态结构 */
- dataPoint_t currentDataPoint;
- bool STA[5]={0}; //用于存储5个开关的状态
- uint32_t time_data[5]={0};//用于存储定时数据 0.定时时 1.定时分 2.倒计时(分钟)3.定时开:ON 定时关关:OFF 4。需要定时的开关01234
- _tm ntptimeStr;//时间结构体返回临时值
- /**@name Gizwits 用户界面
- * @{
- */
- /**
- * @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))
- {
- GIZWITS_LOG("!!! gizwitsEventProcess Error \n");
- return -1;
- }
- for(i = 0; i < info->num; i++)
- {
- switch(info->event[i])
- {
- case EVENT_sw1 :
- currentDataPoint.valuesw1 = dataPointPtr->valuesw1;
- GIZWITS_LOG("Evt: EVENT_sw1 %d \n", currentDataPoint.valuesw1);
- if(0x01 == currentDataPoint.valuesw1)
- {
- STA[0]=1;//用户处理
- }
- else
- {
- STA[0]=0;//用户处理
- }
- break;
- case EVENT_sw2 :
- currentDataPoint.valuesw2 = dataPointPtr->valuesw2;
- GIZWITS_LOG("Evt: EVENT_sw2 %d \n", currentDataPoint.valuesw2);
- if(0x01 == currentDataPoint.valuesw2)
- {
- STA[1]=1;//用户处理
- }
- else
- {
- STA[1]=0;//用户处理
- }
- break;
- case EVENT_sw3 :
- currentDataPoint.valuesw3 = dataPointPtr->valuesw3;
- GIZWITS_LOG("Evt: EVENT_sw3 %d \n", currentDataPoint.valuesw3);
- if(0x01 == currentDataPoint.valuesw3)
- {
- STA[2]=1;//用户处理
- }
- else
- {
- STA[2]=0;//用户处理
- }
- break;
- case EVENT_sw4 :
- currentDataPoint.valuesw4 = dataPointPtr->valuesw4;
- GIZWITS_LOG("Evt: EVENT_sw4 %d \n", currentDataPoint.valuesw4);
- if(0x01 == currentDataPoint.valuesw4)
- {
- STA[3]=1;//用户处理
- }
- else
- {
- STA[3]=0;//用户处理
- }
- break;
- case EVENT_ok :
- currentDataPoint.valueok = dataPointPtr->valueok;
- GIZWITS_LOG("Evt: EVENT_ok %d \n", currentDataPoint.valueok);
- if(0x01 == currentDataPoint.valueok)
- {
- STA[4]=0;//用户处理
- }
- else
- {
- STA[4]=1;//用户处理
- }
- break;
- case EVENT_sw:
- currentDataPoint.valuesw = dataPointPtr->valuesw;
- GIZWITS_LOG("Evt: EVENT_sw %d\n", currentDataPoint.valuesw);
- switch(currentDataPoint.valuesw)
- {
- case sw_VALUE0://开关1
- time_data[4]=0;//用户处理
- break;
- case sw_VALUE1://开关2
- time_data[4]=1;//用户处理
- break;
- case sw_VALUE2://开关3
- time_data[4]=2;//用户处理
- break;
- case sw_VALUE3://开关4
- time_data[4]=3;//用户处理
- break;
- case sw_VALUE4://所有开关
- time_data[4]=4;//用户处理
- break;
- default:
- break;
- }
- break;
- case EVENT_mode:
- currentDataPoint.valuemode = dataPointPtr->valuemode;
- GIZWITS_LOG("Evt: EVENT_mode %d\n", currentDataPoint.valuemode);
- switch(currentDataPoint.valuemode)
- {
- case mode_VALUE0:
- time_data[3]=1;//用户处理
- break;
- case mode_VALUE1:
- time_data[3]=0;//用户处理
- break;
- default:
- break;
- }
- break;
- case EVENT_hour:
- currentDataPoint.valuehour= dataPointPtr->valuehour;
- GIZWITS_LOG("Evt:EVENT_hour %d\n",currentDataPoint.valuehour);
- time_data[0]=currentDataPoint.valuehour;//用户处理
- break;
- case EVENT_minute:
- currentDataPoint.valueminute= dataPointPtr->valueminute;
- GIZWITS_LOG("Evt:EVENT_minute %d\n",currentDataPoint.valueminute);
- time_data[1]=currentDataPoint.valueminute;//用户处理
- break;
- case EVENT_countdown:
- currentDataPoint.valuecountdown= dataPointPtr->valuecountdown;
- GIZWITS_LOG("Evt:EVENT_countdown %d\n",currentDataPoint.valuecountdown);
- time_data[2]=currentDataPoint.valuecountdown * 60;//用户处理,转换成秒钟
- break;
- case WIFI_SOFTAP://WIFI处于SOFTAP模式,热点模式,Access Point,提供无线接入服务,允许其它无线设备接入,提供数据访问,一般的无线路由/网桥工作在该模式下。AP和AP之间允许相互连接 Sta模式;
- break;
- case WIFI_AIRLINK://WIFI处于AIRLINK模式,广播模式
- break;
- case WIFI_STATION://WIFI处于STATION模式,类似于无线终端,sta本身并不接受无线的接入,它可以连接到AP,一般无线网卡即工作在该模式。
- break;
- case WIFI_CON_ROUTER://wifi连接路由器
- GIZWITS_LOG("@@@@ connected router\n");
- break;
- case WIFI_DISCON_ROUTER://WiFi断开路由器
- GIZWITS_LOG("@@@@ disconnected router\n");
- break;
- case WIFI_CON_M2M://WIFI连接M2M
- GIZWITS_LOG("@@@@ connected m2m\n");
- setConnectM2MStatus(0x01);
- break;
- case WIFI_DISCON_M2M://WIFI断开M2M
- GIZWITS_LOG("@@@@ disconnected m2m\n");
- setConnectM2MStatus(0x00);
- break;
- case WIFI_RSSI://wifi接收信号的强度
- GIZWITS_LOG("@@@@ RSSI %d\n", wifiData->rssi);
- break;
- case TRANSPARENT_DATA://透明数据传输
- GIZWITS_LOG("TRANSPARENT_DATA \n");
- //用户处理 , 读取数据 [data] , 大小 [len]
- break;
- case MODULE_INFO://模块信息
- GIZWITS_LOG("MODULE INFO ...\n");
- break;
-
- default:
- break;
- }
- }
- system_os_post(USER_TASK_PRIO_2, SIG_UPGRADE_DATA, 0);
- return 0;
- }
- /**
- * 用户网络时间获取与数据处理
- * 这里用户除了需要获取网络时间以外,还要创建相应的任务
- * @参数 无
- * @返回 无
- */
- void ICACHE_FLASH_ATTR getntpTimerFunc(void)
- {
- //倒计时缓存数据
- bool swls1[2] = {0};//临时缓存倒计时
- bool swls2[2] = {0};//临时缓存定时
- uint32_t swls[4] = {0};//缓存需要设置的开关标志
- /******************倒计时************************
- ******倒计时处理,定时器可以实现掉网情况下也能执行,还可******************
- ******以通过网络时间判定,触发了之后保存现在时间,计算出******************
- ******要相应的时间,然后判断当前时间是否达到了控制的时间******************
- ******网络处理方法请自行参考上述流程写*************************/
- if((time_data[2]!=0) && (STA[4]==1) && (swls1[0]==0))
- {
- swls1[0]=1;
- swls1[1]=1;
- STA[4]=0;//确定开关也要进行清位上报
- }
- if((time_data[2]!=0) && (swls1[0]==1))//如果倒计时值大于0,而起OK开关按下,倒计时不创建多任务,创建多任务之后无法看到剩余时间
- {
- if(swls1[1]==1)
- {
- swls[0]=time_data[4];//缓存要使用的开关标志
- swls[1]=time_data[3];//缓存需要设置的开关标志
- time_data[4]=0;//云端清位
- time_data[3]=0;//云端清位
- swls1[1]=0;
- }
- time_data[2]--;//由于此函数是1秒执行一次,所以每秒减1就行了
- }
- else//倒计时结束了
- {
- swls1[0]=0;
- //开关控制
- switch(swls[0])
- {
- case 0 :
- {
- if(swls[1]==0) STA[0]=0;//设置第一个开关的状态
- else STA[0]=1;//设置第一个开关的状态
- }
- break;
- case 1 :
- {
- if(swls[1]==0) STA[1]=0;//设置第二个开关的状态
- else STA[1]=1;//设置第一个开关的状态
- }
- break;
- case 2 :
- {
- if(swls[1]==0) STA[2]=0;//设置第三个开关的状态
- else STA[2]=1;//设置第一个开关的状态
- }
- break;
- case 3 :
- {
- if(swls[1]==0) STA[3]=0;//设置第四个开关的状态
- else STA[3]=1;//设置第一个开关的状态
- }
- break;
- case 4 :
- {
- if(swls[1]==0) //设置全部开关的状态
- {
- STA[0]=0;
- STA[1]=0;
- STA[2]=0;
- STA[3]=0;
- }
- else
- {
- STA[0]=1;
- STA[1]=1;
- STA[2]=1;
- STA[3]=1;
- }
- }
- break;
- default:
- break;
- }
- }
- /******************倒计时处理结束************************/
- /******************定时预约处理*************************/
- /*currentDataPoint.valuehour = time_data[0];
- currentDataPoint.valueminute = time_data[1];*/
- gagentGetNTP(&ntptimeStr);
- os_printf("gagentntp secon: %d",ntptimeStr.second);//打印时间
- if(((time_data[0] != 0) || (time_data[1] != 0)) && (STA[4]==1) && (swls2[0]==0))
- {
- swls2[0]=1;
- swls2[1]=1;
- STA[4]=0;//确定开关也要进行清位上报
- currentDataPoint.valuehour = 0;//云端清除
- currentDataPoint.valueminute = 0;//云端清除
- }
- if(((time_data[0] != 0) || (time_data[1] != 0)) && (swls2[0]==1) )
- {
- if(swls2[1]==1)
- {
- swls[2]=time_data[4];//缓存要使用的开关标志
- swls[3]=time_data[3];//缓存需要设置的开关标志
- time_data[4]=0;//云端清位
- time_data[3]=0;//云端清位
- swls2[1]=0;
- }
- if(ntptimeStr.hour == time_data[0])//时
- {
- if(ntptimeStr.minute == time_data[1])//分
- {
- swls2[0]=0;
- //开关控制
- switch(swls[0])
- {
- case 0 :
- {
- if(swls[1]==0) STA[0]=0;//设置第一个开关的状态
- else STA[0]=1;//设置第一个开关的状态
- }
- break;
- case 1 :
- {
- if(swls[1]==0) STA[1]=0;//设置第二个开关的状态
- else STA[1]=1;//设置第一个开关的状态
- }
- break;
- case 2 :
- {
- if(swls[1]==0) STA[2]=0;//设置第三个开关的状态
- else STA[2]=1;//设置第一个开关的状态
- }
- break;
- case 3 :
- {
- if(swls[1]==0) STA[3]=0;//设置第四个开关的状态
- else STA[3]=1;//设置第一个开关的状态
- }
- break;
- case 4 :
- {
- if(swls[1]==0) //设置全部开关的状态
- {
- STA[0]=0;
- STA[1]=0;
- STA[2]=0;
- STA[3]=0;
- }
- else
- {
- STA[0]=1;
- STA[1]=1;
- STA[2]=1;
- STA[3]=1;
- }
- }
- break;
- default:
- break;
- }
- }
- }
- }
- }
- /**
- * 用户数据采集
- * 这里用户除了需要实现数据点采集以外的数据采集外,还可以自定义采集频率和设计数据滤波算法。
- * @参数 无
- * @返回 无
- */
- void ICACHE_FLASH_ATTR userHandle(void)
- {
- //GPIO开关控制,此处为低电平有效控制,若改为高电平,则不需要取反
- GPIO_OUTPUT_SET(GPIO_ID_PIN(12), !STA[0]);
- GPIO_OUTPUT_SET(GPIO_ID_PIN(13), !STA[1]);
- GPIO_OUTPUT_SET(GPIO_ID_PIN(14), !STA[2]);
- GPIO_OUTPUT_SET(GPIO_ID_PIN(15), !STA[3]);
- //数据上报,可适当增加定时上报时间,节约芯片上传产生不必要的负荷
- currentDataPoint.valuesw1 = STA[0];
- currentDataPoint.valuesw2 = STA[1];
- currentDataPoint.valuesw3 = STA[2];
- currentDataPoint.valuesw4 = STA[3];
- currentDataPoint.valueok = STA[4];
- if(time_data[2]<60 && time_data[2]>0) currentDataPoint.valuecountdown =1;//不到1分钟按照1分钟计算
- else currentDataPoint.valuecountdown = time_data[2]/60;//秒钟转换成分钟
- system_os_post(USER_TASK_PRIO_2, SIG_UPGRADE_DATA, 0);
- }
- /**
- * 数据点初始化功能
- * 在函数中完成初始用户相关数据
- * @参数 无
- * @返回 无
- * @note 开发人员可以在这个函数中添加一个数据点状态初始化值。
- */
- void ICACHE_FLASH_ATTR userInit(void)
- {
- gizMemset((uint8_t *)¤tDataPoint, 0, sizeof(dataPoint_t));
- /** 警告!!!因变量的初始化,必须在数据范围 **/
- //以下数据点都不具备掉电存储的初始化
- currentDataPoint.valuesw1 = 0;
- currentDataPoint.valuesw2 = 0;
- currentDataPoint.valuesw3 = 0;
- currentDataPoint.valuesw4 = 0;
- currentDataPoint.valueok = 0;
- currentDataPoint.valuesw = 0;
- currentDataPoint.valuemode = 0;
- currentDataPoint.valuehour = 0;
- currentDataPoint.valueminute = 0;
- }
复制代码 user_main.c
- #include "ets_sys.h"
- #include "osapi.h"
- #include "user_interface.h"
- #include "gagent_soc.h"
- #include "user_devicefind.h"
- #include "user_webserver.h"
- #include "gizwits_product.h"
- #include "driver/hal_key.h"
- #if ESP_PLATFORM
- #include "user_esp_platform.h"
- #endif
- #ifdef SERVER_SSL_ENABLE
- #include "ssl/cert.h"
- #include "ssl/private_key.h"
- #else
- #ifdef CLIENT_SSL_ENABLE
- unsigned char *default_certificate;
- unsigned int default_certificate_len = 0;
- unsigned char *default_private_key;
- unsigned int default_private_key_len = 0;
- #endif
- #endif
- /**@name 用户定时器相关参数
- * @{
- */
- #define USER_TIME_MS 50 ///< 50毫秒时间
- LOCAL os_timer_t userTimer; ///< 用户定时器结构
- #define NTP_TIME_1000MS 1000 ///< 1000毫秒时间
- LOCAL os_timer_t ntpTimer1000ms; ///< 用户定时器结构
- /**@} */
- /**@name 按键的相关定义
- * @{
- */
- #define GPIO_KEY_NUM 4 ///< 定义按键成员的总数。
- #define KEY_0_IO_MUX PERIPHS_IO_MUX_GPIO2_U ///< ESP8266 GPIO 功能
- #define KEY_0_IO_NUM 2 ///< ESP8266 GPIO 数
- #define KEY_0_IO_FUNC FUNC_GPIO2 ///< ESP8266 GPIO 名称
- #define KEY_1_IO_MUX PERIPHS_IO_MUX_GPIO0_U ///< ESP8266 GPIO 功能
- #define KEY_1_IO_NUM 0 ///< ESP8266 GPIO 数
- #define KEY_1_IO_FUNC FUNC_GPIO0 ///< ESP8266 GPIO 名称
- #define KEY_2_IO_MUX PERIPHS_IO_MUX_GPIO4_U ///< ESP8266 GPIO 功能
- #define KEY_2_IO_NUM 4 ///< ESP8266 GPIO 数
- #define KEY_2_IO_FUNC FUNC_GPIO4 ///< ESP8266 GPIO 名称
- #define KEY_3_IO_MUX PERIPHS_IO_MUX_GPIO5_U ///< ESP8266 GPIO 功能
- #define KEY_3_IO_NUM 5 ///< ESP8266 GPIO 数
- #define KEY_3_IO_FUNC FUNC_GPIO5 ///< ESP8266 GPIO 名称
- LOCAL key_typedef_t * singleKey[GPIO_KEY_NUM]; ///< 定义单个按键成员数组指针
- LOCAL keys_typedef_t keys; ///< 定义总体按键模块结构指针。
- /**@} */
- /*key1按键短按处理*/
- LOCAL void ICACHE_FLASH_ATTR key1ShortPress(void)
- {
- STA[1]=!STA[1];
- }
- /*key1按键长按处理*/
- LOCAL void ICACHE_FLASH_ATTR key1LongPress(void)
- {
- gizwitsSetMode(WIFI_SOFTAP_MODE);
- //gizwitsSetMode(WIFI_AIRLINK_MODE);
- }
- /*key2按键短按处理*/
- LOCAL void ICACHE_FLASH_ATTR key2ShortPress(void)
- {
- STA[2]=!STA[2];
- }
- /* key2按键长按处理*/
- LOCAL void ICACHE_FLASH_ATTR key2LongPress(void)
- {
- gizwitsSetMode(WIFI_SOFTAP_MODE);
- }
- /*key3按键短按处理*/
- LOCAL void ICACHE_FLASH_ATTR key3ShortPress(void)
- {
- STA[3]=!STA[3];
- }
- /*key3按键长按处理*/
- LOCAL void ICACHE_FLASH_ATTR key3LongPress(void)
- {
- gizwitsSetMode(WIFI_SOFTAP_MODE);
- }
- //key4按键短按处理*
- LOCAL void ICACHE_FLASH_ATTR key4ShortPress(void)
- {
- STA[4]=!STA[4];
- }
- //key4按键长按处理*
- LOCAL void ICACHE_FLASH_ATTR key4LongPress(void)
- {
- gizwitsSetMode(WIFI_SOFTAP_MODE);
- }
- /**
- * 按键初始化
- * @参数 无
- * @返回 无
- */
- LOCAL void ICACHE_FLASH_ATTR keyInit(void)
- {
- singleKey[0] = keyInitOne(KEY_0_IO_NUM, KEY_0_IO_MUX, KEY_0_IO_FUNC,
- key1LongPress, key1ShortPress);
- singleKey[1] = keyInitOne(KEY_1_IO_NUM, KEY_1_IO_MUX, KEY_1_IO_FUNC,
- key2LongPress, key2ShortPress);
- singleKey[2] = keyInitOne(KEY_2_IO_NUM, KEY_2_IO_MUX, KEY_2_IO_FUNC,
- key3LongPress, key3ShortPress);
- singleKey[3] = keyInitOne(KEY_3_IO_NUM, KEY_3_IO_MUX, KEY_3_IO_FUNC,
- key4LongPress, key4ShortPress);
- keys.singleKey = singleKey;
- keyParaInit(&keys);
- PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);//开关1
- PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);//开关2
- PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);//开关3
- PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);//开关4
- }
- /**
- * @brief user_rf_cal_sector_set
- * 在Flash中使用第636扇区的(2544k ~ 2548k)存储rf_cal参数
- * @参数 无
- * @返回 无
- */
- uint32_t ICACHE_FLASH_ATTR user_rf_cal_sector_set()
- {
- return 636;
- }
- /**
- * @brief 程序的入口函数
- * 在函数中完成与用户相关的初始化
- * @参数 无
- * @返回 无
- */
- void ICACHE_FLASH_ATTR user_init(void)
- {
- uint32_t system_free_size = 0;
- wifi_station_set_auto_connect(1);
- wifi_set_sleep_type(NONE_SLEEP_T);//设置无休眠模式
- espconn_tcp_set_max_con(10);
- uart_init_3(9600,115200);
- UART_SetPrintPort(1);
- GIZWITS_LOG( "---------------SDK version:%s--------------\n", system_get_sdk_version());
- GIZWITS_LOG( "system_get_free_heap_size=%d\n",system_get_free_heap_size());
- struct rst_info *rtc_info = system_get_rst_info();
- GIZWITS_LOG( "reset reason: %x\n", rtc_info->reason);
- if (rtc_info->reason == REASON_WDT_RST ||
- rtc_info->reason == REASON_EXCEPTION_RST ||
- rtc_info->reason == REASON_SOFT_WDT_RST)
- {
- if (rtc_info->reason == REASON_EXCEPTION_RST)
- {
- GIZWITS_LOG("Fatal exception (%d):\n", rtc_info->exccause);
- }
- GIZWITS_LOG( "epc1=0x%08x, epc2=0x%08x, epc3=0x%08x, excvaddr=0x%08x, depc=0x%08x\n",
- rtc_info->epc1, rtc_info->epc2, rtc_info->epc3, rtc_info->excvaddr, rtc_info->depc);
- }
- if (system_upgrade_userbin_check() == UPGRADE_FW_BIN1)
- {
- GIZWITS_LOG( "---UPGRADE_FW_BIN1---\n");
- }
- else if (system_upgrade_userbin_check() == UPGRADE_FW_BIN2)
- {
- GIZWITS_LOG( "---UPGRADE_FW_BIN2---\n");
- }
- keyInit();
-
- userInit();
- gizwitsInit();
- //使用定时
- os_timer_disarm(&userTimer);
- os_timer_setfn(&userTimer, (os_timer_func_t *)userHandle, NULL);
- os_timer_arm(&userTimer, USER_TIME_MS, 1);
- //定时获取网络时间以及处理函数
- os_timer_disarm(&ntpTimer1000ms);
- os_timer_setfn(&ntpTimer1000ms, (os_timer_func_t *)getntpTimerFunc, NULL);
- os_timer_arm(&ntpTimer1000ms, NTP_TIME_1000MS, 1);
- GIZWITS_LOG("--- system_free_size = %d ---\n", system_get_free_heap_size());
- }
复制代码
|
|