Hi,I´m studying the Home Automation Profile in Zigbee Stack.In fact I´m having some troubles to undertand the "Sample Light" and "Sample Switch" examples.To send a data I have used the function:AF_DataRequest(&dstAddr, srcEPT, ZCL_CLUSTER_ID_GEN_ON_OFF, 1, buffData, buffTransID, AF_DISCV_ROUTE, AF_DEFAULT_RADIUS);Am I right?I saw, with a packet sniffer, that the other device has ansewred with a ACK, but how can I use the received data on this device?My goal is: When I press a button on device 1, for example, I wanna see that a LED on device 2 goes ON.Which functions I have to use to send/receive data?Regards.
Hi,
You can use zclGeneral_SendOnOff_CmdOn and zclGeneral_SendOnOff_CmdOff to send this HA command.
Regards!
YK Chen
Thanks YK Chen, it works.Now I´m trying to send Data as you said in the other post. "There is no standard command to send current and voltage levels. You can define your proprietary ZCL_CLUSTER_ID/ATTRID and use zcl_SendReportCmd() to send out current /voltage levels."By the way, to send secured messages i´ve set:- zgPreConfigKeys=TRUE (ZGlobals.c)- -DDEFAULT_KEY=..... (f8wConfig.cfg)- -DSECURE=1 (f8wConfig.cfg)I´ve tryed diferent Keys for different devices. I´d expected that the command doesn´t pass from one device to another. But, even with different keys, it has worked.
Do you have any suggestion to enable secured mode?
Regards.
It's great to hear that your project works fine. For security mode, we enable it in our project and there is one thing you need to know. Change -DDEFAULT_KEY in f8wConfig,cfg is not enough. TI has hard code defaultKey in nwk_globals.c so you also need to change defaultKey. I have no idea why TI keeps this obvious bug from very old Z-Stack version.
Hi YiKai,
For defalutKey I can use/change the default key in f8wConfig.cgf:
-DDEFAULT_KEY="{0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0D}"
If DEFAULT_KEY is defined it will be used in nwk_globals.c, don´t you agree?
Meanwhile I didn´t arrive to use a secure network.
I´ve set:
-DSECURE=1 (f8wconfig.cfg)
zgPreConfigKeys = TRUE; (ZGlobals.c)
and -DDEFAULT_KEY="{......}"
As far as I´m concerned if the coordinator DEFAULT_KEY is different from end device DEFAULT_KEY they won´t communicate.
If DEFAULT_KEY is the same they can communicate.
Am I right?
But up to now I didn´t set the secure mode.
Is there another thing to do?
Best Regards,
Marconi.
Hi Marconi,
Yes, that's all you need to do to enable secure mode. Could you describe more specifically what's your problem is? Is that your Zigbee ED or router can not join coordinator after you enable secure mode or something else?
Hi YK Chen,
If "zgPreConfigKeys = TRUE" my end device joins the network and suddenly leave it.Even if DEFAULT_KEY="{......}" is the same for end device and coordinador I can´t exchange messages with coordinator.
I expect that if "zgPreConfigKeys = TRUE" and DEFAULT_KEY="{......}" is different for end device and coordinator they couldn´t communicate.But if "zgPreConfigKeys = TRUE" and DEFAULT_KEY="{......}" is the same they could communicate in secure mode.
Is It clear?
Br,
Let's start from non-secure mode first. If you set -DSECURE=0, does everything work fine? Do both joining and communication work well?
Yes. In non secure mode it works.
When I set the secure mode my packets would be encrypted, that´s right?
Meanwhile, when I see the packets with a packet sniffer they aren´t encrypted.
So, my question is: What a Secure mode means? What I would expect in this mode? How to send encrypted package?
Marconi
If the non secure mode works, I suggest you can try "-DSECURE=1" and "zgPreConfigKeys = FALSE" first. Under these defines, there will be a secure zigbee network without pre-config key.
I´ve, in other posts, that other people have the same problem as me.
I´ve made a lit change on ZigBee stack in order to use secure mode with pre-defined key and it works.
Now I would like to read my end devices IEEE address.
Meanwhile I´m getting some trouble to find the Binding table.
How my coordinator can be informed every time that a device has joined the network?
Before the device has joined the network is it possible to ask my coordinator if it want it?
How can I access the biding table?
Best regards.
When a device joins zigbee network, there is end node announcement and you can add the following codes in ZDApp_InMsgCB() of ZDApp.c to get IEEE address and short address of a new-joined device.
ZDO_DeviceAnnce_t devAnnce;
if ( inMsg->clusterID == Device_annce ) { ZDO_ParseDeviceAnnce( inMsg, &devAnnce ); }
When a device joins the network, it is impossible to ask coordinator if it wants it. The only way is that coordinator use NLME_LeaveReq() to ask the device to leave after it joins the network.
For access the binding table, you can have a look at BindingTable.h.
Hi, I´ve read on Z-Stack Developer´s guide the following information (chapter 10.4 - Key Updates): "The Trust Center can update the common Network key at its discretion. Application developers have to modify the Network key update policy. The default Trust Center implementation can be used to suit the developer's specific policy. An example policy would be to update the Network key at regular periodic intervals. Another would be to update the NWK key upon user input (like a button-press). The ZDO Security Manager (ZDSecMgr.c) API provides this functionality via ZDSecMgrUpdateNwkKey() and ZDSecMgrSwitchNwkKey(). ZDSecMgrUpdateNwkKey() allows the Trust Center to broadcast a new Network key to all devices on the network. At this point the new Network key is stored as an alternate key in all devices. Once the Trust Center calls ZDSecMgrSwitchNwkKey(), a network wide broadcast will trigger all devices to use their alternate key." I have used the ZDSecMgrUpdateNwkKey() and ZDSecMgrSwitchNwkKey() functions to change my network key. Both functions has returned ZSuccess, meanwhile it doesn´t work, my End Device doesn´t change the nwk key. Is there another thing to do, as set any DEFINE? How can I change the network key on all devices? How can I be informed that all devices has changed the key? Regards. Marconi.
Continuing,For a normal message the option AF_ACK_REQUEST can be used as described on Z-Stack Developer´s Guide (chapter 8). I´ve tried this option and now I know if the message was delivered to a specific device or not. Meanwhile this message is an APSDE_DataReq(&req) format. (see function AF_DataRequest) To change/switch the network key the format is APSME, not APSDE. (see functions: ZDSecMgrUpdateNwkKey and ZDSecMgrSwitchNwkKey) So, the question remains: how to know if a specific device has received the network change/switch key command? Regards, Marconi.