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.

Help with Device binding using GenericApp

Other Parts Discussed in Thread: CC2530, Z-STACK

Hello everyone,

I'm using GenericApp for this project of mine and I've noticed that in order to bind two devices, we have to use the joystick given on the SmartRF05EB board. I want my network to be such that the coordinator and a router/end point must bind and start sending messages to each other automatically, without even touching the joystick. I tried doing this, by modifying the GenericApp code. I disabled all key interrupts by using HalKeyConfig() regardless of the '#if' statements, under the function InitBoard(). I then commented out RegisterForKeys() under GenericAppInit() to prevent key events from registering.

I then copied the EDP_DeviceBindReq() function call  and dstAddr addressing mode statements (Basically, everything under the "if" statement when you move the joystick to the right)  under GenericApp_HandleKeys() and pasted it in the "case" statement of ZDO_CB_MSG in GenericAppProcessEvents() function after the message processing function GenericApp_ProcessZDOMsgs. I then removed the "case" of KEY_CHANGE with GenericAppHandleKeys() function under it.

Code is compiling properly. But after I flash the respective Coordinator and Router codes onto the boards, they're not binding. The LCD shows the usual "ZigBee Coord Network ID: xxxx" on the Coordinator and Router is fine too. But they're not binding and exchanging information.

I'm using the CC2530. How do I proceed from here? Thanks in advance.

  • EDP_DeviceBindReq must be sent from both two devices. If you put EDP_DeviceBindReq under ZDO_CB_MSG in GenericAppProcessEvents() function, how can you make sure both of two devices send EDP_DeviceBindReq
  • Oh, I thought ZDO_CB_MSG was common to both Coordinator and Router. But how do I proceed with this? Where exactly should I call EDP_DeviceBindReq?
  • My suggestion is to do the followings:
    1. On router side, you can put EDP_DeviceBindReq in ZDO_STATE_CHANGE. When ZDO_STATE_CHANGE changes to router state, it means router joins Zigbee network. So, you let it sends EDP_DeviceBindReq.
    2. When a device joins Zigbee network, it will broadcast end node announcement. On Coordinator side, you can register end node announcement event. When coordinator receives a end node announcement, let coordinator sends EDP_DeviceBindReq.

    In this way, both router and coordinator will send EDP_DeviceBindReq when router joins coordinator.
  • I actually put both EDP_DeviceBindReq for Coordinator and Router in AF_DATA_CONFIRM_CMD and it works.

    But, I have three questions:
    1)Exactly which part of the code is the code for end node announcement?
    2)I want to have these two boards running perpetually forever. So, my question is, since the boards are sending information to each other, it'll take up a lot of memory eventually, right? I need a way to delete the old data after some point to make space for new data to be received. How can I do this?
    3)If the present coordinator goes offline, I need a way to assign a new coordinator for my network. How can I modify the GenericApp code to achieve this?
  • 1. You have to put ZDO_RegisterForZDOMsg(task_id, Device_annce) in your zclXXX_Init and add if(pMsg->clusterID == Device_annce){...} in zclXXX_ProcessZDOMsgs to process it.
    2. This is about your application so I think you should know better how to free memory before it goes full or overwritten.
    3. If a Zigbee coordinator is off line, a Zigbee router can keep work alone. I don't know how to switch coordinator.
  • In reference to answer '1', which file do you find zclXXX_ProcessZDOMsgs in?
    And in reference to 2, in general, if you want to erase only data without affecting the program code, how do you accomplish that?

  • 1. Since you use GenericApp, you should put "case Device_annce:" in GenericApp_ProcessZDOMsgs to process end node announcement.
    2. I am confused by your questions. erase only data without affecting the program code? Do you mean to erase NV flash data?
  • As in, if I'm using GenericApp, suppose I want to send sensor values to the board. Will it get stored? Or will it keep getting overwritten?
    If it is getting stored, won't the memory run out eventually? And if it does, how do I erase the old sensor values to make space for the new sensor values?
  • It will be overwritten.
  • Okay, thank you, it works fine now. I have one last question. I'm trying to poll UART and send the serial data from the hyperterminal and through the EB, I want to send it wirelessly to another EB and into another hyperterminal. All this, without the help of Z-Tool.
    To achieve this, I included the HAL_UART and HAL_DMA in the preprocessor. So, it should automatically poll the UART, right? To send the data, theMessageData which was originally "Hello World", I replaced "Hello World" with U0DBUF, since this is the default UART buffer for HAL_UART_DMA == 1, and changed the data type to unsigned char. And in the call to AF_DataRequest() under GenericAppSendTheMessage(), I replaced the original "len" parameter (byte)osal_strlen(TheMessageData) + 1; and I put (byte)(2*sizeof(TheMessageData) + 1.

    Everything is compiling fine. But I haven't tried out the code yet interfacing with a hyperterminal. Will this work properly? Because I realize that the board will need to receive and transmit as well using the same buffer. Will there be a conflict between the received data and yet to be transmitted data? And how do I prevent them from overwriting each other?
  • GenericApp uses MT commands which is in hex format. I think you will have problem using hypertermainal to send MT commands. You can refer to Z-Stack Monitor and Test API.pdf for MT command details.
  • Do MT commands include sensor data? I'm not interested in Monitor or Testing. I want to send only simple data from a device which uses UART to give it to the board. And then the board sends these sensor values to the other board, this other board after receiving the data sends it to a device it is connected to, through UART for it to have some kind of response. So basically, these two boards keep sending information to each other. Is there a way I can do this?
  • MT command is a command set that allows you to communicate with TI Z-Stack. You can use AF_DATA_REQUEST in section 3.2.1.2 of Z-Stack Monitor and Test API.pdf to send sensor data through UART from sender and receiver side will receive sensor data by AF_INCOMING_MSG in section 3.2.1.3.