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: more details of znp and zigbee for beginners

Part Number: CC2530
Other Parts Discussed in Thread: Z-STACK,

Hi friends

I have started to working with znp through uart, i have read "Developing a ZigBee® System Using a CC2530-ZNP Approach" and "Z-Stack Monitor and Test API" documents but still don't understand some things and how to set some configs by znp command, i think i need more details of znp commands, as very simple example in " ZB_WRITE_CONFIGURATION -> ZCD_NV_LOGICAL_TYPE" there are 2 bytes i should use to define logical type but i don't know what number should I set to set coordinator and what numbers for router and etc. and ever more details about ZB_WRITE_CONFIGURATION itself, where can i see what does numbers mean and in responses what does each number say! some of them are in z-stack monitor and test document but with very low details!! and my other problem is that i don't understand some general zigbee definitions too, for example I don't know what should i do with app id, device id, NOIC, commissioning cluser ... and how to set them. 

In general I need to make simple zigbee network and i found using host mcu and znp through uart is simple way but i need more details and understanding to try it. what should i read to get more general understanding of main zigbee stuff i need to know to work with znp? i made my own breakout board by cc2530 and mcu, i have connected them and cc2530 znp works properly but i need more understanding than just 3 znp documents.

Regards 

  • I found this link usefull to understand some important zigbee definitions, do you know some other good sources to give some general view to zigbee?

    http://www.informit.com/articles/article.aspx?p=1409785&seqNum=8

    +Does znp uses zigbee pro or not?

    Thanks

  • Hi Navid,

    With the release of ZigBee 3.0, The ZNP Interface Specification document was updated to include more information about the software command interface. Please see Section 3 in this document. In addition, the Z-Stack 3.0 Developer's Guide has a lot of useful information about the basics of setting up a ZigBee network.
  • what difference between using NV_RESTORE and not using it on compiler defines? I know it cause that some network settings load from NV memory after repowering the chip, but what are those? something like PAN ID, TC link key and ...? can somebody tell me all of them please?
    and I see on nwkglobals.h these codes:
    -----
    // ZigBee Alliance Pre-configured TC Link Key - 'ZigBeeAlliance09' (for Centralized networks)
    #define DEFAULT_TC_LINK_KEY { 0x5a, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6c,\
    0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x30, 0x39 }
    -----
    but i never see this code on my devices, what znp command should i use to check it?
    Regards
  • NV_RESTORE ENABLE would keep all of network information into NV such as PAN ID, channel, network key, short address... TC link key is applied to encrypt network key while device joins network and exchange network key first time. This is handled by Z-Stack and application developers don't have to handle it.
  • Thanks again YiKai
    So what is "ZB_WRITE_CONFIGURATION -> ZCD_NV_TC_LINK_KEY" for in znp development documentation?

    what does "ZB_WRITE_CONFIGURATION -> ZCD_NV_STARTUP_OPTION " do if NV_RESTORE automatically restores those data?

    can you tell me which one of them should be set on coordinator and which one should be set on Router and ED? I know short address of ZC is zero and short address of Router is random number and changes each time, IEEE is constant for each device, but what about network key and PAN ID? usually i see PAN ID is zero in default, but if we want to change it we should change just on coordinator or on Router too?
    I'm not clear with setting network key !!

    sorry YiKai for much questions!!

  • 1. You can use "ZB_WRITE_CONFIGURATION -> ZCD_NV_TC_LINK_KEY" to overwrite the default TC Link key on ZNP.
    2. PAN ID is assigned by ZC when ZC scan channel and form a Zigbee network. There is a default network key on ZNP too. If you want to change PAN ID or network key, you should change it on coordinator.
  • what does "ZB_WRITE_CONFIGURATION -> ZCD_NV_STARTUP_OPTION " do if NV_RESTORE automatically restores those data?
    So i don't need to change PAN ID and network key on Router right? and changing them on Coordinator is optionally too?
  • 1. If you use 0x3 in ZB_WRITE_CONFIGURATION -> ZCD_NV_STARTUP_OPTION, it will clean NV data when power recycle next time. When you enable NV_RESTORE, the NV data would restore to your application automatically.
    2. Yes, you don't need to change PAN ID and network key on Router right. And, changing them on Coordinator is optional.
  • Thanks very much YiKai you are awsome man :)
    can somebody tell me where can i find more details of "APP_CNF_BDB_COMMISIONING_NOTIFICATION" ? maybe one header file depands on it!! ( I think somebody is YiKai agan!! ) ;)

    and one other question, where should i set PRECFGKEY? is it optional too? how can i check it while network is running?

    Regards

  • You can check MT_AppCnfCommissioningNotification in bdb_event_loop() for more details of "APP_CNF_BDB_COMMISIONING_NOTIFICATION".
  • Hi YiKai
    what if i want to develope zigbee without any external MCU and znp? is it much more difficault for me to write my application to IAR zstack 3.0? I mean if i want to use cc2530 itself!
  • I don't think it will be difficult. I usually do it in this way and don't use ZNP.
  • how should i start on that way to do a simple task like i did with znp ( make somple ZC and ZED or ZR network and send some byte )?
    where to start and what more should i read?
    Regards
  • I suggest you to start from SampleLight and SampleSwitch examples. Use IAR to build SampleLight as coordinator and SampleSwitch as end device to make them communicate to each other. There's sample user guide and developer guide in Z-Stack 3.0 document folder.
  • Whats "SYS_SET_TX_POWER" default value for z-stack 3.0 for CC2530? I found this value can get 1 byte data, but as CC2530 datasheet, it's max TX power is 4.5 dbm, so how should i set float number to byte? how can i set it to max value ( 4.5 ). or maybe z-stack changes it to max power when it needs?!!
  • Default TX power is 0 dbm. If you want to change it to 4.5 dbm by default, you can set the first element (label as /* tramsmit power level of the first entry */ in the following example) of macRadioDefsTxPwrBare [] in mac_radio_defs.c from 3 to 0.

    const uint8 CODE macRadioDefsTxPwrBare[] =
    {
      3,  /* tramsmit power level of the first entry */
      (uint8)(int8)-22, /* transmit power level of the last entry */
      /*   3 dBm */   0xF5,   /* characterized as  4.5 dBm in datasheet */
      /*   2 dBm */   0xE5,   /* characterized as  2.5 dBm in datasheet */
      /*   1 dBm */   0xD5,   /* characterized as  1   dBm in datasheet */

  • Thanks YiKai

    I should change it from 3 to 0 to get 4.5 dBm?!!! are you sure? do you mean setting it to 3 will cause 0 dBm and setting to 3 will cause 4.5 dBm?! something like enum?!

    What if i don't want to change default value? I can change it after powerup right? should i send 0 to set 4.5 dBm with "sys_set_tx_power" ? 

    How much difference will be between 0 and 4.5 dBm with onboard antenna in action?! what a general question!!

    Regards

  • Yes, it's like enum. It should be setting it to 3 will cause 0 dBm and setting to 0 will cause 4.5 dBm. Yes, you can set it after power up using sys_set_tx_power with parameter=4 would set it to 4.5 dbm.
  • What command should i use with z-stack 3.0 znp to get new device list of coordinator? when I have 2 end device i see them by utill_get_device_info, but when i power off one of those ED and get util_get_device_info, it still shows 2 device but realy it's just one device, is there any command to find real devices on the moment? how coordinator should check which ZED and ZR are connected at the moment?
    Regards
  • utill_get_device_info only returns the items on association list. If you intend to know ZED and ZR are connected at the moment, you can send active endpoint requests periodically to all of ZED and ZR had joined ZC. If ZC get response from ZED or ZR, it's connected at the moment. Otherwise, it's not.
  • I have new questions :)
    1- we found coordinator doesn't show Routers on number of device associated when we get util device info, how we should count number of Routers are connected to coordinator? I need a network with one coordinator and more than 10 routers that some are directly connect to ZC and some other to other ZR, but i don't now how should i look for them on my coordinator in znp and how to manage them!
    2- I understand when ZED losts it's parent a message from znp come to my mcu just after parent lost, and i use it to find new parent or etc, but when Router lost parent it doesn't give me any message!! how should i check if my Router is connected to it's parent ( usually ZC ) ? should i check it frequently? how should we do this in znp?
  • 1. In Z-Stack 3.0, ZR won't be listed on association list so you cannot get number of ZR count by using util device info.
    2. There is no parent-child relation on a ZR node. In Zigbee spec, ZR is designed to work without ZC after it joins a Zigbee network.
  • Hi YK,

    In Z3.0, routers are put in the association table of the parent device that it joins through. In 1.2.2a there was a bug that prevented routers from being removed from the association table if they were no longer connected to that parent, so the change in Z3.0 is that routers can now be "aged out" of association (and neighbor) tables, based on how many link status periods a parent device misses from any router in its association table. The default route age (i.e. max number of link statuses allowed to be missed) is 3, defined by NWK_ROUTE_AGE_LIMIT, and based on the uncertainty of when in a 15 second period you will receive a link status message, devices will be removed at a maximum of 15*(NWK_ROUTE_AGE_LIMIT + 1) seconds.

    Another thing to note is the difference between the association table and the neighbor table on a ZC/ZR device. The association table is for devices that have joined through this parent directly, i.e. child end devices or routers that haven't been aged out. The neighbor table is for devices that are within radio range of this device but are not a direct child, i.e. devices are added to this table on a routing device if a link status messaged is received that came from another device that is not in its association table.

    For example, if a router A joins through coordinator C, A will be in the association table of C initially. Then if A is turned off, C will remove A from its association table after ~60s. Then, if A had NV restore enabled and it is turned back on, C will put A in its neighbor table once A starts sending link status messages again. Then, if A is turned off again, C will remove A from its neighbor table after ~60s.
  • @JasonB Thanks for detail explanations. However, I do see router is listed on association list when I test ZNP in Z-Stack and use steps in sunmaysky.blogspot.tw/.../use-ztool-z-stack-30-znp-to-set-up.html . When a ZR joins ZC, I send UTIL_GET_DEVICE_INFO to ZC and see NumAssocDevices is still 0. Can you verify this?
  • I do the test to join a ZR to ZC again and the followings are ZTOOL console of ZC. As you can see, ZR 0x7472 joins ZC but I don't see it listed on Association table when I issue UTIL_GET_DEVICE_INFO or ZDO_IEEE_ADDR_REQ to ZC. If you are correct about ZR would show on ZC's association list, NumAssocDevices shouldn't be 0. Can you verify this?

    <RX>01:46:53.55 COM1 ZDO_END_DEVICE_ANNCE_IND (0x45C1)
    SrcAddr: 0x7472
    NwkAddr: 0x7472
    IEEEAddr: 0x00124B0000E5003E
    Capabilities: 0x8E

    <TX>01:47:03.07 COM1 UTIL_GET_DEVICE_INFO (0x2700)

    <RX>01:47:03.08 COM1 UTIL_GET_DEVICE_INFO_RESPONSE (0x6700)
    Status: SUCCESS (0x0)
    IEEEAddr: 0x00124B0001025822
    ShortAddress: 0x0000
    DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
    DeviceState: DEV_ZB_COORD (0x9)
    NumAssocDevices: 0x00
    AssocDevicesList

    <TX>01:47:30.26 COM1 ZDO_IEEE_ADDR_REQ (0x2501)
    ShortAddr: 0x7472
    ReqType: SINGLE_DEVICE_RESPONSE (0x0)
    StartIndex: 0x00

    <RX>01:47:30.27 COM1 ZDO_IEEE_ADDR_REQ_SRSP (0x6501)
    Status: afStatus_SUCCESS (0x0)

    <RX>01:47:30.3 COM1 ZDO_IEEE_ADDR_RSP (0x4581)
    Status: ZDP_SUCCESS (0x0)
    IEEEAddr: 0x00124B0000E5003E
    NwkAddr: 0x7472
    StartIndex: 0x83
    NumAssocDev: 0x00
    AssocDevList

    <TX>01:47:42.54 COM1 ZDO_IEEE_ADDR_REQ (0x2501)
    ShortAddr: 0x0000
    ReqType: SINGLE_DEVICE_RESPONSE (0x0)
    StartIndex: 0x00

    <RX>01:47:42.55 COM1 ZDO_IEEE_ADDR_REQ_SRSP (0x6501)
    Status: afStatus_SUCCESS (0x0)

    <RX>01:47:42.56 COM1 ZDO_IEEE_ADDR_RSP (0x4581)
    Status: ZDP_SUCCESS (0x0)
    IEEEAddr: 0x00124B0001025822
    NwkAddr: 0x0000
    StartIndex: 0x00
    NumAssocDev: 0x00
    AssocDevList

    <TX>01:47:55.17 COM1 ZDO_IEEE_ADDR_REQ (0x2501)
    ShortAddr: 0x7472
    ReqType: SINGLE_DEVICE_RESPONSE (0x0)
    StartIndex: 0x00

    <RX>01:47:55.19 COM1 ZDO_IEEE_ADDR_REQ_SRSP (0x6501)
    Status: afStatus_SUCCESS (0x0)

    <RX>01:47:55.21 COM1 ZDO_IEEE_ADDR_RSP (0x4581)
    Status: ZDP_SUCCESS (0x0)
    IEEEAddr: 0x00124B0000E5003E
    NwkAddr: 0x7472
    StartIndex: 0x00
    NumAssocDev: 0x00
    AssocDevList

    <TX>01:48:13.68 COM1 UTIL_GET_DEVICE_INFO (0x2700)

    <RX>01:48:13.69 COM1 UTIL_GET_DEVICE_INFO_RESPONSE (0x6700)
    Status: SUCCESS (0x0)
    IEEEAddr: 0x00124B0001025822
    ShortAddress: 0x0000
    DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
    DeviceState: DEV_ZB_COORD (0x9)
    NumAssocDevices: 0x00
    AssocDevicesList
  • Thanks friends for your complete answers, I have NumAssocDevices = 0 when i send util_get_device info on ZC, however ZR is connect and they can transfer data to each other!!
  • Let's wait Jason to verify this.
  • Hi Jason, do you have any update about if ZR should show in association list in Z-Stack 3.0?
  • Hi YK,

    It turns out that even if routers are in the association table, UTIL_GET_DEVICE_INFO intentionally ignores router devices and only returns any end devices that are in the association table. The function used in this command to return the association table is also used by ZDP_NwkAddrReq in some cases, and the ZigBee spec mandates here that this list only includes end devices, hence the exclusion of routers.

    I see now that this is misleading, we will take this into consideration for the next release. We will need to add MT command(s) that provide lists of devices in the association and neighbor tables. At the moment, the only work around available through MT is the following explained here, basically reading the association table from NV and parsing it:
    e2e.ti.com/.../1992352
  • I see. I have try to use ZCD_NV_DEVICE_LIST to read device list and I can see ZR listed on it.
  • Thanks friends but I didn't understand finally what MT commands should i use to see if all routers are in network!! I need a ZC and about 20 ZR which some ZRs are not in range of ZC and will connect to ZC through other Routers, I should take care of all routers to be in network because ZC should send server commands to all Routers and ZC should check network to see if one of Routers or more of them is not available!
  • You can use SYS_OSAL_NV_READ with NV ID 0x22 to get device list and would see router is listed on it.
  • Thank YiKai two new question about your answer:
    1- can i use it on both ZC and ZR? or just ZC?
    2- does it give real time data? ie i have 20 Routers and i see them by means of SYS_OSAL_NV_READ than on of them removes from network for any reason, 10 seconds later I use SYS_NV_READ again, am i see 19 devices this time?
    Regards
  • 1. Yes, you can use it on both ZC and ZR.
    2. Yes, it's real time data.
  • Thanks YiKai
    Yesterday i have connect one Router to my Coordinator, and i have used "SYS_OSAL_NV_READ" with NV ID 0x22, i got the address of Router from NV. after that i have disconnected both Router and coordinator, now after 1 day i connect my coordinator and read it's nv id0x22 again and still it shows address of that Router from yesterday. as i understand from Jason posts, coordinator needs 1 minute to remove address of Routers that disconnect from network, so what should i do now? is it still will remove it after one minute? or I should remove whole nv? are you sure in znp coordinator will remove Routers id when it disconnects from network after 1 minute?!
  • I have wait now more than one minute and after restart and power off it still has that address on nv, I think i should manualy remove last address, but how can i find if some device is disconnected from network when it doesn't remove it and util_get_device_info doesn't shows Routers too!
  • You should turn off router and check device list of coordinator a while later. If you turn on router again, it would be added to device list again. You should keep router off.
  • Thanks a lot YiKai I did it and it removed that address after one minute. this process is not exactly what i need but can work!
    one other thing that is not clear for me is that when Routers and End Devices want to join network they get new random short address which all devices use these short addresses to send data and etc on zigbee. however they have fixed long address too. my problem is when all devices go power off and they want to join new network again, each device get new address again, so if i have a system like valve control network i don't know which new short address is for which vale now!! I think i should use long address that is fixed address to find which device has what short address!! short address is random but my valves has special task and fix place, how should i understand which new short address is for which device! i think i should find a relation between random short addresses and device long addresses but i don't know how?!!
    I hope you understand what i mean!!
  • If you don't do the following step to clear NV , the short address should not change after power recycling or reset.

    10:36:58.53 COM1 SYS_OSAL_NV_WRITE (0x2109) --> Write startup option to clear NV when reset
  • I think usually maybe need to clear nv and short address but still need to know special device!! maybe there is other way to find relation between device short address and long address or some way to maually define short address for special device by knowing it's long address?! for example i know long address of device for kitchen lamp, is there any way to give it special short address after it joins network?! anyway to define short address relative to long address in startup process?
  • Short address is assigned by Z-Stack and your application cannot assign it. If you know long address, you can use API ZDP_NwkAddrReq to request device short address.
  • can i do this using znp MT commands?!

    is it "ZDO_NODE_DESC_REQ" ?

  • so which command is for this task?!!
  • You can use ZDO_NWK_ADDR_REQ to do this.
  • After someday i was busy i'm backed on my zigbee work, My coordinator is up and Router is connect to it with known short address, after Router power of and joining again, if it's less than 1 minute it's short address doesn't change, but if it's more than one minute however coordinator is running, Router will get new short address, as i checked by coordinator nv_read with id 0x22, short address of Router removes after 1 minute of it's disconnect from ZC ( as jason said too ) and now it joins again with different address. but i don't want this address changing!! as you said i should avoid using nv_startup_option on my Router, but if i don't use it on Router it'll not join to coordinator!!
  • If you don't use nv_startup_option on your Router, how do you know it doesn't connect to coordinator after power recycle?
  • I send data to it's last short address but it doesn't receive anything, and in other way when ZC tries to get zdo network short address of that Router by use of it's long address it doesn't receive anything!
  • Hi Navid,

    You can send nwk address request as a broadcast, this way all the devices will relay this frame until it reaches the intended device or anyone that can answer on behalf of the intended device.

    Hope this helps!