Reformat files
parent
edff6aef13
commit
222faed678
45
app_cfg.h
45
app_cfg.h
|
@ -25,10 +25,10 @@
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Version configuration
|
* Version configuration
|
||||||
*/
|
*/
|
||||||
|
@ -56,32 +56,31 @@ extern "C" {
|
||||||
|
|
||||||
/* Board define */
|
/* Board define */
|
||||||
#if defined(MCU_CORE_826x)
|
#if defined(MCU_CORE_826x)
|
||||||
#define BOARD BOARD_826x_DONGLE
|
#define BOARD BOARD_826x_DONGLE
|
||||||
#define CLOCK_SYS_CLOCK_HZ 32000000
|
#define CLOCK_SYS_CLOCK_HZ 32000000
|
||||||
#elif defined(MCU_CORE_8258)
|
#elif defined(MCU_CORE_8258)
|
||||||
#if (CHIP_TYPE == TLSR_8258_1M)
|
#if (CHIP_TYPE == TLSR_8258_1M)
|
||||||
#define FLASH_CAP_SIZE_1M 1
|
#define FLASH_CAP_SIZE_1M 1
|
||||||
#endif
|
#endif
|
||||||
#define BOARD BOARD_GLC002P
|
#define BOARD BOARD_GLC002P
|
||||||
#define CLOCK_SYS_CLOCK_HZ 48000000
|
#define CLOCK_SYS_CLOCK_HZ 48000000
|
||||||
#elif defined(MCU_CORE_8278)
|
#elif defined(MCU_CORE_8278)
|
||||||
#define FLASH_CAP_SIZE_1M 1
|
#define FLASH_CAP_SIZE_1M 1
|
||||||
#define BOARD BOARD_8278_DONGLE//BOARD_8278_EVK
|
#define BOARD BOARD_8278_DONGLE // BOARD_8278_EVK
|
||||||
#define CLOCK_SYS_CLOCK_HZ 48000000
|
#define CLOCK_SYS_CLOCK_HZ 48000000
|
||||||
#elif defined(MCU_CORE_B91)
|
#elif defined(MCU_CORE_B91)
|
||||||
#define FLASH_CAP_SIZE_1M 1
|
#define FLASH_CAP_SIZE_1M 1
|
||||||
#define BOARD BOARD_9518_DONGLE//BOARD_9518_EVK
|
#define BOARD BOARD_9518_DONGLE // BOARD_9518_EVK
|
||||||
#define CLOCK_SYS_CLOCK_HZ 48000000
|
#define CLOCK_SYS_CLOCK_HZ 48000000
|
||||||
#else
|
#else
|
||||||
#error "MCU is undefined!"
|
#error "MCU is undefined!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Board include */
|
/* Board include */
|
||||||
#if(BOARD == BOARD_GLC002P)
|
#if (BOARD == BOARD_GLC002P)
|
||||||
#include "board_glc002p.h"
|
#include "board_glc002p.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Voltage detect module */
|
/* Voltage detect module */
|
||||||
/* If you want to define the VOLTAGE_DETECT_ENABLE to 1,
|
/* If you want to define the VOLTAGE_DETECT_ENABLE to 1,
|
||||||
* and the model of the development board is B91 evk or dongle,
|
* and the model of the development board is B91 evk or dongle,
|
||||||
|
@ -98,10 +97,9 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (ZBHCI_USB_PRINT || ZBHCI_USB_CDC || ZBHCI_USB_HID || ZBHCI_UART)
|
#if (ZBHCI_USB_PRINT || ZBHCI_USB_CDC || ZBHCI_USB_HID || ZBHCI_UART)
|
||||||
#define ZBHCI_EN 1
|
#define ZBHCI_EN 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* ZCL cluster support setting
|
* ZCL cluster support setting
|
||||||
*/
|
*/
|
||||||
|
@ -121,22 +119,21 @@ extern "C" {
|
||||||
|
|
||||||
#define AF_TEST_ENABLE 0
|
#define AF_TEST_ENABLE 0
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Stack configuration
|
* Stack configuration
|
||||||
*/
|
*/
|
||||||
#include "stack_cfg.h"
|
#include "stack_cfg.h"
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
/**********************************************************************
|
|
||||||
* EV configuration
|
* EV configuration
|
||||||
*/
|
*/
|
||||||
typedef enum{
|
typedef enum
|
||||||
|
{
|
||||||
EV_POLL_ED_DETECT,
|
EV_POLL_ED_DETECT,
|
||||||
EV_POLL_HCI,
|
EV_POLL_HCI,
|
||||||
EV_POLL_IDLE,
|
EV_POLL_IDLE,
|
||||||
EV_POLL_MAX,
|
EV_POLL_MAX,
|
||||||
}ev_poll_e;
|
} ev_poll_e;
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
92
app_ui.c
92
app_ui.c
|
@ -36,70 +36,86 @@
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL FUNCTIONS
|
* LOCAL FUNCTIONS
|
||||||
*/
|
*/
|
||||||
void led_on(u32 pin){
|
void led_on(u32 pin)
|
||||||
|
{
|
||||||
drv_gpio_write(pin, LED_ON);
|
drv_gpio_write(pin, LED_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_off(u32 pin){
|
void led_off(u32 pin)
|
||||||
|
{
|
||||||
drv_gpio_write(pin, LED_OFF);
|
drv_gpio_write(pin, LED_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_init(void){
|
void led_init(void)
|
||||||
|
{
|
||||||
led_off(LED_STATUS_R);
|
led_off(LED_STATUS_R);
|
||||||
led_off(LED_STATUS_G);
|
led_off(LED_STATUS_G);
|
||||||
led_off(LED_STATUS_B);
|
led_off(LED_STATUS_B);
|
||||||
}
|
}
|
||||||
|
|
||||||
void localPermitJoinState(void){
|
void localPermitJoinState(void)
|
||||||
|
{
|
||||||
static bool assocPermit = 0;
|
static bool assocPermit = 0;
|
||||||
if(assocPermit != zb_getMacAssocPermit()){
|
if (assocPermit != zb_getMacAssocPermit())
|
||||||
|
{
|
||||||
assocPermit = zb_getMacAssocPermit();
|
assocPermit = zb_getMacAssocPermit();
|
||||||
if(assocPermit){
|
if (assocPermit)
|
||||||
|
{
|
||||||
led_on(LED_STATUS_R);
|
led_on(LED_STATUS_R);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
led_off(LED_STATUS_R);
|
led_off(LED_STATUS_R);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void buttonKeepPressed(u8 btNum){
|
void buttonKeepPressed(u8 btNum)
|
||||||
if(btNum == VK_SW1){
|
{
|
||||||
|
if (btNum == VK_SW1)
|
||||||
|
{
|
||||||
gLightCtx.state = APP_FACTORY_NEW_DOING;
|
gLightCtx.state = APP_FACTORY_NEW_DOING;
|
||||||
led_on(LED_STATUS_R);
|
led_on(LED_STATUS_R);
|
||||||
led_on(LED_STATUS_G);
|
led_on(LED_STATUS_G);
|
||||||
led_on(LED_STATUS_B);
|
led_on(LED_STATUS_B);
|
||||||
|
|
||||||
zb_factoryReset();
|
zb_factoryReset();
|
||||||
}else if(btNum == VK_SW2){
|
}
|
||||||
|
else if (btNum == VK_SW2)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void buttonShortPressed(u8 btNum){
|
void buttonShortPressed(u8 btNum)
|
||||||
if(btNum == VK_SW1){
|
{
|
||||||
if(zb_isDeviceJoinedNwk()){
|
if (btNum == VK_SW1)
|
||||||
|
{
|
||||||
|
if (zb_isDeviceJoinedNwk())
|
||||||
|
{
|
||||||
gLightCtx.sta = !gLightCtx.sta;
|
gLightCtx.sta = !gLightCtx.sta;
|
||||||
if(gLightCtx.sta){
|
if (gLightCtx.sta)
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_ONOFF_STATUS_ON);
|
sampleLight_onoff(ZCL_ONOFF_STATUS_ON);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_ONOFF_STATUS_OFF);
|
sampleLight_onoff(ZCL_ONOFF_STATUS_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(btNum == VK_SW2){
|
}
|
||||||
|
else if (btNum == VK_SW2)
|
||||||
|
{
|
||||||
/* toggle local permit Joining */
|
/* toggle local permit Joining */
|
||||||
static u8 duration = 0;
|
static u8 duration = 0;
|
||||||
duration = duration ? 0 : 0xff;
|
duration = duration ? 0 : 0xff;
|
||||||
|
@ -107,42 +123,52 @@ void buttonShortPressed(u8 btNum){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void keyScan_keyPressedCB(kb_data_t *kbEvt){
|
void keyScan_keyPressedCB(kb_data_t *kbEvt)
|
||||||
// u8 toNormal = 0;
|
{
|
||||||
|
// u8 toNormal = 0;
|
||||||
u8 keyCode = kbEvt->keycode[0];
|
u8 keyCode = kbEvt->keycode[0];
|
||||||
// static u8 lastKeyCode = 0xff;
|
// static u8 lastKeyCode = 0xff;
|
||||||
|
|
||||||
buttonShortPressed(keyCode);
|
buttonShortPressed(keyCode);
|
||||||
|
|
||||||
if(keyCode == VK_SW1){
|
if (keyCode == VK_SW1)
|
||||||
|
{
|
||||||
gLightCtx.keyPressedTime = clock_time();
|
gLightCtx.keyPressedTime = clock_time();
|
||||||
gLightCtx.state = APP_FACTORY_NEW_SET_CHECK;
|
gLightCtx.state = APP_FACTORY_NEW_SET_CHECK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void keyScan_keyReleasedCB(u8 keyCode)
|
||||||
void keyScan_keyReleasedCB(u8 keyCode){
|
{
|
||||||
gLightCtx.state = APP_STATE_NORMAL;
|
gLightCtx.state = APP_STATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile u8 T_keyPressedNum = 0;
|
volatile u8 T_keyPressedNum = 0;
|
||||||
void app_key_handler(void){
|
void app_key_handler(void)
|
||||||
|
{
|
||||||
static u8 valid_keyCode = 0xff;
|
static u8 valid_keyCode = 0xff;
|
||||||
|
|
||||||
if(gLightCtx.state == APP_FACTORY_NEW_SET_CHECK){
|
if (gLightCtx.state == APP_FACTORY_NEW_SET_CHECK)
|
||||||
if(clock_time_exceed(gLightCtx.keyPressedTime, 5*1000*1000)){
|
{
|
||||||
|
if (clock_time_exceed(gLightCtx.keyPressedTime, 5 * 1000 * 1000))
|
||||||
|
{
|
||||||
buttonKeepPressed(VK_SW1);
|
buttonKeepPressed(VK_SW1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kb_scan_key(0 , 1)){
|
if (kb_scan_key(0, 1))
|
||||||
|
{
|
||||||
T_keyPressedNum++;
|
T_keyPressedNum++;
|
||||||
if(kb_event.cnt){
|
if (kb_event.cnt)
|
||||||
|
{
|
||||||
keyScan_keyPressedCB(&kb_event);
|
keyScan_keyPressedCB(&kb_event);
|
||||||
if(kb_event.cnt == 1){
|
if (kb_event.cnt == 1)
|
||||||
|
{
|
||||||
valid_keyCode = kb_event.keycode[0];
|
valid_keyCode = kb_event.keycode[0];
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
keyScan_keyReleasedCB(valid_keyCode);
|
keyScan_keyReleasedCB(valid_keyCode);
|
||||||
valid_keyCode = 0xff;
|
valid_keyCode = 0xff;
|
||||||
}
|
}
|
||||||
|
|
5
app_ui.h
5
app_ui.h
|
@ -30,17 +30,16 @@
|
||||||
#define LED_ON 1
|
#define LED_ON 1
|
||||||
#define LED_OFF 0
|
#define LED_OFF 0
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
enum{
|
enum
|
||||||
|
{
|
||||||
APP_STATE_NORMAL,
|
APP_STATE_NORMAL,
|
||||||
APP_FACTORY_NEW_SET_CHECK,
|
APP_FACTORY_NEW_SET_CHECK,
|
||||||
APP_FACTORY_NEW_DOING,
|
APP_FACTORY_NEW_DOING,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* FUNCTIONS
|
* FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,13 +25,14 @@
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*******************************************************************************************************
|
/*******************************************************************************************************
|
||||||
*********************TLSR8258F512ET32 32 Pins: Start*****************************************************
|
*********************TLSR8258F512ET32 32 Pins: Start*****************************************************
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
// Option Button
|
// Option Button
|
||||||
#define BUTTON_OPT GPIO_PB7
|
#define BUTTON_OPT GPIO_PB7
|
||||||
#define PB7_FUNC AS_GPIO
|
#define PB7_FUNC AS_GPIO
|
||||||
#define PB7_OUTPUT_ENABLE 0
|
#define PB7_OUTPUT_ENABLE 0
|
||||||
|
@ -52,31 +53,40 @@ extern "C" {
|
||||||
#define LED_C GPIO_PD2 // PWM3
|
#define LED_C GPIO_PD2 // PWM3
|
||||||
#define LED_W GPIO_PB4 // PWM4
|
#define LED_W GPIO_PB4 // PWM4
|
||||||
|
|
||||||
#define PWM_B_CHANNEL 0//PWM0
|
#define PWM_B_CHANNEL 0 // PWM0
|
||||||
#define PWM_B_CHANNEL_SET() do{ \
|
#define PWM_B_CHANNEL_SET() \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
gpio_set_func(LED_B, AS_PWM0); \
|
gpio_set_func(LED_B, AS_PWM0); \
|
||||||
}while(0)
|
} while (0)
|
||||||
|
|
||||||
#define PWM_G_CHANNEL 1//PWM1
|
#define PWM_G_CHANNEL 1 // PWM1
|
||||||
#define PWM_G_CHANNEL_SET() do{ \
|
#define PWM_G_CHANNEL_SET() \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
gpio_set_func(LED_G, AS_PWM1); \
|
gpio_set_func(LED_G, AS_PWM1); \
|
||||||
}while(0)
|
} while (0)
|
||||||
|
|
||||||
#define PWM_R_CHANNEL 2//PWM2
|
#define PWM_R_CHANNEL 2 // PWM2
|
||||||
#define PWM_R_CHANNEL_SET() do{ \
|
#define PWM_R_CHANNEL_SET() \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
gpio_set_func(LED_R, AS_PWM2); \
|
gpio_set_func(LED_R, AS_PWM2); \
|
||||||
}while(0)
|
} while (0)
|
||||||
|
|
||||||
|
#define PWM_C_CHANNEL 3 // PWM3
|
||||||
#define PWM_C_CHANNEL 3//PWM3
|
#define PWM_C_CHANNEL_SET() \
|
||||||
#define PWM_C_CHANNEL_SET() do{ \
|
do \
|
||||||
|
{ \
|
||||||
gpio_set_func(LED_C, AS_PWM3); \
|
gpio_set_func(LED_C, AS_PWM3); \
|
||||||
}while(0)
|
} while (0)
|
||||||
|
|
||||||
#define PWM_W_CHANNEL 4//PWM4
|
#define PWM_W_CHANNEL 4 // PWM4
|
||||||
#define PWM_W_CHANNEL_SET() do{ \
|
#define PWM_W_CHANNEL_SET() \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
gpio_set_func(LED_W, AS_PWM4); \
|
gpio_set_func(LED_W, AS_PWM4); \
|
||||||
}while(0)
|
} while (0)
|
||||||
|
|
||||||
#define R_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
#define R_LIGHT_PWM_CHANNEL PWM_R_CHANNEL
|
||||||
#define G_LIGHT_PWM_CHANNEL PWM_G_CHANNEL
|
#define G_LIGHT_PWM_CHANNEL PWM_G_CHANNEL
|
||||||
|
@ -112,29 +122,41 @@ extern "C" {
|
||||||
|
|
||||||
// UART
|
// UART
|
||||||
#if ZBHCI_UART
|
#if ZBHCI_UART
|
||||||
#error please configure the uart PIN!!!!!!
|
#error please configure the uart PIN!!!!!!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
#if UART_PRINTF_MODE
|
#if UART_PRINTF_MODE
|
||||||
#define DEBUG_INFO_TX_PIN GPIO_PC4//print
|
#define DEBUG_INFO_TX_PIN GPIO_PC4 // print
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum{
|
enum
|
||||||
|
{
|
||||||
VK_SW1 = 0x01,
|
VK_SW1 = 0x01,
|
||||||
VK_SW2 = 0x02
|
VK_SW2 = 0x02
|
||||||
};
|
};
|
||||||
|
|
||||||
#define KB_MAP_NORMAL {\
|
#define KB_MAP_NORMAL \
|
||||||
{VK_SW1,}, \
|
{ \
|
||||||
{VK_SW2,}, }
|
{ \
|
||||||
|
VK_SW1, \
|
||||||
|
}, \
|
||||||
|
{ \
|
||||||
|
VK_SW2, \
|
||||||
|
}, \
|
||||||
|
}
|
||||||
|
|
||||||
#define KB_MAP_NUM KB_MAP_NORMAL
|
#define KB_MAP_NUM KB_MAP_NORMAL
|
||||||
#define KB_MAP_FN KB_MAP_NORMAL
|
#define KB_MAP_FN KB_MAP_NORMAL
|
||||||
|
|
||||||
#define KB_DRIVE_PINS {NULL }
|
#define KB_DRIVE_PINS \
|
||||||
#define KB_SCAN_PINS {BUTTON_OPT, BUTTON_RESET}
|
{ \
|
||||||
|
NULL \
|
||||||
|
}
|
||||||
|
#define KB_SCAN_PINS \
|
||||||
|
{ \
|
||||||
|
BUTTON_OPT, BUTTON_RESET \
|
||||||
|
}
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
|
@ -47,22 +47,19 @@
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
*/
|
*/
|
||||||
app_ctx_t gLightCtx;
|
app_ctx_t gLightCtx;
|
||||||
|
|
||||||
|
|
||||||
#ifdef ZCL_OTA
|
#ifdef ZCL_OTA
|
||||||
extern ota_callBack_t sampleLight_otaCb;
|
extern ota_callBack_t sampleLight_otaCb;
|
||||||
|
|
||||||
//running code firmware information
|
// running code firmware information
|
||||||
ota_preamble_t sampleLight_otaInfo = {
|
ota_preamble_t sampleLight_otaInfo = {
|
||||||
.fileVer = FILE_VERSION,
|
.fileVer = FILE_VERSION,
|
||||||
.imageType = IMAGE_TYPE,
|
.imageType = IMAGE_TYPE,
|
||||||
|
@ -70,34 +67,32 @@ ota_preamble_t sampleLight_otaInfo = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Must declare the application call back function which used by ZDO layer
|
||||||
//Must declare the application call back function which used by ZDO layer
|
|
||||||
const zdo_appIndCb_t appCbLst = {
|
const zdo_appIndCb_t appCbLst = {
|
||||||
bdb_zdoStartDevCnf,//start device cnf cb
|
bdb_zdoStartDevCnf, // start device cnf cb
|
||||||
NULL,//reset cnf cb
|
NULL, // reset cnf cb
|
||||||
NULL,//device announce indication cb
|
NULL, // device announce indication cb
|
||||||
sampleLight_leaveIndHandler,//leave ind cb
|
sampleLight_leaveIndHandler, // leave ind cb
|
||||||
sampleLight_leaveCnfHandler,//leave cnf cb
|
sampleLight_leaveCnfHandler, // leave cnf cb
|
||||||
sampleLight_nwkUpdateIndicateHandler,//nwk update ind cb
|
sampleLight_nwkUpdateIndicateHandler, // nwk update ind cb
|
||||||
NULL,//permit join ind cb
|
NULL, // permit join ind cb
|
||||||
NULL,//nlme sync cnf cb
|
NULL, // nlme sync cnf cb
|
||||||
NULL,//tc join ind cb
|
NULL, // tc join ind cb
|
||||||
NULL,//tc detects that the frame counter is near limit
|
NULL, // tc detects that the frame counter is near limit
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Definition for bdb commissioning setting
|
* @brief Definition for bdb commissioning setting
|
||||||
*/
|
*/
|
||||||
bdb_commissionSetting_t g_bdbCommissionSetting = {
|
bdb_commissionSetting_t g_bdbCommissionSetting = {
|
||||||
.linkKey.tcLinkKey.keyType = SS_GLOBAL_LINK_KEY,
|
.linkKey.tcLinkKey.keyType = SS_GLOBAL_LINK_KEY,
|
||||||
.linkKey.tcLinkKey.key = (u8 *)tcLinkKeyCentralDefault, //can use unique link key stored in NV
|
.linkKey.tcLinkKey.key = (u8 *)tcLinkKeyCentralDefault, // can use unique link key stored in NV
|
||||||
|
|
||||||
.linkKey.distributeLinkKey.keyType = MASTER_KEY,
|
.linkKey.distributeLinkKey.keyType = MASTER_KEY,
|
||||||
.linkKey.distributeLinkKey.key = (u8 *)linkKeyDistributedMaster, //use linkKeyDistributedCertification before testing
|
.linkKey.distributeLinkKey.key = (u8 *)linkKeyDistributedMaster, // use linkKeyDistributedCertification before testing
|
||||||
|
|
||||||
.linkKey.touchLinkKey.keyType = MASTER_KEY,
|
.linkKey.touchLinkKey.keyType = MASTER_KEY,
|
||||||
.linkKey.touchLinkKey.key = (u8 *)touchLinkKeyMaster, //use touchLinkKeyCertification before testing
|
.linkKey.touchLinkKey.key = (u8 *)touchLinkKeyMaster, // use touchLinkKeyCertification before testing
|
||||||
|
|
||||||
#if TOUCHLINK_SUPPORT
|
#if TOUCHLINK_SUPPORT
|
||||||
.touchlinkEnable = 1, /* enable touch-link */
|
.touchlinkEnable = 1, /* enable touch-link */
|
||||||
|
@ -113,7 +108,6 @@ bdb_commissionSetting_t g_bdbCommissionSetting = {
|
||||||
*/
|
*/
|
||||||
ev_timer_event_t *sampleLightAttrsStoreTimerEvt = NULL;
|
ev_timer_event_t *sampleLightAttrsStoreTimerEvt = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* FUNCTIONS
|
* FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
@ -184,8 +178,6 @@ void user_app_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
s32 sampleLightAttrsStoreTimerCb(void *arg)
|
s32 sampleLightAttrsStoreTimerCb(void *arg)
|
||||||
{
|
{
|
||||||
zcl_onOffAttr_save();
|
zcl_onOffAttr_save();
|
||||||
|
@ -198,7 +190,8 @@ s32 sampleLightAttrsStoreTimerCb(void *arg)
|
||||||
|
|
||||||
void sampleLightAttrsStoreTimerStart(void)
|
void sampleLightAttrsStoreTimerStart(void)
|
||||||
{
|
{
|
||||||
if(sampleLightAttrsStoreTimerEvt){
|
if (sampleLightAttrsStoreTimerEvt)
|
||||||
|
{
|
||||||
TL_ZB_TIMER_CANCEL(&sampleLightAttrsStoreTimerEvt);
|
TL_ZB_TIMER_CANCEL(&sampleLightAttrsStoreTimerEvt);
|
||||||
}
|
}
|
||||||
sampleLightAttrsStoreTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLightAttrsStoreTimerCb, NULL, 200);
|
sampleLightAttrsStoreTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLightAttrsStoreTimerCb, NULL, 200);
|
||||||
|
@ -206,9 +199,11 @@ void sampleLightAttrsStoreTimerStart(void)
|
||||||
|
|
||||||
void sampleLightAttrsChk(void)
|
void sampleLightAttrsChk(void)
|
||||||
{
|
{
|
||||||
if(gLightCtx.lightAttrsChanged){
|
if (gLightCtx.lightAttrsChanged)
|
||||||
|
{
|
||||||
gLightCtx.lightAttrsChanged = FALSE;
|
gLightCtx.lightAttrsChanged = FALSE;
|
||||||
if(zb_isDeviceJoinedNwk()){
|
if (zb_isDeviceJoinedNwk())
|
||||||
|
{
|
||||||
sampleLightAttrsStoreTimerStart();
|
sampleLightAttrsStoreTimerStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,16 +211,20 @@ void sampleLightAttrsChk(void)
|
||||||
|
|
||||||
void report_handler(void)
|
void report_handler(void)
|
||||||
{
|
{
|
||||||
if(zb_isDeviceJoinedNwk()){
|
if (zb_isDeviceJoinedNwk())
|
||||||
if(zcl_reportingEntryActiveNumGet()){
|
{
|
||||||
u16 second = 1;//TODO: fix me
|
if (zcl_reportingEntryActiveNumGet())
|
||||||
|
{
|
||||||
|
u16 second = 1; // TODO: fix me
|
||||||
|
|
||||||
reportNoMinLimit();
|
reportNoMinLimit();
|
||||||
|
|
||||||
//start report timer
|
// start report timer
|
||||||
reportAttrTimerStart(second);
|
reportAttrTimerStart(second);
|
||||||
}else{
|
}
|
||||||
//stop report timer
|
else
|
||||||
|
{
|
||||||
|
// stop report timer
|
||||||
reportAttrTimerStop();
|
reportAttrTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,12 +234,13 @@ void app_task(void)
|
||||||
{
|
{
|
||||||
app_key_handler();
|
app_key_handler();
|
||||||
localPermitJoinState();
|
localPermitJoinState();
|
||||||
if(BDB_STATE_GET() == BDB_STATE_IDLE){
|
if (BDB_STATE_GET() == BDB_STATE_IDLE)
|
||||||
//factroyRst_handler();
|
{
|
||||||
|
// factroyRst_handler();
|
||||||
|
|
||||||
report_handler();
|
report_handler();
|
||||||
|
|
||||||
#if 0/* NOTE: If set to '1', the latest status of lighting will be stored. */
|
#if 0 /* NOTE: If set to '1', the latest status of lighting will be stored. */
|
||||||
sampleLightAttrsChk();
|
sampleLightAttrsChk();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -253,8 +253,8 @@ static void sampleLightSysException(void)
|
||||||
zcl_colorCtrlAttr_save();
|
zcl_colorCtrlAttr_save();
|
||||||
|
|
||||||
SYSTEM_RESET();
|
SYSTEM_RESET();
|
||||||
//led_on(LED_POWER);
|
// led_on(LED_POWER);
|
||||||
//while(1);
|
// while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -274,7 +274,7 @@ void user_init(bool isRetention)
|
||||||
led_init();
|
led_init();
|
||||||
hwLight_init();
|
hwLight_init();
|
||||||
|
|
||||||
//factroyRst_init();
|
// factroyRst_init();
|
||||||
|
|
||||||
/* Initialize Stack */
|
/* Initialize Stack */
|
||||||
stack_init();
|
stack_init();
|
||||||
|
@ -296,7 +296,8 @@ void user_init(bool isRetention)
|
||||||
ev_on_poll(EV_POLL_IDLE, app_task);
|
ev_on_poll(EV_POLL_IDLE, app_task);
|
||||||
|
|
||||||
/* Read the pre-install code from NV */
|
/* Read the pre-install code from NV */
|
||||||
if(bdb_preInstallCodeLoad(&gLightCtx.tcLinkKey.keyType, gLightCtx.tcLinkKey.key) == RET_OK){
|
if (bdb_preInstallCodeLoad(&gLightCtx.tcLinkKey.keyType, gLightCtx.tcLinkKey.key) == RET_OK)
|
||||||
|
{
|
||||||
g_bdbCommissionSetting.linkKey.tcLinkKey.keyType = gLightCtx.tcLinkKey.keyType;
|
g_bdbCommissionSetting.linkKey.tcLinkKey.keyType = gLightCtx.tcLinkKey.keyType;
|
||||||
g_bdbCommissionSetting.linkKey.tcLinkKey.key = gLightCtx.tcLinkKey.key;
|
g_bdbCommissionSetting.linkKey.tcLinkKey.key = gLightCtx.tcLinkKey.key;
|
||||||
}
|
}
|
||||||
|
@ -311,4 +312,3 @@ void user_init(bool isRetention)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __PROJECT_TL_DIMMABLE_LIGHT__ */
|
#endif /* __PROJECT_TL_DIMMABLE_LIGHT__ */
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
#ifndef _SAMPLE_LIGHT_H_
|
#ifndef _SAMPLE_LIGHT_H_
|
||||||
#define _SAMPLE_LIGHT_H_
|
#define _SAMPLE_LIGHT_H_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* CONSTANT
|
* CONSTANT
|
||||||
*/
|
*/
|
||||||
|
@ -35,33 +33,36 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
u8 keyType; /* ERTIFICATION_KEY or MASTER_KEY key for touch-link or distribute network
|
u8 keyType; /* ERTIFICATION_KEY or MASTER_KEY key for touch-link or distribute network
|
||||||
SS_UNIQUE_LINK_KEY or SS_GLOBAL_LINK_KEY for distribute network */
|
SS_UNIQUE_LINK_KEY or SS_GLOBAL_LINK_KEY for distribute network */
|
||||||
u8 key[16]; /* the key used */
|
u8 key[16]; /* the key used */
|
||||||
}app_linkKey_info_t;
|
} app_linkKey_info_t;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
ev_timer_event_t *timerLedEvt;
|
ev_timer_event_t *timerLedEvt;
|
||||||
u32 keyPressedTime;
|
u32 keyPressedTime;
|
||||||
|
|
||||||
u16 ledOnTime;
|
u16 ledOnTime;
|
||||||
u16 ledOffTime;
|
u16 ledOffTime;
|
||||||
u8 oriSta; //original state before blink
|
u8 oriSta; // original state before blink
|
||||||
u8 sta; //current state in blink
|
u8 sta; // current state in blink
|
||||||
u8 times; //blink times
|
u8 times; // blink times
|
||||||
u8 state;
|
u8 state;
|
||||||
|
|
||||||
bool bdbFindBindFlg;
|
bool bdbFindBindFlg;
|
||||||
bool lightAttrsChanged;
|
bool lightAttrsChanged;
|
||||||
|
|
||||||
app_linkKey_info_t tcLinkKey;
|
app_linkKey_info_t tcLinkKey;
|
||||||
}app_ctx_t;
|
} app_ctx_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for basic cluster attributes
|
* @brief Defined for basic cluster attributes
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
u8 zclVersion;
|
u8 zclVersion;
|
||||||
u8 appVersion;
|
u8 appVersion;
|
||||||
u8 stackVersion;
|
u8 stackVersion;
|
||||||
|
@ -71,57 +72,63 @@ typedef struct{
|
||||||
u8 swBuildId[ZCL_BASIC_MAX_LENGTH];
|
u8 swBuildId[ZCL_BASIC_MAX_LENGTH];
|
||||||
u8 powerSource;
|
u8 powerSource;
|
||||||
u8 deviceEnable;
|
u8 deviceEnable;
|
||||||
}zcl_basicAttr_t;
|
} zcl_basicAttr_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for identify cluster attributes
|
* @brief Defined for identify cluster attributes
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
u16 identifyTime;
|
u16 identifyTime;
|
||||||
}zcl_identifyAttr_t;
|
} zcl_identifyAttr_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for group cluster attributes
|
* @brief Defined for group cluster attributes
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
u8 nameSupport;
|
u8 nameSupport;
|
||||||
}zcl_groupAttr_t;
|
} zcl_groupAttr_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for scene cluster attributes
|
* @brief Defined for scene cluster attributes
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
u8 sceneCount;
|
u8 sceneCount;
|
||||||
u8 currentScene;
|
u8 currentScene;
|
||||||
u8 nameSupport;
|
u8 nameSupport;
|
||||||
bool sceneValid;
|
bool sceneValid;
|
||||||
u16 currentGroup;
|
u16 currentGroup;
|
||||||
}zcl_sceneAttr_t;
|
} zcl_sceneAttr_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for on/off cluster attributes
|
* @brief Defined for on/off cluster attributes
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
u16 onTime;
|
u16 onTime;
|
||||||
u16 offWaitTime;
|
u16 offWaitTime;
|
||||||
u8 startUpOnOff;
|
u8 startUpOnOff;
|
||||||
bool onOff;
|
bool onOff;
|
||||||
bool globalSceneControl;
|
bool globalSceneControl;
|
||||||
}zcl_onOffAttr_t;
|
} zcl_onOffAttr_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for level cluster attributes
|
* @brief Defined for level cluster attributes
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
u16 remainingTime;
|
u16 remainingTime;
|
||||||
u8 curLevel;
|
u8 curLevel;
|
||||||
u8 startUpCurrentLevel;
|
u8 startUpCurrentLevel;
|
||||||
}zcl_levelAttr_t;
|
} zcl_levelAttr_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for color control cluster attributes
|
* @brief Defined for color control cluster attributes
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
u8 colorMode;
|
u8 colorMode;
|
||||||
u8 options;
|
u8 options;
|
||||||
u8 enhancedColorMode;
|
u8 enhancedColorMode;
|
||||||
|
@ -141,33 +148,36 @@ typedef struct{
|
||||||
u16 colorTempPhysicalMinMireds;
|
u16 colorTempPhysicalMinMireds;
|
||||||
u16 colorTempPhysicalMaxMireds;
|
u16 colorTempPhysicalMaxMireds;
|
||||||
u16 startUpColorTemperatureMireds;
|
u16 startUpColorTemperatureMireds;
|
||||||
}zcl_lightColorCtrlAttr_t;
|
} zcl_lightColorCtrlAttr_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for saving on/off attributes
|
* @brief Defined for saving on/off attributes
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
u8 onOff;
|
u8 onOff;
|
||||||
u8 startUpOnOff;
|
u8 startUpOnOff;
|
||||||
}zcl_nv_onOff_t;
|
} zcl_nv_onOff_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for saving level attributes
|
* @brief Defined for saving level attributes
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
u8 curLevel;
|
u8 curLevel;
|
||||||
u8 startUpCurLevel;
|
u8 startUpCurLevel;
|
||||||
}zcl_nv_level_t;
|
} zcl_nv_level_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defined for saving color control attributes
|
* @brief Defined for saving color control attributes
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
u8 currentHue;
|
u8 currentHue;
|
||||||
u8 currentSaturation;
|
u8 currentSaturation;
|
||||||
u16 colorTemperatureMireds;
|
u16 colorTemperatureMireds;
|
||||||
u16 startUpColorTemperatureMireds;
|
u16 startUpColorTemperatureMireds;
|
||||||
}zcl_nv_colorCtrl_t;
|
} zcl_nv_colorCtrl_t;
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
|
@ -176,7 +186,6 @@ extern app_ctx_t gLightCtx;
|
||||||
extern bdb_commissionSetting_t g_bdbCommissionSetting;
|
extern bdb_commissionSetting_t g_bdbCommissionSetting;
|
||||||
extern bdb_appCb_t g_zbDemoBdbCb;
|
extern bdb_appCb_t g_zbDemoBdbCb;
|
||||||
|
|
||||||
|
|
||||||
extern u8 SAMPLELIGHT_CB_CLUSTER_NUM;
|
extern u8 SAMPLELIGHT_CB_CLUSTER_NUM;
|
||||||
extern const zcl_specClusterInfo_t g_sampleLightClusterList[];
|
extern const zcl_specClusterInfo_t g_sampleLightClusterList[];
|
||||||
extern const af_simple_descriptor_t sampleLight_simpleDesc;
|
extern const af_simple_descriptor_t sampleLight_simpleDesc;
|
||||||
|
|
|
@ -30,26 +30,23 @@
|
||||||
#include "zcl_include.h"
|
#include "zcl_include.h"
|
||||||
#include "sampleLight.h"
|
#include "sampleLight.h"
|
||||||
#include "sampleLightCtrl.h"
|
#include "sampleLightCtrl.h"
|
||||||
#include<math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
*/
|
*/
|
||||||
#define PWM_FREQUENCY 1000 //1KHz
|
#define PWM_FREQUENCY 1000 // 1KHz
|
||||||
#define PWM_FULL_DUTYCYCLE 100
|
#define PWM_FULL_DUTYCYCLE 100
|
||||||
#define PMW_MAX_TICK (PWM_CLOCK_SOURCE / PWM_FREQUENCY)
|
#define PMW_MAX_TICK (PWM_CLOCK_SOURCE / PWM_FREQUENCY)
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* FUNCTIONS
|
* FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
@ -132,13 +129,16 @@ void hwLight_init(void)
|
||||||
*/
|
*/
|
||||||
void hwLight_onOffUpdate(u8 onOff)
|
void hwLight_onOffUpdate(u8 onOff)
|
||||||
{
|
{
|
||||||
if(onOff){
|
if (onOff)
|
||||||
|
{
|
||||||
drv_pwm_start(R_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(R_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_start(G_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(G_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_start(B_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(B_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_start(COOL_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(COOL_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_start(WARM_LIGHT_PWM_CHANNEL);
|
drv_pwm_start(WARM_LIGHT_PWM_CHANNEL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
drv_pwm_stop(R_LIGHT_PWM_CHANNEL);
|
drv_pwm_stop(R_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_stop(G_LIGHT_PWM_CHANNEL);
|
drv_pwm_stop(G_LIGHT_PWM_CHANNEL);
|
||||||
drv_pwm_stop(B_LIGHT_PWM_CHANNEL);
|
drv_pwm_stop(B_LIGHT_PWM_CHANNEL);
|
||||||
|
@ -147,7 +147,6 @@ void hwLight_onOffUpdate(u8 onOff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn hwLight_levelUpdate
|
* @fn hwLight_levelUpdate
|
||||||
*
|
*
|
||||||
|
@ -242,16 +241,20 @@ void hsvToRGB(u8 hue, u8 saturation, u8 level, u8 *R, u8 *G, u8 *B)
|
||||||
u8 rS = saturation;
|
u8 rS = saturation;
|
||||||
u8 rV = level;
|
u8 rV = level;
|
||||||
|
|
||||||
if(saturation == 0){
|
if (saturation == 0)
|
||||||
|
{
|
||||||
*R = rV;
|
*R = rV;
|
||||||
*G = rV;
|
*G = rV;
|
||||||
*B = rV;
|
*B = rV;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rHue < 360){
|
if (rHue < 360)
|
||||||
|
{
|
||||||
region = rHue / 60;
|
region = rHue / 60;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
region = 0;
|
region = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,27 +264,38 @@ void hsvToRGB(u8 hue, u8 saturation, u8 level, u8 *R, u8 *G, u8 *B)
|
||||||
q = (rV * (255 - ((rS * remainder) >> 8))) >> 8;
|
q = (rV * (255 - ((rS * remainder) >> 8))) >> 8;
|
||||||
t = (rV * (255 - ((rS * (255 - remainder)) >> 8))) >> 8;
|
t = (rV * (255 - ((rS * (255 - remainder)) >> 8))) >> 8;
|
||||||
|
|
||||||
if (region == 0) {
|
if (region == 0)
|
||||||
|
{
|
||||||
*R = rV;
|
*R = rV;
|
||||||
*G = t;
|
*G = t;
|
||||||
*B = p;
|
*B = p;
|
||||||
} else if (region == 1) {
|
}
|
||||||
|
else if (region == 1)
|
||||||
|
{
|
||||||
*R = q;
|
*R = q;
|
||||||
*G = rV;
|
*G = rV;
|
||||||
*B = p;
|
*B = p;
|
||||||
} else if (region == 2) {
|
}
|
||||||
|
else if (region == 2)
|
||||||
|
{
|
||||||
*R = p;
|
*R = p;
|
||||||
*G = rV;
|
*G = rV;
|
||||||
*B = t;
|
*B = t;
|
||||||
} else if (region == 3) {
|
}
|
||||||
|
else if (region == 3)
|
||||||
|
{
|
||||||
*R = p;
|
*R = p;
|
||||||
*G = q;
|
*G = q;
|
||||||
*B = rV;
|
*B = rV;
|
||||||
} else if (region == 4) {
|
}
|
||||||
|
else if (region == 4)
|
||||||
|
{
|
||||||
*R = t;
|
*R = t;
|
||||||
*G = p;
|
*G = p;
|
||||||
*B = rV;
|
*B = rV;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*R = rV;
|
*R = rV;
|
||||||
*G = p;
|
*G = p;
|
||||||
*B = q;
|
*B = q;
|
||||||
|
@ -309,10 +323,11 @@ void hwLight_colorUpdate_HSV2RGB(u8 hue, u8 saturation, u8 level)
|
||||||
|
|
||||||
hsvToRGB(hue, saturation, level, &R, &G, &B);
|
hsvToRGB(hue, saturation, level, &R, &G, &B);
|
||||||
|
|
||||||
hwLight_colorUpdate_RGB(R,G,B);
|
hwLight_colorUpdate_RGB(R, G, B);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hwLight_colorUpdate_RGB(u8 R, u8 G, u8 B) {
|
void hwLight_colorUpdate_RGB(u8 R, u8 G, u8 B)
|
||||||
|
{
|
||||||
u16 gammaCorrectR = ((u16)R * R) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
u16 gammaCorrectR = ((u16)R * R) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
||||||
u16 gammaCorrectG = ((u16)G * G) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
u16 gammaCorrectG = ((u16)G * G) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
||||||
u16 gammaCorrectB = ((u16)B * B) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
u16 gammaCorrectB = ((u16)B * B) / ZCL_LEVEL_ATTR_MAX_LEVEL;
|
||||||
|
@ -324,15 +339,19 @@ void hwLight_colorUpdate_RGB(u8 R, u8 G, u8 B) {
|
||||||
pwmSetDuty(WARM_LIGHT_PWM_CHANNEL, 0);
|
pwmSetDuty(WARM_LIGHT_PWM_CHANNEL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float ENFORCE_BOUNDS_FLOAT(float lowerBound, float num, float upperBound) {
|
static float ENFORCE_BOUNDS_FLOAT(float lowerBound, float num, float upperBound)
|
||||||
return num < lowerBound ? lowerBound : num > upperBound ? upperBound : num;
|
{
|
||||||
|
return num < lowerBound ? lowerBound : num > upperBound ? upperBound
|
||||||
|
: num;
|
||||||
}
|
}
|
||||||
|
|
||||||
float LINEAR_TO_SRGB_GAMMA_CORRECTION(const float part) {
|
float LINEAR_TO_SRGB_GAMMA_CORRECTION(const float part)
|
||||||
|
{
|
||||||
return part <= 0.0031308 ? 12.92 * part : 1.055 * pow(part, 1.0 / 2.4) - 0.055;
|
return part <= 0.0031308 ? 12.92 * part : 1.055 * pow(part, 1.0 / 2.4) - 0.055;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hwLight_colorUpdate_XY2RGB(u16 xI, u16 yI, u8 level) {
|
void hwLight_colorUpdate_XY2RGB(u16 xI, u16 yI, u8 level)
|
||||||
|
{
|
||||||
float x = xI / 65536.f;
|
float x = xI / 65536.f;
|
||||||
float y = yI / 65536.f;
|
float y = yI / 65536.f;
|
||||||
|
|
||||||
|
@ -353,7 +372,7 @@ void hwLight_colorUpdate_XY2RGB(u16 xI, u16 yI, u8 level) {
|
||||||
g = ENFORCE_BOUNDS_FLOAT(0.0, g * 255, 255.0);
|
g = ENFORCE_BOUNDS_FLOAT(0.0, g * 255, 255.0);
|
||||||
b = ENFORCE_BOUNDS_FLOAT(0.0, b * 255, 255.0);
|
b = ENFORCE_BOUNDS_FLOAT(0.0, b * 255, 255.0);
|
||||||
|
|
||||||
hwLight_colorUpdate_RGB((u8)r,(u8)g,(u8)b);
|
hwLight_colorUpdate_RGB((u8)r, (u8)g, (u8)b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -413,27 +432,38 @@ void light_fresh(void)
|
||||||
*/
|
*/
|
||||||
void light_applyUpdate(u8 *curLevel, u16 *curLevel256, s32 *stepLevel256, u16 *remainingTime, u8 minLevel, u8 maxLevel, bool wrap)
|
void light_applyUpdate(u8 *curLevel, u16 *curLevel256, s32 *stepLevel256, u16 *remainingTime, u8 minLevel, u8 maxLevel, bool wrap)
|
||||||
{
|
{
|
||||||
if((*stepLevel256 > 0) && ((((s32)*curLevel256 + *stepLevel256) / 256) > maxLevel)){
|
if ((*stepLevel256 > 0) && ((((s32)*curLevel256 + *stepLevel256) / 256) > maxLevel))
|
||||||
|
{
|
||||||
*curLevel256 = (wrap) ? ((u16)minLevel * 256 + ((*curLevel256 + *stepLevel256) - (u16)maxLevel * 256) - 256)
|
*curLevel256 = (wrap) ? ((u16)minLevel * 256 + ((*curLevel256 + *stepLevel256) - (u16)maxLevel * 256) - 256)
|
||||||
: ((u16)maxLevel * 256);
|
: ((u16)maxLevel * 256);
|
||||||
}else if((*stepLevel256 < 0) && ((((s32)*curLevel256 + *stepLevel256) / 256) < minLevel)){
|
}
|
||||||
|
else if ((*stepLevel256 < 0) && ((((s32)*curLevel256 + *stepLevel256) / 256) < minLevel))
|
||||||
|
{
|
||||||
*curLevel256 = (wrap) ? ((u16)maxLevel * 256 - ((u16)minLevel * 256 - ((s32)*curLevel256 + *stepLevel256)) + 256)
|
*curLevel256 = (wrap) ? ((u16)maxLevel * 256 - ((u16)minLevel * 256 - ((s32)*curLevel256 + *stepLevel256)) + 256)
|
||||||
: ((u16)minLevel * 256);
|
: ((u16)minLevel * 256);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*curLevel256 += *stepLevel256;
|
*curLevel256 += *stepLevel256;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*stepLevel256 > 0){
|
if (*stepLevel256 > 0)
|
||||||
|
{
|
||||||
*curLevel = (*curLevel256 + 127) / 256;
|
*curLevel = (*curLevel256 + 127) / 256;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*curLevel = *curLevel256 / 256;
|
*curLevel = *curLevel256 / 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*remainingTime == 0){
|
if (*remainingTime == 0)
|
||||||
|
{
|
||||||
*curLevel256 = ((u16)*curLevel) * 256;
|
*curLevel256 = ((u16)*curLevel) * 256;
|
||||||
*stepLevel256 = 0;
|
*stepLevel256 = 0;
|
||||||
}else if(*remainingTime != 0xFFFF){
|
}
|
||||||
*remainingTime = *remainingTime -1;
|
else if (*remainingTime != 0xFFFF)
|
||||||
|
{
|
||||||
|
*remainingTime = *remainingTime - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
light_fresh();
|
light_fresh();
|
||||||
|
@ -450,27 +480,38 @@ void light_applyUpdate(u8 *curLevel, u16 *curLevel256, s32 *stepLevel256, u16 *r
|
||||||
*/
|
*/
|
||||||
void light_applyUpdate_16(u16 *curLevel, u32 *curLevel256, s32 *stepLevel256, u16 *remainingTime, u16 minLevel, u16 maxLevel, bool wrap)
|
void light_applyUpdate_16(u16 *curLevel, u32 *curLevel256, s32 *stepLevel256, u16 *remainingTime, u16 minLevel, u16 maxLevel, bool wrap)
|
||||||
{
|
{
|
||||||
if((*stepLevel256 > 0) && ((((s32)*curLevel256 + *stepLevel256) / 256) > maxLevel)){
|
if ((*stepLevel256 > 0) && ((((s32)*curLevel256 + *stepLevel256) / 256) > maxLevel))
|
||||||
|
{
|
||||||
*curLevel256 = (wrap) ? ((u32)minLevel * 256 + ((*curLevel256 + *stepLevel256) - (u32)maxLevel * 256) - 256)
|
*curLevel256 = (wrap) ? ((u32)minLevel * 256 + ((*curLevel256 + *stepLevel256) - (u32)maxLevel * 256) - 256)
|
||||||
: ((u32)maxLevel * 256);
|
: ((u32)maxLevel * 256);
|
||||||
}else if((*stepLevel256 < 0) && ((((s32)*curLevel256 + *stepLevel256) / 256) < minLevel)){
|
}
|
||||||
|
else if ((*stepLevel256 < 0) && ((((s32)*curLevel256 + *stepLevel256) / 256) < minLevel))
|
||||||
|
{
|
||||||
*curLevel256 = (wrap) ? ((u32)maxLevel * 256 - ((u32)minLevel * 256 - ((s32)*curLevel256 + *stepLevel256)) + 256)
|
*curLevel256 = (wrap) ? ((u32)maxLevel * 256 - ((u32)minLevel * 256 - ((s32)*curLevel256 + *stepLevel256)) + 256)
|
||||||
: ((u32)minLevel * 256);
|
: ((u32)minLevel * 256);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*curLevel256 += *stepLevel256;
|
*curLevel256 += *stepLevel256;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*stepLevel256 > 0){
|
if (*stepLevel256 > 0)
|
||||||
|
{
|
||||||
*curLevel = (*curLevel256 + 127) / 256;
|
*curLevel = (*curLevel256 + 127) / 256;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*curLevel = *curLevel256 / 256;
|
*curLevel = *curLevel256 / 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*remainingTime == 0){
|
if (*remainingTime == 0)
|
||||||
|
{
|
||||||
*curLevel256 = ((u32)*curLevel) * 256;
|
*curLevel256 = ((u32)*curLevel) * 256;
|
||||||
*stepLevel256 = 0;
|
*stepLevel256 = 0;
|
||||||
}else if(*remainingTime != 0xFFFF){
|
}
|
||||||
*remainingTime = *remainingTime -1;
|
else if (*remainingTime != 0xFFFF)
|
||||||
|
{
|
||||||
|
*remainingTime = *remainingTime - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
light_fresh();
|
light_fresh();
|
||||||
|
@ -489,13 +530,19 @@ s32 light_blink_TimerEvtCb(void *arg)
|
||||||
{
|
{
|
||||||
u32 interval = 0;
|
u32 interval = 0;
|
||||||
|
|
||||||
if(gLightCtx.sta == gLightCtx.oriSta){
|
if (gLightCtx.sta == gLightCtx.oriSta)
|
||||||
if(gLightCtx.times){
|
{
|
||||||
|
if (gLightCtx.times)
|
||||||
|
{
|
||||||
gLightCtx.times--;
|
gLightCtx.times--;
|
||||||
if(gLightCtx.times <= 0){
|
if (gLightCtx.times <= 0)
|
||||||
if(gLightCtx.oriSta){
|
{
|
||||||
|
if (gLightCtx.oriSta)
|
||||||
|
{
|
||||||
hwLight_onOffUpdate(ZCL_CMD_ONOFF_ON);
|
hwLight_onOffUpdate(ZCL_CMD_ONOFF_ON);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hwLight_onOffUpdate(ZCL_CMD_ONOFF_OFF);
|
hwLight_onOffUpdate(ZCL_CMD_ONOFF_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,10 +553,13 @@ s32 light_blink_TimerEvtCb(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
gLightCtx.sta = !gLightCtx.sta;
|
gLightCtx.sta = !gLightCtx.sta;
|
||||||
if(gLightCtx.sta){
|
if (gLightCtx.sta)
|
||||||
|
{
|
||||||
hwLight_onOffUpdate(ZCL_CMD_ONOFF_ON);
|
hwLight_onOffUpdate(ZCL_CMD_ONOFF_ON);
|
||||||
interval = gLightCtx.ledOnTime;
|
interval = gLightCtx.ledOnTime;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hwLight_onOffUpdate(ZCL_CMD_ONOFF_OFF);
|
hwLight_onOffUpdate(ZCL_CMD_ONOFF_OFF);
|
||||||
interval = gLightCtx.ledOffTime;
|
interval = gLightCtx.ledOffTime;
|
||||||
}
|
}
|
||||||
|
@ -536,12 +586,16 @@ void light_blink_start(u8 times, u16 ledOnTime, u16 ledOffTime)
|
||||||
gLightCtx.oriSta = pOnoff->onOff;
|
gLightCtx.oriSta = pOnoff->onOff;
|
||||||
gLightCtx.times = times;
|
gLightCtx.times = times;
|
||||||
|
|
||||||
if(!gLightCtx.timerLedEvt){
|
if (!gLightCtx.timerLedEvt)
|
||||||
if(gLightCtx.oriSta){
|
{
|
||||||
|
if (gLightCtx.oriSta)
|
||||||
|
{
|
||||||
hwLight_onOffUpdate(ZCL_CMD_ONOFF_OFF);
|
hwLight_onOffUpdate(ZCL_CMD_ONOFF_OFF);
|
||||||
gLightCtx.sta = 0;
|
gLightCtx.sta = 0;
|
||||||
interval = ledOffTime;
|
interval = ledOffTime;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hwLight_onOffUpdate(ZCL_CMD_ONOFF_ON);
|
hwLight_onOffUpdate(ZCL_CMD_ONOFF_ON);
|
||||||
gLightCtx.sta = 1;
|
gLightCtx.sta = 1;
|
||||||
interval = ledOnTime;
|
interval = ledOnTime;
|
||||||
|
@ -564,13 +618,17 @@ void light_blink_start(u8 times, u16 ledOnTime, u16 ledOffTime)
|
||||||
*/
|
*/
|
||||||
void light_blink_stop(void)
|
void light_blink_stop(void)
|
||||||
{
|
{
|
||||||
if(gLightCtx.timerLedEvt){
|
if (gLightCtx.timerLedEvt)
|
||||||
|
{
|
||||||
TL_ZB_TIMER_CANCEL(&gLightCtx.timerLedEvt);
|
TL_ZB_TIMER_CANCEL(&gLightCtx.timerLedEvt);
|
||||||
|
|
||||||
gLightCtx.times = 0;
|
gLightCtx.times = 0;
|
||||||
if(gLightCtx.oriSta){
|
if (gLightCtx.oriSta)
|
||||||
|
{
|
||||||
hwLight_onOffUpdate(ZCL_CMD_ONOFF_ON);
|
hwLight_onOffUpdate(ZCL_CMD_ONOFF_ON);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hwLight_onOffUpdate(ZCL_CMD_ONOFF_OFF);
|
hwLight_onOffUpdate(ZCL_CMD_ONOFF_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,10 @@
|
||||||
#ifndef _SAMPLE_LIGHT_CTRL_H_
|
#ifndef _SAMPLE_LIGHT_CTRL_H_
|
||||||
#define _SAMPLE_LIGHT_CTRL_H_
|
#define _SAMPLE_LIGHT_CTRL_H_
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* CONSTANT
|
* CONSTANT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* FUNCTIONS
|
* FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,29 +30,36 @@
|
||||||
#include "zcl_include.h"
|
#include "zcl_include.h"
|
||||||
#include "sampleLight.h"
|
#include "sampleLight.h"
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
*/
|
*/
|
||||||
#ifndef ZCL_BASIC_MFG_NAME
|
#ifndef ZCL_BASIC_MFG_NAME
|
||||||
#define ZCL_BASIC_MFG_NAME {8,'G','L','E','D','O','P','T','O'}
|
#define ZCL_BASIC_MFG_NAME \
|
||||||
|
{ \
|
||||||
|
8, 'G', 'L', 'E', 'D', 'O', 'P', 'T', 'O' \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef ZCL_BASIC_MODEL_ID
|
#ifndef ZCL_BASIC_MODEL_ID
|
||||||
#define ZCL_BASIC_MODEL_ID {9,'G','L','-','C','-','0','0','8','P'}
|
#define ZCL_BASIC_MODEL_ID \
|
||||||
|
{ \
|
||||||
|
9, 'G', 'L', '-', 'C', '-', '0', '0', '8', 'P' \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef ZCL_BASIC_SW_BUILD_ID
|
#ifndef ZCL_BASIC_SW_BUILD_ID
|
||||||
#define ZCL_BASIC_SW_BUILD_ID {8,'2','0','2','2','0','4','0','1'}
|
#define ZCL_BASIC_SW_BUILD_ID \
|
||||||
|
{ \
|
||||||
|
8, '2', '0', '2', '2', '0', '4', '0', '1' \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define COLOR_TEMPERATURE_PHYSICAL_MIN 0x009A//6500K
|
#define COLOR_TEMPERATURE_PHYSICAL_MIN 0x009A // 6500K
|
||||||
#define COLOR_TEMPERATURE_PHYSICAL_MAX 0x01C6//2200K
|
#define COLOR_TEMPERATURE_PHYSICAL_MAX 0x01C6 // 2200K
|
||||||
#define COLOR_TEMPERATURE_DEFAULT 0x00FA//4000K
|
#define COLOR_TEMPERATURE_DEFAULT 0x00FA // 4000K
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +67,7 @@
|
||||||
* @brief Definition for Incoming cluster / Sever Cluster
|
* @brief Definition for Incoming cluster / Sever Cluster
|
||||||
*/
|
*/
|
||||||
const u16 sampleLight_inClusterList[] =
|
const u16 sampleLight_inClusterList[] =
|
||||||
{
|
{
|
||||||
ZCL_CLUSTER_GEN_BASIC,
|
ZCL_CLUSTER_GEN_BASIC,
|
||||||
ZCL_CLUSTER_GEN_IDENTIFY,
|
ZCL_CLUSTER_GEN_IDENTIFY,
|
||||||
#ifdef ZCL_GROUP
|
#ifdef ZCL_GROUP
|
||||||
|
@ -90,7 +97,7 @@ const u16 sampleLight_inClusterList[] =
|
||||||
* @brief Definition for Outgoing cluster / Client Cluster
|
* @brief Definition for Outgoing cluster / Client Cluster
|
||||||
*/
|
*/
|
||||||
const u16 sampleLight_outClusterList[] =
|
const u16 sampleLight_outClusterList[] =
|
||||||
{
|
{
|
||||||
#ifdef ZCL_OTA
|
#ifdef ZCL_OTA
|
||||||
ZCL_CLUSTER_OTA,
|
ZCL_CLUSTER_OTA,
|
||||||
#endif
|
#endif
|
||||||
|
@ -99,14 +106,14 @@ const u16 sampleLight_outClusterList[] =
|
||||||
/**
|
/**
|
||||||
* @brief Definition for Server cluster number and Client cluster number
|
* @brief Definition for Server cluster number and Client cluster number
|
||||||
*/
|
*/
|
||||||
#define SAMPLELIGHT_IN_CLUSTER_NUM (sizeof(sampleLight_inClusterList)/sizeof(sampleLight_inClusterList[0]))
|
#define SAMPLELIGHT_IN_CLUSTER_NUM (sizeof(sampleLight_inClusterList) / sizeof(sampleLight_inClusterList[0]))
|
||||||
#define SAMPLELIGHT_OUT_CLUSTER_NUM (sizeof(sampleLight_outClusterList)/sizeof(sampleLight_outClusterList[0]))
|
#define SAMPLELIGHT_OUT_CLUSTER_NUM (sizeof(sampleLight_outClusterList) / sizeof(sampleLight_outClusterList[0]))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Definition for simple description for HA profile
|
* @brief Definition for simple description for HA profile
|
||||||
*/
|
*/
|
||||||
const af_simple_descriptor_t sampleLight_simpleDesc =
|
const af_simple_descriptor_t sampleLight_simpleDesc =
|
||||||
{
|
{
|
||||||
HA_PROFILE_ID, /* Application profile identifier */
|
HA_PROFILE_ID, /* Application profile identifier */
|
||||||
HA_DEV_COLOR_DIMMABLE_LIGHT,
|
HA_DEV_COLOR_DIMMABLE_LIGHT,
|
||||||
SAMPLE_LIGHT_ENDPOINT, /* Endpoint */
|
SAMPLE_LIGHT_ENDPOINT, /* Endpoint */
|
||||||
|
@ -120,7 +127,7 @@ const af_simple_descriptor_t sampleLight_simpleDesc =
|
||||||
|
|
||||||
/* Basic */
|
/* Basic */
|
||||||
zcl_basicAttr_t g_zcl_basicAttrs =
|
zcl_basicAttr_t g_zcl_basicAttrs =
|
||||||
{
|
{
|
||||||
.zclVersion = 0x03,
|
.zclVersion = 0x03,
|
||||||
.appVersion = 0x00,
|
.appVersion = 0x00,
|
||||||
.stackVersion = 0x00,
|
.stackVersion = 0x00,
|
||||||
|
@ -133,34 +140,33 @@ zcl_basicAttr_t g_zcl_basicAttrs =
|
||||||
};
|
};
|
||||||
|
|
||||||
const zclAttrInfo_t basic_attrTbl[] =
|
const zclAttrInfo_t basic_attrTbl[] =
|
||||||
{
|
{
|
||||||
{ ZCL_ATTRID_BASIC_ZCL_VER, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_basicAttrs.zclVersion},
|
{ZCL_ATTRID_BASIC_ZCL_VER, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_basicAttrs.zclVersion},
|
||||||
{ ZCL_ATTRID_BASIC_APP_VER, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_basicAttrs.appVersion},
|
{ZCL_ATTRID_BASIC_APP_VER, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_basicAttrs.appVersion},
|
||||||
{ ZCL_ATTRID_BASIC_STACK_VER, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_basicAttrs.stackVersion},
|
{ZCL_ATTRID_BASIC_STACK_VER, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_basicAttrs.stackVersion},
|
||||||
{ ZCL_ATTRID_BASIC_HW_VER, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_basicAttrs.hwVersion},
|
{ZCL_ATTRID_BASIC_HW_VER, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_basicAttrs.hwVersion},
|
||||||
{ ZCL_ATTRID_BASIC_MFR_NAME, ZCL_DATA_TYPE_CHAR_STR, ACCESS_CONTROL_READ, (u8*)g_zcl_basicAttrs.manuName},
|
{ZCL_ATTRID_BASIC_MFR_NAME, ZCL_DATA_TYPE_CHAR_STR, ACCESS_CONTROL_READ, (u8 *)g_zcl_basicAttrs.manuName},
|
||||||
{ ZCL_ATTRID_BASIC_MODEL_ID, ZCL_DATA_TYPE_CHAR_STR, ACCESS_CONTROL_READ, (u8*)g_zcl_basicAttrs.modelId},
|
{ZCL_ATTRID_BASIC_MODEL_ID, ZCL_DATA_TYPE_CHAR_STR, ACCESS_CONTROL_READ, (u8 *)g_zcl_basicAttrs.modelId},
|
||||||
{ ZCL_ATTRID_BASIC_POWER_SOURCE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ, (u8*)&g_zcl_basicAttrs.powerSource},
|
{ZCL_ATTRID_BASIC_POWER_SOURCE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_basicAttrs.powerSource},
|
||||||
{ ZCL_ATTRID_BASIC_DEV_ENABLED, ZCL_DATA_TYPE_BOOLEAN, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_basicAttrs.deviceEnable},
|
{ZCL_ATTRID_BASIC_DEV_ENABLED, ZCL_DATA_TYPE_BOOLEAN, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8 *)&g_zcl_basicAttrs.deviceEnable},
|
||||||
{ ZCL_ATTRID_BASIC_SW_BUILD_ID, ZCL_DATA_TYPE_CHAR_STR, ACCESS_CONTROL_READ, (u8*)&g_zcl_basicAttrs.swBuildId},
|
{ZCL_ATTRID_BASIC_SW_BUILD_ID, ZCL_DATA_TYPE_CHAR_STR, ACCESS_CONTROL_READ, (u8 *)&g_zcl_basicAttrs.swBuildId},
|
||||||
|
|
||||||
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
{ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&zcl_attr_global_clusterRevision},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZCL_BASIC_ATTR_NUM sizeof(basic_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_BASIC_ATTR_NUM sizeof(basic_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
|
|
||||||
|
|
||||||
/* Identify */
|
/* Identify */
|
||||||
zcl_identifyAttr_t g_zcl_identifyAttrs =
|
zcl_identifyAttr_t g_zcl_identifyAttrs =
|
||||||
{
|
{
|
||||||
.identifyTime = 0x0000,
|
.identifyTime = 0x0000,
|
||||||
};
|
};
|
||||||
|
|
||||||
const zclAttrInfo_t identify_attrTbl[] =
|
const zclAttrInfo_t identify_attrTbl[] =
|
||||||
{
|
{
|
||||||
{ ZCL_ATTRID_IDENTIFY_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_identifyAttrs.identifyTime },
|
{ZCL_ATTRID_IDENTIFY_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8 *)&g_zcl_identifyAttrs.identifyTime},
|
||||||
|
|
||||||
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
{ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&zcl_attr_global_clusterRevision},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZCL_IDENTIFY_ATTR_NUM sizeof(identify_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_IDENTIFY_ATTR_NUM sizeof(identify_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
|
@ -168,15 +174,15 @@ const zclAttrInfo_t identify_attrTbl[] =
|
||||||
#ifdef ZCL_GROUP
|
#ifdef ZCL_GROUP
|
||||||
/* Group */
|
/* Group */
|
||||||
zcl_groupAttr_t g_zcl_groupAttrs =
|
zcl_groupAttr_t g_zcl_groupAttrs =
|
||||||
{
|
{
|
||||||
.nameSupport = 0,
|
.nameSupport = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const zclAttrInfo_t group_attrTbl[] =
|
const zclAttrInfo_t group_attrTbl[] =
|
||||||
{
|
{
|
||||||
{ ZCL_ATTRID_GROUP_NAME_SUPPORT, ZCL_DATA_TYPE_BITMAP8, ACCESS_CONTROL_READ, (u8*)&g_zcl_groupAttrs.nameSupport },
|
{ZCL_ATTRID_GROUP_NAME_SUPPORT, ZCL_DATA_TYPE_BITMAP8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_groupAttrs.nameSupport},
|
||||||
|
|
||||||
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
{ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&zcl_attr_global_clusterRevision},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZCL_GROUP_ATTR_NUM sizeof(group_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_GROUP_ATTR_NUM sizeof(group_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
|
@ -185,7 +191,7 @@ const zclAttrInfo_t group_attrTbl[] =
|
||||||
#ifdef ZCL_SCENE
|
#ifdef ZCL_SCENE
|
||||||
/* Scene */
|
/* Scene */
|
||||||
zcl_sceneAttr_t g_zcl_sceneAttrs =
|
zcl_sceneAttr_t g_zcl_sceneAttrs =
|
||||||
{
|
{
|
||||||
.sceneCount = 0,
|
.sceneCount = 0,
|
||||||
.currentScene = 0,
|
.currentScene = 0,
|
||||||
.currentGroup = 0x0000,
|
.currentGroup = 0x0000,
|
||||||
|
@ -194,14 +200,14 @@ zcl_sceneAttr_t g_zcl_sceneAttrs =
|
||||||
};
|
};
|
||||||
|
|
||||||
const zclAttrInfo_t scene_attrTbl[] =
|
const zclAttrInfo_t scene_attrTbl[] =
|
||||||
{
|
{
|
||||||
{ ZCL_ATTRID_SCENE_SCENE_COUNT, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_sceneAttrs.sceneCount },
|
{ZCL_ATTRID_SCENE_SCENE_COUNT, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_sceneAttrs.sceneCount},
|
||||||
{ ZCL_ATTRID_SCENE_CURRENT_SCENE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_sceneAttrs.currentScene },
|
{ZCL_ATTRID_SCENE_CURRENT_SCENE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_sceneAttrs.currentScene},
|
||||||
{ ZCL_ATTRID_SCENE_CURRENT_GROUP, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_sceneAttrs.currentGroup },
|
{ZCL_ATTRID_SCENE_CURRENT_GROUP, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_sceneAttrs.currentGroup},
|
||||||
{ ZCL_ATTRID_SCENE_SCENE_VALID, ZCL_DATA_TYPE_BOOLEAN, ACCESS_CONTROL_READ, (u8*)&g_zcl_sceneAttrs.sceneValid },
|
{ZCL_ATTRID_SCENE_SCENE_VALID, ZCL_DATA_TYPE_BOOLEAN, ACCESS_CONTROL_READ, (u8 *)&g_zcl_sceneAttrs.sceneValid},
|
||||||
{ ZCL_ATTRID_SCENE_NAME_SUPPORT, ZCL_DATA_TYPE_BITMAP8, ACCESS_CONTROL_READ, (u8*)&g_zcl_sceneAttrs.nameSupport },
|
{ZCL_ATTRID_SCENE_NAME_SUPPORT, ZCL_DATA_TYPE_BITMAP8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_sceneAttrs.nameSupport},
|
||||||
|
|
||||||
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
{ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&zcl_attr_global_clusterRevision},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZCL_SCENE_ATTR_NUM sizeof(scene_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_SCENE_ATTR_NUM sizeof(scene_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
|
@ -210,7 +216,7 @@ const zclAttrInfo_t scene_attrTbl[] =
|
||||||
#ifdef ZCL_ON_OFF
|
#ifdef ZCL_ON_OFF
|
||||||
/* On/Off */
|
/* On/Off */
|
||||||
zcl_onOffAttr_t g_zcl_onOffAttrs =
|
zcl_onOffAttr_t g_zcl_onOffAttrs =
|
||||||
{
|
{
|
||||||
.onOff = 0x00,
|
.onOff = 0x00,
|
||||||
.globalSceneControl = 1,
|
.globalSceneControl = 1,
|
||||||
.onTime = 0x0000,
|
.onTime = 0x0000,
|
||||||
|
@ -219,14 +225,14 @@ zcl_onOffAttr_t g_zcl_onOffAttrs =
|
||||||
};
|
};
|
||||||
|
|
||||||
const zclAttrInfo_t onOff_attrTbl[] =
|
const zclAttrInfo_t onOff_attrTbl[] =
|
||||||
{
|
{
|
||||||
{ ZCL_ATTRID_ONOFF, ZCL_DATA_TYPE_BOOLEAN, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_onOffAttrs.onOff},
|
{ZCL_ATTRID_ONOFF, ZCL_DATA_TYPE_BOOLEAN, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8 *)&g_zcl_onOffAttrs.onOff},
|
||||||
{ ZCL_ATTRID_GLOBAL_SCENE_CONTROL, ZCL_DATA_TYPE_BOOLEAN, ACCESS_CONTROL_READ, (u8*)&g_zcl_onOffAttrs.globalSceneControl},
|
{ZCL_ATTRID_GLOBAL_SCENE_CONTROL, ZCL_DATA_TYPE_BOOLEAN, ACCESS_CONTROL_READ, (u8 *)&g_zcl_onOffAttrs.globalSceneControl},
|
||||||
{ ZCL_ATTRID_ON_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_onOffAttrs.onTime},
|
{ZCL_ATTRID_ON_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8 *)&g_zcl_onOffAttrs.onTime},
|
||||||
{ ZCL_ATTRID_OFF_WAIT_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_onOffAttrs.offWaitTime},
|
{ZCL_ATTRID_OFF_WAIT_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8 *)&g_zcl_onOffAttrs.offWaitTime},
|
||||||
{ ZCL_ATTRID_START_UP_ONOFF, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_onOffAttrs.startUpOnOff},
|
{ZCL_ATTRID_START_UP_ONOFF, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8 *)&g_zcl_onOffAttrs.startUpOnOff},
|
||||||
|
|
||||||
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
{ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&zcl_attr_global_clusterRevision},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZCL_ONOFF_ATTR_NUM sizeof(onOff_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_ONOFF_ATTR_NUM sizeof(onOff_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
|
@ -235,19 +241,19 @@ const zclAttrInfo_t onOff_attrTbl[] =
|
||||||
#ifdef ZCL_LEVEL_CTRL
|
#ifdef ZCL_LEVEL_CTRL
|
||||||
/* Level */
|
/* Level */
|
||||||
zcl_levelAttr_t g_zcl_levelAttrs =
|
zcl_levelAttr_t g_zcl_levelAttrs =
|
||||||
{
|
{
|
||||||
.curLevel = 0xFE,
|
.curLevel = 0xFE,
|
||||||
.remainingTime = 0,
|
.remainingTime = 0,
|
||||||
.startUpCurrentLevel = ZCL_START_UP_CURRENT_LEVEL_TO_PREVIOUS,
|
.startUpCurrentLevel = ZCL_START_UP_CURRENT_LEVEL_TO_PREVIOUS,
|
||||||
};
|
};
|
||||||
|
|
||||||
const zclAttrInfo_t level_attrTbl[] =
|
const zclAttrInfo_t level_attrTbl[] =
|
||||||
{
|
{
|
||||||
{ ZCL_ATTRID_LEVEL_CURRENT_LEVEL, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_levelAttrs.curLevel },
|
{ZCL_ATTRID_LEVEL_CURRENT_LEVEL, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8 *)&g_zcl_levelAttrs.curLevel},
|
||||||
{ ZCL_ATTRID_LEVEL_REMAINING_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_levelAttrs.remainingTime },
|
{ZCL_ATTRID_LEVEL_REMAINING_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_levelAttrs.remainingTime},
|
||||||
{ ZCL_ATTRID_LEVEL_START_UP_CURRENT_LEVEL, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_levelAttrs.startUpCurrentLevel },
|
{ZCL_ATTRID_LEVEL_START_UP_CURRENT_LEVEL, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8 *)&g_zcl_levelAttrs.startUpCurrentLevel},
|
||||||
|
|
||||||
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
{ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&zcl_attr_global_clusterRevision},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZCL_LEVEL_ATTR_NUM sizeof(level_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_LEVEL_ATTR_NUM sizeof(level_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
|
@ -255,7 +261,7 @@ const zclAttrInfo_t level_attrTbl[] =
|
||||||
|
|
||||||
/* Color Control */
|
/* Color Control */
|
||||||
zcl_lightColorCtrlAttr_t g_zcl_colorCtrlAttrs =
|
zcl_lightColorCtrlAttr_t g_zcl_colorCtrlAttrs =
|
||||||
{
|
{
|
||||||
.colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS,
|
.colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS,
|
||||||
.options = 0,
|
.options = 0,
|
||||||
.enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS,
|
.enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS,
|
||||||
|
@ -278,28 +284,28 @@ zcl_lightColorCtrlAttr_t g_zcl_colorCtrlAttrs =
|
||||||
};
|
};
|
||||||
|
|
||||||
const zclAttrInfo_t lightColorCtrl_attrTbl[] =
|
const zclAttrInfo_t lightColorCtrl_attrTbl[] =
|
||||||
{
|
{
|
||||||
{ ZCL_ATTRID_COLOR_MODE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorMode },
|
{ZCL_ATTRID_COLOR_MODE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.colorMode},
|
||||||
{ ZCL_ATTRID_COLOR_OPTIONS, ZCL_DATA_TYPE_BITMAP8, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_colorCtrlAttrs.options },
|
{ZCL_ATTRID_COLOR_OPTIONS, ZCL_DATA_TYPE_BITMAP8, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8 *)&g_zcl_colorCtrlAttrs.options},
|
||||||
{ ZCL_ATTRID_ENHANCED_COLOR_MODE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.enhancedColorMode },
|
{ZCL_ATTRID_ENHANCED_COLOR_MODE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.enhancedColorMode},
|
||||||
{ ZCL_ATTRID_COLOR_CAPABILITIES, ZCL_DATA_TYPE_BITMAP16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorCapabilities },
|
{ZCL_ATTRID_COLOR_CAPABILITIES, ZCL_DATA_TYPE_BITMAP16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.colorCapabilities},
|
||||||
{ ZCL_ATTRID_NUMBER_OF_PRIMARIES, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.numOfPrimaries },
|
{ZCL_ATTRID_NUMBER_OF_PRIMARIES, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.numOfPrimaries},
|
||||||
{ ZCL_ATTRID_CURRENT_X, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.currentX },
|
{ZCL_ATTRID_CURRENT_X, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.currentX},
|
||||||
{ ZCL_ATTRID_CURRENT_Y, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.currentY },
|
{ZCL_ATTRID_CURRENT_Y, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.currentY},
|
||||||
{ ZCL_ATTRID_CURRENT_HUE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.currentHue },
|
{ZCL_ATTRID_CURRENT_HUE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8 *)&g_zcl_colorCtrlAttrs.currentHue},
|
||||||
{ ZCL_ATTRID_ENHANCED_CURRENT_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.currentHue },
|
{ZCL_ATTRID_ENHANCED_CURRENT_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.currentHue},
|
||||||
{ ZCL_ATTRID_CURRENT_SATURATION, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.currentSaturation },
|
{ZCL_ATTRID_CURRENT_SATURATION, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8 *)&g_zcl_colorCtrlAttrs.currentSaturation},
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_ACTIVE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopActive },
|
{ZCL_ATTRID_COLOR_LOOP_ACTIVE, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8 *)&g_zcl_colorCtrlAttrs.colorLoopActive},
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_DIRECTION, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopDirection },
|
{ZCL_ATTRID_COLOR_LOOP_DIRECTION, ZCL_DATA_TYPE_UINT8, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8 *)&g_zcl_colorCtrlAttrs.colorLoopDirection},
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorLoopTime },
|
{ZCL_ATTRID_COLOR_LOOP_TIME, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8 *)&g_zcl_colorCtrlAttrs.colorLoopTime},
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_START_ENHANCED_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorLoopStartEnhancedHue },
|
{ZCL_ATTRID_COLOR_LOOP_START_ENHANCED_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.colorLoopStartEnhancedHue},
|
||||||
{ ZCL_ATTRID_COLOR_LOOP_STORED_ENHANCED_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorLoopStoredEnhancedHue },
|
{ZCL_ATTRID_COLOR_LOOP_STORED_ENHANCED_HUE, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.colorLoopStoredEnhancedHue},
|
||||||
{ ZCL_ATTRID_COLOR_TEMPERATURE_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8*)&g_zcl_colorCtrlAttrs.colorTemperatureMireds },
|
{ZCL_ATTRID_COLOR_TEMPERATURE_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_REPORTABLE, (u8 *)&g_zcl_colorCtrlAttrs.colorTemperatureMireds},
|
||||||
{ ZCL_ATTRID_COLOR_TEMP_PHYSICAL_MIN_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorTempPhysicalMinMireds },
|
{ZCL_ATTRID_COLOR_TEMP_PHYSICAL_MIN_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.colorTempPhysicalMinMireds},
|
||||||
{ ZCL_ATTRID_COLOR_TEMP_PHYSICAL_MAX_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&g_zcl_colorCtrlAttrs.colorTempPhysicalMaxMireds },
|
{ZCL_ATTRID_COLOR_TEMP_PHYSICAL_MAX_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&g_zcl_colorCtrlAttrs.colorTempPhysicalMaxMireds},
|
||||||
{ ZCL_ATTRID_START_UP_COLOR_TEMPERATURE_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds },
|
{ZCL_ATTRID_START_UP_COLOR_TEMPERATURE_MIREDS, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8 *)&g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds},
|
||||||
|
|
||||||
{ ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision},
|
{ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8 *)&zcl_attr_global_clusterRevision},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZCL_COLOR_ATTR_NUM sizeof(lightColorCtrl_attrTbl) / sizeof(zclAttrInfo_t)
|
#define ZCL_COLOR_ATTR_NUM sizeof(lightColorCtrl_attrTbl) / sizeof(zclAttrInfo_t)
|
||||||
|
@ -308,7 +314,7 @@ const zclAttrInfo_t lightColorCtrl_attrTbl[] =
|
||||||
* @brief Definition for simple light ZCL specific cluster
|
* @brief Definition for simple light ZCL specific cluster
|
||||||
*/
|
*/
|
||||||
const zcl_specClusterInfo_t g_sampleLightClusterList[] =
|
const zcl_specClusterInfo_t g_sampleLightClusterList[] =
|
||||||
{
|
{
|
||||||
{ZCL_CLUSTER_GEN_BASIC, MANUFACTURER_CODE_NONE, ZCL_BASIC_ATTR_NUM, basic_attrTbl, zcl_basic_register, sampleLight_basicCb},
|
{ZCL_CLUSTER_GEN_BASIC, MANUFACTURER_CODE_NONE, ZCL_BASIC_ATTR_NUM, basic_attrTbl, zcl_basic_register, sampleLight_basicCb},
|
||||||
{ZCL_CLUSTER_GEN_IDENTIFY, MANUFACTURER_CODE_NONE, ZCL_IDENTIFY_ATTR_NUM, identify_attrTbl, zcl_identify_register, sampleLight_identifyCb},
|
{ZCL_CLUSTER_GEN_IDENTIFY, MANUFACTURER_CODE_NONE, ZCL_IDENTIFY_ATTR_NUM, identify_attrTbl, zcl_identify_register, sampleLight_identifyCb},
|
||||||
{ZCL_CLUSTER_GEN_GROUPS, MANUFACTURER_CODE_NONE, ZCL_GROUP_ATTR_NUM, group_attrTbl, zcl_group_register, NULL},
|
{ZCL_CLUSTER_GEN_GROUPS, MANUFACTURER_CODE_NONE, ZCL_GROUP_ATTR_NUM, group_attrTbl, zcl_group_register, NULL},
|
||||||
|
@ -318,14 +324,12 @@ const zcl_specClusterInfo_t g_sampleLightClusterList[] =
|
||||||
{ZCL_CLUSTER_LIGHTING_COLOR_CONTROL, MANUFACTURER_CODE_NONE, ZCL_COLOR_ATTR_NUM, lightColorCtrl_attrTbl, zcl_lightColorCtrl_register, sampleLight_colorCtrlCb},
|
{ZCL_CLUSTER_LIGHTING_COLOR_CONTROL, MANUFACTURER_CODE_NONE, ZCL_COLOR_ATTR_NUM, lightColorCtrl_attrTbl, zcl_lightColorCtrl_register, sampleLight_colorCtrlCb},
|
||||||
};
|
};
|
||||||
|
|
||||||
u8 SAMPLELIGHT_CB_CLUSTER_NUM = (sizeof(g_sampleLightClusterList)/sizeof(g_sampleLightClusterList[0]));
|
u8 SAMPLELIGHT_CB_CLUSTER_NUM = (sizeof(g_sampleLightClusterList) / sizeof(g_sampleLightClusterList[0]));
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* FUNCTIONS
|
* FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn zcl_onOffAttr_save
|
* @fn zcl_onOffAttr_save
|
||||||
*
|
*
|
||||||
|
@ -342,20 +346,24 @@ nv_sts_t zcl_onOffAttr_save(void)
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_onOff_t zcl_nv_onOff;
|
zcl_nv_onOff_t zcl_nv_onOff;
|
||||||
|
|
||||||
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8*)&zcl_nv_onOff);
|
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8 *)&zcl_nv_onOff);
|
||||||
|
|
||||||
if(st == NV_SUCC){
|
if (st == NV_SUCC)
|
||||||
if((zcl_nv_onOff.onOff != g_zcl_onOffAttrs.onOff) || (zcl_nv_onOff.startUpOnOff != g_zcl_onOffAttrs.startUpOnOff)){
|
{
|
||||||
|
if ((zcl_nv_onOff.onOff != g_zcl_onOffAttrs.onOff) || (zcl_nv_onOff.startUpOnOff != g_zcl_onOffAttrs.startUpOnOff))
|
||||||
|
{
|
||||||
zcl_nv_onOff.onOff = g_zcl_onOffAttrs.onOff;
|
zcl_nv_onOff.onOff = g_zcl_onOffAttrs.onOff;
|
||||||
zcl_nv_onOff.startUpOnOff = g_zcl_onOffAttrs.startUpOnOff;
|
zcl_nv_onOff.startUpOnOff = g_zcl_onOffAttrs.startUpOnOff;
|
||||||
|
|
||||||
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8*)&zcl_nv_onOff);
|
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8 *)&zcl_nv_onOff);
|
||||||
}
|
}
|
||||||
}else if(st == NV_ITEM_NOT_FOUND){
|
}
|
||||||
|
else if (st == NV_ITEM_NOT_FOUND)
|
||||||
|
{
|
||||||
zcl_nv_onOff.onOff = g_zcl_onOffAttrs.onOff;
|
zcl_nv_onOff.onOff = g_zcl_onOffAttrs.onOff;
|
||||||
zcl_nv_onOff.startUpOnOff = g_zcl_onOffAttrs.startUpOnOff;
|
zcl_nv_onOff.startUpOnOff = g_zcl_onOffAttrs.startUpOnOff;
|
||||||
|
|
||||||
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8*)&zcl_nv_onOff);
|
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8 *)&zcl_nv_onOff);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
st = NV_ENABLE_PROTECT_ERROR;
|
st = NV_ENABLE_PROTECT_ERROR;
|
||||||
|
@ -380,9 +388,10 @@ nv_sts_t zcl_onOffAttr_restore(void)
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_onOff_t zcl_nv_onOff;
|
zcl_nv_onOff_t zcl_nv_onOff;
|
||||||
|
|
||||||
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8*)&zcl_nv_onOff);
|
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8 *)&zcl_nv_onOff);
|
||||||
|
|
||||||
if(st == NV_SUCC){
|
if (st == NV_SUCC)
|
||||||
|
{
|
||||||
g_zcl_onOffAttrs.onOff = zcl_nv_onOff.onOff;
|
g_zcl_onOffAttrs.onOff = zcl_nv_onOff.onOff;
|
||||||
g_zcl_onOffAttrs.startUpOnOff = zcl_nv_onOff.startUpOnOff;
|
g_zcl_onOffAttrs.startUpOnOff = zcl_nv_onOff.startUpOnOff;
|
||||||
}
|
}
|
||||||
|
@ -409,20 +418,24 @@ nv_sts_t zcl_levelAttr_save(void)
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_level_t zcl_nv_level;
|
zcl_nv_level_t zcl_nv_level;
|
||||||
|
|
||||||
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_LEVEL, sizeof(zcl_nv_level_t), (u8*)&zcl_nv_level);
|
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_LEVEL, sizeof(zcl_nv_level_t), (u8 *)&zcl_nv_level);
|
||||||
|
|
||||||
if(st == NV_SUCC){
|
if (st == NV_SUCC)
|
||||||
if((zcl_nv_level.curLevel != g_zcl_levelAttrs.curLevel) || (zcl_nv_level.startUpCurLevel != g_zcl_levelAttrs.startUpCurrentLevel)){
|
{
|
||||||
|
if ((zcl_nv_level.curLevel != g_zcl_levelAttrs.curLevel) || (zcl_nv_level.startUpCurLevel != g_zcl_levelAttrs.startUpCurrentLevel))
|
||||||
|
{
|
||||||
zcl_nv_level.curLevel = g_zcl_levelAttrs.curLevel;
|
zcl_nv_level.curLevel = g_zcl_levelAttrs.curLevel;
|
||||||
zcl_nv_level.startUpCurLevel = g_zcl_levelAttrs.startUpCurrentLevel;
|
zcl_nv_level.startUpCurLevel = g_zcl_levelAttrs.startUpCurrentLevel;
|
||||||
|
|
||||||
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_LEVEL, sizeof(zcl_nv_level_t), (u8*)&zcl_nv_level);
|
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_LEVEL, sizeof(zcl_nv_level_t), (u8 *)&zcl_nv_level);
|
||||||
}
|
}
|
||||||
}else if(st == NV_ITEM_NOT_FOUND){
|
}
|
||||||
|
else if (st == NV_ITEM_NOT_FOUND)
|
||||||
|
{
|
||||||
zcl_nv_level.curLevel = g_zcl_levelAttrs.curLevel;
|
zcl_nv_level.curLevel = g_zcl_levelAttrs.curLevel;
|
||||||
zcl_nv_level.startUpCurLevel = g_zcl_levelAttrs.startUpCurrentLevel;
|
zcl_nv_level.startUpCurLevel = g_zcl_levelAttrs.startUpCurrentLevel;
|
||||||
|
|
||||||
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_LEVEL, sizeof(zcl_nv_level_t), (u8*)&zcl_nv_level);
|
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_LEVEL, sizeof(zcl_nv_level_t), (u8 *)&zcl_nv_level);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
st = NV_ENABLE_PROTECT_ERROR;
|
st = NV_ENABLE_PROTECT_ERROR;
|
||||||
|
@ -447,9 +460,10 @@ nv_sts_t zcl_levelAttr_restore(void)
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_level_t zcl_nv_level;
|
zcl_nv_level_t zcl_nv_level;
|
||||||
|
|
||||||
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_LEVEL, sizeof(zcl_nv_level_t), (u8*)&zcl_nv_level);
|
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_LEVEL, sizeof(zcl_nv_level_t), (u8 *)&zcl_nv_level);
|
||||||
|
|
||||||
if(st == NV_SUCC){
|
if (st == NV_SUCC)
|
||||||
|
{
|
||||||
g_zcl_levelAttrs.curLevel = zcl_nv_level.curLevel;
|
g_zcl_levelAttrs.curLevel = zcl_nv_level.curLevel;
|
||||||
g_zcl_levelAttrs.startUpCurrentLevel = zcl_nv_level.startUpCurLevel;
|
g_zcl_levelAttrs.startUpCurrentLevel = zcl_nv_level.startUpCurLevel;
|
||||||
}
|
}
|
||||||
|
@ -477,12 +491,12 @@ nv_sts_t zcl_colorCtrlAttr_save(void)
|
||||||
bool needSave = FALSE;
|
bool needSave = FALSE;
|
||||||
zcl_nv_colorCtrl_t zcl_nv_colorCtrl;
|
zcl_nv_colorCtrl_t zcl_nv_colorCtrl;
|
||||||
|
|
||||||
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8 *)&zcl_nv_colorCtrl);
|
||||||
|
|
||||||
if(st == NV_SUCC){
|
if (st == NV_SUCC)
|
||||||
if((zcl_nv_colorCtrl.currentHue != g_zcl_colorCtrlAttrs.currentHue) || (zcl_nv_colorCtrl.currentSaturation != g_zcl_colorCtrlAttrs.currentSaturation)
|
{
|
||||||
|| (zcl_nv_colorCtrl.colorTemperatureMireds != g_zcl_colorCtrlAttrs.colorTemperatureMireds)
|
if ((zcl_nv_colorCtrl.currentHue != g_zcl_colorCtrlAttrs.currentHue) || (zcl_nv_colorCtrl.currentSaturation != g_zcl_colorCtrlAttrs.currentSaturation) || (zcl_nv_colorCtrl.colorTemperatureMireds != g_zcl_colorCtrlAttrs.colorTemperatureMireds) || (zcl_nv_colorCtrl.startUpColorTemperatureMireds != g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds))
|
||||||
|| (zcl_nv_colorCtrl.startUpColorTemperatureMireds != g_zcl_colorCtrlAttrs.startUpColorTemperatureMireds)){
|
{
|
||||||
zcl_nv_colorCtrl.currentHue = g_zcl_colorCtrlAttrs.currentHue;
|
zcl_nv_colorCtrl.currentHue = g_zcl_colorCtrlAttrs.currentHue;
|
||||||
zcl_nv_colorCtrl.currentSaturation = g_zcl_colorCtrlAttrs.currentSaturation;
|
zcl_nv_colorCtrl.currentSaturation = g_zcl_colorCtrlAttrs.currentSaturation;
|
||||||
zcl_nv_colorCtrl.colorTemperatureMireds = g_zcl_colorCtrlAttrs.colorTemperatureMireds;
|
zcl_nv_colorCtrl.colorTemperatureMireds = g_zcl_colorCtrlAttrs.colorTemperatureMireds;
|
||||||
|
@ -490,7 +504,9 @@ nv_sts_t zcl_colorCtrlAttr_save(void)
|
||||||
|
|
||||||
needSave = TRUE;
|
needSave = TRUE;
|
||||||
}
|
}
|
||||||
}else if(st == NV_ITEM_NOT_FOUND){
|
}
|
||||||
|
else if (st == NV_ITEM_NOT_FOUND)
|
||||||
|
{
|
||||||
zcl_nv_colorCtrl.currentHue = g_zcl_colorCtrlAttrs.currentHue;
|
zcl_nv_colorCtrl.currentHue = g_zcl_colorCtrlAttrs.currentHue;
|
||||||
zcl_nv_colorCtrl.currentSaturation = g_zcl_colorCtrlAttrs.currentSaturation;
|
zcl_nv_colorCtrl.currentSaturation = g_zcl_colorCtrlAttrs.currentSaturation;
|
||||||
zcl_nv_colorCtrl.colorTemperatureMireds = g_zcl_colorCtrlAttrs.colorTemperatureMireds;
|
zcl_nv_colorCtrl.colorTemperatureMireds = g_zcl_colorCtrlAttrs.colorTemperatureMireds;
|
||||||
|
@ -499,9 +515,9 @@ nv_sts_t zcl_colorCtrlAttr_save(void)
|
||||||
needSave = TRUE;
|
needSave = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (needSave)
|
||||||
if(needSave){
|
{
|
||||||
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8 *)&zcl_nv_colorCtrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -525,9 +541,10 @@ nv_sts_t zcl_colorCtrlAttr_restore(void)
|
||||||
#if NV_ENABLE
|
#if NV_ENABLE
|
||||||
zcl_nv_colorCtrl_t zcl_nv_colorCtrl;
|
zcl_nv_colorCtrl_t zcl_nv_colorCtrl;
|
||||||
|
|
||||||
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8*)&zcl_nv_colorCtrl);
|
st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_COLOR_CTRL, sizeof(zcl_nv_colorCtrl_t), (u8 *)&zcl_nv_colorCtrl);
|
||||||
|
|
||||||
if(st == NV_SUCC){
|
if (st == NV_SUCC)
|
||||||
|
{
|
||||||
g_zcl_colorCtrlAttrs.currentHue = zcl_nv_colorCtrl.currentHue;
|
g_zcl_colorCtrlAttrs.currentHue = zcl_nv_colorCtrl.currentHue;
|
||||||
g_zcl_colorCtrlAttrs.currentSaturation = zcl_nv_colorCtrl.currentSaturation;
|
g_zcl_colorCtrlAttrs.currentSaturation = zcl_nv_colorCtrl.currentSaturation;
|
||||||
g_zcl_colorCtrlAttrs.colorTemperatureMireds = zcl_nv_colorCtrl.colorTemperatureMireds;
|
g_zcl_colorCtrlAttrs.colorTemperatureMireds = zcl_nv_colorCtrl.colorTemperatureMireds;
|
||||||
|
|
13
stack_cfg.h
13
stack_cfg.h
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Working channel
|
* @brief Working channel
|
||||||
* Valid value: 11 ~ 26
|
* Valid value: 11 ~ 26
|
||||||
|
@ -40,7 +39,6 @@
|
||||||
*/
|
*/
|
||||||
#define SECURITY_ENABLE 1
|
#define SECURITY_ENABLE 1
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Following parameter need user to adjust according the app requirement
|
* Following parameter need user to adjust according the app requirement
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +60,6 @@
|
||||||
*/
|
*/
|
||||||
#define ZCL_SCENE_TABLE_NUM 8
|
#define ZCL_SCENE_TABLE_NUM 8
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief APS: MAX number of groups size in the group table
|
* @brief APS: MAX number of groups size in the group table
|
||||||
* In each group entry, there is 8 endpoints existed.
|
* In each group entry, there is 8 endpoints existed.
|
||||||
|
@ -74,7 +71,6 @@
|
||||||
*/
|
*/
|
||||||
#define APS_BINDING_TABLE_NUM 8
|
#define APS_BINDING_TABLE_NUM 8
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Following configuration will calculated automatically
|
* Following configuration will calculated automatically
|
||||||
*/
|
*/
|
||||||
|
@ -83,11 +79,10 @@
|
||||||
Auto definition for the role
|
Auto definition for the role
|
||||||
*/
|
*/
|
||||||
#if (COORDINATOR)
|
#if (COORDINATOR)
|
||||||
#define ZB_ROUTER_ROLE 1
|
#define ZB_ROUTER_ROLE 1
|
||||||
#define ZB_COORDINATOR_ROLE 1
|
#define ZB_COORDINATOR_ROLE 1
|
||||||
#elif (ROUTER)
|
#elif (ROUTER)
|
||||||
#define ZB_ROUTER_ROLE 1
|
#define ZB_ROUTER_ROLE 1
|
||||||
#elif (END_DEVICE)
|
#elif (END_DEVICE)
|
||||||
#define ZB_ED_ROLE 1
|
#define ZB_ED_ROLE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,29 +26,29 @@
|
||||||
#include "../common/comm_cfg.h"
|
#include "../common/comm_cfg.h"
|
||||||
|
|
||||||
#if defined(MCU_CORE_826x)
|
#if defined(MCU_CORE_826x)
|
||||||
#if (CHIP_8269)
|
#if (CHIP_8269)
|
||||||
#define CHIP_TYPE TLSR_8269
|
#define CHIP_TYPE TLSR_8269
|
||||||
#else
|
#else
|
||||||
#define CHIP_TYPE TLSR_8267
|
#define CHIP_TYPE TLSR_8267
|
||||||
#endif
|
#endif
|
||||||
#elif defined(MCU_CORE_8258)
|
#elif defined(MCU_CORE_8258)
|
||||||
#define CHIP_TYPE TLSR_8258_512K//TLSR_8258_1M
|
#define CHIP_TYPE TLSR_8258_512K // TLSR_8258_1M
|
||||||
#elif defined(MCU_CORE_8278)
|
#elif defined(MCU_CORE_8278)
|
||||||
#define CHIP_TYPE TLSR_8278
|
#define CHIP_TYPE TLSR_8278
|
||||||
#elif defined(MCU_CORE_B91)
|
#elif defined(MCU_CORE_B91)
|
||||||
#define CHIP_TYPE TLSR_9518
|
#define CHIP_TYPE TLSR_9518
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define APP_RELEASE 0x10//app release 1.0
|
#define APP_RELEASE 0x10 // app release 1.0
|
||||||
#define APP_BUILD 0x01//app build 01
|
#define APP_BUILD 0x01 // app build 01
|
||||||
#define STACK_RELEASE 0x30//stack release 3.0
|
#define STACK_RELEASE 0x30 // stack release 3.0
|
||||||
#define STACK_BUILD 0x01//stack build 01
|
#define STACK_BUILD 0x01 // stack build 01
|
||||||
|
|
||||||
/*********************************************************************************************
|
/*********************************************************************************************
|
||||||
* During OTA upgrade, the upgraded device will check the rules of the following three fields.
|
* During OTA upgrade, the upgraded device will check the rules of the following three fields.
|
||||||
* Refer to ZCL OTA specification for details.
|
* Refer to ZCL OTA specification for details.
|
||||||
*/
|
*/
|
||||||
#define MANUFACTURER_CODE_TELINK 0x124f //Gledopto ID
|
#define MANUFACTURER_CODE_TELINK 0x124f // Gledopto ID
|
||||||
#define IMAGE_TYPE ((CHIP_TYPE << 8) | IMAGE_TYPE_LIGHT)
|
#define IMAGE_TYPE ((CHIP_TYPE << 8) | IMAGE_TYPE_LIGHT)
|
||||||
#define FILE_VERSION ((APP_RELEASE << 24) | (APP_BUILD << 16) | (STACK_RELEASE << 8) | STACK_BUILD)
|
#define FILE_VERSION ((APP_RELEASE << 24) | (APP_BUILD << 16) | (STACK_RELEASE << 8) | STACK_BUILD)
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,10 @@
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL FUNCTIONS
|
* LOCAL FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +51,6 @@
|
||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL VARIABLES
|
* LOCAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
@ -74,13 +71,15 @@ static void afTest_testReqPrc(apsdeDataInd_t *pApsdeInd)
|
||||||
|
|
||||||
u8 dataLen = 50;
|
u8 dataLen = 50;
|
||||||
u8 *pBuf = (u8 *)ev_buf_allocate(dataLen);
|
u8 *pBuf = (u8 *)ev_buf_allocate(dataLen);
|
||||||
if(pBuf){
|
if (pBuf)
|
||||||
|
{
|
||||||
u8 *pData = pBuf;
|
u8 *pData = pBuf;
|
||||||
|
|
||||||
*pData++ = LO_UINT16(g_afTest_rcvReqCnt);
|
*pData++ = LO_UINT16(g_afTest_rcvReqCnt);
|
||||||
*pData++ = HI_UINT16(g_afTest_rcvReqCnt);
|
*pData++ = HI_UINT16(g_afTest_rcvReqCnt);
|
||||||
|
|
||||||
for(u8 i = 0; i < dataLen - 2; i++){
|
for (u8 i = 0; i < dataLen - 2; i++)
|
||||||
|
{
|
||||||
*pData++ = i;
|
*pData++ = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +114,8 @@ void afTest_rx_handler(void *arg)
|
||||||
{
|
{
|
||||||
apsdeDataInd_t *pApsdeInd = (apsdeDataInd_t *)arg;
|
apsdeDataInd_t *pApsdeInd = (apsdeDataInd_t *)arg;
|
||||||
|
|
||||||
switch(pApsdeInd->indInfo.cluster_id){
|
switch (pApsdeInd->indInfo.cluster_id)
|
||||||
|
{
|
||||||
case ZCL_CLUSTER_TELINK_SDK_TEST_CLEAR_REQ:
|
case ZCL_CLUSTER_TELINK_SDK_TEST_CLEAR_REQ:
|
||||||
g_afTest_rcvReqCnt = 0;
|
g_afTest_rcvReqCnt = 0;
|
||||||
afTest_testClearReqPrc(pApsdeInd);
|
afTest_testClearReqPrc(pApsdeInd);
|
||||||
|
@ -137,8 +137,7 @@ void afTest_rx_handler(void *arg)
|
||||||
|
|
||||||
void afTest_dataSendConfirm(void *arg)
|
void afTest_dataSendConfirm(void *arg)
|
||||||
{
|
{
|
||||||
// apsdeDataConf_t *pApsDataCnf = (apsdeDataConf_t *)arg;
|
// apsdeDataConf_t *pApsDataCnf = (apsdeDataConf_t *)arg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* AF_TEST_ENABLE */
|
#endif /* AF_TEST_ENABLE */
|
||||||
|
|
152
zb_appCb.c
152
zb_appCb.c
|
@ -43,7 +43,6 @@
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL FUNCTIONS
|
* LOCAL FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +50,6 @@ void zbdemo_bdbInitCb(u8 status, u8 joinedNetwork);
|
||||||
void zbdemo_bdbCommissioningCb(u8 status, void *arg);
|
void zbdemo_bdbCommissioningCb(u8 status, void *arg);
|
||||||
void zbdemo_bdbIdentifyCb(u8 endpoint, u16 srcAddr, u16 identifyTime);
|
void zbdemo_bdbIdentifyCb(u8 endpoint, u16 srcAddr, u16 identifyTime);
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
@ -59,7 +57,7 @@ bdb_appCb_t g_zbDemoBdbCb = {zbdemo_bdbInitCb, zbdemo_bdbCommissioningCb, zbdemo
|
||||||
|
|
||||||
#ifdef ZCL_OTA
|
#ifdef ZCL_OTA
|
||||||
ota_callBack_t sampleLight_otaCb =
|
ota_callBack_t sampleLight_otaCb =
|
||||||
{
|
{
|
||||||
sampleLight_otaProcessMsgHandler,
|
sampleLight_otaProcessMsgHandler,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -77,8 +75,10 @@ ev_timer_event_t *heartTimerEvt = NULL;
|
||||||
* FUNCTIONS
|
* FUNCTIONS
|
||||||
*/
|
*/
|
||||||
#if DEBUG_HEART
|
#if DEBUG_HEART
|
||||||
static s32 heartTimerCb(void *arg){
|
static s32 heartTimerCb(void *arg)
|
||||||
if(heartInterval == 0){
|
{
|
||||||
|
if (heartInterval == 0)
|
||||||
|
{
|
||||||
heartTimerEvt = NULL;
|
heartTimerEvt = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -89,14 +89,16 @@ static s32 heartTimerCb(void *arg){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s32 sampleLight_bdbNetworkSteerStart(void *arg){
|
s32 sampleLight_bdbNetworkSteerStart(void *arg)
|
||||||
|
{
|
||||||
bdb_networkSteerStart();
|
bdb_networkSteerStart();
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FIND_AND_BIND_SUPPORT
|
#if FIND_AND_BIND_SUPPORT
|
||||||
s32 sampleLight_bdbFindAndBindStart(void *arg){
|
s32 sampleLight_bdbFindAndBindStart(void *arg)
|
||||||
|
{
|
||||||
bdb_findAndBindStart(BDB_COMMISSIONING_ROLE_TARGET);
|
bdb_findAndBindStart(BDB_COMMISSIONING_ROLE_TARGET);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -114,34 +116,43 @@ s32 sampleLight_bdbFindAndBindStart(void *arg){
|
||||||
*
|
*
|
||||||
* @return None
|
* @return None
|
||||||
*/
|
*/
|
||||||
void zbdemo_bdbInitCb(u8 status, u8 joinedNetwork){
|
void zbdemo_bdbInitCb(u8 status, u8 joinedNetwork)
|
||||||
if(status == BDB_INIT_STATUS_SUCCESS){
|
{
|
||||||
|
if (status == BDB_INIT_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* start bdb commissioning
|
* start bdb commissioning
|
||||||
* */
|
* */
|
||||||
if(joinedNetwork){
|
if (joinedNetwork)
|
||||||
|
{
|
||||||
heartInterval = 1000;
|
heartInterval = 1000;
|
||||||
|
|
||||||
#ifdef ZCL_OTA
|
#ifdef ZCL_OTA
|
||||||
ota_queryStart(OTA_PERIODIC_QUERY_INTERVAL);
|
ota_queryStart(OTA_PERIODIC_QUERY_INTERVAL);
|
||||||
#endif
|
#endif
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
heartInterval = 500;
|
heartInterval = 500;
|
||||||
|
|
||||||
#if (!ZBHCI_EN)
|
#if (!ZBHCI_EN)
|
||||||
u16 jitter = 0;
|
u16 jitter = 0;
|
||||||
do{
|
do
|
||||||
|
{
|
||||||
jitter = zb_random() % 0x0fff;
|
jitter = zb_random() % 0x0fff;
|
||||||
}while(jitter == 0);
|
} while (jitter == 0);
|
||||||
TL_ZB_TIMER_SCHEDULE(sampleLight_bdbNetworkSteerStart, NULL, jitter);
|
TL_ZB_TIMER_SCHEDULE(sampleLight_bdbNetworkSteerStart, NULL, jitter);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
heartInterval = 200;
|
heartInterval = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_HEART
|
#if DEBUG_HEART
|
||||||
if(heartTimerEvt){
|
if (heartTimerEvt)
|
||||||
|
{
|
||||||
TL_ZB_TIMER_CANCEL(&heartTimerEvt);
|
TL_ZB_TIMER_CANCEL(&heartTimerEvt);
|
||||||
}
|
}
|
||||||
heartTimerEvt = TL_ZB_TIMER_SCHEDULE(heartTimerCb, NULL, heartInterval);
|
heartTimerEvt = TL_ZB_TIMER_SCHEDULE(heartTimerCb, NULL, heartInterval);
|
||||||
|
@ -159,12 +170,15 @@ void zbdemo_bdbInitCb(u8 status, u8 joinedNetwork){
|
||||||
*
|
*
|
||||||
* @return None
|
* @return None
|
||||||
*/
|
*/
|
||||||
void zbdemo_bdbCommissioningCb(u8 status, void *arg){
|
void zbdemo_bdbCommissioningCb(u8 status, void *arg)
|
||||||
if(status == BDB_COMMISSION_STA_SUCCESS){
|
{
|
||||||
|
if (status == BDB_COMMISSION_STA_SUCCESS)
|
||||||
|
{
|
||||||
heartInterval = 1000;
|
heartInterval = 1000;
|
||||||
|
|
||||||
#if FIND_AND_BIND_SUPPORT
|
#if FIND_AND_BIND_SUPPORT
|
||||||
if(!gLightCtx.bdbFindBindFlg){
|
if (!gLightCtx.bdbFindBindFlg)
|
||||||
|
{
|
||||||
gLightCtx.bdbFindBindFlg = TRUE;
|
gLightCtx.bdbFindBindFlg = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -175,73 +189,94 @@ void zbdemo_bdbCommissioningCb(u8 status, void *arg){
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FIND_AND_BIND_SUPPORT
|
#if FIND_AND_BIND_SUPPORT
|
||||||
//start Finding & Binding
|
// start Finding & Binding
|
||||||
TL_ZB_TIMER_SCHEDULE(sampleLight_bdbFindAndBindStart, NULL, 1000);
|
TL_ZB_TIMER_SCHEDULE(sampleLight_bdbFindAndBindStart, NULL, 1000);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}else if(status == BDB_COMMISSION_STA_IN_PROGRESS){
|
}
|
||||||
|
else if (status == BDB_COMMISSION_STA_IN_PROGRESS)
|
||||||
}else if(status == BDB_COMMISSION_STA_NOT_AA_CAPABLE){
|
{
|
||||||
|
}
|
||||||
}else if((status == BDB_COMMISSION_STA_NO_NETWORK)||(status == BDB_COMMISSION_STA_TCLK_EX_FAILURE)){
|
else if (status == BDB_COMMISSION_STA_NOT_AA_CAPABLE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if ((status == BDB_COMMISSION_STA_NO_NETWORK) || (status == BDB_COMMISSION_STA_TCLK_EX_FAILURE))
|
||||||
|
{
|
||||||
u16 jitter = 0;
|
u16 jitter = 0;
|
||||||
do{
|
do
|
||||||
|
{
|
||||||
jitter = zb_random() % 0x0fff;
|
jitter = zb_random() % 0x0fff;
|
||||||
}while(jitter == 0);
|
} while (jitter == 0);
|
||||||
TL_ZB_TIMER_SCHEDULE(sampleLight_bdbNetworkSteerStart, NULL, jitter);
|
TL_ZB_TIMER_SCHEDULE(sampleLight_bdbNetworkSteerStart, NULL, jitter);
|
||||||
}else if(status == BDB_COMMISSION_STA_TARGET_FAILURE){
|
}
|
||||||
|
else if (status == BDB_COMMISSION_STA_TARGET_FAILURE)
|
||||||
}else if(status == BDB_COMMISSION_STA_FORMATION_FAILURE){
|
{
|
||||||
|
}
|
||||||
}else if(status == BDB_COMMISSION_STA_NO_IDENTIFY_QUERY_RESPONSE){
|
else if (status == BDB_COMMISSION_STA_FORMATION_FAILURE)
|
||||||
|
{
|
||||||
}else if(status == BDB_COMMISSION_STA_BINDING_TABLE_FULL){
|
}
|
||||||
|
else if (status == BDB_COMMISSION_STA_NO_IDENTIFY_QUERY_RESPONSE)
|
||||||
}else if(status == BDB_COMMISSION_STA_NO_SCAN_RESPONSE){
|
{
|
||||||
|
}
|
||||||
}else if(status == BDB_COMMISSION_STA_NOT_PERMITTED){
|
else if (status == BDB_COMMISSION_STA_BINDING_TABLE_FULL)
|
||||||
|
{
|
||||||
}else if(status == BDB_COMMISSION_STA_REJOIN_FAILURE){
|
}
|
||||||
|
else if (status == BDB_COMMISSION_STA_NO_SCAN_RESPONSE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (status == BDB_COMMISSION_STA_NOT_PERMITTED)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (status == BDB_COMMISSION_STA_REJOIN_FAILURE)
|
||||||
|
{
|
||||||
zb_rejoinReq(NLME_REJOIN_METHOD_REJOIN, zb_apsChannelMaskGet());
|
zb_rejoinReq(NLME_REJOIN_METHOD_REJOIN, zb_apsChannelMaskGet());
|
||||||
}else if(status == BDB_COMMISSION_STA_FORMATION_DONE){
|
}
|
||||||
|
else if (status == BDB_COMMISSION_STA_FORMATION_DONE)
|
||||||
|
{
|
||||||
#if ZBHCI_EN
|
#if ZBHCI_EN
|
||||||
|
|
||||||
#else
|
#else
|
||||||
tl_zbMacChannelSet(DEFAULT_CHANNEL); //set default channel
|
tl_zbMacChannelSet(DEFAULT_CHANNEL); // set default channel
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern void sampleLight_zclIdentifyCmdHandler(u8 endpoint, u16 srcAddr, u16 identifyTime);
|
extern void sampleLight_zclIdentifyCmdHandler(u8 endpoint, u16 srcAddr, u16 identifyTime);
|
||||||
void zbdemo_bdbIdentifyCb(u8 endpoint, u16 srcAddr, u16 identifyTime){
|
void zbdemo_bdbIdentifyCb(u8 endpoint, u16 srcAddr, u16 identifyTime)
|
||||||
|
{
|
||||||
#if FIND_AND_BIND_SUPPORT
|
#if FIND_AND_BIND_SUPPORT
|
||||||
sampleLight_zclIdentifyCmdHandler(endpoint, srcAddr, identifyTime);
|
sampleLight_zclIdentifyCmdHandler(endpoint, srcAddr, identifyTime);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ZCL_OTA
|
#ifdef ZCL_OTA
|
||||||
void sampleLight_otaProcessMsgHandler(u8 evt, u8 status)
|
void sampleLight_otaProcessMsgHandler(u8 evt, u8 status)
|
||||||
{
|
{
|
||||||
if(evt == OTA_EVT_START){
|
if (evt == OTA_EVT_START)
|
||||||
if(status == ZCL_STA_SUCCESS){
|
{
|
||||||
|
if (status == ZCL_STA_SUCCESS)
|
||||||
}else{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}else if(evt == OTA_EVT_COMPLETE){
|
else
|
||||||
if(status == ZCL_STA_SUCCESS){
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (evt == OTA_EVT_COMPLETE)
|
||||||
|
{
|
||||||
|
if (status == ZCL_STA_SUCCESS)
|
||||||
|
{
|
||||||
ota_mcuReboot();
|
ota_mcuReboot();
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ota_queryStart(OTA_PERIODIC_QUERY_INTERVAL);
|
ota_queryStart(OTA_PERIODIC_QUERY_INTERVAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s32 sampleLight_softReset(void *arg){
|
s32 sampleLight_softReset(void *arg)
|
||||||
|
{
|
||||||
SYSTEM_RESET();
|
SYSTEM_RESET();
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -258,10 +293,11 @@ s32 sampleLight_softReset(void *arg){
|
||||||
*/
|
*/
|
||||||
void sampleLight_leaveCnfHandler(nlme_leave_cnf_t *pLeaveCnf)
|
void sampleLight_leaveCnfHandler(nlme_leave_cnf_t *pLeaveCnf)
|
||||||
{
|
{
|
||||||
if(pLeaveCnf->status == SUCCESS){
|
if (pLeaveCnf->status == SUCCESS)
|
||||||
|
{
|
||||||
light_blink_start(3, 200, 200);
|
light_blink_start(3, 200, 200);
|
||||||
|
|
||||||
//waiting blink over
|
// waiting blink over
|
||||||
TL_ZB_TIMER_SCHEDULE(sampleLight_softReset, NULL, 2 * 1000);
|
TL_ZB_TIMER_SCHEDULE(sampleLight_softReset, NULL, 2 * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,10 +313,10 @@ void sampleLight_leaveCnfHandler(nlme_leave_cnf_t *pLeaveCnf)
|
||||||
*/
|
*/
|
||||||
void sampleLight_leaveIndHandler(nlme_leave_ind_t *pLeaveInd)
|
void sampleLight_leaveIndHandler(nlme_leave_ind_t *pLeaveInd)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 sampleLight_nwkUpdateIndicateHandler(nwkCmd_nwkUpdate_t *pNwkUpdate){
|
u8 sampleLight_nwkUpdateIndicateHandler(nwkCmd_nwkUpdate_t *pNwkUpdate)
|
||||||
|
{
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,11 @@
|
||||||
*/
|
*/
|
||||||
#define ZCL_COLOR_CHANGE_INTERVAL 100
|
#define ZCL_COLOR_CHANGE_INTERVAL 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
s32 stepHue256;
|
s32 stepHue256;
|
||||||
u16 currentHue256;
|
u16 currentHue256;
|
||||||
u16 hueRemainingTime;
|
u16 hueRemainingTime;
|
||||||
|
@ -57,7 +56,7 @@ typedef struct{
|
||||||
u16 colorTempRemainingTime;
|
u16 colorTempRemainingTime;
|
||||||
u16 colorTempMinMireds;
|
u16 colorTempMinMireds;
|
||||||
u16 colorTempMaxMireds;
|
u16 colorTempMaxMireds;
|
||||||
}zcl_colorInfo_t;
|
} zcl_colorInfo_t;
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL VARIABLES
|
* LOCAL VARIABLES
|
||||||
|
@ -81,13 +80,11 @@ static zcl_colorInfo_t colorInfo = {
|
||||||
static ev_timer_event_t *colorTimerEvt = NULL;
|
static ev_timer_event_t *colorTimerEvt = NULL;
|
||||||
static ev_timer_event_t *colorLoopTimerEvt = NULL;
|
static ev_timer_event_t *colorLoopTimerEvt = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* FUNCTIONS
|
* FUNCTIONS
|
||||||
*/
|
*/
|
||||||
void sampleLight_updateColorMode(u8 colorMode);
|
void sampleLight_updateColorMode(u8 colorMode);
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn sampleLight_colorInit
|
* @fn sampleLight_colorInit
|
||||||
*
|
*
|
||||||
|
@ -117,7 +114,6 @@ void sampleLight_colorInit(void)
|
||||||
|
|
||||||
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
||||||
pColor->colorTempPhysicalMinMireds, pColor->colorTempPhysicalMaxMireds, FALSE);
|
pColor->colorTempPhysicalMinMireds, pColor->colorTempPhysicalMaxMireds, FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -136,13 +132,16 @@ void sampleLight_updateColorMode(u8 colorMode)
|
||||||
{
|
{
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
if(colorMode != pColor->colorMode){
|
if (colorMode != pColor->colorMode)
|
||||||
if(colorMode == ZCL_COLOR_MODE_CURRENT_X_Y){
|
{
|
||||||
|
if (colorMode == ZCL_COLOR_MODE_CURRENT_X_Y)
|
||||||
}else if(colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION){
|
{
|
||||||
|
}
|
||||||
}else if(colorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS){
|
else if (colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (colorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,11 +160,16 @@ void sampleLight_updateColor(void)
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
zcl_levelAttr_t *pLevel = zcl_levelAttrGet();
|
zcl_levelAttr_t *pLevel = zcl_levelAttrGet();
|
||||||
|
|
||||||
if(pColor->colorMode == ZCL_COLOR_MODE_CURRENT_X_Y) {
|
if (pColor->colorMode == ZCL_COLOR_MODE_CURRENT_X_Y)
|
||||||
|
{
|
||||||
hwLight_colorUpdate_XY2RGB(pColor->currentX, pColor->currentY, pLevel->curLevel);
|
hwLight_colorUpdate_XY2RGB(pColor->currentX, pColor->currentY, pLevel->curLevel);
|
||||||
} else if(pColor->colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION || pColor->enhancedColorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION){
|
}
|
||||||
|
else if (pColor->colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION || pColor->enhancedColorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION)
|
||||||
|
{
|
||||||
hwLight_colorUpdate_HSV2RGB(pColor->currentHue, pColor->currentSaturation, pLevel->curLevel);
|
hwLight_colorUpdate_HSV2RGB(pColor->currentHue, pColor->currentSaturation, pLevel->curLevel);
|
||||||
} else if(pColor->colorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS){
|
}
|
||||||
|
else if (pColor->colorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS)
|
||||||
|
{
|
||||||
hwLight_colorUpdate_colorTemperature(pColor->colorTemperatureMireds, pLevel->curLevel);
|
hwLight_colorUpdate_colorTemperature(pColor->colorTemperatureMireds, pLevel->curLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,28 +187,36 @@ static s32 sampleLight_colorTimerEvtCb(void *arg)
|
||||||
{
|
{
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
if( (pColor->enhancedColorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION) ||
|
if ((pColor->enhancedColorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION) ||
|
||||||
(pColor->enhancedColorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION) ){
|
(pColor->enhancedColorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION))
|
||||||
if(colorInfo.saturationRemainingTime){
|
{
|
||||||
|
if (colorInfo.saturationRemainingTime)
|
||||||
|
{
|
||||||
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
||||||
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(colorInfo.hueRemainingTime){
|
if (colorInfo.hueRemainingTime)
|
||||||
|
{
|
||||||
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
||||||
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(pColor->enhancedColorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS){
|
else if (pColor->enhancedColorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS)
|
||||||
if(colorInfo.colorTempRemainingTime){
|
{
|
||||||
|
if (colorInfo.colorTempRemainingTime)
|
||||||
|
{
|
||||||
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
||||||
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(colorInfo.saturationRemainingTime || colorInfo.hueRemainingTime || colorInfo.colorTempRemainingTime){
|
if (colorInfo.saturationRemainingTime || colorInfo.hueRemainingTime || colorInfo.colorTempRemainingTime)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
colorTimerEvt = NULL;
|
colorTimerEvt = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +233,8 @@ static s32 sampleLight_colorTimerEvtCb(void *arg)
|
||||||
*/
|
*/
|
||||||
static void sampleLight_colorTimerStop(void)
|
static void sampleLight_colorTimerStop(void)
|
||||||
{
|
{
|
||||||
if(colorTimerEvt){
|
if (colorTimerEvt)
|
||||||
|
{
|
||||||
TL_ZB_TIMER_CANCEL(&colorTimerEvt);
|
TL_ZB_TIMER_CANCEL(&colorTimerEvt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,9 +252,11 @@ static s32 sampleLight_colorLoopTimerEvtCb(void *arg)
|
||||||
{
|
{
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
if(pColor->colorLoopActive){
|
if (pColor->colorLoopActive)
|
||||||
|
{
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
colorLoopTimerEvt = NULL;
|
colorLoopTimerEvt = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -260,12 +275,12 @@ static s32 sampleLight_colorLoopTimerEvtCb(void *arg)
|
||||||
*/
|
*/
|
||||||
static void sampleLight_colorLoopTimerStop(void)
|
static void sampleLight_colorLoopTimerStop(void)
|
||||||
{
|
{
|
||||||
if(colorLoopTimerEvt){
|
if (colorLoopTimerEvt)
|
||||||
|
{
|
||||||
TL_ZB_TIMER_CANCEL(&colorLoopTimerEvt);
|
TL_ZB_TIMER_CANCEL(&colorLoopTimerEvt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn sampleLight_moveToHueProcess
|
* @fn sampleLight_moveToHueProcess
|
||||||
*
|
*
|
||||||
|
@ -288,28 +303,37 @@ static void sampleLight_moveToHueProcess(zcl_colorCtrlMoveToHueCmd_t *cmd)
|
||||||
|
|
||||||
s16 hueDiff = (s16)cmd->hue - pColor->currentHue;
|
s16 hueDiff = (s16)cmd->hue - pColor->currentHue;
|
||||||
|
|
||||||
switch(cmd->direction){
|
switch (cmd->direction)
|
||||||
|
{
|
||||||
case COLOR_CTRL_DIRECTION_SHORTEST_DISTANCE:
|
case COLOR_CTRL_DIRECTION_SHORTEST_DISTANCE:
|
||||||
if(hueDiff > (ZCL_COLOR_ATTR_HUE_MAX / 2)){
|
if (hueDiff > (ZCL_COLOR_ATTR_HUE_MAX / 2))
|
||||||
|
{
|
||||||
hueDiff -= (ZCL_COLOR_ATTR_HUE_MAX + 1);
|
hueDiff -= (ZCL_COLOR_ATTR_HUE_MAX + 1);
|
||||||
}else if(hueDiff < -ZCL_COLOR_ATTR_HUE_MAX / 2){
|
}
|
||||||
|
else if (hueDiff < -ZCL_COLOR_ATTR_HUE_MAX / 2)
|
||||||
|
{
|
||||||
hueDiff += (ZCL_COLOR_ATTR_HUE_MAX + 1);
|
hueDiff += (ZCL_COLOR_ATTR_HUE_MAX + 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_DIRECTION_LONGEST_DISTANCE:
|
case COLOR_CTRL_DIRECTION_LONGEST_DISTANCE:
|
||||||
if((hueDiff > 0) && (hueDiff < (ZCL_COLOR_ATTR_HUE_MAX / 2))){
|
if ((hueDiff > 0) && (hueDiff < (ZCL_COLOR_ATTR_HUE_MAX / 2)))
|
||||||
|
{
|
||||||
hueDiff -= (ZCL_COLOR_ATTR_HUE_MAX + 1);
|
hueDiff -= (ZCL_COLOR_ATTR_HUE_MAX + 1);
|
||||||
}else if((hueDiff < 0) && (hueDiff > -ZCL_COLOR_ATTR_HUE_MAX / 2)){
|
}
|
||||||
|
else if ((hueDiff < 0) && (hueDiff > -ZCL_COLOR_ATTR_HUE_MAX / 2))
|
||||||
|
{
|
||||||
hueDiff += (ZCL_COLOR_ATTR_HUE_MAX + 1);
|
hueDiff += (ZCL_COLOR_ATTR_HUE_MAX + 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_DIRECTION_UP:
|
case COLOR_CTRL_DIRECTION_UP:
|
||||||
if(hueDiff < 0){
|
if (hueDiff < 0)
|
||||||
|
{
|
||||||
hueDiff += ZCL_COLOR_ATTR_HUE_MAX;
|
hueDiff += ZCL_COLOR_ATTR_HUE_MAX;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_DIRECTION_DOWN:
|
case COLOR_CTRL_DIRECTION_DOWN:
|
||||||
if(hueDiff > 0){
|
if (hueDiff > 0)
|
||||||
|
{
|
||||||
hueDiff -= ZCL_COLOR_ATTR_HUE_MAX;
|
hueDiff -= ZCL_COLOR_ATTR_HUE_MAX;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -324,10 +348,13 @@ static void sampleLight_moveToHueProcess(zcl_colorCtrlMoveToHueCmd_t *cmd)
|
||||||
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
||||||
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
||||||
|
|
||||||
if(colorInfo.hueRemainingTime){
|
if (colorInfo.hueRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,7 +379,8 @@ static void sampleLight_moveHueProcess(zcl_colorCtrlMoveHueCmd_t *cmd)
|
||||||
|
|
||||||
colorInfo.currentHue256 = (u16)(pColor->currentHue) << 8;
|
colorInfo.currentHue256 = (u16)(pColor->currentHue) << 8;
|
||||||
|
|
||||||
switch(cmd->moveMode){
|
switch (cmd->moveMode)
|
||||||
|
{
|
||||||
case COLOR_CTRL_MOVE_STOP:
|
case COLOR_CTRL_MOVE_STOP:
|
||||||
colorInfo.stepHue256 = 0;
|
colorInfo.stepHue256 = 0;
|
||||||
colorInfo.hueRemainingTime = 0;
|
colorInfo.hueRemainingTime = 0;
|
||||||
|
@ -372,10 +400,13 @@ static void sampleLight_moveHueProcess(zcl_colorCtrlMoveHueCmd_t *cmd)
|
||||||
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
||||||
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
||||||
|
|
||||||
if(colorInfo.hueRemainingTime){
|
if (colorInfo.hueRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -404,7 +435,8 @@ static void sampleLight_stepHueProcess(zcl_colorCtrlStepHueCmd_t *cmd)
|
||||||
|
|
||||||
colorInfo.stepHue256 = (((s32)cmd->stepSize) << 8) / colorInfo.hueRemainingTime;
|
colorInfo.stepHue256 = (((s32)cmd->stepSize) << 8) / colorInfo.hueRemainingTime;
|
||||||
|
|
||||||
switch(cmd->stepMode){
|
switch (cmd->stepMode)
|
||||||
|
{
|
||||||
case COLOR_CTRL_STEP_MODE_UP:
|
case COLOR_CTRL_STEP_MODE_UP:
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_STEP_MODE_DOWN:
|
case COLOR_CTRL_STEP_MODE_DOWN:
|
||||||
|
@ -417,10 +449,13 @@ static void sampleLight_stepHueProcess(zcl_colorCtrlStepHueCmd_t *cmd)
|
||||||
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
light_applyUpdate(&pColor->currentHue, &colorInfo.currentHue256, &colorInfo.stepHue256, &colorInfo.hueRemainingTime,
|
||||||
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
|
||||||
|
|
||||||
if(colorInfo.hueRemainingTime){
|
if (colorInfo.hueRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,10 +488,13 @@ static void sampleLight_moveToSaturationProcess(zcl_colorCtrlMoveToSaturationCmd
|
||||||
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
||||||
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
||||||
|
|
||||||
if(colorInfo.saturationRemainingTime){
|
if (colorInfo.saturationRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,7 +519,8 @@ static void sampleLight_moveSaturationProcess(zcl_colorCtrlMoveSaturationCmd_t *
|
||||||
|
|
||||||
colorInfo.currentSaturation256 = (u16)(pColor->currentSaturation) << 8;
|
colorInfo.currentSaturation256 = (u16)(pColor->currentSaturation) << 8;
|
||||||
|
|
||||||
switch(cmd->moveMode){
|
switch (cmd->moveMode)
|
||||||
|
{
|
||||||
case COLOR_CTRL_MOVE_STOP:
|
case COLOR_CTRL_MOVE_STOP:
|
||||||
colorInfo.stepSaturation256 = 0;
|
colorInfo.stepSaturation256 = 0;
|
||||||
colorInfo.saturationRemainingTime = 0;
|
colorInfo.saturationRemainingTime = 0;
|
||||||
|
@ -501,10 +540,13 @@ static void sampleLight_moveSaturationProcess(zcl_colorCtrlMoveSaturationCmd_t *
|
||||||
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
||||||
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
||||||
|
|
||||||
if(colorInfo.saturationRemainingTime){
|
if (colorInfo.saturationRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,7 +575,8 @@ static void sampleLight_stepSaturationProcess(zcl_colorCtrlStepSaturationCmd_t *
|
||||||
|
|
||||||
colorInfo.stepSaturation256 = (((s32)cmd->stepSize) << 8) / colorInfo.saturationRemainingTime;
|
colorInfo.stepSaturation256 = (((s32)cmd->stepSize) << 8) / colorInfo.saturationRemainingTime;
|
||||||
|
|
||||||
switch(cmd->stepMode){
|
switch (cmd->stepMode)
|
||||||
|
{
|
||||||
case COLOR_CTRL_STEP_MODE_UP:
|
case COLOR_CTRL_STEP_MODE_UP:
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_STEP_MODE_DOWN:
|
case COLOR_CTRL_STEP_MODE_DOWN:
|
||||||
|
@ -546,10 +589,13 @@ static void sampleLight_stepSaturationProcess(zcl_colorCtrlStepSaturationCmd_t *
|
||||||
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
light_applyUpdate(&pColor->currentSaturation, &colorInfo.currentSaturation256, &colorInfo.stepSaturation256, &colorInfo.saturationRemainingTime,
|
||||||
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
ZCL_COLOR_ATTR_SATURATION_MIN, ZCL_COLOR_ATTR_SATURATION_MAX, FALSE);
|
||||||
|
|
||||||
if(colorInfo.saturationRemainingTime){
|
if (colorInfo.saturationRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,8 +642,6 @@ static void sampleLight_moveToColorProcess(zcl_colorCtrlMoveToColorCmd_t *cmd)
|
||||||
|
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
||||||
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -617,8 +661,6 @@ static void sampleLight_moveColorProcess(zcl_colorCtrlMoveColorCmd_t *cmd)
|
||||||
|
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
||||||
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -638,8 +680,6 @@ static void sampleLight_stepColorProcess(zcl_colorCtrlStepColorCmd_t *cmd)
|
||||||
|
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
||||||
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -660,7 +700,8 @@ static void sampleLight_enhancedMoveToHueProcess(zcl_colorCtrlEnhancedMoveToHueC
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_HUE_SATURATION;
|
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_HUE_SATURATION;
|
||||||
pColor->enhancedColorMode = ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION;
|
pColor->enhancedColorMode = ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION;
|
||||||
|
|
||||||
switch(cmd->direction){
|
switch (cmd->direction)
|
||||||
|
{
|
||||||
case COLOR_CTRL_DIRECTION_SHORTEST_DISTANCE:
|
case COLOR_CTRL_DIRECTION_SHORTEST_DISTANCE:
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_DIRECTION_LONGEST_DISTANCE:
|
case COLOR_CTRL_DIRECTION_LONGEST_DISTANCE:
|
||||||
|
@ -672,8 +713,6 @@ static void sampleLight_enhancedMoveToHueProcess(zcl_colorCtrlEnhancedMoveToHueC
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -694,7 +733,8 @@ static void sampleLight_enhancedMoveHueProcess(zcl_colorCtrlEnhancedMoveHueCmd_t
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_HUE_SATURATION;
|
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_HUE_SATURATION;
|
||||||
pColor->enhancedColorMode = ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION;
|
pColor->enhancedColorMode = ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION;
|
||||||
|
|
||||||
switch(cmd->moveMode){
|
switch (cmd->moveMode)
|
||||||
|
{
|
||||||
case COLOR_CTRL_MOVE_STOP:
|
case COLOR_CTRL_MOVE_STOP:
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_MOVE_UP:
|
case COLOR_CTRL_MOVE_UP:
|
||||||
|
@ -704,8 +744,6 @@ static void sampleLight_enhancedMoveHueProcess(zcl_colorCtrlEnhancedMoveHueCmd_t
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -726,7 +764,8 @@ static void sampleLight_enhancedStepHueProcess(zcl_colorCtrlEnhancedStepHueCmd_t
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_HUE_SATURATION;
|
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_HUE_SATURATION;
|
||||||
pColor->enhancedColorMode = ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION;
|
pColor->enhancedColorMode = ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION;
|
||||||
|
|
||||||
switch(cmd->stepMode){
|
switch (cmd->stepMode)
|
||||||
|
{
|
||||||
case COLOR_CTRL_STEP_MODE_UP:
|
case COLOR_CTRL_STEP_MODE_UP:
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_STEP_MODE_DOWN:
|
case COLOR_CTRL_STEP_MODE_DOWN:
|
||||||
|
@ -734,8 +773,6 @@ static void sampleLight_enhancedStepHueProcess(zcl_colorCtrlEnhancedStepHueCmd_t
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -776,20 +813,25 @@ static void sampleLight_colorLoopSetProcess(zcl_colorCtrlColorLoopSetCmd_t *cmd)
|
||||||
{
|
{
|
||||||
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
if(cmd->updateFlags.bits.direction){
|
if (cmd->updateFlags.bits.direction)
|
||||||
|
{
|
||||||
pColor->colorLoopDirection = cmd->direction;
|
pColor->colorLoopDirection = cmd->direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmd->updateFlags.bits.time){
|
if (cmd->updateFlags.bits.time)
|
||||||
|
{
|
||||||
pColor->colorLoopTime = cmd->time;
|
pColor->colorLoopTime = cmd->time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmd->updateFlags.bits.startHue){
|
if (cmd->updateFlags.bits.startHue)
|
||||||
|
{
|
||||||
pColor->colorLoopStartEnhancedHue = cmd->startHue;
|
pColor->colorLoopStartEnhancedHue = cmd->startHue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmd->updateFlags.bits.action){
|
if (cmd->updateFlags.bits.action)
|
||||||
switch(cmd->action){
|
{
|
||||||
|
switch (cmd->action)
|
||||||
|
{
|
||||||
case COLOR_LOOP_SET_DEACTION:
|
case COLOR_LOOP_SET_DEACTION:
|
||||||
break;
|
break;
|
||||||
case COLOR_LOOP_SET_ACTION_FROM_COLOR_LOOP_START_ENHANCED_HUE:
|
case COLOR_LOOP_SET_ACTION_FROM_COLOR_LOOP_START_ENHANCED_HUE:
|
||||||
|
@ -833,10 +875,13 @@ static void sampleLight_moveToColorTemperatureProcess(zcl_colorCtrlMoveToColorTe
|
||||||
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
||||||
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
||||||
|
|
||||||
if(colorInfo.colorTempRemainingTime){
|
if (colorInfo.colorTempRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,23 +904,30 @@ static void sampleLight_moveColorTemperatureProcess(zcl_colorCtrlMoveColorTemper
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
pColor->colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
||||||
pColor->enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
pColor->enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
||||||
|
|
||||||
if(cmd->colorTempMinMireds){
|
if (cmd->colorTempMinMireds)
|
||||||
|
{
|
||||||
colorInfo.colorTempMinMireds = (cmd->colorTempMinMireds < pColor->colorTempPhysicalMinMireds) ? pColor->colorTempPhysicalMinMireds
|
colorInfo.colorTempMinMireds = (cmd->colorTempMinMireds < pColor->colorTempPhysicalMinMireds) ? pColor->colorTempPhysicalMinMireds
|
||||||
: cmd->colorTempMinMireds;
|
: cmd->colorTempMinMireds;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
colorInfo.colorTempMinMireds = pColor->colorTempPhysicalMinMireds;
|
colorInfo.colorTempMinMireds = pColor->colorTempPhysicalMinMireds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmd->colorTempMaxMireds){
|
if (cmd->colorTempMaxMireds)
|
||||||
|
{
|
||||||
colorInfo.colorTempMaxMireds = (cmd->colorTempMaxMireds > pColor->colorTempPhysicalMaxMireds) ? pColor->colorTempPhysicalMaxMireds
|
colorInfo.colorTempMaxMireds = (cmd->colorTempMaxMireds > pColor->colorTempPhysicalMaxMireds) ? pColor->colorTempPhysicalMaxMireds
|
||||||
: cmd->colorTempMaxMireds;
|
: cmd->colorTempMaxMireds;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
colorInfo.colorTempMaxMireds = pColor->colorTempPhysicalMaxMireds;
|
colorInfo.colorTempMaxMireds = pColor->colorTempPhysicalMaxMireds;
|
||||||
}
|
}
|
||||||
|
|
||||||
colorInfo.currentColorTemp256 = (u32)(pColor->colorTemperatureMireds) << 8;
|
colorInfo.currentColorTemp256 = (u32)(pColor->colorTemperatureMireds) << 8;
|
||||||
|
|
||||||
switch(cmd->moveMode){
|
switch (cmd->moveMode)
|
||||||
|
{
|
||||||
case COLOR_CTRL_MOVE_STOP:
|
case COLOR_CTRL_MOVE_STOP:
|
||||||
colorInfo.stepColorTemp256 = 0;
|
colorInfo.stepColorTemp256 = 0;
|
||||||
colorInfo.colorTempRemainingTime = 0;
|
colorInfo.colorTempRemainingTime = 0;
|
||||||
|
@ -895,10 +947,13 @@ static void sampleLight_moveColorTemperatureProcess(zcl_colorCtrlMoveColorTemper
|
||||||
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
||||||
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
||||||
|
|
||||||
if(colorInfo.colorTempRemainingTime){
|
if (colorInfo.colorTempRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -921,17 +976,23 @@ static void sampleLight_stepColorTemperatureProcess(zcl_colorCtrlStepColorTemper
|
||||||
pColor->colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
pColor->colorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
||||||
pColor->enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
pColor->enhancedColorMode = ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS;
|
||||||
|
|
||||||
if(cmd->colorTempMinMireds){
|
if (cmd->colorTempMinMireds)
|
||||||
|
{
|
||||||
colorInfo.colorTempMinMireds = (cmd->colorTempMinMireds < pColor->colorTempPhysicalMinMireds) ? pColor->colorTempPhysicalMinMireds
|
colorInfo.colorTempMinMireds = (cmd->colorTempMinMireds < pColor->colorTempPhysicalMinMireds) ? pColor->colorTempPhysicalMinMireds
|
||||||
: cmd->colorTempMinMireds;
|
: cmd->colorTempMinMireds;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
colorInfo.colorTempMinMireds = pColor->colorTempPhysicalMinMireds;
|
colorInfo.colorTempMinMireds = pColor->colorTempPhysicalMinMireds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmd->colorTempMaxMireds){
|
if (cmd->colorTempMaxMireds)
|
||||||
|
{
|
||||||
colorInfo.colorTempMaxMireds = (cmd->colorTempMaxMireds > pColor->colorTempPhysicalMaxMireds) ? pColor->colorTempPhysicalMaxMireds
|
colorInfo.colorTempMaxMireds = (cmd->colorTempMaxMireds > pColor->colorTempPhysicalMaxMireds) ? pColor->colorTempPhysicalMaxMireds
|
||||||
: cmd->colorTempMaxMireds;
|
: cmd->colorTempMaxMireds;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
colorInfo.colorTempMaxMireds = pColor->colorTempPhysicalMaxMireds;
|
colorInfo.colorTempMaxMireds = pColor->colorTempPhysicalMaxMireds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,7 +1002,8 @@ static void sampleLight_stepColorTemperatureProcess(zcl_colorCtrlStepColorTemper
|
||||||
|
|
||||||
colorInfo.stepColorTemp256 = (((s32)cmd->stepSize) << 8) / colorInfo.colorTempRemainingTime;
|
colorInfo.stepColorTemp256 = (((s32)cmd->stepSize) << 8) / colorInfo.colorTempRemainingTime;
|
||||||
|
|
||||||
switch(cmd->stepMode){
|
switch (cmd->stepMode)
|
||||||
|
{
|
||||||
case COLOR_CTRL_STEP_MODE_UP:
|
case COLOR_CTRL_STEP_MODE_UP:
|
||||||
break;
|
break;
|
||||||
case COLOR_CTRL_STEP_MODE_DOWN:
|
case COLOR_CTRL_STEP_MODE_DOWN:
|
||||||
|
@ -954,15 +1016,17 @@ static void sampleLight_stepColorTemperatureProcess(zcl_colorCtrlStepColorTemper
|
||||||
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
light_applyUpdate_16(&pColor->colorTemperatureMireds, &colorInfo.currentColorTemp256, &colorInfo.stepColorTemp256, &colorInfo.colorTempRemainingTime,
|
||||||
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
|
||||||
|
|
||||||
if(colorInfo.colorTempRemainingTime){
|
if (colorInfo.colorTempRemainingTime)
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_colorTimerStop();
|
sampleLight_colorTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn sampleLight_stopMoveStepProcess
|
* @fn sampleLight_stopMoveStepProcess
|
||||||
*
|
*
|
||||||
|
@ -974,7 +1038,7 @@ static void sampleLight_stepColorTemperatureProcess(zcl_colorCtrlStepColorTemper
|
||||||
*/
|
*/
|
||||||
static void sampleLight_stopMoveStepProcess(void)
|
static void sampleLight_stopMoveStepProcess(void)
|
||||||
{
|
{
|
||||||
//zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
// zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
|
||||||
|
|
||||||
colorInfo.hueRemainingTime = 0;
|
colorInfo.hueRemainingTime = 0;
|
||||||
colorInfo.saturationRemainingTime = 0;
|
colorInfo.saturationRemainingTime = 0;
|
||||||
|
@ -996,8 +1060,10 @@ static void sampleLight_stopMoveStepProcess(void)
|
||||||
*/
|
*/
|
||||||
status_t sampleLight_colorCtrlCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
status_t sampleLight_colorCtrlCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
||||||
{
|
{
|
||||||
if(pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT){
|
if (pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT)
|
||||||
switch(cmdId){
|
{
|
||||||
|
switch (cmdId)
|
||||||
|
{
|
||||||
case ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_HUE:
|
case ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_HUE:
|
||||||
sampleLight_moveToHueProcess((zcl_colorCtrlMoveToHueCmd_t *)cmdPayload);
|
sampleLight_moveToHueProcess((zcl_colorCtrlMoveToHueCmd_t *)cmdPayload);
|
||||||
break;
|
break;
|
||||||
|
|
101
zcl_levelCb.c
101
zcl_levelCb.c
|
@ -41,11 +41,12 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
typedef struct{
|
typedef struct
|
||||||
|
{
|
||||||
s32 stepLevel256;
|
s32 stepLevel256;
|
||||||
u16 currentLevel256;
|
u16 currentLevel256;
|
||||||
u8 withOnOff;
|
u8 withOnOff;
|
||||||
}zcl_levelInfo_t;
|
} zcl_levelInfo_t;
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL VARIABLES
|
* LOCAL VARIABLES
|
||||||
|
@ -108,24 +109,30 @@ void sampleLight_updateLevel(void)
|
||||||
*
|
*
|
||||||
* @return 0: timer continue on; -1: timer will be canceled
|
* @return 0: timer continue on; -1: timer will be canceled
|
||||||
*/
|
*/
|
||||||
static s32 sampleLight_levelTimerEvtCb(void * arg)
|
static s32 sampleLight_levelTimerEvtCb(void *arg)
|
||||||
{
|
{
|
||||||
zcl_levelAttr_t *pLevel = zcl_levelAttrGet();
|
zcl_levelAttr_t *pLevel = zcl_levelAttrGet();
|
||||||
|
|
||||||
if(pLevel->remainingTime){
|
if (pLevel->remainingTime)
|
||||||
|
{
|
||||||
light_applyUpdate(&pLevel->curLevel, &levelInfo.currentLevel256, &levelInfo.stepLevel256, &pLevel->remainingTime,
|
light_applyUpdate(&pLevel->curLevel, &levelInfo.currentLevel256, &levelInfo.stepLevel256, &pLevel->remainingTime,
|
||||||
ZCL_LEVEL_ATTR_MIN_LEVEL, ZCL_LEVEL_ATTR_MAX_LEVEL, FALSE);
|
ZCL_LEVEL_ATTR_MIN_LEVEL, ZCL_LEVEL_ATTR_MAX_LEVEL, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(levelInfo.withOnOff){
|
if (levelInfo.withOnOff)
|
||||||
if(pLevel->curLevel == ZCL_LEVEL_ATTR_MIN_LEVEL){
|
{
|
||||||
|
if (pLevel->curLevel == ZCL_LEVEL_ATTR_MIN_LEVEL)
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pLevel->remainingTime){
|
if (pLevel->remainingTime)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
levelTimerEvt = NULL;
|
levelTimerEvt = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +149,8 @@ static s32 sampleLight_levelTimerEvtCb(void * arg)
|
||||||
*/
|
*/
|
||||||
static void sampleLight_LevelTimerStop(void)
|
static void sampleLight_LevelTimerStop(void)
|
||||||
{
|
{
|
||||||
if(levelTimerEvt){
|
if (levelTimerEvt)
|
||||||
|
{
|
||||||
TL_ZB_TIMER_CANCEL(&levelTimerEvt);
|
TL_ZB_TIMER_CANCEL(&levelTimerEvt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,18 +179,25 @@ static void sampleLight_moveToLevelProcess(u8 cmdId, moveToLvl_t *cmd)
|
||||||
light_applyUpdate(&pLevel->curLevel, &levelInfo.currentLevel256, &levelInfo.stepLevel256, &pLevel->remainingTime,
|
light_applyUpdate(&pLevel->curLevel, &levelInfo.currentLevel256, &levelInfo.stepLevel256, &pLevel->remainingTime,
|
||||||
ZCL_LEVEL_ATTR_MIN_LEVEL, ZCL_LEVEL_ATTR_MAX_LEVEL, FALSE);
|
ZCL_LEVEL_ATTR_MIN_LEVEL, ZCL_LEVEL_ATTR_MAX_LEVEL, FALSE);
|
||||||
|
|
||||||
if(levelInfo.withOnOff){
|
if (levelInfo.withOnOff)
|
||||||
if(levelInfo.stepLevel256 > 0){
|
{
|
||||||
|
if (levelInfo.stepLevel256 > 0)
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_ON);
|
sampleLight_onoff(ZCL_CMD_ONOFF_ON);
|
||||||
}else if(pLevel->curLevel == ZCL_LEVEL_ATTR_MIN_LEVEL){
|
}
|
||||||
|
else if (pLevel->curLevel == ZCL_LEVEL_ATTR_MIN_LEVEL)
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pLevel->remainingTime){
|
if (pLevel->remainingTime)
|
||||||
|
{
|
||||||
sampleLight_LevelTimerStop();
|
sampleLight_LevelTimerStop();
|
||||||
levelTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_levelTimerEvtCb, NULL, ZCL_LEVEL_CHANGE_INTERVAL);
|
levelTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_levelTimerEvtCb, NULL, ZCL_LEVEL_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_LevelTimerStop();
|
sampleLight_LevelTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,23 +222,29 @@ static void sampleLight_moveProcess(u8 cmdId, move_t *cmd)
|
||||||
u32 rate = (u32)cmd->rate * 100;
|
u32 rate = (u32)cmd->rate * 100;
|
||||||
u8 newLevel;
|
u8 newLevel;
|
||||||
u8 deltaLevel;
|
u8 deltaLevel;
|
||||||
if(cmd->moveMode == LEVEL_MOVE_UP){
|
if (cmd->moveMode == LEVEL_MOVE_UP)
|
||||||
|
{
|
||||||
newLevel = ZCL_LEVEL_ATTR_MAX_LEVEL;
|
newLevel = ZCL_LEVEL_ATTR_MAX_LEVEL;
|
||||||
deltaLevel = ZCL_LEVEL_ATTR_MAX_LEVEL - pLevel->curLevel;
|
deltaLevel = ZCL_LEVEL_ATTR_MAX_LEVEL - pLevel->curLevel;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
newLevel = ZCL_LEVEL_ATTR_MIN_LEVEL;
|
newLevel = ZCL_LEVEL_ATTR_MIN_LEVEL;
|
||||||
deltaLevel = pLevel->curLevel - ZCL_LEVEL_ATTR_MIN_LEVEL;
|
deltaLevel = pLevel->curLevel - ZCL_LEVEL_ATTR_MIN_LEVEL;
|
||||||
}
|
}
|
||||||
pLevel->remainingTime = ((u32)deltaLevel * 1000) / rate;
|
pLevel->remainingTime = ((u32)deltaLevel * 1000) / rate;
|
||||||
if(pLevel->remainingTime == 0){
|
if (pLevel->remainingTime == 0)
|
||||||
|
{
|
||||||
pLevel->remainingTime = 1;
|
pLevel->remainingTime = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
levelInfo.stepLevel256 = ((s32)(newLevel - pLevel->curLevel)) << 8;
|
levelInfo.stepLevel256 = ((s32)(newLevel - pLevel->curLevel)) << 8;
|
||||||
levelInfo.stepLevel256 /= (s32)pLevel->remainingTime;
|
levelInfo.stepLevel256 /= (s32)pLevel->remainingTime;
|
||||||
|
|
||||||
if(cmd->moveMode == LEVEL_MOVE_UP){
|
if (cmd->moveMode == LEVEL_MOVE_UP)
|
||||||
if(levelInfo.withOnOff){
|
{
|
||||||
|
if (levelInfo.withOnOff)
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_ON);
|
sampleLight_onoff(ZCL_CMD_ONOFF_ON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,16 +252,21 @@ static void sampleLight_moveProcess(u8 cmdId, move_t *cmd)
|
||||||
light_applyUpdate(&pLevel->curLevel, &levelInfo.currentLevel256, &levelInfo.stepLevel256, &pLevel->remainingTime,
|
light_applyUpdate(&pLevel->curLevel, &levelInfo.currentLevel256, &levelInfo.stepLevel256, &pLevel->remainingTime,
|
||||||
ZCL_LEVEL_ATTR_MIN_LEVEL, ZCL_LEVEL_ATTR_MAX_LEVEL, FALSE);
|
ZCL_LEVEL_ATTR_MIN_LEVEL, ZCL_LEVEL_ATTR_MAX_LEVEL, FALSE);
|
||||||
|
|
||||||
if(levelInfo.withOnOff){
|
if (levelInfo.withOnOff)
|
||||||
if(pLevel->curLevel == ZCL_LEVEL_ATTR_MIN_LEVEL){
|
{
|
||||||
|
if (pLevel->curLevel == ZCL_LEVEL_ATTR_MIN_LEVEL)
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pLevel->remainingTime){
|
if (pLevel->remainingTime)
|
||||||
|
{
|
||||||
sampleLight_LevelTimerStop();
|
sampleLight_LevelTimerStop();
|
||||||
levelTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_levelTimerEvtCb, NULL, ZCL_LEVEL_CHANGE_INTERVAL);
|
levelTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_levelTimerEvtCb, NULL, ZCL_LEVEL_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_LevelTimerStop();
|
sampleLight_LevelTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,27 +291,36 @@ static void sampleLight_stepProcess(u8 cmdId, step_t *cmd)
|
||||||
levelInfo.currentLevel256 = (u16)(pLevel->curLevel) << 8;
|
levelInfo.currentLevel256 = (u16)(pLevel->curLevel) << 8;
|
||||||
levelInfo.stepLevel256 = (((s32)cmd->stepSize) << 8) / pLevel->remainingTime;
|
levelInfo.stepLevel256 = (((s32)cmd->stepSize) << 8) / pLevel->remainingTime;
|
||||||
|
|
||||||
if(cmd->stepMode == LEVEL_STEP_UP){
|
if (cmd->stepMode == LEVEL_STEP_UP)
|
||||||
if(levelInfo.withOnOff){
|
{
|
||||||
|
if (levelInfo.withOnOff)
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_ON);
|
sampleLight_onoff(ZCL_CMD_ONOFF_ON);
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
levelInfo.stepLevel256 = -levelInfo.stepLevel256;
|
levelInfo.stepLevel256 = -levelInfo.stepLevel256;
|
||||||
}
|
}
|
||||||
|
|
||||||
light_applyUpdate(&pLevel->curLevel, &levelInfo.currentLevel256, &levelInfo.stepLevel256, &pLevel->remainingTime,
|
light_applyUpdate(&pLevel->curLevel, &levelInfo.currentLevel256, &levelInfo.stepLevel256, &pLevel->remainingTime,
|
||||||
ZCL_LEVEL_ATTR_MIN_LEVEL, ZCL_LEVEL_ATTR_MAX_LEVEL, FALSE);
|
ZCL_LEVEL_ATTR_MIN_LEVEL, ZCL_LEVEL_ATTR_MAX_LEVEL, FALSE);
|
||||||
|
|
||||||
if(levelInfo.withOnOff){
|
if (levelInfo.withOnOff)
|
||||||
if(pLevel->curLevel == ZCL_LEVEL_ATTR_MIN_LEVEL){
|
{
|
||||||
|
if (pLevel->curLevel == ZCL_LEVEL_ATTR_MIN_LEVEL)
|
||||||
|
{
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pLevel->remainingTime){
|
if (pLevel->remainingTime)
|
||||||
|
{
|
||||||
sampleLight_LevelTimerStop();
|
sampleLight_LevelTimerStop();
|
||||||
levelTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_levelTimerEvtCb, NULL, ZCL_LEVEL_CHANGE_INTERVAL);
|
levelTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_levelTimerEvtCb, NULL, ZCL_LEVEL_CHANGE_INTERVAL);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleLight_LevelTimerStop();
|
sampleLight_LevelTimerStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,8 +358,10 @@ static void sampleLight_stopProcess(u8 cmdId, stop_t *cmd)
|
||||||
*/
|
*/
|
||||||
status_t sampleLight_levelCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
status_t sampleLight_levelCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
||||||
{
|
{
|
||||||
if(pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT){
|
if (pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT)
|
||||||
switch(cmdId){
|
{
|
||||||
|
switch (cmdId)
|
||||||
|
{
|
||||||
case ZCL_CMD_LEVEL_MOVE_TO_LEVEL:
|
case ZCL_CMD_LEVEL_MOVE_TO_LEVEL:
|
||||||
case ZCL_CMD_LEVEL_MOVE_TO_LEVEL_WITH_ON_OFF:
|
case ZCL_CMD_LEVEL_MOVE_TO_LEVEL_WITH_ON_OFF:
|
||||||
sampleLight_moveToLevelProcess(cmdId, (moveToLvl_t *)cmdPayload);
|
sampleLight_moveToLevelProcess(cmdId, (moveToLvl_t *)cmdPayload);
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
*/
|
*/
|
||||||
#define ZCL_ONOFF_TIMER_INTERVAL 100 //the timer interval to change the offWaitTime/onTime attribute of the ONOFF cluster
|
#define ZCL_ONOFF_TIMER_INTERVAL 100 // the timer interval to change the offWaitTime/onTime attribute of the ONOFF cluster
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL VARIABLES
|
* LOCAL VARIABLES
|
||||||
|
@ -91,25 +91,35 @@ void sampleLight_onoff(u8 cmd)
|
||||||
{
|
{
|
||||||
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
||||||
|
|
||||||
if(cmd == ZCL_CMD_ONOFF_ON){
|
if (cmd == ZCL_CMD_ONOFF_ON)
|
||||||
|
{
|
||||||
pOnOff->globalSceneControl = TRUE;
|
pOnOff->globalSceneControl = TRUE;
|
||||||
|
|
||||||
pOnOff->onOff = ZCL_ONOFF_STATUS_ON;
|
pOnOff->onOff = ZCL_ONOFF_STATUS_ON;
|
||||||
if(pOnOff->onTime == 0){
|
if (pOnOff->onTime == 0)
|
||||||
|
{
|
||||||
pOnOff->offWaitTime = 0;
|
pOnOff->offWaitTime = 0;
|
||||||
}
|
}
|
||||||
}else if(cmd == ZCL_CMD_ONOFF_OFF){
|
}
|
||||||
|
else if (cmd == ZCL_CMD_ONOFF_OFF)
|
||||||
|
{
|
||||||
pOnOff->onOff = ZCL_ONOFF_STATUS_OFF;
|
pOnOff->onOff = ZCL_ONOFF_STATUS_OFF;
|
||||||
pOnOff->onTime = 0;
|
pOnOff->onTime = 0;
|
||||||
}else{
|
}
|
||||||
if(pOnOff->onOff == ZCL_ONOFF_STATUS_OFF){
|
else
|
||||||
|
{
|
||||||
|
if (pOnOff->onOff == ZCL_ONOFF_STATUS_OFF)
|
||||||
|
{
|
||||||
pOnOff->globalSceneControl = TRUE;
|
pOnOff->globalSceneControl = TRUE;
|
||||||
|
|
||||||
pOnOff->onOff = ZCL_ONOFF_STATUS_ON;
|
pOnOff->onOff = ZCL_ONOFF_STATUS_ON;
|
||||||
if(pOnOff->onTime == 0){
|
if (pOnOff->onTime == 0)
|
||||||
|
{
|
||||||
pOnOff->offWaitTime = 0;
|
pOnOff->offWaitTime = 0;
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pOnOff->onOff = ZCL_ONOFF_STATUS_OFF;
|
pOnOff->onOff = ZCL_ONOFF_STATUS_OFF;
|
||||||
pOnOff->onTime = 0;
|
pOnOff->onTime = 0;
|
||||||
}
|
}
|
||||||
|
@ -136,25 +146,32 @@ static s32 sampleLight_OnWithTimedOffTimerCb(void *arg)
|
||||||
{
|
{
|
||||||
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
||||||
|
|
||||||
if((pOnOff->onOff == ZCL_ONOFF_STATUS_ON) && pOnOff->onTime){
|
if ((pOnOff->onOff == ZCL_ONOFF_STATUS_ON) && pOnOff->onTime)
|
||||||
|
{
|
||||||
pOnOff->onTime--;
|
pOnOff->onTime--;
|
||||||
if(pOnOff->onTime <= 0){
|
if (pOnOff->onTime <= 0)
|
||||||
|
{
|
||||||
pOnOff->offWaitTime = 0;
|
pOnOff->offWaitTime = 0;
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((pOnOff->onOff == ZCL_ONOFF_STATUS_OFF) && pOnOff->offWaitTime){
|
if ((pOnOff->onOff == ZCL_ONOFF_STATUS_OFF) && pOnOff->offWaitTime)
|
||||||
|
{
|
||||||
pOnOff->offWaitTime--;
|
pOnOff->offWaitTime--;
|
||||||
if(pOnOff->offWaitTime <= 0){
|
if (pOnOff->offWaitTime <= 0)
|
||||||
|
{
|
||||||
onWithTimedOffTimerEvt = NULL;
|
onWithTimedOffTimerEvt = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pOnOff->onTime || pOnOff->offWaitTime){
|
if (pOnOff->onTime || pOnOff->offWaitTime)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
onWithTimedOffTimerEvt = NULL;
|
onWithTimedOffTimerEvt = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +188,8 @@ static s32 sampleLight_OnWithTimedOffTimerCb(void *arg)
|
||||||
*/
|
*/
|
||||||
static void sampleLight_OnWithTimedOffTimerStop(void)
|
static void sampleLight_OnWithTimedOffTimerStop(void)
|
||||||
{
|
{
|
||||||
if(onWithTimedOffTimerEvt){
|
if (onWithTimedOffTimerEvt)
|
||||||
|
{
|
||||||
TL_ZB_TIMER_CANCEL(&onWithTimedOffTimerEvt);
|
TL_ZB_TIMER_CANCEL(&onWithTimedOffTimerEvt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,20 +207,26 @@ static void sampleLight_onoff_onWithTimedOffProcess(zcl_onoff_onWithTimeOffCmd_t
|
||||||
{
|
{
|
||||||
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
||||||
|
|
||||||
if(cmd->onOffCtrl.bits.acceptOnlyWhenOn && (pOnOff->onOff == ZCL_ONOFF_STATUS_OFF)){
|
if (cmd->onOffCtrl.bits.acceptOnlyWhenOn && (pOnOff->onOff == ZCL_ONOFF_STATUS_OFF))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pOnOff->offWaitTime && (pOnOff->onOff == ZCL_ONOFF_STATUS_OFF)){
|
if (pOnOff->offWaitTime && (pOnOff->onOff == ZCL_ONOFF_STATUS_OFF))
|
||||||
|
{
|
||||||
pOnOff->offWaitTime = min2(pOnOff->offWaitTime, cmd->offWaitTime);
|
pOnOff->offWaitTime = min2(pOnOff->offWaitTime, cmd->offWaitTime);
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pOnOff->onTime = max2(pOnOff->onTime, cmd->onTime);
|
pOnOff->onTime = max2(pOnOff->onTime, cmd->onTime);
|
||||||
pOnOff->offWaitTime = cmd->offWaitTime;
|
pOnOff->offWaitTime = cmd->offWaitTime;
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_ON);
|
sampleLight_onoff(ZCL_CMD_ONOFF_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((pOnOff->onTime < 0xFFFF) && (pOnOff->offWaitTime < 0xFFFF)){
|
if ((pOnOff->onTime < 0xFFFF) && (pOnOff->offWaitTime < 0xFFFF))
|
||||||
if(pOnOff->onTime || pOnOff->offWaitTime){
|
{
|
||||||
|
if (pOnOff->onTime || pOnOff->offWaitTime)
|
||||||
|
{
|
||||||
sampleLight_OnWithTimedOffTimerStop();
|
sampleLight_OnWithTimedOffTimerStop();
|
||||||
onWithTimedOffTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_OnWithTimedOffTimerCb, NULL, ZCL_ONOFF_TIMER_INTERVAL);
|
onWithTimedOffTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_OnWithTimedOffTimerCb, NULL, ZCL_ONOFF_TIMER_INTERVAL);
|
||||||
}
|
}
|
||||||
|
@ -220,7 +244,7 @@ static void sampleLight_onoff_onWithTimedOffProcess(zcl_onoff_onWithTimeOffCmd_t
|
||||||
*/
|
*/
|
||||||
static void sampleLight_onoff_offWithEffectProcess(zcl_onoff_offWithEffectCmd_t *cmd)
|
static void sampleLight_onoff_offWithEffectProcess(zcl_onoff_offWithEffectCmd_t *cmd)
|
||||||
{
|
{
|
||||||
//TODO: FIXED ME
|
// TODO: FIXED ME
|
||||||
|
|
||||||
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
sampleLight_onoff(ZCL_CMD_ONOFF_OFF);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +260,6 @@ static void sampleLight_onoff_offWithEffectProcess(zcl_onoff_offWithEffectCmd_t
|
||||||
*/
|
*/
|
||||||
static void sampleLight_onoff_onWithRecallGlobalSceneProcess(void)
|
static void sampleLight_onoff_onWithRecallGlobalSceneProcess(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -254,15 +277,18 @@ status_t sampleLight_onOffCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *c
|
||||||
{
|
{
|
||||||
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
||||||
|
|
||||||
if(pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT){
|
if (pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT)
|
||||||
switch(cmdId){
|
{
|
||||||
|
switch (cmdId)
|
||||||
|
{
|
||||||
case ZCL_CMD_ONOFF_ON:
|
case ZCL_CMD_ONOFF_ON:
|
||||||
case ZCL_CMD_ONOFF_OFF:
|
case ZCL_CMD_ONOFF_OFF:
|
||||||
case ZCL_CMD_ONOFF_TOGGLE:
|
case ZCL_CMD_ONOFF_TOGGLE:
|
||||||
sampleLight_onoff(cmdId);
|
sampleLight_onoff(cmdId);
|
||||||
break;
|
break;
|
||||||
case ZCL_CMD_OFF_WITH_EFFECT:
|
case ZCL_CMD_OFF_WITH_EFFECT:
|
||||||
if(pOnOff->globalSceneControl == TRUE){
|
if (pOnOff->globalSceneControl == TRUE)
|
||||||
|
{
|
||||||
/* TODO: store its settings in its global scene */
|
/* TODO: store its settings in its global scene */
|
||||||
|
|
||||||
pOnOff->globalSceneControl = FALSE;
|
pOnOff->globalSceneControl = FALSE;
|
||||||
|
@ -270,7 +296,8 @@ status_t sampleLight_onOffCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *c
|
||||||
sampleLight_onoff_offWithEffectProcess((zcl_onoff_offWithEffectCmd_t *)cmdPayload);
|
sampleLight_onoff_offWithEffectProcess((zcl_onoff_offWithEffectCmd_t *)cmdPayload);
|
||||||
break;
|
break;
|
||||||
case ZCL_CMD_ON_WITH_RECALL_GLOBAL_SCENE:
|
case ZCL_CMD_ON_WITH_RECALL_GLOBAL_SCENE:
|
||||||
if(pOnOff->globalSceneControl == FALSE){
|
if (pOnOff->globalSceneControl == FALSE)
|
||||||
|
{
|
||||||
sampleLight_onoff_onWithRecallGlobalSceneProcess();
|
sampleLight_onoff_onWithRecallGlobalSceneProcess();
|
||||||
pOnOff->globalSceneControl = TRUE;
|
pOnOff->globalSceneControl = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,10 @@
|
||||||
* LOCAL CONSTANTS
|
* LOCAL CONSTANTS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL FUNCTIONS
|
* LOCAL FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
@ -61,12 +58,10 @@ static void sampleLight_zclReportCmd(zclReportCmd_t *pReportCmd);
|
||||||
#endif
|
#endif
|
||||||
static void sampleLight_zclDfltRspCmd(zclDefaultRspCmd_t *pDftRspCmd);
|
static void sampleLight_zclDfltRspCmd(zclDefaultRspCmd_t *pDftRspCmd);
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* GLOBAL VARIABLES
|
* GLOBAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* LOCAL VARIABLES
|
* LOCAL VARIABLES
|
||||||
*/
|
*/
|
||||||
|
@ -74,7 +69,6 @@ static void sampleLight_zclDfltRspCmd(zclDefaultRspCmd_t *pDftRspCmd);
|
||||||
static ev_timer_event_t *identifyTimerEvt = NULL;
|
static ev_timer_event_t *identifyTimerEvt = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* FUNCTIONS
|
* FUNCTIONS
|
||||||
*/
|
*/
|
||||||
|
@ -90,9 +84,9 @@ static ev_timer_event_t *identifyTimerEvt = NULL;
|
||||||
*/
|
*/
|
||||||
void sampleLight_zclProcessIncomingMsg(zclIncoming_t *pInHdlrMsg)
|
void sampleLight_zclProcessIncomingMsg(zclIncoming_t *pInHdlrMsg)
|
||||||
{
|
{
|
||||||
// printf("sampleLight_zclProcessIncomingMsg\n");
|
// printf("sampleLight_zclProcessIncomingMsg\n");
|
||||||
|
|
||||||
switch(pInHdlrMsg->hdr.cmd)
|
switch (pInHdlrMsg->hdr.cmd)
|
||||||
{
|
{
|
||||||
#ifdef ZCL_READ
|
#ifdef ZCL_READ
|
||||||
case ZCL_CMD_READ_RSP:
|
case ZCL_CMD_READ_RSP:
|
||||||
|
@ -138,8 +132,7 @@ void sampleLight_zclProcessIncomingMsg(zclIncoming_t *pInHdlrMsg)
|
||||||
*/
|
*/
|
||||||
static void sampleLight_zclReadRspCmd(zclReadRspCmd_t *pReadRspCmd)
|
static void sampleLight_zclReadRspCmd(zclReadRspCmd_t *pReadRspCmd)
|
||||||
{
|
{
|
||||||
// printf("sampleLight_zclReadRspCmd\n");
|
// printf("sampleLight_zclReadRspCmd\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -158,9 +151,12 @@ static void sampleLight_zclWriteReqCmd(u16 clusterId, zclWriteCmd_t *pWriteReqCm
|
||||||
u8 numAttr = pWriteReqCmd->numAttr;
|
u8 numAttr = pWriteReqCmd->numAttr;
|
||||||
zclWriteRec_t *attr = pWriteReqCmd->attrList;
|
zclWriteRec_t *attr = pWriteReqCmd->attrList;
|
||||||
|
|
||||||
if(clusterId == ZCL_CLUSTER_GEN_ON_OFF){
|
if (clusterId == ZCL_CLUSTER_GEN_ON_OFF)
|
||||||
for(u8 i = 0; i < numAttr; i++){
|
{
|
||||||
if(attr[i].attrID == ZCL_ATTRID_START_UP_ONOFF){
|
for (u8 i = 0; i < numAttr; i++)
|
||||||
|
{
|
||||||
|
if (attr[i].attrID == ZCL_ATTRID_START_UP_ONOFF)
|
||||||
|
{
|
||||||
zcl_onOffAttr_save();
|
zcl_onOffAttr_save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,12 +174,10 @@ static void sampleLight_zclWriteReqCmd(u16 clusterId, zclWriteCmd_t *pWriteReqCm
|
||||||
*/
|
*/
|
||||||
static void sampleLight_zclWriteRspCmd(zclWriteRspCmd_t *pWriteRspCmd)
|
static void sampleLight_zclWriteRspCmd(zclWriteRspCmd_t *pWriteRspCmd)
|
||||||
{
|
{
|
||||||
// printf("sampleLight_zclWriteRspCmd\n");
|
// printf("sampleLight_zclWriteRspCmd\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn sampleLight_zclDfltRspCmd
|
* @fn sampleLight_zclDfltRspCmd
|
||||||
*
|
*
|
||||||
|
@ -197,9 +191,11 @@ static void sampleLight_zclDfltRspCmd(zclDefaultRspCmd_t *pDftRspCmd)
|
||||||
{
|
{
|
||||||
// printf("sampleLight_zclDfltRspCmd\n");
|
// printf("sampleLight_zclDfltRspCmd\n");
|
||||||
#ifdef ZCL_OTA
|
#ifdef ZCL_OTA
|
||||||
if( (pDftRspCmd->commandID == ZCL_CMD_OTA_UPGRADE_END_REQ) &&
|
if ((pDftRspCmd->commandID == ZCL_CMD_OTA_UPGRADE_END_REQ) &&
|
||||||
(pDftRspCmd->statusCode == ZCL_STA_ABORT) ){
|
(pDftRspCmd->statusCode == ZCL_STA_ABORT))
|
||||||
if(zcl_attr_imageUpgradeStatus == IMAGE_UPGRADE_STATUS_DOWNLOAD_COMPLETE){
|
{
|
||||||
|
if (zcl_attr_imageUpgradeStatus == IMAGE_UPGRADE_STATUS_DOWNLOAD_COMPLETE)
|
||||||
|
{
|
||||||
ota_upgradeAbort();
|
ota_upgradeAbort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,8 +214,7 @@ static void sampleLight_zclDfltRspCmd(zclDefaultRspCmd_t *pDftRspCmd)
|
||||||
*/
|
*/
|
||||||
static void sampleLight_zclCfgReportCmd(zclCfgReportCmd_t *pCfgReportCmd)
|
static void sampleLight_zclCfgReportCmd(zclCfgReportCmd_t *pCfgReportCmd)
|
||||||
{
|
{
|
||||||
// printf("sampleLight_zclCfgReportCmd\n");
|
// printf("sampleLight_zclCfgReportCmd\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -233,8 +228,7 @@ static void sampleLight_zclCfgReportCmd(zclCfgReportCmd_t *pCfgReportCmd)
|
||||||
*/
|
*/
|
||||||
static void sampleLight_zclCfgReportRspCmd(zclCfgReportRspCmd_t *pCfgReportRspCmd)
|
static void sampleLight_zclCfgReportRspCmd(zclCfgReportRspCmd_t *pCfgReportRspCmd)
|
||||||
{
|
{
|
||||||
// printf("sampleLight_zclCfgReportRspCmd\n");
|
// printf("sampleLight_zclCfgReportRspCmd\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -248,8 +242,7 @@ static void sampleLight_zclCfgReportRspCmd(zclCfgReportRspCmd_t *pCfgReportRspCm
|
||||||
*/
|
*/
|
||||||
static void sampleLight_zclReportCmd(zclReportCmd_t *pReportCmd)
|
static void sampleLight_zclReportCmd(zclReportCmd_t *pReportCmd)
|
||||||
{
|
{
|
||||||
// printf("sampleLight_zclReportCmd\n");
|
// printf("sampleLight_zclReportCmd\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -267,9 +260,10 @@ static void sampleLight_zclReportCmd(zclReportCmd_t *pReportCmd)
|
||||||
*/
|
*/
|
||||||
status_t sampleLight_basicCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
status_t sampleLight_basicCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
||||||
{
|
{
|
||||||
if(cmdId == ZCL_CMD_BASIC_RESET_FAC_DEFAULT){
|
if (cmdId == ZCL_CMD_BASIC_RESET_FAC_DEFAULT)
|
||||||
//Reset all the attributes of all its clusters to factory defaults
|
{
|
||||||
//zcl_nv_attr_reset();
|
// Reset all the attributes of all its clusters to factory defaults
|
||||||
|
// zcl_nv_attr_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ZCL_STA_SUCCESS;
|
return ZCL_STA_SUCCESS;
|
||||||
|
@ -279,7 +273,8 @@ status_t sampleLight_basicCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *c
|
||||||
#ifdef ZCL_IDENTIFY
|
#ifdef ZCL_IDENTIFY
|
||||||
s32 sampleLight_zclIdentifyTimerCb(void *arg)
|
s32 sampleLight_zclIdentifyTimerCb(void *arg)
|
||||||
{
|
{
|
||||||
if(g_zcl_identifyAttrs.identifyTime <= 0){
|
if (g_zcl_identifyAttrs.identifyTime <= 0)
|
||||||
|
{
|
||||||
light_blink_stop();
|
light_blink_stop();
|
||||||
|
|
||||||
identifyTimerEvt = NULL;
|
identifyTimerEvt = NULL;
|
||||||
|
@ -291,7 +286,8 @@ s32 sampleLight_zclIdentifyTimerCb(void *arg)
|
||||||
|
|
||||||
void sampleLight_zclIdentifyTimerStop(void)
|
void sampleLight_zclIdentifyTimerStop(void)
|
||||||
{
|
{
|
||||||
if(identifyTimerEvt){
|
if (identifyTimerEvt)
|
||||||
|
{
|
||||||
TL_ZB_TIMER_CANCEL(&identifyTimerEvt);
|
TL_ZB_TIMER_CANCEL(&identifyTimerEvt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,11 +307,15 @@ void sampleLight_zclIdentifyCmdHandler(u8 endpoint, u16 srcAddr, u16 identifyTim
|
||||||
{
|
{
|
||||||
g_zcl_identifyAttrs.identifyTime = identifyTime;
|
g_zcl_identifyAttrs.identifyTime = identifyTime;
|
||||||
|
|
||||||
if(identifyTime == 0){
|
if (identifyTime == 0)
|
||||||
|
{
|
||||||
sampleLight_zclIdentifyTimerStop();
|
sampleLight_zclIdentifyTimerStop();
|
||||||
light_blink_stop();
|
light_blink_stop();
|
||||||
}else{
|
}
|
||||||
if(!identifyTimerEvt){
|
else
|
||||||
|
{
|
||||||
|
if (!identifyTimerEvt)
|
||||||
|
{
|
||||||
light_blink_start(identifyTime, 500, 500);
|
light_blink_start(identifyTime, 500, 500);
|
||||||
identifyTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_zclIdentifyTimerCb, NULL, 1000);
|
identifyTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_zclIdentifyTimerCb, NULL, 1000);
|
||||||
}
|
}
|
||||||
|
@ -334,9 +334,10 @@ void sampleLight_zclIdentifyCmdHandler(u8 endpoint, u16 srcAddr, u16 identifyTim
|
||||||
static void sampleLight_zcltriggerCmdHandler(zcl_triggerEffect_t *pTriggerEffect)
|
static void sampleLight_zcltriggerCmdHandler(zcl_triggerEffect_t *pTriggerEffect)
|
||||||
{
|
{
|
||||||
u8 effectId = pTriggerEffect->effectId;
|
u8 effectId = pTriggerEffect->effectId;
|
||||||
// u8 effectVariant = pTriggerEffect->effectVariant;
|
// u8 effectVariant = pTriggerEffect->effectVariant;
|
||||||
|
|
||||||
switch(effectId){
|
switch (effectId)
|
||||||
|
{
|
||||||
case IDENTIFY_EFFECT_BLINK:
|
case IDENTIFY_EFFECT_BLINK:
|
||||||
light_blink_start(1, 500, 500);
|
light_blink_start(1, 500, 500);
|
||||||
break;
|
break;
|
||||||
|
@ -373,9 +374,12 @@ static void sampleLight_zcltriggerCmdHandler(zcl_triggerEffect_t *pTriggerEffect
|
||||||
*/
|
*/
|
||||||
status_t sampleLight_identifyCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
status_t sampleLight_identifyCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
||||||
{
|
{
|
||||||
if(pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT){
|
if (pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT)
|
||||||
if(pAddrInfo->dirCluster == ZCL_FRAME_CLIENT_SERVER_DIR){
|
{
|
||||||
switch(cmdId){
|
if (pAddrInfo->dirCluster == ZCL_FRAME_CLIENT_SERVER_DIR)
|
||||||
|
{
|
||||||
|
switch (cmdId)
|
||||||
|
{
|
||||||
case ZCL_CMD_IDENTIFY:
|
case ZCL_CMD_IDENTIFY:
|
||||||
sampleLight_zclIdentifyCmdHandler(pAddrInfo->dstEp, pAddrInfo->srcAddr, ((zcl_identifyCmd_t *)cmdPayload)->identifyTime);
|
sampleLight_zclIdentifyCmdHandler(pAddrInfo->dstEp, pAddrInfo->srcAddr, ((zcl_identifyCmd_t *)cmdPayload)->identifyTime);
|
||||||
break;
|
break;
|
||||||
|
@ -393,5 +397,3 @@ status_t sampleLight_identifyCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __PROJECT_TL_DIMMABLE_LIGHT__ */
|
#endif /* __PROJECT_TL_DIMMABLE_LIGHT__ */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#if (__PROJECT_TL_DIMMABLE_LIGHT__)
|
#if (__PROJECT_TL_DIMMABLE_LIGHT__)
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* INCLUDES
|
* INCLUDES
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +31,6 @@
|
||||||
#include "zcl_include.h"
|
#include "zcl_include.h"
|
||||||
#include "sampleLight.h"
|
#include "sampleLight.h"
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn sampleLight_sceneRecallReqHandler
|
* @fn sampleLight_sceneRecallReqHandler
|
||||||
*
|
*
|
||||||
|
@ -50,20 +48,20 @@ static void sampleLight_sceneRecallReqHandler(zclIncomingAddrInfo_t *pAddrInfo,
|
||||||
#ifdef ZCL_ON_OFF
|
#ifdef ZCL_ON_OFF
|
||||||
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
zcl_onOffAttr_t *pOnOff = zcl_onoffAttrGet();
|
||||||
|
|
||||||
pOnOff->onOff = pScene->extField[extLen+3];
|
pOnOff->onOff = pScene->extField[extLen + 3];
|
||||||
extLen += 4;
|
extLen += 4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZCL_LEVEL_CTRL
|
#ifdef ZCL_LEVEL_CTRL
|
||||||
u8 level = pScene->extField[extLen+3];
|
u8 level = pScene->extField[extLen + 3];
|
||||||
extLen += 4;
|
extLen += 4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
||||||
u8 colorMode = pScene->extField[extLen+3];
|
u8 colorMode = pScene->extField[extLen + 3];
|
||||||
u8 hue = pScene->extField[extLen+4];
|
u8 hue = pScene->extField[extLen + 4];
|
||||||
u8 saturation = pScene->extField[extLen+5];
|
u8 saturation = pScene->extField[extLen + 5];
|
||||||
u16 colorTemperatureMireds = BUILD_U16(pScene->extField[extLen+6], pScene->extField[extLen+7]);
|
u16 colorTemperatureMireds = BUILD_U16(pScene->extField[extLen + 6], pScene->extField[extLen + 7]);
|
||||||
extLen += 8;
|
extLen += 8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -77,14 +75,17 @@ static void sampleLight_sceneRecallReqHandler(zclIncomingAddrInfo_t *pAddrInfo,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
#ifdef ZCL_LIGHT_COLOR_CONTROL
|
||||||
if (colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION) {
|
if (colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION)
|
||||||
|
{
|
||||||
zcl_colorCtrlMoveToColorTemperatureCmd_t move2ColorTemp;
|
zcl_colorCtrlMoveToColorTemperatureCmd_t move2ColorTemp;
|
||||||
move2ColorTemp.colorTemperature = colorTemperatureMireds;
|
move2ColorTemp.colorTemperature = colorTemperatureMireds;
|
||||||
move2ColorTemp.transitionTime = pScene->transTime;
|
move2ColorTemp.transitionTime = pScene->transTime;
|
||||||
move2ColorTemp.optPresent = 0;
|
move2ColorTemp.optPresent = 0;
|
||||||
|
|
||||||
sampleLight_colorCtrlCb(pAddrInfo, ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_COLOR_TEMPERATURE, &move2ColorTemp);
|
sampleLight_colorCtrlCb(pAddrInfo, ZCL_CMD_LIGHT_COLOR_CONTROL_MOVE_TO_COLOR_TEMPERATURE, &move2ColorTemp);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
zcl_colorCtrlMoveToHueAndSaturationCmd_t move2HueAndSat;
|
zcl_colorCtrlMoveToHueAndSaturationCmd_t move2HueAndSat;
|
||||||
move2HueAndSat.hue = hue;
|
move2HueAndSat.hue = hue;
|
||||||
move2HueAndSat.saturation = saturation;
|
move2HueAndSat.saturation = saturation;
|
||||||
|
@ -156,9 +157,12 @@ static void sampleLight_sceneStoreReqHandler(zcl_sceneEntry_t *pScene)
|
||||||
*/
|
*/
|
||||||
status_t sampleLight_sceneCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
status_t sampleLight_sceneCb(zclIncomingAddrInfo_t *pAddrInfo, u8 cmdId, void *cmdPayload)
|
||||||
{
|
{
|
||||||
if(pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT){
|
if (pAddrInfo->dstEp == SAMPLE_LIGHT_ENDPOINT)
|
||||||
if(pAddrInfo->dirCluster == ZCL_FRAME_CLIENT_SERVER_DIR){
|
{
|
||||||
switch(cmdId){
|
if (pAddrInfo->dirCluster == ZCL_FRAME_CLIENT_SERVER_DIR)
|
||||||
|
{
|
||||||
|
switch (cmdId)
|
||||||
|
{
|
||||||
case ZCL_CMD_SCENE_STORE_SCENE:
|
case ZCL_CMD_SCENE_STORE_SCENE:
|
||||||
sampleLight_sceneStoreReqHandler((zcl_sceneEntry_t *)cmdPayload);
|
sampleLight_sceneStoreReqHandler((zcl_sceneEntry_t *)cmdPayload);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue