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.
I am trying to use Z-Stack 3.0.2 to form a ZigBee network. My intent is to send ZCL On/Off commands using the SampleSwitch and SampleLight examples. In the documentation section of the Z-Stack 3.0.2 install I am following pages 30 and 31 of the Z-Stack 3.0 Sample Application User's Guide.
I have successfully managed to pair a SampleSwitch Coordinator and SampleLight End Device together. This was done by calling :
bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_FORMATION);
on the Coordinator and:
bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING);
on the End Device using physical key switches which take the following form in the modified HandleKeys function located in the zcl_sampleapp.c file:
/********************************************************************* * @fn zclSampleLight_HandleKeys * * @brief Handles all key events for this device. * * @param shift - true if in shift/alt. * @param keys - bit field for key events. Valid entries: * HAL_KEY_UP * HAL_KEY_DOWN * * @return none */ static void zclSampleLight_HandleKeys( byte shift, byte keys ) { if (keys == HAL_KEY_UP) { bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_FORMATION); } if (keys == HAL_KEY_DOWN) { bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING); } UI_MainStateMachine(keys); }
I have captured the network traffic using the CC2531EMK dongle with TiWsPc piping the data into Wireshark. Below are the results:
Packets 1 and 2 indicate when the network was formed by the Coordinator, and packets 3 onward when network steering was initialized on the End Device. After a few seconds the devices appear to pair and there is constant network traffic which takes the form below:
On both devices there is LED 2 which flashes to indicate each device has taken the form of Coordinator and End Device according to this table:
So all in all according to what is shown from network traffic and physical hardware it appears a ZigBee network has been formed. No problem.
The problem is that I cannot seem to send any ZCL messages. I do not know why.
SampleSwitch has a function which I believe is responsible for sending ZCL commands:
void zclSampleSw_UiActionToggleLight(uint16 keys) { if (zclSampleSw_OnOffSwitchActions == ON_OFF_SWITCH_ACTIONS_TOGGLE) { if (keys & UI_KEY_SW_5_PRESSED) { zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, bdb_getZCLFrameCounter() ); } } else if (((keys & UI_KEY_SW_5_PRESSED) && (zclSampleSw_OnOffSwitchActions == ON_OFF_SWITCH_ACTIONS_ON)) || ((keys & UI_KEY_SW_5_RELEASED) && (zclSampleSw_OnOffSwitchActions == ON_OFF_SWITCH_ACTIONS_OFF))) { zclGeneral_SendOnOff_CmdOn( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, bdb_getZCLFrameCounter() ); } else { zclGeneral_SendOnOff_CmdOff( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, bdb_getZCLFrameCounter() ); } }
So I went ahead and moved the line:
zclGeneral_SendOnOff_CmdToggle ( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, FALSE, bdb_getZCLFrameCounter() );
into a function where I can call it with a physical button. When I press this button nothing happens on the network. What am I missing?
In the IAR preprocessor I have defined all required ZCL symbols... it is the barebones SampleSwitch project workspace. I have also searched this forum for solutions and swear ive been through every post.
Here is a list of things that might be the issue and I have been trying to solve
1. This is custom hardware. It uses the variant of the CC2538 with 256kB of flash memory. I have had to modify a lot of files related to memory mapping. Here is the modified linker file I am using because the one included with IAR does not work.
I have also had to modify various files such as hal_board_config.h and iocc2538.h which had incorrect memory locations for the CA Public Key, Device Private Key, IEEE address, etc.
Would there be any other memory locations that are critical for the radio functionality and may be preventing ZCL commands? Keep in mind that foundation commands are working as indicated from the Wireshark network analysis above.
2. This is custom hardware. What is interesting is that even with NV_RESTORE defined in the preprocessor, when power cycled the network state is not restored. It may seem that the NVM is not functioning properly. Would this prevent ZCL commands from being sent?
I understand that in order to write to the NVM the processor must perform a voltage level check. Setting a breakpoint after the ADC measurement indicates that it indeed is VOLT_LEVEL_GOOD.
3. When calling the ZCL On/Off command is the end point set correctly? From what I understand the SampleSwitch and SampleLight example should work by default.
Thank you.
//***************************************************************************** // // Linker configuration file for CC2538. // // Copyright (c) 2012-2013 Texas Instruments Incorporated. All rights reserved. // //***************************************************************************** // // Define a memory region that covers the entire 4 GB addressible space of the // processor. // define memory mem with size = 4G; // // Define a region for the on-chip program code space. // define region FLASH = mem:[from 0x00200000 to 0x0023C7FF]; // // Define a region for the OTA CRC structure. // //define region CRC = mem:[from 0x002001EC to 0x002001F3]; // // Define a region for the OTA Preamble structure. // //define region PREAMBLE = mem:[from 0x002001F4 to 0x002001FF]; // // Define a region for the NVIC table that is 512-byte aligned. // //define region INTVEC = mem:[from 0x00200200 to 0x002003FF]; // // Define a region for the on-chip non-volatile (NV) memory. // "HAL_NV_PAGE_CNT" pages of on-chip flash memory (originally 6 pages) are // designated for Z-Stack NV items to be stored outside program code space. // The size of this region MUST MATCH the size defined by "HAL_NV_PAGE_CNT" // in the file: hal_board_cfg.h // define region NV_MEM = mem:[from 0x0023C800 to 0x0023F7FF]; // // Define regions for on-chip factory Commissioning Parameters. // One page of on-chip flash memory (originally page 255) is designated // for various parameters to be "commissioned" outside program code space. // // Key-Establishment "Implicit Certificate" define region CP_IMPC = mem:[from 0x0023FF6C to 0x0023FF9B]; // // Key-Establishment "Certificate Authority Public Key" define region CP_CAPK = mem:[from 0x0023FF9C to 0x0023FFB3]; // // Key-Establishment "Device Private Key" define region CP_DEPK = mem:[from 0x0023FFB4 to 0x0023FFCB]; // // Device's unique 64-bit IEEE address define region CP_IEEE = mem:[from 0x0023FFCC to 0x0023FFD3]; // // Define a region for Customer Configuration Area in flash. define region FLASH_CCA = mem:[from 0x0023FFD4 to 0x0023FFDF]; // // Define the region for Lock Bits in flash. define region FLASH_LCK = mem:[from 0x0023FFE0 to 0x0023FFFF]; // // Define the region for Image Boot Manager (IBM) Ledger Page. //define region LEDGER_PAGE = mem:[from 0x0023C000 to 0x0023C7FF]; // // Define the region for Image Boot Manager (IBM) //define region BOOTLOADER_PAGE = mem:[from 0x0023F800 to 0x0023FD00]; // // Define a region for the on-chip SRAM. // define region SRAM = mem:[from 0x20004000 to 0x20007FFF]; // // Define a block for the heap. The size should be set to something other // than zero if things in the C library that require the heap are used. // define block HEAP with alignment = 8, size = 0x00000100 { }; // // Indicate that the read/write values should be initialized by copying from // flash. // initialize by copy { readwrite }; // // Indicate that the noinit values should be left alone. This includes the // stack, which if initialized will destroy the return address from the // initialization code, causing the processor to branch to zero and fault. // do not initialize { section .noinit }; // // Place the OTA CRC structure. // //place at start of CRC { readonly section .crc }; // // Place the OTA Preamble structure. // //place at start of PREAMBLE { readonly section .preamble }; // // Place the interrupt vectors. // place at start of FLASH { readonly section .intvec }; // // Place the cca area at the end of flash. // place at start of FLASH_CCA { readonly section .cca }; // // Place the commissioning parameter items. // place at start of CP_IEEE { readonly section IEEE_ADDRESS_SPACE }; place at start of CP_DEPK { readonly section DEV_PRIVATE_KEY_ADDRESS_SPACE }; place at start of CP_CAPK { readonly section CA_PUBLIC_KEY_ADDRESS_SPACE }; place at start of CP_IMPC { readonly section IMPLICIT_CERTIFICATE_ADDRESS_SPACE }; // // Place the remainder of the read-only items into flash. // place in FLASH { readonly }; // // Place the RAM vector table at the start of SRAM. // place at start of SRAM { section VTABLE }; // // Place all read/write items into SRAM. // place in SRAM { readwrite, block HEAP }; // // Place the ledger page, if it's defined // //place at start of LEDGER_PAGE { section .ledger }; //do not initialize { section .ledger }; // // Place the bootloader page, if it's defined startup_ewarm // //place at start of BOOTLOADER_PAGE { section .bootloader };
Linker file for CC2538SF23
Hi,
The switch needs to bind with the light.
In the unmodified sample application, you can see that the DEFAULT_COMISSIONING_MODE includes BDB_COMMISSIONING_MODE_FINDING_BINDING. Is there a specific reason you're not including this?
Please try the following:
// on coordinator bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING | BDB_COMMISSIONING_MODE_NWK_FORMATION | BDB_COMMISSIONING_MODE_FINDING_BINDING);
// on end device bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING| BDB_COMMISSIONING_MODE_FINDING_BINDING);
You can find more details on finding and binding by in "Z-Stack 3.0.2/Documents/Z-Stack 3.0 Developer's Guide.pdf".
The alternative is manual binding, which you can also find details on in the Developer's Guide, and some steps you can refer to are .
Regards,
Toby
YiKai Chen, I have been monitoring the network over the air with the CC2531EMK dongle using Wireshark.
Using a test command with a modified zclSampleSw_DstAddr2:
zclGeneral_SendOnOff_CmdOn( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr2, FALSE, bdb_getZCLFrameCounter());
where afAddrType_t and it's afAddrMode_t = AddrBroadcast I am able to observe a ZCL Broadcast message for the On/Off cluster. However, none of the End Devices respond to this test packet.
YiKai Chen,
In this case would it be advisable to form a network of ZC's and ZED's, then, use the :
ZDP_NwkAddrReq()
function to get the short addresses of each ZED and address them in Addr16Bit mode for ZCL commands?
Thank you,