This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530: ZigBee 1.2 Sending ZCL command

Part Number: CC2530
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








  • Hi,

    The post YK referenced is the preferred way to command remote devices to change channel.

    Note that a reset of the device is not necessary for a channel change.

    Regards,
    Toby

  • Part Number: CC2530

    Dear Sir.

    I am taking over my ex-workmate Zigbee projects, which is using ZigBee 1.2 CC2530 chipset.

    Our product is lighting project.

    I am new to ZigBee.

    Firstly, I'd like to add our own command to set default channel in individual end devices. 

    So, I tried to make it simple by modify on top of Toggle command

    In first step, I add my manuCode.


    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 the manuCode is not equal to 0.

    Please advance and comment how to add my manufacture command.


    Thanks for help in advance


    Regards,

    Billy

  • Hi Toby,

    Thanks for answer, but I have to follow the old project use cases defined by Customer.

    At this moment, they assigned each device to have fixed one channel (default channel).  However, in real case, they are suffer from the problem in re-assign the fixed default channel to some device after installation.

    So, I am writing to ask help seeking for whether I can use manuCode (our own Manufacture command to set remote channel)

    I tried, by modifying current ZCL commands, such as ZCL_CLUSTER_ID_GEN_ON_OFF, COMMAND_OFF_WITH_EFFECT with setting the manuCode = 0

    It works fine.  But if I set the manuCode to 0x1234.  I can't receive it.  The callback function defined in Lighting tube is not called.

    Here is my testing codes.

    if (zclSampleSw_OnOffSwitchActions == ON_OFF_SWITCH_ACTIONS_SET_CHANNEL)
    {
    if (keys & UI_KEY_SW_5_PRESSED)
    {
    uint16 manuCode = 0;
    uint8 cmd[2] = {0x23, 15};
    uint16 cmdFormatLen = sizeof(cmd)/sizeof(uint8) ;
    uint8 *cmdFormat = cmd;

    zcl_SendCommand( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, ZCL_CLUSTER_ID_GEN_ON_OFF, COMMAND_OFF_WITH_EFFECT, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR, FALSE, manuCode, bdb_getZCLFrameCounter(), cmdFormatLen, cmdFormat);
    }

    Thanks

    Regards,

    Billy 

  • Do you check if zcl_SendCommand returns success after it is called?

  • Hi Billy,

     has done some work for incorporating manufacturer-specific commands into Z-Stack that you may benefit from: https://e2e.ti.com/search?q=manufacturer%20specific&category=forum&group=341 

    Regards,
    Ryan

  • The ZCL allows the manufacturer to extend the functionality of standard clusters.

    However, since this must be implemented per manufacturer, you would need to add functionality to the current zcl files as necessary. Otherwise, the device receiving the manufacturer specific command will not pass this command to the application layer (eg. the lighting tube callback).
    If you use a sniffer, you will likely see this behavior (the manuspecific command is still sent, but the receiving device will send a default response indicating "unsupported command").

    Again, it is possible to use MT_ZdoMgmtNwkUpdateRequest to update the channel (use ScanDuration 0xFE and set ScanChannels to the desired channel). 

    You can refer to the related E2E discussion that Ryan shared to see how handling of manufacturer specific commands can be added.

  • Per TI's Online Terms of Use: https://www.ti.com/legal/terms-of-use.html, commercial solicitation is not permitted on E2E support forums.

    As such, I am about to delete the previous post.  Continued violation of these terms may result in being banned from these forums.

    -Jim

    Manager, Online Support

    Texas Instruments

  • On_off_toggle command is a no-payload command, don't try to fill payload in it.

    If you want to control more than one lights in a node, the other lights can be located at other endpoint. In Z-stack, device's default endpoint is '8', you must change it.