Other Parts Discussed in Thread: Z-STACK
Dear Sir,
I am taking over my ex-workmate ZigBee projects. It is old code and developed several years ago, which is ZigBee 1.2, CC2530 (8051 chips) .
Our product have Zigbee Hub server, lighting tube & switch device.
Normally, Hub server is co-coordinator, lighting tube is router and switch is end device
We'd like to add remote set default channel command in our product.
For example, after the lighting tube join the network which is channel 13, we'd like to send command to force it switch to default channel 15 and reset.
For simple testing, I use the simple ZCL General Cluster Library On/Off command for testing
// In zcl_samplelight.c
static void zclSampleLight_OnOffCB( uint8 cmd )
{
.......
if ( cmd == COMMAND_TOGGLE )
{
//Tested by Billy, 2020-02-07
zgDefaultChannelList = 0x00008000; // 15 - 0x0F
osal_nv_write( ZCD_NV_CHANLIST, 0, sizeof(zgDefaultChannelList), &zgDefaultChannelList );
zclSampleLight_BasicResetCB();
}
}
void NV_init(void)
{
//Addded by Billy, 2020-02-05
if (osal_nv_item_init(ZCD_NV_CHANLIST, sizeof(zgDefaultChannelList), NULL ) == NV_ITEM_UNINIT)
{
osal_nv_write( ZCD_NV_CHANLIST, 0, sizeof(zgDefaultChannelList), &zgDefaultChannelList );
}
else
{
osal_nv_read( ZCD_NV_CHANLIST, 0, sizeof(zgDefaultChannelList), &zgDefaultChannelList );
}
}
The above codes work fine. I can set & switch the default channel, then re-join the new network by using new default channel.
Then, I want to move to next step, but I got few questions and problems.
1. Does Zigbee has standard command for remote configuration or setting the default channel and reset?
2. If Q1 answer is negative (No), should I use write attribute commands? Do you have any reference sample code and documents?
3. In addition, I tried to make Toggle command to be proprietary extensions by using manuCode to overcome above issue.
Here is my codes in switch device
if (zclSampleSw_OnOffSwitchActions == ON_OFF_SWITCH_ACTIONS_TOGGLE)
{
if (keys & UI_KEY_SW_5_PRESSED)
{
uint16 manuCode = 1234;
//uint16 cmdFormatLen;
uint8 cmd[3] = {0x23, 0x45, 15};
uint16 cmdFormatLen = sizeof(cmd)/sizeof(uint8) ;
uint8 *cmdFormat = cmd;
zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, manuCode, bdb_getZCLFrameCounter(), cmdFormatLen, cmdFormat);
//zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, manuCode, bdb_getZCLFrameCounter(), 0, NULL);
}
}
It does not work.
I am not sure whether the command cannot be sent by switch device or the light tube does not call the zclGeneral_ProcessInOnOff() because of manuCode not equal to 0.
Please advance and comment.
Thanks for help in advance
Regards,
Billy