IOT 台灯设计
1、作品简介
随着IOT的兴起,越来越多的家庭设备通过网关或者路由接入云端,用户可以远在千里之外控制监控家里的设备,灯具天然具有IOT基因的,使用频率高,7X24供电,不需要单独在铺设网线或电线,只要有路由或者网关就可以很方便接入云,实现远程控制。因为具有了IOT功能,可以赋予台灯更多的新的功能,台灯不再只是照明设备还是一个可以随心把玩的家庭伴侣,通过APP可以实现各种炫酷的灯效和功能,定时开关机、全家外出旅游的时候模拟家庭灯光情况,不法分子通过灯光以为家庭有人而怯步。炫酷灯效和模拟自然界的太阳阳光节律。所有这些功能可以通过手机APP和rs10的BLE连接实现控制和和功能转换。
2、系统框图
RSL10 QFN EVB作为IOT灯具的主控,因为RSL10的GPIO 有限,数据协议采用单线归零码的通讯方式,系统只需要一个GPIO1 作为LED RGBW的驱动GPIO用来驱动WS2812 ,WS2812是一个集控制电路与发光电路于一体的智能外控LED光源。其外型与一个5050LED灯珠相同,每个元件即为一个像素点。像素点内部包含了智能数字接口数据锁存信号整形放大驱动电路,还包含有高精度的内部振荡器和12V高压可编程定电流控制部分,有效保证了像素点光的颜色高度一致。,另外一个ADC口用来采集灯具的温度,在温度超过限定标准的情况下自动降低灯具的发光效率避免温度过高烧坏LED。
3、软件架构
IOT台灯基础架构
要实现IOT功能、因为蓝牙不能直接连上物联网,必须通过网关进行连接进行转换,IOT蓝牙台灯架构如下:
a、蓝牙和网关通讯功能,所有控制命令和设备参数通过BLE和发送给网关网关再把IOT台灯的参数上报云端服务器、通过手机APP把数据通过网关转换后发给IOT台灯执行、还有就是没有网络的时候在家APP直接通过BLE和IOT台灯进行通讯实现台灯功能。
b、RS10demo程序已经有freertos,为了方便调试和模块化编程,采用了FREERTOS
c、因为网关通讯协议涉及公司机密本次大赛不把协议内容进行具体阐述,只进行APP和BLE直接通讯进行控制、和台灯功能实现。
4、部分功能实现
WS1258驱动
#define WS1258_GPIO 0
#define WS2812_EN_GPIO 1
#define _nop_() __NOP()
#define PERCENT 1
#define T0H (350+150/PERCENT) //0.35us
#define T0L (800+150/PERCENT) //0.8us
#define T1H (700+150/PERCENT) //0.7us
#define T1L (600+150/PERCENT) //0.6us
#define RESTIME 2400
void delay_us(uint32_t ns)
{
uint32_t i =0;
while(ns){
ns--;
for(i=100;i>1;i--){
_nop_();
}
}
}
void ledGpioInit(void)
{
Sys_DIO_Config(WS1258_GPIO, DIO_MODE_GPIO_OUT_0);
Sys_DIO_Config(WS2812_EN_GPIO, DIO_MODE_GPIO_OUT_0);
}
void ledGpio(gpio_status_e on)
{
if (GPIO_HIGH==on){
Sys_GPIO_Set_High(WS1258_GPIO);
}else{
Sys_GPIO_Set_Low(WS1258_GPIO);
}
}
void onsemLedEnable(xt_ledenable_e enable)
{
if (enable==LEDENABLE){
Sys_GPIO_Set_High(WS2812_EN_GPIO);
}else{
Sys_GPIO_Set_Low(WS2812_EN_GPIO);
}
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
//子程序名称:ResetDateFlow(void)
//功能:复位,为下一次发送做准备,
//说明:将DI置位为0后,延时约65us
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
void ResetDataFlow(void)
{
unsigned char i,j;
ledGpio(GPIO_LOW);//DI=0;
delay_us(RESTIME);
}
//发送3BYTE的数据给LED 控制RGB
static void WS2811_SendByte(uint32_t dat)//
{
uint8_t i = 0;
uint32_t temp =dat;
for(i=0;i<24;i++)
{
if(temp&0x800000) //
{
//LINEZERO_GPIO_Port->BSRR = (uint32_t)LINEZERO_Pin;
ledGpio(GPIO_HIGH);
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
//delay_us(T1H);
//LINEZERO_GPIO_Port->BRR = (uint32_t)LINEZERO_Pin;
ledGpio(GPIO_LOW); //DI=0;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
//delay_us(T1L);
}
else
{
//LINEZERO_GPIO_Port->BSRR = (uint32_t)LINEZERO_Pin;
ledGpio(GPIO_HIGH);
//delay_us(T0H);
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
//LINEZERO_GPIO_Port->BRR = (uint32_t)LINEZERO_Pin;
ledGpio(GPIO_LOW); //DI=0;
//delay_us(T0L);
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
}
temp=(temp<<1);
}
}
//把RGB打包发送
void send_data(uint8_t r,uint8_t g,uint8_t b)
{
uint8_t i;
uint32_t para =0;
para= (r<<16|g<<8|b);
WS2811_SendByte(para);
//ResetDataFlow();
}
//应用直接调用函数
void ledDriver(RGB_T rgb[],uint8_t lens )
{
uint8_t i=0;
if (rgb==NULL||lens<1){
return;
}
ResetDataFlow(); //发送帧复位信号
for (i=0;i<lens;i++){//sizeof(rgb)/sizeof(rgb[0])
send_data(rgb.r,rgb.g ,rgb.b);
}
ResetDataFlow(); //发送帧复位信号
}
APP 和RS10 通过BLE通讯接收数据
uint8_t CUSTOMSS_RXLongCharCallback(uint8_t conidx, uint16_t attidx, uint16_t handle,
uint8_t *to, const uint8_t *from, uint16_t length,
uint16_t operation)
{
memcpy(to, from, length);
#if RSL10_DEBUG
PRINTF("\n\rRXLongCharCallback (%d): ", conidx, length);
for (int i = 0; i < length; i++)
{
PRINTF("%02x ", app_env_cs.from_air_buffer_long);
}
#endif /* if RSL10_DEBUG */
PRINTF("\r\n");
/* Update TX long characteristic with the inverted version of
* RX long characteristic just received */
if(operation == GATTC_WRITE_REQ_IND)
{
for (uint8_t i = 0; i < CS_LONG_VALUE_MAX_LENGTH; i++)
{
//app_env_cs.to_air_buffer_long = 0xFF ^ app_env_cs.from_air_buffer_long;
}
smartLightProtocolDataInsert((void *)app_env_cs.from_air_buffer_long, length); //接收数据放入缓冲区
}
return ATT_ERR_NO_ERROR;
}
协议解析和灯效功能实现
__NO_RETURN void ledDriverThread(void *argument)
{
EFFECT_MODE effectMode = EFFECT_MAX;
uint8_t state=0;
uint64_t pass_time =0;
LIGHT_ATTR light_attr;
xt_protocol_data_t *ble_protocol_data=& sg_ble_protocol_data;
/* creation of rgbQueue */
rgbQueueHandle = osMessageQueueNew (1, sizeof(LIGHT_ATTR), &rgbQueue_attributes);
memset(&gradint_timer,0,sizeof(gradint_timer));
memset(&light_attr,0,sizeof(light_attr));
gradint_timer.expired_ms=500;
//gradint_timer.status=1;
//XtimerStart(&gradint_timer);
for(;;)
{
osDelay(10);
if(1==onsemi_fifo_HaveData(&fifo_dev)){
smartLightProtocolDataRead();
PRINTF("%s header[0]=%x\r\n",__func__,ble_protocol_data->header[0]);
if (HEADER_0==ble_protocol_data->header[0]&&HEADER_1==ble_protocol_data->header[1]){
effectMode = ble_protocol_data->cmd;
if (effectMode<EFFECT_MAX){
PRINTF("%s\r\n",effectmode[effectMode]);
}
gradint_timer.expired_ms=1000;
XtimerStart(&gradint_timer);
sg_ble_to_air_data.header[0]=0x7F;
sg_ble_to_air_data.header[1]=0x80;
sg_ble_to_air_data.lenght=3;
sg_ble_to_air_data.cmd=ble_protocol_data->cmd;
sg_ble_to_air_data.buf[0]=0x0d;
sg_ble_to_air_data.buf[1]=0x0a;
airProtocolDataInsert(&sg_ble_to_air_data, sg_ble_to_air_data.lenght+4);
}
}
switch(effectMode)
{
case PARTY:
//ke_msg_send_basic(APP_LIGHT_ACTION, TASK_APP, TASK_APP);
pass_time =XtimerPassMs(&gradint_timer);
if(XOK==timeExpire(&gradint_timer)){
gradint_timer.expired_ms=1000;
XtimerStart(&gradint_timer);
PRINTF("gradint_timer restart\r\n");
}
//PRINTF("gradint_timer.oldtick=%d gradint_timer.status=:%d pass_time:%d\r\n",gradint_timer.oldtick,gradint_timer.status,(xt_u32)pass_time);
PRINTF("%s pass_time:%d\r\n",__func__,(xt_u32)pass_time);
switch(state){
case 0:
pass_time = XtimerPassMs(&gradint_timer);
gain= pass_time*1.0/gradint_timer.expired_ms;
gain = gain>1?1:gain;
currgb[0] =currgb[0] + (targetrgb[0]-currgb[0])*gain;
currgb[1] =currgb[1] + (targetrgb[1]-currgb[1])*gain;
currgb[2] =currgb[2] + (targetrgb[2]-currgb[2])*gain;
cur_rgb[0].r=(uint8_t)currgb[0];
cur_rgb[1].r=(uint8_t)currgb[0];
cur_rgb[2].r=(uint8_t)currgb[0];
cur_rgb[3].r=(uint8_t)currgb[0];
cur_rgb[0].g=(uint8_t)0;
cur_rgb[1].g=(uint8_t)0;
cur_rgb[2].g=(uint8_t)0;
cur_rgb[3].g=(uint8_t)0;
cur_rgb[0].b=(uint8_t)0;
cur_rgb[1].b=(uint8_t)0;
cur_rgb[2].b=(uint8_t)0;
cur_rgb[3].b=(uint8_t)0;
memcpy(&light_attr.rgb[0],&cur_rgb[0],sizeof(light_attr.rgb));
//gradient_time++;
if (timeExpire(&gradint_timer)==XOK){
currgb[0] =1;
currgb[1] =1;
currgb[2] =1;
currgb[3] =1;
resetCurRgb();
//XtimerStop(&gled_timer);
gradint_timer.expired_ms=PARTY_TIME;
XtimerStart(&gradint_timer);
state = 1;
}
break;
case 1:
pass_time = XtimerPassMs(&gradint_timer);
gain= pass_time*1.0/gradint_timer.expired_ms;
gain = gain>1?1:gain;
currgb[0] =currgb[0] + (targetrgb[0]-currgb[0])*gain;
currgb[1] =currgb[1] + (targetrgb[1]-currgb[1])*gain;
currgb[2] =currgb[2] + (targetrgb[2]-currgb[2])*gain;
cur_rgb[0].g=(uint8_t)currgb[1];
cur_rgb[1].g=(uint8_t)currgb[1];
cur_rgb[2].g=(uint8_t)currgb[1];
cur_rgb[3].g=(uint8_t)currgb[1];
cur_rgb[0].b=(uint8_t)0;
cur_rgb[1].b=(uint8_t)0;
cur_rgb[2].b=(uint8_t)0;
cur_rgb[3].b=(uint8_t)0;
cur_rgb[0].r=(uint8_t)0;
cur_rgb[1].r=(uint8_t)0;
cur_rgb[2].r=(uint8_t)0;
cur_rgb[3].r=(uint8_t)0;
memcpy(&light_attr.rgb[0],&cur_rgb[0],sizeof(light_attr.rgb));
if (timeExpire(&gradint_timer)==XOK){
currgb[0] =5;
currgb[1] =10;
currgb[2] =3;
currgb[3] =5;
resetCurRgb();
gradint_timer.expired_ms=PARTY_TIME;
XtimerStart(&gradint_timer);
state = 2;
}
break;
case 2:
pass_time = XtimerPassMs(&gradint_timer);
gain= pass_time*1.0/gradint_timer.expired_ms;
gain = gain>1?1:gain;
currgb[0] =currgb[0] + (targetrgb[0]-currgb[0])*gain;
currgb[1] =currgb[1] + (targetrgb[1]-currgb[1])*gain;
currgb[2] =currgb[2] + (targetrgb[2]-currgb[2])*gain;
cur_rgb[0].r=(uint8_t)0;
cur_rgb[1].r=(uint8_t)0;
cur_rgb[2].r=(uint8_t)0;
cur_rgb[3].r=(uint8_t)0;
cur_rgb[0].g=(uint8_t)0;
cur_rgb[1].g=(uint8_t)0;
cur_rgb[2].g=(uint8_t)0;
cur_rgb[3].g=(uint8_t)0;
cur_rgb[0].b=(uint8_t)currgb[2];
cur_rgb[1].b=(uint8_t)currgb[2];
cur_rgb[2].b=(uint8_t)currgb[2];
cur_rgb[3].b=(uint8_t)currgb[2];
memcpy(&light_attr.rgb[0],&cur_rgb[0],sizeof(light_attr.rgb));
if (timeExpire(&gradint_timer)==1){
currgb[0] =3;
currgb[1] =2;
currgb[2] =5;
currgb[3] =2;
resetCurRgb();
gradint_timer.expired_ms=PARTY_TIME;
XtimerStart(&gradint_timer);
state = 3;
}
break;
case 3:
pass_time = XtimerPassMs(&gradint_timer);
gain= pass_time*1.0/gradint_timer.expired_ms;
gain = gain>1?1:gain;
currgb[0] =currgb[0] + (targetrgb[0]-currgb[0])*gain;
currgb[1] =currgb[1] + (targetrgb[1]-currgb[1])*gain;
currgb[2] =currgb[2] + (targetrgb[2]-currgb[2])*gain;
cur_rgb[0].r=(uint8_t)0;
cur_rgb[1].r=(uint8_t)0;
cur_rgb[2].r=(uint8_t)0;
cur_rgb[3].r=(uint8_t)0;
cur_rgb[0].g=(uint8_t)currgb[1];
cur_rgb[1].g=(uint8_t)currgb[1];
cur_rgb[2].g=(uint8_t)currgb[1];
cur_rgb[3].g=(uint8_t)currgb[1];
cur_rgb[0].b=(uint8_t)currgb[2];
cur_rgb[1].b=(uint8_t)currgb[2];
cur_rgb[2].b=(uint8_t)currgb[2];
cur_rgb[3].b=(uint8_t)currgb[2];
memcpy(&light_attr.rgb[0],&cur_rgb[0],sizeof(light_attr.rgb));
if (timeExpire(&gradint_timer)==1){
currgb[0] =2;
currgb[1] =3;
currgb[2] =4;
currgb[3] =2;
resetCurRgb();
gradint_timer.expired_ms=PARTY_TIME;
XtimerStart(&gradint_timer);
state = 4;
}
break;
case 4:
pass_time = XtimerPassMs(&gradint_timer);
gain= pass_time*1.0/gradint_timer.expired_ms;
gain = gain>1?1:gain;
currgb[0] =currgb[0] + (targetrgb[0]-currgb[0])*gain;
currgb[1] =currgb[1] + (targetrgb[1]-currgb[1])*gain;
currgb[2] =currgb[2] + (targetrgb[2]-currgb[2])*gain;
cur_rgb[0].r=(uint8_t)currgb[0];
cur_rgb[1].r=(uint8_t)currgb[0];
cur_rgb[2].r=(uint8_t)currgb[0];
cur_rgb[3].r=(uint8_t)currgb[0];
cur_rgb[0].b=(uint8_t)currgb[1];
cur_rgb[1].b=(uint8_t)currgb[1];
cur_rgb[2].b=(uint8_t)currgb[1];
cur_rgb[3].b=(uint8_t)currgb[1];
cur_rgb[0].g=(uint8_t)0;
cur_rgb[1].g=(uint8_t)0;
cur_rgb[2].g=(uint8_t)0;
cur_rgb[3].g=(uint8_t)0;
memcpy(&light_attr.rgb[0],&cur_rgb[0],sizeof(light_attr.rgb));
if (timeExpire(&gradint_timer)==XOK){
currgb[0] =4;
currgb[1] =3;
currgb[2] =6;
currgb[3] =0;
resetCurRgb();
gradint_timer.expired_ms=PARTY_TIME;
XtimerStart(&gradint_timer);
state = 5;
}
break;
case 5:
pass_time = XtimerPassMs(&gradint_timer);
gain= pass_time*1.0/gradint_timer.expired_ms;
gain = gain>1?1:gain;
currgb[0] =currgb[0] + (targetrgb[0]-currgb[0])*gain;
currgb[1] =currgb[1] + (targetrgb[1]-currgb[1])*gain;
currgb[2] =currgb[2] + (targetrgb[2]-currgb[2])*gain;
cur_rgb[0].r=(uint8_t)currgb[0];
cur_rgb[1].r=(uint8_t)currgb[0];
cur_rgb[2].r=(uint8_t)currgb[0];
cur_rgb[3].r=(uint8_t)currgb[0];
cur_rgb[0].b=(uint8_t)0;
cur_rgb[1].b=(uint8_t)0;
cur_rgb[2].b=(uint8_t)0;
cur_rgb[3].b=(uint8_t)0;
cur_rgb[0].g=(uint8_t)currgb[2];
cur_rgb[1].g=(uint8_t)currgb[2];
cur_rgb[2].g=(uint8_t)currgb[2];
cur_rgb[3].g=(uint8_t)currgb[2];
memcpy(&light_attr.rgb[0],&cur_rgb[0],sizeof(light_attr.rgb));
if (timeExpire(&gradint_timer)==1){
currgb[0] =10;
currgb[1] =10;
currgb[2] =10;
currgb[3] =10;
resetCurRgb();
gradint_timer.expired_ms=PARTY_TIME;
XtimerStart(&gradint_timer);
state = 0;
}
break;
default:
;
}
//log_debug(logger,"%d state:%d currgb:%f %f %f\r\n",__LINE__,state ,currgb[0],currgb[1],currgb[2]);
osDelay(100);
//light_attr.mode = PARTY;
//LightEffectProcess(light_attr);
break;
break;
case NIGHT:
pass_time = XtimerPassMs(&gradint_timer);
gain= pass_time*1.0/gradint_timer.expired_ms;
gain = gain>1?1:gain;
currgb[0] =currgb[0] + (targetrgb[0]-currgb[0])*gain;
currgb[1] =currgb[1] + (targetrgb[1]-currgb[1])*gain;
currgb[2] =currgb[2] + (targetrgb[2]-currgb[2])*gain;
cur_rgb[0].r=(uint8_t)0;
cur_rgb[1].r=(uint8_t)0;
cur_rgb[2].r=(uint8_t)0;
cur_rgb[3].r=(uint8_t)0;
cur_rgb[0].b=(uint8_t)currgb[1];
cur_rgb[1].b=(uint8_t)currgb[1];
cur_rgb[2].b=(uint8_t)currgb[1];
cur_rgb[3].b=(uint8_t)currgb[1];
cur_rgb[0].g=(uint8_t)currgb[2];
cur_rgb[1].g=(uint8_t)currgb[2];
cur_rgb[2].g=(uint8_t)currgb[2];
cur_rgb[3].g=(uint8_t)currgb[2];
memcpy(&light_attr.rgb[0],&cur_rgb[0],sizeof(light_attr.rgb));
if (timeExpire(&gradint_timer)==XOK){
XtimerStop(&gradint_timer);
}
break;
case SUNSET:
#if 1
if(0==light_attr.startFlag){
//log_debug(logger,"%d SUNSET currgb:%f %f %f\r\n",__LINE__,currgb[0],currgb[1],currgb[2]);
pass_time = XtimerPassMs(&gradint_timer);
gain= pass_time*1.0/gradint_timer.expired_ms;
gain = gain>1?1:gain;
currgb[0] =currgb[0] + (targetrgb[0]-currgb[0])*gain;
currgb[1] =currgb[1] + (targetrgb[1]-currgb[1])*gain;
currgb[2] =currgb[2] + (targetrgb[2]-currgb[2])*gain;
cur_rgb[0].r=(uint8_t)0;
cur_rgb[1].r=(uint8_t)0;
cur_rgb[2].r=(uint8_t)0;
cur_rgb[3].r=(uint8_t)0;
cur_rgb[0].b=(uint8_t)currgb[1];
cur_rgb[1].b=(uint8_t)currgb[1];
cur_rgb[2].b=(uint8_t)currgb[1];
cur_rgb[3].b=(uint8_t)currgb[1];
cur_rgb[0].g=(uint8_t)currgb[2];
cur_rgb[1].g=(uint8_t)currgb[2];
cur_rgb[2].g=(uint8_t)currgb[2];
cur_rgb[3].g=(uint8_t)currgb[2];
//memcpy(&light_attr.rgb[0],&cur_rgb[0],sizeof(light_attr.rgb));
if (timeExpire(&gradint_timer)==XOK){
gradint_timer.expired_ms=SUNSET_TIME;
XtimerStop(&gradint_timer);
light_attr.startFlag =1;
}
}
#endif
light_attr.mode =SUNSET;
//memcpy(light_attr.rgb,cur_rgb,sizeof(cur_rgb));
//LightEffectProcess(light_attr);
break;
case VOICE_CONTROL:
break;
case FLASH_MODE:
#if 1
switch(state){
case 0:
cur_rgb[0].r=0xff;
cur_rgb[1].r=0xff;
cur_rgb[2].r=0xff;
cur_rgb[3].r=0xff;
cur_rgb[0].b=0;
cur_rgb[1].b=0;
cur_rgb[2].b=0;
cur_rgb[3].b=0;
cur_rgb[0].g=0;//(uint32_t)input[2]&0xFF;
cur_rgb[1].g=0;//(uint32_t)input[2]&0xFF;
cur_rgb[2].g=0;//(uint32_t)input[2]&0xFF;
cur_rgb[3].g=0;//(uint32_t)input[2]&0xFF;
if (XOK==timeExpire(&gradint_timer)){
XtimerStart(&gradint_timer);
gradint_timer.expired_ms=FLASH_MODE_TIME;
//light_attr_para->processFlag=1;
state =1;
}
break;
case 1:
cur_rgb[0].r=0;
cur_rgb[1].r=0;
cur_rgb[2].r=0;
cur_rgb[3].r=0;
cur_rgb[0].b=0xff;
cur_rgb[1].b=0xff;
cur_rgb[2].b=0xff;
cur_rgb[3].b=0xff;
cur_rgb[0].g=0;//(uint32_t)input[2]&0xFF;
cur_rgb[1].g=0;//(uint32_t)input[2]&0xFF;
cur_rgb[2].g=0;//(uint32_t)input[2]&0xFF;
cur_rgb[3].g=0;//(uint32_t)input[2]&0xFF;
if (XOK==timeExpire(&gradint_timer)){
gradint_timer.expired_ms=FLASH_MODE_TIME;
XtimerStart(&gradint_timer);
//light_attr_para->processFlag=1;
state =0;
}
break;
}
//ledDriver(cur_rgb,4 );
#endif
break;
default:
pass_time = XtimerPassMs(&gradint_timer);
}
ledDriver(cur_rgb,4 );
}
}
注册灯效事件
void APP_LIGHT_Action_Handler(ke_msg_id_t const msg_id,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
uint8_t conidx = KE_IDX_GET(src_id);
PRINTF("%s msg_id:%d\r\n",__func__,msg_id);
switch(msg_id)
{
case GAPM_CMP_EVT:
{
PRINTF("%s GAPM_CMP_EVT msg_id:%d\r\n",__func__,msg_id);
//onsemLedEnable(LEDDISABLE);
}
break;
case GAPM_PROFILE_ADDED_IND:
{
onsemLedEnable(LEDENABLE);
PRINTF("%s GAPM_CMP_EVT msg_id:%d\r\n",__func__,msg_id);
}
break;
case GAPC_CONNECTION_REQ_IND:
{
PRINTF("%s GAPM_PROFILE_ADDED_IND msg_id:%d\r\n",__func__,msg_id);
}
break;
case GAPC_DISCONNECT_IND:
{
PRINTF("%s GAPC_DISCONNECT_IND msg_id:%d\r\n",__func__,msg_id);
onsemLedEnable(LEDDISABLE);
}
break;
case APP_LIGHT_ACTION:
{
PRINTF("APP_LIGHT_ACTION\r\n");
}
break;
default:
;
}
}
4 、竞赛源码
https://download.eeworld.com.cn/detail/skyworth74/620208
5、作品视频演示
6、总结
IOT(物联网)是最近几年非常火爆的一个新趋势、未来随着5G的普及 IOT更是会深入到社会的各个方面,灯具是很好的物联网载体,有家的地方就有灯,用户体验到IOT的好处以后会更容易接受其它智能产品、比如智能窗帘、智能晾衣架,RS10是一款优秀的SOC芯片,拥有超低功耗提供了大量的实用例程,嵌入式工程师很容易就上手开发自己想要的产品,唯一的做IOT的缺点就是必须配套网关进行转换才能接入互联网,否则只能进行短距离控制。
7、其他
分享帖:
IOT台灯软件设计-【作者:skyworth74】.doc
(302.5 KB, 下载次数: 4)
|