I am new to Ti Z-Stack. I start of writing a simple application:
1. I set ZCD_NV_PANID to be 0xFFFF, which means dynamically create a PANID.
2. I set ZCD_NV_CHANLIST to include all channels, which means I want the device to scan all channels to find the best one.
3. I set ZCD_NV_APS_USE_EXT_PANID to be a valid extended id.
4. I set ZCD_NV_LOGICAL_TYPE to be coordinator to start the network.
5. I start the network by calling zb_StartRequest()
6. Network is started successfully and zb_StartConfirm is called.
Now my question is how can I find out what PANID that the network is using and which Channel it is on??
Try to check zgConfigPANID, zgApsUseExtendedPANID, and zgDefaultChannelList after your ZB network is composed.
In zb_StartConfirm() function, I checked those values: zgConfigPANID, zgApsUseExtendedPANID, and zgDefaultChannelList. They are the same values as what I set to NV.
For example, zgConfigPANID is 0xFFFF, and zgDefaultChannelList is 0x7FFF800. They do not tell me what channel and PANID the device picks for the network...
Did I check them in the wrong function?
I need to know after CC2530 successfully starts the network, what channel and PANID it picks...
You should check it after you receive ZDO_STATE_CHANGE and ( (XXX_NwkState == DEV_ZB_COORD) || (XXX_NwkState == DEV_ROUTER) || (XXX_NwkState == DEV_END_DEVICE) ) inside zclXXX_event_loop(), which should be located in your zcl_XXX.c.
That is what I did. My application is based on Sensor Demo applicaton. zb_StartConfirm() is called when ZDO_STATE_CHANGE and iif(pMsg->status == DEV_END_DEVICE || pMsg->status == DEV_ROUTER || pMsg->status == DEV_ZB_COORD ) is TRUE.
As I mentioned, in zb_StartConfirm() I check zgConfigPANID, zgApsUseExtendedPANID, and zgDefaultChannelList. And they are the same value as what I initially set. They do not have the values to indicate which PANID and channel is picked by the stack...
However, I did find out that global variable _NIB contains the correct information. But I wonder should I directly check _NIB structure in zb_StartConfirm()??? And I cannot find any code that modifies the variable, but it does get updated.... Wonder where is the code that updates the variable???
In addition, ZCD_NV_NIB does not contain all the data of _NIB, wonder why is that???
Yes, you can read these information from _NIB. By the way, ZCD_NV_NIB only stores the short address of device and I also have no idea why TI only stores short address.
Actually I am still confused...
After the network is started, does "nwkLogicalChannel" in _NIB have the value that is the channel picked by Z-Stack?
What is "channelList" in _NIB? After the network is started, why does it have a different value (i.e. 0x00300000) than the one I saved to ZCD_NV_CHANLIST (i.e. 0x07FFF800)?
Can anybody help?
ZMAC to the rescue and Hi, Ho Silver, Away!
#include "ZMAC.h" #include "zmac_internal.h"
uint8 currChannel; (void)ZMacGetReq(ZMacChannel, &currChannel);
Thanks for your help! It works!!! Now I can continue explore ZigBee using CC2530!
One more question: I can not find that API in any document (i.e. Z-Stack API reference only has two ZMac API listed ). Is there a document that will list and explain all ZMac APIs?
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.