Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
Z3SiliconlabsSDKV6.9.2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dingmz
Z3SiliconlabsSDKV6.9.2
Commits
6941e0c5
Commit
6941e0c5
authored
Mar 16, 2022
by
dingmz
Browse files
Options
Browse Files
Download
Plain Diff
merge sdk3.1.1 to master-panel.Z3Light12W
parents
d204f7e5
3b9389c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1640 additions
and
1637 deletions
+1640
-1637
README.md
README.md
+6
-16
v3.1/protocol/zigbee/app/framework/plugin/on-off/on-off.c
v3.1/protocol/zigbee/app/framework/plugin/on-off/on-off.c
+283
-279
v3.1/protocol/zigbee/app/framework/util/af-main-common.c
v3.1/protocol/zigbee/app/framework/util/af-main-common.c
+1351
-1342
No files found.
README.md
View file @
6941e0c5
一:SDK3.1_V1.1 2021.09.
16
SDKV3.1.1-202109
16
SDK更新内容:
1、SDK中上报网关,不需要defaultResponds,而多控保留defaultResponds的功能;
2、改编译脚本,修复频偏校准值未正常写入的问题;
1、SDK中上报网关,不需要defaultResponds,而多控保留defaultResponds的功能;
2、改编译脚本,修复频偏校准值未正常写入的问题;
ikonke_app更新内容:
1、为了兼容老设备token的位置,防止OTA之后设备进入产测等状况发送,本次模板修改了自定义token和mfg-token的位置,将灯控面板新加入的标志位等后移,使新模板中的token和原本SDK中的token一一对应,并设置了四字节的SDK版本token,使其在OTA之后,单板和整机的标志位能够自动写入产测通过对应的值。
本次修改的具体实现为:在脚本中定义一个SDK-token的特殊值,并通过脚本有选择地在合成.hex文件时加入特殊值,生成.ota文件时不加入,当旧版本固件OTA到新固件时该token为非特殊值,在初始化的时候产测标志位会被自动写入产测通过的数值。
由于插座等固件中的token位置与灯控不相同,之后会加入新的token,目前token已加,功能在下一次更新时实现。
2、修改了cmei、isn等数组写入时,当数据长度为33字节时会复位的问题,但是目前该类型数组数据长度依旧定义为34字节。
3、增加了LED群组控制,将系统灯、字符灯和按键灯等分组并控制亮灭,opcode为ED17,如果有其他设备使用可以手动修改内容;增加了ED17的错误码E0。
4、删掉了interpan使能标志位与token相关内容。
5、删掉了已经不启用的installcode中与token相关的内容。
6、修复了FCC0中installcode因长度判断有误而无法读取属性的问题;
7、修复私有协议指令长度错误的问题
8、修复按下按键之后立刻读取心跳,数据粘包的问题
9、修改了token id,全部改为1000开始;
SDKV3.1.0-20210916
1、初始版本;
v3.1/protocol/zigbee/app/framework/plugin/on-off/on-off.c
View file @
6941e0c5
/***************************************************************************//**
* @file
* @brief Routines for the On-Off plugin, which implements the On-Off server
* cluster.
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#include "af.h"
#ifdef EMBER_AF_PLUGIN_REPORTING
#include "app/framework/plugin/reporting/reporting.h"
#endif
#ifdef EMBER_AF_PLUGIN_SCENES
#include "../scenes/scenes.h"
#endif //EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
#include "../zll-on-off-server/zll-on-off-server.h"
#endif
#ifdef EMBER_AF_PLUGIN_ZLL_LEVEL_CONTROL_SERVER
#include "../zll-level-control-server/zll-level-control-server.h"
#endif
#ifdef ZCL_USING_ON_OFF_CLUSTER_START_UP_ON_OFF_ATTRIBUTE
static
bool
areStartUpOnOffServerAttributesTokenized
(
uint8_t
endpoint
);
#endif
EmberAfStatus
emberAfOnOffClusterSetValueCallback
(
uint8_t
endpoint
,
uint8_t
command
,
bool
initiatedByLevelChange
)
{
EmberAfStatus
status
;
bool
currentValue
,
newValue
;
emberAfOnOffClusterPrintln
(
"On/Off set value: %x %x"
,
endpoint
,
command
);
// read current on/off value
status
=
emberAfReadAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
currentValue
,
sizeof
(
currentValue
),
NULL
);
// data type
if
(
status
!=
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfOnOffClusterPrintln
(
"ERR: reading on/off %x"
,
status
);
return
status
;
}
// if the value is already what we want to set it to then do nothing
if
((
!
currentValue
&&
command
==
ZCL_OFF_COMMAND_ID
)
||
(
currentValue
&&
command
==
ZCL_ON_COMMAND_ID
))
{
emberAfOnOffClusterPrintln
(
"On/off already set to new value"
);
return
EMBER_ZCL_STATUS_SUCCESS
;
}
// we either got a toggle, or an on when off, or an off when on,
// so we need to swap the value
newValue
=
!
currentValue
;
emberAfOnOffClusterPrintln
(
"Toggle on/off from %x to %x"
,
currentValue
,
newValue
);
// the sequence of updating on/off attribute and kick off level change effect should
// be depend on whether we are turning on or off. If we are turning on the light, we
// should update the on/off attribute before kicking off level change, if we are
// turning off the light, we should do the opposite, that is kick off level change
// before updating the on/off attribute.
if
(
newValue
)
{
// write the new on/off value
status
=
emberAfWriteAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
newValue
,
ZCL_BOOLEAN_ATTRIBUTE_TYPE
);
if
(
status
!=
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfOnOffClusterPrintln
(
"ERR: writing on/off %x"
,
status
);
return
status
;
}
// If initiatedByLevelChange is false, then we assume that the level change
// ZCL stuff has not happened and we do it here
if
(
!
initiatedByLevelChange
&&
emberAfContainsServer
(
endpoint
,
ZCL_LEVEL_CONTROL_CLUSTER_ID
))
{
emberAfOnOffClusterLevelControlEffectCallback
(
endpoint
,
newValue
);
}
}
else
{
// If initiatedByLevelChange is false, then we assume that the level change
// ZCL stuff has not happened and we do it here
if
(
!
initiatedByLevelChange
&&
emberAfContainsServer
(
endpoint
,
ZCL_LEVEL_CONTROL_CLUSTER_ID
))
{
emberAfOnOffClusterLevelControlEffectCallback
(
endpoint
,
newValue
);
}
// write the new on/off value
status
=
emberAfWriteAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
newValue
,
ZCL_BOOLEAN_ATTRIBUTE_TYPE
);
if
(
status
!=
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfOnOffClusterPrintln
(
"ERR: writing on/off %x"
,
status
);
return
status
;
}
}
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
if
(
initiatedByLevelChange
)
{
emberAfPluginZllOnOffServerLevelControlZllExtensions
(
endpoint
);
}
#endif
// the scene has been changed (the value of on/off has changed) so
// the current scene as descibed in the attribute table is invalid,
// so mark it as invalid (just writes the valid/invalid attribute)
if
(
emberAfContainsServer
(
endpoint
,
ZCL_SCENES_CLUSTER_ID
))
{
emberAfScenesClusterMakeInvalidCallback
(
endpoint
);
}
// The returned status is based solely on the On/Off cluster. Errors in the
// Level Control and/or Scenes cluster are ignored.
return
EMBER_ZCL_STATUS_SUCCESS
;
}
bool
emberAfOnOffClusterOffCallback
(
void
)
{
EmberAfStatus
status
=
emberAfOnOffClusterSetValueCallback
(
emberAfCurrentEndpoint
(),
ZCL_OFF_COMMAND_ID
,
false
);
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfPluginZllOnOffServerOffZllExtensions
(
emberAfCurrentCommand
());
}
#endif
emberAfSendImmediateDefaultResponse
(
status
);
return
true
;
}
bool
emberAfOnOffClusterOnCallback
(
void
)
{
EmberAfStatus
status
=
emberAfOnOffClusterSetValueCallback
(
emberAfCurrentEndpoint
(),
ZCL_ON_COMMAND_ID
,
false
);
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfPluginZllOnOffServerOnZllExtensions
(
emberAfCurrentCommand
());
}
#endif
emberAfSendImmediateDefaultResponse
(
status
);
return
true
;
}
bool
emberAfOnOffClusterToggleCallback
(
void
)
{
EmberAfStatus
status
=
emberAfOnOffClusterSetValueCallback
(
emberAfCurrentEndpoint
(),
ZCL_TOGGLE_COMMAND_ID
,
false
);
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfPluginZllOnOffServerToggleZllExtensions
(
emberAfCurrentCommand
());
}
#endif
emberAfSendImmediateDefaultResponse
(
status
);
return
true
;
}
void
emberAfOnOffClusterServerInitCallback
(
uint8_t
endpoint
)
{
#ifdef ZCL_USING_ON_OFF_CLUSTER_START_UP_ON_OFF_ATTRIBUTE
// StartUp behavior relies on OnOff and StartUpOnOff attributes being tokenized.
if
(
areStartUpOnOffServerAttributesTokenized
(
endpoint
))
{
// Read the StartUpOnOff attribute and set the OnOff attribute as per
// following from zcl 7 14-0127-20i-zcl-ch-3-general.doc.
// 3.8.2.2.5 StartUpOnOff Attribute
// The StartUpOnOff attribute SHALL define the desired startup behavior of a
// lamp device when it is supplied with power and this state SHALL be
// reflected in the OnOff attribute. The values of the StartUpOnOff
// attribute are listed below.
// Table 3 46. Values of the StartUpOnOff Attribute
// Value Action on power up
// 0x00 Set the OnOff attribute to 0 (off).
// 0x01 Set the OnOff attribute to 1 (on).
// 0x02 If the previous value of the OnOff attribute is equal to 0,
// set the OnOff attribute to 1.If the previous value of the OnOff
// attribute is equal to 1, set the OnOff attribute to 0 (toggle).
// 0x03-0xfe These values are reserved. No action.
// 0xff Set the OnOff attribute to its previous value.
// Initialize startUpOnOff to No action value 0xFE
uint8_t
startUpOnOff
=
0xFE
;
EmberAfStatus
status
=
emberAfReadAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_START_UP_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
startUpOnOff
,
sizeof
(
startUpOnOff
),
NULL
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
// Initialise updated value to 0
bool
updatedOnOff
=
0
;
status
=
emberAfReadAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
updatedOnOff
,
sizeof
(
updatedOnOff
),
NULL
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
switch
(
startUpOnOff
)
{
case
EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_OFF
:
updatedOnOff
=
0
;
// Off
break
;
case
EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_ON
:
updatedOnOff
=
1
;
//On
break
;
case
EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_TOGGLE
:
updatedOnOff
=
!
updatedOnOff
;
break
;
case
EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_PREVIOUS
:
default:
// All other values 0x03- 0xFE are reserved - no action.
// When value is 0xFF - update with last value - that is as good as
// no action.
break
;
}
status
=
emberAfWriteAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
updatedOnOff
,
ZCL_BOOLEAN_ATTRIBUTE_TYPE
);
}
}
}
#endif
emberAfPluginOnOffClusterServerPostInitCallback
(
endpoint
);
}
#ifdef ZCL_USING_ON_OFF_CLUSTER_START_UP_ON_OFF_ATTRIBUTE
static
bool
areStartUpOnOffServerAttributesTokenized
(
uint8_t
endpoint
)
{
EmberAfAttributeMetadata
*
metadata
;
metadata
=
emberAfLocateAttributeMetadata
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
EMBER_AF_NULL_MANUFACTURER_CODE
);
if
(
!
emberAfAttributeIsTokenized
(
metadata
))
{
return
false
;
}
metadata
=
emberAfLocateAttributeMetadata
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_START_UP_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
EMBER_AF_NULL_MANUFACTURER_CODE
);
if
(
!
emberAfAttributeIsTokenized
(
metadata
))
{
return
false
;
}
return
true
;
}
#endif
/***************************************************************************//**
* @file
* @brief Routines for the On-Off plugin, which implements the On-Off server
* cluster.
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#include "af.h"
#ifdef EMBER_AF_PLUGIN_REPORTING
#include "app/framework/plugin/reporting/reporting.h"
#endif
#ifdef EMBER_AF_PLUGIN_SCENES
#include "../scenes/scenes.h"
#endif //EMBER_AF_PLUGIN_SCENES
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
#include "../zll-on-off-server/zll-on-off-server.h"
#endif
#ifdef EMBER_AF_PLUGIN_ZLL_LEVEL_CONTROL_SERVER
#include "../zll-level-control-server/zll-level-control-server.h"
#endif
#ifdef ZCL_USING_ON_OFF_CLUSTER_START_UP_ON_OFF_ATTRIBUTE
static
bool
areStartUpOnOffServerAttributesTokenized
(
uint8_t
endpoint
);
#endif
EmberAfStatus
emberAfOnOffClusterSetValueCallback
(
uint8_t
endpoint
,
uint8_t
command
,
bool
initiatedByLevelChange
)
{
EmberAfStatus
status
;
bool
currentValue
,
newValue
;
emberAfOnOffClusterPrintln
(
"On/Off set value: %x %x"
,
endpoint
,
command
);
// read current on/off value
status
=
emberAfReadAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
currentValue
,
sizeof
(
currentValue
),
NULL
);
// data type
if
(
status
!=
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfOnOffClusterPrintln
(
"ERR: reading on/off %x"
,
status
);
return
status
;
}
// if the value is already what we want to set it to then do nothing
if
((
!
currentValue
&&
command
==
ZCL_OFF_COMMAND_ID
)
||
(
currentValue
&&
command
==
ZCL_ON_COMMAND_ID
))
{
emberAfOnOffClusterPrintln
(
"On/off already set to new value"
);
extern
uint8_t
kZclClusterAttrDelayReportQueueAdd
(
uint8_t
endpoint
,
uint16_t
clusterId
,
uint16_t
attributeId
);
kZclClusterAttrDelayReportQueueAdd
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
);
return
EMBER_ZCL_STATUS_SUCCESS
;
}
// we either got a toggle, or an on when off, or an off when on,
// so we need to swap the value
newValue
=
!
currentValue
;
emberAfOnOffClusterPrintln
(
"Toggle on/off from %x to %x"
,
currentValue
,
newValue
);
// the sequence of updating on/off attribute and kick off level change effect should
// be depend on whether we are turning on or off. If we are turning on the light, we
// should update the on/off attribute before kicking off level change, if we are
// turning off the light, we should do the opposite, that is kick off level change
// before updating the on/off attribute.
if
(
newValue
)
{
// write the new on/off value
status
=
emberAfWriteAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
newValue
,
ZCL_BOOLEAN_ATTRIBUTE_TYPE
);
if
(
status
!=
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfOnOffClusterPrintln
(
"ERR: writing on/off %x"
,
status
);
return
status
;
}
// If initiatedByLevelChange is false, then we assume that the level change
// ZCL stuff has not happened and we do it here
if
(
!
initiatedByLevelChange
&&
emberAfContainsServer
(
endpoint
,
ZCL_LEVEL_CONTROL_CLUSTER_ID
))
{
emberAfOnOffClusterLevelControlEffectCallback
(
endpoint
,
newValue
);
}
}
else
{
// If initiatedByLevelChange is false, then we assume that the level change
// ZCL stuff has not happened and we do it here
if
(
!
initiatedByLevelChange
&&
emberAfContainsServer
(
endpoint
,
ZCL_LEVEL_CONTROL_CLUSTER_ID
))
{
emberAfOnOffClusterLevelControlEffectCallback
(
endpoint
,
newValue
);
}
// write the new on/off value
status
=
emberAfWriteAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
newValue
,
ZCL_BOOLEAN_ATTRIBUTE_TYPE
);
if
(
status
!=
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfOnOffClusterPrintln
(
"ERR: writing on/off %x"
,
status
);
return
status
;
}
}
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
if
(
initiatedByLevelChange
)
{
emberAfPluginZllOnOffServerLevelControlZllExtensions
(
endpoint
);
}
#endif
// the scene has been changed (the value of on/off has changed) so
// the current scene as descibed in the attribute table is invalid,
// so mark it as invalid (just writes the valid/invalid attribute)
if
(
emberAfContainsServer
(
endpoint
,
ZCL_SCENES_CLUSTER_ID
))
{
emberAfScenesClusterMakeInvalidCallback
(
endpoint
);
}
// The returned status is based solely on the On/Off cluster. Errors in the
// Level Control and/or Scenes cluster are ignored.
return
EMBER_ZCL_STATUS_SUCCESS
;
}
bool
emberAfOnOffClusterOffCallback
(
void
)
{
EmberAfStatus
status
=
emberAfOnOffClusterSetValueCallback
(
emberAfCurrentEndpoint
(),
ZCL_OFF_COMMAND_ID
,
false
);
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfPluginZllOnOffServerOffZllExtensions
(
emberAfCurrentCommand
());
}
#endif
emberAfSendImmediateDefaultResponse
(
status
);
return
true
;
}
bool
emberAfOnOffClusterOnCallback
(
void
)
{
EmberAfStatus
status
=
emberAfOnOffClusterSetValueCallback
(
emberAfCurrentEndpoint
(),
ZCL_ON_COMMAND_ID
,
false
);
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfPluginZllOnOffServerOnZllExtensions
(
emberAfCurrentCommand
());
}
#endif
emberAfSendImmediateDefaultResponse
(
status
);
return
true
;
}
bool
emberAfOnOffClusterToggleCallback
(
void
)
{
EmberAfStatus
status
=
emberAfOnOffClusterSetValueCallback
(
emberAfCurrentEndpoint
(),
ZCL_TOGGLE_COMMAND_ID
,
false
);
#ifdef EMBER_AF_PLUGIN_ZLL_ON_OFF_SERVER
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
emberAfPluginZllOnOffServerToggleZllExtensions
(
emberAfCurrentCommand
());
}
#endif
emberAfSendImmediateDefaultResponse
(
status
);
return
true
;
}
void
emberAfOnOffClusterServerInitCallback
(
uint8_t
endpoint
)
{
#ifdef ZCL_USING_ON_OFF_CLUSTER_START_UP_ON_OFF_ATTRIBUTE
// StartUp behavior relies on OnOff and StartUpOnOff attributes being tokenized.
if
(
areStartUpOnOffServerAttributesTokenized
(
endpoint
))
{
// Read the StartUpOnOff attribute and set the OnOff attribute as per
// following from zcl 7 14-0127-20i-zcl-ch-3-general.doc.
// 3.8.2.2.5 StartUpOnOff Attribute
// The StartUpOnOff attribute SHALL define the desired startup behavior of a
// lamp device when it is supplied with power and this state SHALL be
// reflected in the OnOff attribute. The values of the StartUpOnOff
// attribute are listed below.
// Table 3 46. Values of the StartUpOnOff Attribute
// Value Action on power up
// 0x00 Set the OnOff attribute to 0 (off).
// 0x01 Set the OnOff attribute to 1 (on).
// 0x02 If the previous value of the OnOff attribute is equal to 0,
// set the OnOff attribute to 1.If the previous value of the OnOff
// attribute is equal to 1, set the OnOff attribute to 0 (toggle).
// 0x03-0xfe These values are reserved. No action.
// 0xff Set the OnOff attribute to its previous value.
// Initialize startUpOnOff to No action value 0xFE
uint8_t
startUpOnOff
=
0xFE
;
EmberAfStatus
status
=
emberAfReadAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_START_UP_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
startUpOnOff
,
sizeof
(
startUpOnOff
),
NULL
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
// Initialise updated value to 0
bool
updatedOnOff
=
0
;
status
=
emberAfReadAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
updatedOnOff
,
sizeof
(
updatedOnOff
),
NULL
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
)
{
switch
(
startUpOnOff
)
{
case
EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_OFF
:
updatedOnOff
=
0
;
// Off
break
;
case
EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_ON
:
updatedOnOff
=
1
;
//On
break
;
case
EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_TOGGLE
:
updatedOnOff
=
!
updatedOnOff
;
break
;
case
EMBER_ZCL_START_UP_ON_OFF_VALUE_SET_TO_PREVIOUS
:
default:
// All other values 0x03- 0xFE are reserved - no action.
// When value is 0xFF - update with last value - that is as good as
// no action.
break
;
}
status
=
emberAfWriteAttribute
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
(
uint8_t
*
)
&
updatedOnOff
,
ZCL_BOOLEAN_ATTRIBUTE_TYPE
);
}
}
}
#endif
emberAfPluginOnOffClusterServerPostInitCallback
(
endpoint
);
}
#ifdef ZCL_USING_ON_OFF_CLUSTER_START_UP_ON_OFF_ATTRIBUTE
static
bool
areStartUpOnOffServerAttributesTokenized
(
uint8_t
endpoint
)
{
EmberAfAttributeMetadata
*
metadata
;
metadata
=
emberAfLocateAttributeMetadata
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
EMBER_AF_NULL_MANUFACTURER_CODE
);
if
(
!
emberAfAttributeIsTokenized
(
metadata
))
{
return
false
;
}
metadata
=
emberAfLocateAttributeMetadata
(
endpoint
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_START_UP_ON_OFF_ATTRIBUTE_ID
,
CLUSTER_MASK_SERVER
,
EMBER_AF_NULL_MANUFACTURER_CODE
);
if
(
!
emberAfAttributeIsTokenized
(
metadata
))
{
return
false
;
}
return
true
;
}
#endif
v3.1/protocol/zigbee/app/framework/util/af-main-common.c
View file @
6941e0c5
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment