资深版主
- 积分
- 1211
- 金钱
- 1211
- 注册时间
- 2020-2-25
- 在线时间
- 115 小时
|
第一篇内容:总体设计/系统功能介绍/机智云自助开发平台-开发利器GAgent等等
点击下载:【Io开发笔记】机智云智能浇花器实战(1)-基础Demo实现
第二篇内容:
继电器实现/功能测试/DHT11驱动代码实现/OLED屏幕显示传感器数据/中文字模制作等等
点击下载:机智云智能浇花器实战(2)-基础Demo实现
一,BH1750光照传感器原理图
二,BH1750传感器代码
- #include "bh1750.h"
- #include "delay.h"
- uint8_t BUF[8]; //接收数据缓存区
- int mcy; //进位标志
- /**开始信号**/
- void BH1750_Start()
- {
- BH1750_SDA_H; //拉高数据线
- BH1750_SCL_H; //拉高时钟线
- Delay_nus(5); //延时
- GPIO_ResetBits(BH1750_PORT, BH1750_SDA_PIN); //产生下降沿
- Delay_nus(5); //延时
- GPIO_ResetBits(BH1750_PORT, BH1750_SCL_PIN); //拉低时钟线
- }
- /***停止信号***/
- void BH1750_Stop()
- {
- BH1750_SDA_L; //拉低数据线
- BH1750_SCL_H; //拉高时钟线
- Delay_nus(5); //延时
- GPIO_SetBits(BH1750_PORT, BH1750_SDA_PIN); //产生上升沿
- Delay_nus(5); //延时
- }
- /******************
- 发送应答信号
- 入口参数:ack (0:ACK 1:NAK)
- ******************/
- void BH1750_SendACK(int ack)
- {
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStruct.GPIO_Pin = BH1750_SDA_PIN;
- GPIO_Init(BH1750_PORT, &GPIO_InitStruct);
- if(ack == 1) //写应答信号
- BH1750_SDA_H;
- else if(ack == 0)
- BH1750_SDA_L;
- else
- return;
- BH1750_SCL_H; //拉高时钟线
- Delay_nus(5); //延时
- BH1750_SCL_L; //拉低时钟线
- Delay_nus(5); //延时
- }
- /******************
- 接收应答信号
- ******************/
- int BH1750_RecvACK()
- {
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Mode=GPIO_Mode_IPU; /*这里一定要设成输入上拉,否则不能读出数据*/
- GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
- GPIO_InitStruct.GPIO_Pin=BH1750_SDA_PIN;
- GPIO_Init(BH1750_PORT,&GPIO_InitStruct);
- BH1750_SCL_H; //拉高时钟线
- Delay_nus(5); //延时
- if(GPIO_ReadInputDataBit(BH1750_PORT,BH1750_SDA_PIN)==1)//读应答信号
- mcy = 1 ;
- else
- mcy = 0 ;
- BH1750_SCL_L; //拉低时钟线
- Delay_nus(5); //延时
- GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;
- GPIO_Init(BH1750_PORT,&GPIO_InitStruct);
- return mcy;
- }
- /******************
- 向IIC总线发送一个字节数据
- ******************/
- void BH1750_SendByte(uint8_t dat)
- {
- uint8_t i;
- for (i=0; i<8; i++) //8位计数器
- {
- if( 0X80 & dat )
- GPIO_SetBits(BH1750_PORT,BH1750_SDA_PIN);
- else
- GPIO_ResetBits(BH1750_PORT,BH1750_SDA_PIN);
- dat <<= 1;
- BH1750_SCL_H; //拉高时钟线
- Delay_nus(5); //延时
- BH1750_SCL_L; //拉低时钟线
- Delay_nus(5); //延时
- }
- BH1750_RecvACK();
- }
- uint8_t BH1750_RecvByte()
- {
- uint8_t i;
- uint8_t dat = 0;
- uint8_t bit;
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU; /*这里一定要设成输入上拉,否则不能读出数据*/
- GPIO_InitStruct.GPIO_Pin = BH1750_SDA_PIN;
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(BH1750_PORT,&GPIO_InitStruct );
- GPIO_SetBits(BH1750_PORT,BH1750_SDA_PIN); //使能内部上拉,准备读取数据,
- for (i=0; i<8; i++) //8位计数器
- {
- dat <<= 1;
- BH1750_SCL_H; //拉高时钟线
- Delay_nus(5); //延时
- if( SET == GPIO_ReadInputDataBit(BH1750_PORT,BH1750_SDA_PIN))
- bit = 0X01;
- else
- bit = 0x00;
- dat |= bit; //读数据
- BH1750_SCL_L; //拉低时钟线
- Delay_nus(5); //延时
- }
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_Init(BH1750_PORT, &GPIO_InitStruct );
- return dat;
- }
- void Single_Write_BH1750(uint8_t REG_Address)
- {
- BH1750_Start(); //起始信号
- BH1750_SendByte(SlaveAddress); //发送设备地址+写信号
- BH1750_SendByte(REG_Address); //内部寄存器地址,请参考中文pdf22页
- // BH1750_SendByte(REG_data); //内部寄存器数据,请参考中文pdf22页
- BH1750_Stop(); //发送停止信号
- }
- //初始化BH1750,根据需要请参考pdf进行修改**
- void BH1750_Init()
- {
- GPIO_InitTypeDef GPIO_InitStruct;
- /*开启GPIOB的外设时钟*/
- RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStruct.GPIO_Pin = BH1750_SDA_PIN | BH1750_SCL_PIN ;
- GPIO_Init(BH1750_PORT,&GPIO_InitStruct);
- Single_Write_BH1750(0x01);
- Delay_nms(180); //延时180ms
- }
- //连续读出BH1750内部数据
- void mread(void)
- {
- uint8_t i;
- BH1750_Start(); //起始信号
- BH1750_SendByte(SlaveAddress+1); //发送设备地址+读信号
- for (i=0; i<3; i++) //连续读取6个地址数据,存储中BUF
- {
- BUF = BH1750_RecvByte(); //BUF[0]存储0x32地址中的数据
- if (i == 3)
- {
- BH1750_SendACK(1); //最后一个数据需要回NOACK
- }
- else
- {
- BH1750_SendACK(0); //回应ACK
- }
- }
- BH1750_Stop(); //停止信号
- Delay_nms(5);
- }
- float Read_BH1750(void)
- {
- int dis_data; //变量
- float temp1;
- float temp2;
- Single_Write_BH1750(0x01); // power on
- Single_Write_BH1750(0x10); // H- resolution mode
- Delay_nms(180); //延时180ms
- mread(); //连续读出数据,存储在BUF中
- dis_data=BUF[0];
- dis_data=(dis_data<<8)+BUF[1]; //合成数据
- temp1=dis_data/1.2;
- temp2=10*dis_data/1.2;
- temp2=(int)temp2%10;
- return temp1;
- }
[color=rgb(0, 0, 0) !important]复制代码
- #ifndef __BH1750_H__
- #define __BH1750_H__
- #include "STM32f10x.h"
- /*
- 定义器件在IIC总线中的从地址,根据ALT ADDRESS地址引脚不同修改
- ALT ADDRESS引脚接地时地址为0x46, 接电源时地址为0xB8
- */
- #define SlaveAddress 0x46
- #define BH1750_PORT GPIOB
- #define BH1750_SCL_PIN GPIO_Pin_1
- #define BH1750_SDA_PIN GPIO_Pin_0
- #define BH1750_SCL_H GPIO_SetBits(BH1750_PORT,BH1750_SCL_PIN)
- #define BH1750_SCL_L GPIO_ResetBits(BH1750_PORT,BH1750_SCL_PIN)
- #define BH1750_SDA_H GPIO_SetBits(BH1750_PORT,BH1750_SDA_PIN)
- #define BH1750_SDA_L GPIO_ResetBits(BH1750_PORT,BH1750_SDA_PIN)
- extern uint8_t BUF[8]; //接收数据缓存区
- extern int dis_data; //变量
- extern int mcy; //表示进位标志位
- void BH1750_Init(void);
- void conversion(uint32_t temp_data);
- void Single_Write_BH1750(uint8_t REG_Address); //单个写入数据
- uint8_t Single_Read_BH1750(uint8_t REG_Address); //单个读取内部寄存器数据
- void mread(void); //连续的读取内部寄存器数据
- float Read_BH1750(void);
- #endif
[color=rgb(0, 0, 0) !important]复制代码
BH1750传感器代码说明
核心板单独测试程序在PB0PB1管脚是完全正常,不知道是不是核心板的PB2上接了什么暂时还未排查出来问题,如果你是用开发板或者是自己设计的项目板的话,那么程序是直接可以使用的程序依然按照PB0PB1保留。
三,机智云自助开发平台数据点创建
机智云官方网站:https://www.gizwits.com/
步骤1,创建产品
创建好后就会有基本信息
步骤2,填写机智云产品ProductKey
这两个信息比较重要最好是保存下来
- Product Key :9c8a5a8e38344fb4af14b6db0f5b1df7
- Product Secret :45c86d8c6a2a4b1dac7d68df54f6e4f0
[color=rgb(0, 0, 0) !important]复制代码
步骤3,定义自己的数据点
只读:就是只允许赋值数据传感器赋值给平台平台只能读取
可写:就是数据可以被修改继电器的开关状态平台可以修改
四,MCU开发
mcu开发注意事项平台选Common其实就是STM32F103x平台
1,生成代码包
2,下载自动生成的代码包
3,机智云Gizwits协议移植
这两个文件夹要添加到自己的工程
这是添加的文件夹以及文件的目录
4,修改gizwits_product.c
- #include <stdio.h>
- #include <string.h>
- #include "gizwits_product.h"
- #include "usart3.h"
- static uint32_t timerMsCount;
- uint8_t aRxBuffer;
- dataPoint_t currentDataPoint;
- uint8_t wifi_flag;
- //存放事件处理API接口函数
- int8_t gizwitsEventProcess(eventInfo_t *info, uint8_t *gizdata, uint32_t len)
- {
- uint8_t i = 0;
- dataPoint_t *dataPointPtr = (dataPoint_t *)gizdata;
- moduleStatusInfo_t *wifiData = (moduleStatusInfo_t *)gizdata;
- protocolTime_t *ptime = (protocolTime_t *)gizdata;
- #if MODULE_TYPE
- gprsInfo_t *gprsInfoData = (gprsInfo_t *)gizdata;
- #else
- moduleInfo_t *ptModuleInfo = (moduleInfo_t *)gizdata;
- #endif
- if((NULL == info) || (NULL == gizdata))
- {
- return -1;
- }
- for(i=0; i<info->num; i++)
- {
- switch(info->event)
- {
- case EVENT_Relay_1:
- currentDataPoint.valueRelay_1 = dataPointPtr->valueRelay_1;
- GIZWITS_LOG("Evt: EVENT_Relay_1 %d \n", currentDataPoint.valueRelay_1);
- if(0x01 == currentDataPoint.valueRelay_1)
- {
- currentDataPoint.valueRelay_1 = 1;
- }
- else
- {
- currentDataPoint.valueRelay_1 = 0;
- }
- 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:
- wifi_flag = 1; //WiFi连接标志
- break;
- case WIFI_DISCON_M2M:
- wifi_flag = 0; //WiFi断开标志
- break;
- case WIFI_RSSI:
- GIZWITS_LOG("RSSI %d\n", wifiData->rssi);
- break;
- case TRANSPARENT_DATA:
- GIZWITS_LOG("TRANSPARENT_DATA \n");
- //user handle , Fetch data from [data] , size is [len]
- break;
- case WIFI_NTP:
- GIZWITS_LOG("WIFI_NTP : [%d-%d-%d %02d:%02d:%02d][%d] \n",ptime->year,ptime->month,ptime->day,ptime->hour,ptime->minute,ptime->second,ptime->ntp);
- break;
- case MODULE_INFO:
- GIZWITS_LOG("MODULE INFO ...\n");
- #if MODULE_TYPE
- GIZWITS_LOG("GPRS MODULE ...\n");
- //Format By gprsInfo_t
- #else
- GIZWITS_LOG("WIF MODULE ...\n");
- //Format By moduleInfo_t
- GIZWITS_LOG("moduleType : [%d] \n",ptModuleInfo->moduleType);
- #endif
- break;
- default:
- break;
- }
- }
- return 0;
- }
- void userHandle(void)
- {
- /*
- currentDataPoint.valueTemp = ;//Add Sensor Data Collection
- currentDataPoint.valueHumi = ;//Add Sensor Data Collection
- currentDataPoint.valueLight_Intensity = ;//Add Sensor Data Collection
- */
- }
- void userInit(void)
- {
- memset((uint8_t*)¤tDataPoint, 0, sizeof(dataPoint_t));
- currentDataPoint.valueRelay_1 = 0;
- currentDataPoint.valueTemp = 0;
- currentDataPoint.valueHumi = 0;
- currentDataPoint.valueLight_Intensity = 0;
- }
- void gizTimerMs(void)
- {
- timerMsCount++;
- }
- uint32_t gizGetTimerCount(void)
- {
- return timerMsCount;
- }
- void mcuRestart(void)
- {
- __set_FAULTMASK(1);
- NVIC_SystemReset();
- }
- void TIMER_IRQ_FUN(void)
- {
- gizTimerMs();
- }
- void UART_IRQ_FUN(void)
- {
- uint8_t value = 0;
- gizPutData(&value, 1);
- }
- int32_t uartWrite(uint8_t *buf, uint32_t len)
- {
- uint32_t i = 0;
- if(NULL == buf)
- {
- return -1;
- }
- for(i=0; i<len; i++)
- {
- USART_SendData(USART3,buf);
- while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET); //循环发送,直到发送完毕
- if(i >=2 && buf == 0xFF)
- {
- USART_SendData(USART3, 0x55);
- while (USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET); //循环发送,直到发送完毕
- }
- }
- return len;
- }
[color=rgb(0, 0, 0) !important]复制代码
5,修改
- #ifndef _GIZWITS_PRODUCT_H
- #define _GIZWITS_PRODUCT_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdint.h>
- //#include "stm32f1xx.h"
- #include "gizwits_protocol.h"
- /**
- * MCU software version
- */
- #define SOFTWARE_VERSION "03030000"
- /**
- * MCU hardware version
- */
- #define HARDWARE_VERSION "03010100"
- /**
- * Communication module model
- */
- #define MODULE_TYPE 0 //0,WIFI ;1,GPRS
- /**@name TIM3 related macro definition
- * @{
- */
- #define TIMER TIM3
- #define TIMER_IRQ TIM3_IRQn
- #define TIMER_RCC RCC_APB1Periph_TIM3
- #define TIMER_IRQ_FUN TIM3_IRQHandler
- /**@} */
- /**@name USART related macro definition
- * @{
- */
- #define UART_BAUDRATE 9600
- #define UART_PORT 2
- #define UART USART2
- #define UART_IRQ USART2_IRQn
- #define UART_IRQ_FUN USART2_IRQHandler
- #if (UART_PORT == 1)
- #define UART_GPIO_Cmd RCC_APB2PeriphClockCmd
- #define UART_GPIO_CLK RCC_APB2Periph_GPIOA
- #define UART_AFIO_Cmd RCC_APB2PeriphClockCmd
- #define UART_AFIO_CLK RCC_APB2Periph_AFIO
- #define UART_CLK_Cmd RCC_APB2PeriphClockCmd
- #define UART_CLK RCC_APB2Periph_USART1
- #define UART_GPIO_PORT GPIOA
- #define UART_RxPin GPIO_Pin_10
- #define UART_TxPin GPIO_Pin_9
- #endif
- #if (UART_PORT == 2)
- #define UART_GPIO_Cmd RCC_APB2PeriphClockCmd
- #define UART_GPIO_CLK RCC_APB2Periph_GPIOA
- #define UART_AFIO_Cmd RCC_APB2PeriphClockCmd
- #define UART_AFIO_CLK RCC_APB2Periph_AFIO
- #define UART_CLK_Cmd RCC_APB1PeriphClockCmd
- #define UART_CLK RCC_APB1Periph_USART2
- #define UART_GPIO_PORT GPIOA
- #define UART_RxPin GPIO_Pin_3
- #define UART_TxPin GPIO_Pin_2
- #endif
- #if (UART_PORT == 3)
- #define UART_GPIO_Cmd RCC_APB2PeriphClockCmd
- #define UART_GPIO_CLK RCC_APB2Periph_GPIOC
- #define UART_AFIO_Cmd RCC_APB2PeriphClockCmd
- #define UART_AFIO_CLK RCC_APB2Periph_AFIO
- #define UART_CLK_Cmd RCC_APB1PeriphClockCmd
- #define UART_CLK RCC_APB1Periph_USART3
- #define UART_GPIO_PORT GPIOC
- #define UART_RxPin GPIO_Pin_11
- #define UART_TxPin GPIO_Pin_10
- #endif
- /**@} */
- /** User area the current device state structure*/
- extern dataPoint_t currentDataPoint;
- void gizTimerMs(void);
- uint32_t gizGetTimerCount(void);
- void timerInit(void);
- void uartInit(void);
- void userInit(void);
- void userHandle(void);
- void mcuRestart(void);
- int32_t uartWrite(uint8_t *buf, uint32_t len);
- int8_t gizwitsEventProcess(eventInfo_t *info, uint8_t *data, uint32_t len);
- #ifdef __cplusplus
- }
- #endif
- #endif
[color=rgb(0, 0, 0) !important]复制代码
5,修改gizwits_product.h
Listitem
Listitem
Listitem
Listitem
Listitem
- /**
- ***************************
- * @file gizwits_protocol.c
- * @brief Corresponding gizwits_product.c header file (including product hardware and software version definition)
- * @Author Gizwits
- * @date 2017-07-19
- * @version V03030000
- * @Copyright Gizwits
- *
- * @note 机智云.只为智能硬件而生
- * Gizwits Smart Cloud for Smart Products
- * 链接|增值ֵ|开放|中立|安全|自有|自由|生态
- * www.gizwits.com
- *
- ***************************/
- //#include "ringBuffer.h"
- //#include "gizwits_product.h"
- //#include "dataPointTools.h"
- #include "delay.h"
- /** Protocol global variables **/
- //gizwitsProtocol_t gizwitsProtocol;
- //extern dataPoint_t currentDataPoint;
- //extern uint8_t wifi_flag;
- /**@name The serial port receives the ring buffer implementation
- * @{
- */
- rb_t pRb; ///< Ring buffer structure variable
- static uint8_t rbBuf[RB_MAX_LEN]; ///< Ring buffer data cache buffer
- /**@} */
- /**
- * @brief Write data to the ring buffer
- * @param [in] buf : buf adress
- * @param [in] len : byte length
- * @return correct : Returns the length of the written data
- failure : -1
- */
- int32_t gizPutData(uint8_t *buf, uint32_t len)
- {
- int32_t count = 0;
- if(NULL == buf)
- {
- GIZWITS_LOG("ERR: gizPutData buf is empty \n");
- return -1;
- }
- count = rbWrite(&pRb, buf, len);
- if(count != len)
- {
- GIZWITS_LOG("ERR: Failed to rbWrite \n");
- return -1;
- }
- return count;
- }
- /**
- * @brief Protocol header initialization
- *
- * @param [out] head : Protocol header pointer
- *
- * @return 0, success; other, failure
- */
- static int8_t gizProtocolHeadInit(protocolHead_t *head)
- {
- if(NULL == head)
- {
- GIZWITS_LOG("ERR: gizProtocolHeadInit head is empty \n");
- return -1;
- }
- memset((uint8_t *)head, 0, sizeof(protocolHead_t));
- head->head[0] = 0xFF;
- head->head[1] = 0xFF;
- return 0;
- }
- /**
- * @brief Protocol ACK check processing function
- *
- * @param [in] data : data adress
- * @param [in] len : data length
- *
- * @return 0, suceess; other, failure
- */
- static int8_t gizProtocolWaitAck(uint8_t *gizdata, uint32_t len)
- {
- if(NULL == gizdata)
- {
- GIZWITS_LOG("ERR: data is empty \n");
- return -1;
- }
- memset((uint8_t *)&gizwitsProtocol.waitAck, 0, sizeof(protocolWaitAck_t));
- memcpy((uint8_t *)gizwitsProtocol.waitAck.buf, gizdata, len);
- gizwitsProtocol.waitAck.dataLen = (uint16_t)len;
- gizwitsProtocol.waitAck.flag = 1;
- gizwitsProtocol.waitAck.sendTime = gizGetTimerCount();
- return 0;
- }
- /**
- * @brief generates "controlled events" according to protocol
- * @param [in] issuedData: Controlled data
- * @param [out] info: event queue
- * @param [out] dataPoints: data point data
- * @return 0, the implementation of success, non-0, failed
- */
- static int8_t ICACHE_FLASH_ATTR gizDataPoint2Event(gizwitsIssued_t *issuedData, eventInfo_t *info, dataPoint_t *dataPoints)
- {
- if((NULL == issuedData) || (NULL == info) ||(NULL == dataPoints))
- {
- GIZWITS_LOG("gizDataPoint2Event Error , Illegal Param\n");
- return -1;
- }
- /** Greater than 1 byte to do bit conversion **/
- if(sizeof(issuedData->attrFlags) > 1)
- {
- if(-1 == gizByteOrderExchange((uint8_t *)&issuedData->attrFlags,sizeof(attrFlags_t)))
- {
- GIZWITS_LOG("gizByteOrderExchange Error\n");
- return -1;
- }
- }
- if(0x01 == issuedData->attrFlags.flagRelay_1)
- {
- info->event[info->num] = EVENT_Relay_1;
- info->num++;
- dataPoints->valueRelay_1 = gizStandardDecompressionValue(Relay_1_BYTEOFFSET,Relay_1_BITOFFSET,Relay_1_LEN,(uint8_t *)&issuedData->attrVals.wBitBuf,sizeof(issuedData->attrVals.wBitBuf));
- }
- return 0;
- }
- /**
- * @brief contrasts the current data with the last data
- *
- * @param [in] cur: current data point data
- * @param [in] last: last data point data
- *
- * @return: 0, no change in data; 1, data changes
- */
- static int8_t ICACHE_FLASH_ATTR gizCheckReport(dataPoint_t *cur, dataPoint_t *last)
- {
- int8_t ret = 0;
- static uint32_t lastReportTime = 0;
- uint32_t currentTime = 0;
- if((NULL == cur) || (NULL == last))
- {
- GIZWITS_LOG("gizCheckReport Error , Illegal Param\n");
- return -1;
- }
- currentTime = gizGetTimerCount();
- if(last->valueRelay_1 != cur->valueRelay_1)
- {
- GIZWITS_LOG("valueRelay_1 Changed\n");
- ret = 1;
- }
- if(last->valueTemp != cur->valueTemp)
- {
- if(currentTime - lastReportTime >= REPORT_TIME_MAX)
- {
- GIZWITS_LOG("valueTemp Changed\n");
- ret = 1;
- }
- }
- if(last->valueHumi != cur->valueHumi)
- {
- if(currentTime - lastReportTime >= REPORT_TIME_MAX)
- {
- GIZWITS_LOG("valueHumi Changed\n");
- ret = 1;
- }
- }
- if(last->valueLight_Intensity != cur->valueLight_Intensity)
- {
- if(currentTime - lastReportTime >= REPORT_TIME_MAX)
- {
- GIZWITS_LOG("valueLight_Intensity Changed\n");
- ret = 1;
- }
- }
- if(1 == ret)
- {
- lastReportTime = gizGetTimerCount();
- }
- return ret;
- }
- /**
- * @brief User data point data is converted to wit the cloud to report data point data
- *
- * @param [in] dataPoints: user data point data address
- * @param [out] devStatusPtr: wit the cloud data point data address
- *
- * @return 0, the correct return; -1, the error returned
- */
- static int8_t ICACHE_FLASH_ATTR gizDataPoints2ReportData(dataPoint_t *dataPoints , devStatus_t *devStatusPtr)
- {
- if((NULL == dataPoints) || (NULL == devStatusPtr))
- {
- GIZWITS_LOG("gizDataPoints2ReportData Error , Illegal Param\n");
- return -1;
- }
- gizMemset((uint8_t *)devStatusPtr->wBitBuf,0,sizeof(devStatusPtr->wBitBuf));
- gizStandardCompressValue(Relay_1_BYTEOFFSET,Relay_1_BITOFFSET,Relay_1_LEN,(uint8_t *)devStatusPtr,dataPoints->valueRelay_1);
- gizByteOrderExchange((uint8_t *)devStatusPtr->wBitBuf,sizeof(devStatusPtr->wBitBuf));
- devStatusPtr->valueTemp = gizY2X(Temp_RATIO, Temp_ADDITION, dataPoints->valueTemp);
- devStatusPtr->valueHumi = gizY2X(Humi_RATIO, Humi_ADDITION, dataPoints->valueHumi);
- devStatusPtr->valueLight_Intensity = gizY2X(Light_Intensity_RATIO, Light_Intensity_ADDITION, dataPoints->valueLight_Intensity);
- return 0;
- }
- /**
- * @brief This function is called by the GAgent module to receive the relevant protocol data from the cloud or APP
- * @param [in] inData The protocol data entered
- * @param [in] inLen Enter the length of the data
- * @param [out] outData The output of the protocol data
- * @param [out] outLen The length of the output data
- * @return 0, the implementation of success, non-0, failed
- */
- static int8_t gizProtocolIssuedProcess(char *did, uint8_t *inData, uint32_t inLen, uint8_t *outData, uint32_t *outLen)
- {
- uint8_t issuedAction = inData[0];
- if((NULL == inData)||(NULL == outData)||(NULL == outLen))
- {
- GIZWITS_LOG("gizProtocolIssuedProcess Error , Illegal Param\n");
- return -1;
- }
- if(NULL == did)
- {
- memset((uint8_t *)&gizwitsProtocol.issuedProcessEvent, 0, sizeof(eventInfo_t));
- switch(issuedAction)
- {
- case ACTION_CONTROL_DEVICE:
- gizDataPoint2Event((gizwitsIssued_t *)&inData[1], &gizwitsProtocol.issuedProcessEvent,&gizwitsProtocol.gizCurrentDataPoint);
- gizwitsProtocol.issuedFlag = ACTION_CONTROL_TYPE;
- outData = NULL;
- *outLen = 0;
- break;
- case ACTION_READ_DEV_STATUS:
- if(0 == gizDataPoints2ReportData(&gizwitsProtocol.gizLastDataPoint,&gizwitsProtocol.reportData.devStatus))
- {
- memcpy(outData+1, (uint8_t *)&gizwitsProtocol.reportData.devStatus, sizeof(gizwitsReport_t));
- outData[0] = ACTION_READ_DEV_STATUS_ACK;
- *outLen = sizeof(gizwitsReport_t)+1;
- }
- else
- {
- return -1;
- }
- break;
- case ACTION_W2D_TRANSPARENT_DATA:
- memcpy(gizwitsProtocol.transparentBuff, &inData[1], inLen-1);
- gizwitsProtocol.transparentLen = inLen - 1;
- gizwitsProtocol.issuedProcessEvent.event[gizwitsProtocol.issuedProcessEvent.num] = TRANSPARENT_DATA;
- gizwitsProtocol.issuedProcessEvent.num++;
- gizwitsProtocol.issuedFlag = ACTION_W2D_TRANSPARENT_TYPE;
- outData = NULL;
- *outLen = 0;
- break;
- default:
- break;
- }
- }
- return 0;
- }
- /**
- * @brief The protocol sends data back , P0 ACK
- *
- * @param [in] head : Protocol head pointer
- * @param [in] data : Payload data
- * @param [in] len : Payload data length
- * @param [in] proFlag : DID flag ,1 for Virtual sub device did ,0 for single product or gateway
- *
- * @return : 0,Ack success;
- * -1,Input Param Illegal
- * -2,Serial send faild
- */
- static int32_t gizProtocolIssuedDataAck(protocolHead_t *head, uint8_t *gizdata, uint32_t len, uint8_t proFlag)
- {
- int32_t ret = 0;
- uint8_t tx_buf[RB_MAX_LEN];
- uint32_t offset = 0;
- uint8_t sDidLen = 0;
- uint16_t data_len = 0;
- uint8_t *pTxBuf = tx_buf;
- if(NULL == gizdata)
- {
- GIZWITS_LOG("[ERR] data Is Null \n");
- return -1;
- }
- if(0x1 == proFlag)
- {
- sDidLen = *((uint8_t *)head + sizeof(protocolHead_t));
- data_len = 5 + 1 + sDidLen + len;
- }
- else
- {
- data_len = 5 + len;
- }
- GIZWITS_LOG("len = %d , sDidLen = %d ,data_len = %d\n", len,sDidLen,data_len);
- *pTxBuf ++= 0xFF;
- *pTxBuf ++= 0xFF;
- *pTxBuf ++= (uint8_t)(data_len>>8);
- *pTxBuf ++= (uint8_t)(data_len);
- *pTxBuf ++= head->cmd + 1;
- *pTxBuf ++= head->sn;
- *pTxBuf ++= 0x00;
- *pTxBuf ++= proFlag;
- offset = 8;
- if(0x1 == proFlag)
- {
- *pTxBuf ++= sDidLen;
- offset += 1;
- memcpy(&tx_buf[offset],(uint8_t *)head+sizeof(protocolHead_t)+1,sDidLen);
- offset += sDidLen;
- pTxBuf += sDidLen;
- }
- if(0 != len)
- {
- memcpy(&tx_buf[offset],gizdata,len);
- }
- tx_buf[data_len + 4 - 1 ] = gizProtocolSum( tx_buf , (data_len+4));
- ret = uartWrite(tx_buf, data_len+4);
- if(ret < 0)
- {
- GIZWITS_LOG("uart write error %d \n", ret);
- return -2;
- }
- return 0;
- }
- /**
- * @brief Report data interface
- *
- * @param [in] action : PO action
- * @param [in] data : Payload data
- * @param [in] len : Payload data length
- *
- * @return : 0,Ack success;
- * -1,Input Param Illegal
- * -2,Serial send faild
- */
- static int32_t gizReportData(uint8_t action, uint8_t *gizdata, uint32_t len)
- {
- int32_t ret = 0;
- protocolReport_t protocolReport;
- if(NULL == gizdata)
- {
- GIZWITS_LOG("gizReportData Error , Illegal Param\n");
- return -1;
- }
- gizProtocolHeadInit((protocolHead_t *)&protocolReport);
- protocolReport.head.cmd = CMD_REPORT_P0;
- protocolReport.head.sn = gizwitsProtocol.sn++;
- protocolReport.action = action;
- protocolReport.head.len = exchangeBytes(sizeof(protocolReport_t)-4);
- memcpy((gizwitsReport_t *)&protocolReport.reportData, (gizwitsReport_t *)gizdata,len);
- protocolReport.sum = gizProtocolSum((uint8_t *)&protocolReport, sizeof(protocolReport_t));
- ret = uartWrite((uint8_t *)&protocolReport, sizeof(protocolReport_t));
- if(ret < 0)
- {
- GIZWITS_LOG("ERR: uart write error %d \n", ret);
- return -2;
- }
- gizProtocolWaitAck((uint8_t *)&protocolReport, sizeof(protocolReport_t));
- return ret;
- }/**
- * @brief Datapoints reporting mechanism
- *
- * 1. Changes are reported immediately
- * 2. Data timing report , 600000 Millisecond
- *
- *@param [in] currentData : Current datapoints value
- * @return : NULL
- */
- static void gizDevReportPolicy(dataPoint_t *currentData)
- {
- static uint32_t lastRepTime = 0;
- uint32_t timeNow = gizGetTimerCount();
- if((1 == gizCheckReport(currentData, (dataPoint_t *)&gizwitsProtocol.gizLastDataPoint)))
- {
- GIZWITS_LOG("changed, report data\n");
- if(0 == gizDataPoints2ReportData(currentData,&gizwitsProtocol.reportData.devStatus))
- {
- gizReportData(ACTION_REPORT_DEV_STATUS, (uint8_t *)&gizwitsProtocol.reportData.devStatus, sizeof(devStatus_t)); }
- memcpy((uint8_t *)&gizwitsProtocol.gizLastDataPoint, (uint8_t *)currentData, sizeof(dataPoint_t));
- }
- if((0 == (timeNow % (600000))) && (lastRepTime != timeNow))
- {
- GIZWITS_LOG("Info: 600S report data\n");
- if(0 == gizDataPoints2ReportData(currentData,&gizwitsProtocol.reportData.devStatus))
- {
- gizReportData(ACTION_REPORT_DEV_STATUS, (uint8_t *)&gizwitsProtocol.reportData.devStatus, sizeof(devStatus_t));
- }
- memcpy((uint8_t *)&gizwitsProtocol.gizLastDataPoint, (uint8_t *)currentData, sizeof(dataPoint_t));
- lastRepTime = timeNow;
- }
- }
- /**
- * @brief Get a packet of data from the ring buffer
- *
- * @param [in] rb : Input data address
- * @param [out] data : Output data address
- * @param [out] len : Output data length
- *
- * @return : 0,Return correct ;-1,Return failure;-2,Data check failure
- */
- static int8_t gizProtocolGetOnePacket(rb_t *rb, uint8_t *gizdata, uint16_t *len)
- {
- int32_t ret = 0;
- uint8_t sum = 0;
- int32_t i = 0;
- uint8_t tmpData;
- uint8_t tmpLen = 0;
- uint16_t tmpCount = 0;
- static uint8_t protocolFlag = 0;
- static uint16_t protocolCount = 0;
- static uint8_t lastData = 0;
- static uint8_t debugCount = 0;
- uint8_t *protocolBuff = gizdata;
- protocolHead_t *head = NULL;
- if((NULL == rb) || (NULL == gizdata) ||(NULL == len))
- {
- GIZWITS_LOG("gizProtocolGetOnePacket Error , Illegal Param\n");
- return -1;
- }
- tmpLen = rbCanRead(rb);
- if(0 == tmpLen)
- {
- return -1;
- }
- for(i=0; i<tmpLen; i++)
- {
- ret = rbRead(rb, &tmpData, 1);
- if(0 != ret)
- {
- if((0xFF == lastData) && (0xFF == tmpData))
- {
- if(0 == protocolFlag)
- {
- protocolBuff[0] = 0xFF;
- protocolBuff[1] = 0xFF;
- protocolCount = 2;
- protocolFlag = 1;
- }
- else
- {
- if((protocolCount > 4) && (protocolCount != tmpCount))
- {
- protocolBuff[0] = 0xFF;
- protocolBuff[1] = 0xFF;
- protocolCount = 2;
- }
- }
- }
- else if((0xFF == lastData) && (0x55 == tmpData))
- {
- }
- else
- {
- if(1 == protocolFlag)
- {
- protocolBuff[protocolCount] = tmpData;
- protocolCount++;
- if(protocolCount > 4)
- {
- head = (protocolHead_t *)protocolBuff;
- tmpCount = exchangeBytes(head->len)+4;
- if(protocolCount == tmpCount)
- {
- break;
- }
- }
- }
- }
- lastData = tmpData;
- debugCount++;
- }
- }
- if((protocolCount > 4) && (protocolCount == tmpCount))
- {
- sum = gizProtocolSum(protocolBuff, protocolCount);
- if(protocolBuff[protocolCount-1] == sum)
- {
- memcpy(gizdata, protocolBuff, tmpCount);
- *len = tmpCount;
- protocolFlag = 0;
- protocolCount = 0;
- debugCount = 0;
- lastData = 0;
- return 0;
- }
- else
- {
- return -2;
- }
- }
- return 1;
- }
- /**
- * @brief Protocol data resend
- * The protocol data resend when check timeout and meet the resend limiting
- * @param none
- *
- * @return none
- */
- static void gizProtocolResendData(void)
- {
- int32_t ret = 0;
- if(0 == gizwitsProtocol.waitAck.flag)
- {
- return;
- }
- GIZWITS_LOG("Warning: timeout, resend data \n");
- ret = uartWrite(gizwitsProtocol.waitAck.buf, gizwitsProtocol.waitAck.dataLen);
- if(ret != gizwitsProtocol.waitAck.dataLen)
- {
- GIZWITS_LOG("ERR: resend data error\n");
- }
- gizwitsProtocol.waitAck.sendTime = gizGetTimerCount();
- }
- /**
- * @brief Clear the ACK protocol message
- *
- * @param [in] head : Protocol header address
- *
- * @return 0, success; other, failure
- */
- static int8_t gizProtocolWaitAckCheck(protocolHead_t *head)
- {
- protocolHead_t *waitAckHead = (protocolHead_t *)gizwitsProtocol.waitAck.buf;
- if(NULL == head)
- {
- GIZWITS_LOG("ERR: data is empty \n");
- return -1;
- }
- if(waitAckHead->cmd+1 == head->cmd)
- {
- memset((uint8_t *)&gizwitsProtocol.waitAck, 0, sizeof(protocolWaitAck_t));
- }
- return 0;
- }
- /**
- * @brief Send general protocol message data
- *
- * @param [in] head : Protocol header address
- *
- * @return : Return effective data length;-1,return failure
- */
- static int32_t gizProtocolCommonAck(protocolHead_t *head)
- {
- int32_t ret = 0;
- protocolCommon_t ack;
- if(NULL == head)
- {
- GIZWITS_LOG("ERR: gizProtocolCommonAck data is empty \n");
- return -1;
- }
- memcpy((uint8_t *)&ack, (uint8_t *)head, sizeof(protocolHead_t));
- ack.head.cmd = ack.head.cmd+1;
- ack.head.len = exchangeBytes(sizeof(protocolCommon_t)-4);
- ack.sum = gizProtocolSum((uint8_t *)&ack, sizeof(protocolCommon_t));
- ret = uartWrite((uint8_t *)&ack, sizeof(protocolCommon_t));
- if(ret < 0)
- {
- GIZWITS_LOG("ERR: uart write error %d \n", ret);
- }
- return ret;
- }
- /**
- * @brief ACK processing function
- * Time-out 200ms no ACK resend,resend two times at most
- * @param none
- *
- * @return none
- */
- static void gizProtocolAckHandle(void)
- {
- if(1 == gizwitsProtocol.waitAck.flag)
- {
- if(SEND_MAX_NUM > gizwitsProtocol.waitAck.num)
- {
- // Time-out no ACK resend
- if(SEND_MAX_TIME < (gizGetTimerCount() - gizwitsProtocol.waitAck.sendTime))
- {
- GIZWITS_LOG("Warning:gizProtocolResendData %d %d %d\n", gizGetTimerCount(), gizwitsProtocol.waitAck.sendTime, gizwitsProtocol.waitAck.num);
- gizProtocolResendData();
- gizwitsProtocol.waitAck.num++;
- }
- }
- else
- {
- memset((uint8_t *)&gizwitsProtocol.waitAck, 0, sizeof(protocolWaitAck_t));
- }
- }
- }
- /**
- * @brief Protocol 4.1 WiFi module requests device information
- *
- * @param[in] head : Protocol header address
- *
- * @return Return effective data length;-1,return failure
- */
- static int32_t gizProtocolGetDeviceInfo(protocolHead_t * head)
- {
- int32_t ret = 0;
- protocolDeviceInfo_t deviceInfo;
- if(NULL == head)
- {
- GIZWITS_LOG("gizProtocolGetDeviceInfo Error , Illegal Param\n");
- return -1;
- }
- gizProtocolHeadInit((protocolHead_t *)&deviceInfo);
- deviceInfo.head.cmd = ACK_GET_DEVICE_INFO;
- deviceInfo.head.sn = head->sn;
- memcpy((uint8_t *)deviceInfo.protocolVer, protocol_VERSION, 8);
- memcpy((uint8_t *)deviceInfo.p0Ver, P0_VERSION, 8);
- memcpy((uint8_t *)deviceInfo.softVer, SOFTWARE_VERSION, 8);
- memcpy((uint8_t *)deviceInfo.hardVer, HARDWARE_VERSION, 8);
- memcpy((uint8_t *)deviceInfo.productKey, PRODUCT_KEY, strlen(PRODUCT_KEY));
- memcpy((uint8_t *)deviceInfo.productSecret, PRODUCT_SECRET, strlen(PRODUCT_SECRET));
- memset((uint8_t *)deviceInfo.devAttr, 0, 8);
- deviceInfo.devAttr[7] |= DEV_IS_GATEWAY<<0;
- deviceInfo.devAttr[7] |= (0x01<<1);
- deviceInfo.ninableTime = exchangeBytes(NINABLETIME);
- deviceInfo.head.len = exchangeBytes(sizeof(protocolDeviceInfo_t)-4);
- deviceInfo.sum = gizProtocolSum((uint8_t *)&deviceInfo, sizeof(protocolDeviceInfo_t));
- ret = uartWrite((uint8_t *)&deviceInfo, sizeof(protocolDeviceInfo_t));
- if(ret < 0)
- {
- GIZWITS_LOG("ERR: uart write error %d \n", ret);
- }
- return ret;
- }
- /**
- * @brief Protocol 4.7 Handling of illegal message notification
- * @param[in] head : Protocol header address
- * @param[in] errno : Illegal message notification type
- * @return 0, success; other, failure
- */
- static int32_t gizProtocolErrorCmd(protocolHead_t *head,errorPacketsType_t errno)
- {
- int32_t ret = 0;
- protocolErrorType_t errorType;
- if(NULL == head)
- {
- GIZWITS_LOG("gizProtocolErrorCmd Error , Illegal Param\n");
- return -1;
- }
- gizProtocolHeadInit((protocolHead_t *)&errorType);
- errorType.head.cmd = ACK_ERROR_PACKAGE;
- errorType.head.sn = head->sn;
- errorType.head.len = exchangeBytes(sizeof(protocolErrorType_t)-4);
- errorType.error = errno;
- errorType.sum = gizProtocolSum((uint8_t *)&errorType, sizeof(protocolErrorType_t));
- ret = uartWrite((uint8_t *)&errorType, sizeof(protocolErrorType_t));
- if(ret < 0)
- {
- GIZWITS_LOG("ERR: uart write error %d \n", ret);
- }
- return ret;
- }
- /**
- * @brief Protocol 4.13 Get and process network time
- *
- * @param [in] head : Protocol header address
- *
- * @return 0, success; other, failure
- */
- static int8_t gizProtocolNTP(protocolHead_t *head)
- {
- protocolUTT_t *UTTInfo = (protocolUTT_t *)head;
- if(NULL == head)
- {
- GIZWITS_LOG("ERR: NTP is empty \n");
- return -1;
- }
- memcpy((uint8_t *)&gizwitsProtocol.TimeNTP,(uint8_t *)UTTInfo->time, (7 + 4));
- gizwitsProtocol.TimeNTP.year = exchangeBytes(gizwitsProtocol.TimeNTP.year);
- gizwitsProtocol.TimeNTP.ntp =exchangeWord(gizwitsProtocol.TimeNTP.ntp);
- gizwitsProtocol.NTPEvent.event[gizwitsProtocol.NTPEvent.num] = WIFI_NTP;
- gizwitsProtocol.NTPEvent.num++;
- gizwitsProtocol.issuedFlag = GET_NTP_TYPE;
- return 0;
- }
- /**
- * @brief Protocol 4.4 Device MCU restarts function
- * @param none
- * @return none
- */
- static void gizProtocolReboot(void)
- {
- uint32_t timeDelay = gizGetTimerCount();
- /*Wait 600ms*/
- while((gizGetTimerCount() - timeDelay) <= 600);
- mcuRestart();
- }
- /**
- * @brief Protocol 4.5 :The WiFi module informs the device MCU of working status about the WiFi module
- * @param[in] status WiFi module working status
- * @return none
- */
- static int8_t gizProtocolModuleStatus(protocolWifiStatus_t *status)
- {
- static wifiStatus_t lastStatus;
- if(NULL == status)
- {
- GIZWITS_LOG("gizProtocolModuleStatus Error , Illegal Param\n");
- return -1;
- }
- status->ststus.value = exchangeBytes(status->ststus.value);
- //OnBoarding mode status
- if(lastStatus.types.onboarding != status->ststus.types.onboarding)
- {
- if(1 == status->ststus.types.onboarding)
- {
- if(1 == status->ststus.types.softap)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_SOFTAP;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("OnBoarding: SoftAP or Web mode\n");
- }
- if(1 == status->ststus.types.station)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_AIRLINK;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("OnBoarding: AirLink mode\n");
- }
- }
- else
- {
- if(1 == status->ststus.types.softap)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_SOFTAP;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("OnBoarding: SoftAP or Web mode\n");
- }
- if(1 == status->ststus.types.station)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_STATION;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("OnBoarding: Station mode\n");
- }
- }
- }
- //binding mode status
- if(lastStatus.types.binding != status->ststus.types.binding)
- {
- lastStatus.types.binding = status->ststus.types.binding;
- if(1 == status->ststus.types.binding)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_OPEN_BINDING;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("WiFi status: in binding mode\n");
- }
- else
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_CLOSE_BINDING;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("WiFi status: out binding mode\n");
- }
- }
- //router status
- if(lastStatus.types.con_route != status->ststus.types.con_route)
- {
- lastStatus.types.con_route = status->ststus.types.con_route;
- if(1 == status->ststus.types.con_route)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_CON_ROUTER;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("WiFi status: connected router\n");
- }
- else
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_DISCON_ROUTER;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("WiFi status: disconnected router\n");
- }
- }
- //M2M server status
- if(lastStatus.types.con_m2m != status->ststus.types.con_m2m)
- {
- lastStatus.types.con_m2m = status->ststus.types.con_m2m;
- if(1 == status->ststus.types.con_m2m)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_CON_M2M;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("WiFi status: connected m2m\n");
- }
- else
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_DISCON_M2M;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("WiFi status: disconnected m2m\n");
- }
- }
- //APP status
- if(lastStatus.types.app != status->ststus.types.app)
- {
- lastStatus.types.app = status->ststus.types.app;
- if(1 == status->ststus.types.app)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_CON_APP;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("WiFi status: app connect\n");
- }
- else
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.num] = WIFI_DISCON_APP;
- gizwitsProtocol.wifiStatusEvent.num++;
- GIZWITS_LOG("WiFi status: no app connect\n");
- }
- }
- //test mode status
- if(lastStatus.types.test != status->ststus.types.test)
- {
- lastStatus.types.test = status->ststus.types.test;
- if(1 == status->ststus.types.test)
- {
- gizwitsProtocol.wifiStatusEvent.event[gizwitsProtocol.wifiStatusEvent.n
|
|