EFR32使用zigbee Scene功能

在Zigbee协议中,有Scene这个cluster,用来解决“场景”这个概念,比如在智能家居里面有读书模式、娱乐模式,等不同灯光效果,我们通过对不同的场景设定不同的状态,包括亮度、颜色、饱和度等。

Scene这个功能要依赖于Group,通常会对一组设备里的个体设置不同颜色。有文章说Scene场景功能可以不依赖于Group,这样不能通过组播来完成,只能广播发数据,增加了网络负担,实现效果不是最优。

说回来我们为什么要用场景呢?其实不用也可以,还可以通过发多条命令向控制设备,达到效果。设想,假如对一个灯泡发三条命令,6个灯泡就要发18条命令,无疑增加了网络负担,而且操作很“笨拙”。

基于此,我们需要先建立一个group,然后再对这个group里的设备添加场景。EFR32芯片使用的SDK已经集成了命令进来,演示实际操作命令。

场景用到的命令函数

zcl scenes add 
	<uint16_t> group id
	<uint8_t> scene id
	<uint16_t> transition time
	<string> scene name
	<uint32_t> extension field sets
	
zcl scenes recall
	<uint16_t> group_id
	<uint8_t> scene_id
	<uint16_t> transition time
	
send (args)
	<uint16_t> short id of the device to send the message to
	<uint8_t>  the endpoint to send the message from
	<uint8_t> the endpoint to send the message to
	
send_multicast (args)
	<uint16_t> group id of the multicast group to send the message to
	<uint8_t> the endpoint to send the message from
		

组建立
添加2个灯泡进来

zcl group add 0x1234 "light"
send 0x1E08 1 11

zcl group add 0x1234 "light"
send 0x106E 1 11

在这里插入图片描述
在这里插入图片描述
可以测试一下组控制是否OK

zcl on-off toggle
send_multicast 0x1234 1 

可以观察到灯有明暗变化,证明group控制成功

场景建立

zcl scenes add  0x1234 0x1 1 "light scene" 0x01010006
send 0x1E80 1 11

zcl scenes add 0x1234 0x1 1 "light scene" 0x01010006
send 0x106E 1 11

在这里插入图片描述
在这里插入图片描述

场景执行

zcl scenes recall 0x1234 0x1 1
send_multicast 0x1234 1

在这里插入图片描述
可以观察到,如果我在场景调用前把灯泡关掉,通过上面的“场景执行”,看到俩个灯在1s后同时亮了起来。

如果想让灯的模式更丰富,比如颜色变为红色,绿色,就要在添加场景时,对不同的cluster进行设置,设置extension field sets

目前测试只支持开、关,以及亮度值调整,已和原厂确认!以后可能会更新,或者自己想办法去实现,支持更多extension filed sets

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值