Posts: 11
Registered: ‎03-09-2016
Accepted Solution

How to look up EUID of sending device in  emberAfPreMessageReceivedCallback()?

I'm building a simple coordinator (for testing), and I'm wondering how to look up the EUID of the device which sent the message currently being handled by.


I can get the short source address this way:


boolean emberAfPreMessageReceivedCallback(EmberAfIncomingMessage* incomingMessage)
  emberAfCorePrintln("0x%2x", incomingMessage->source);



But, my application for this base station requires that the EUID of the device be printed.


I've tried looking up the EUID of the packet's source in the Binding Table, but when I look at incomingMessage->bindingTableIndex, I always get 0xFF as the index.  So, looking up the EUID in the Binding Table doesn't look like the way to do this.  The device in question is a sleepy end device.


I've looked through EmberZNet5.4.4-GA/app/framework/plugin/address-table/address-table-management.h and /EmberZNet5.4.4-GA/stack/include/ember-types.h, but I haven't been able to figure out how to look up the EUID.


Does anyone have a quick & easy way to look up the EUID of the device that sent us a message in emberAfPreMessageReceivedCallback()?  Any idea why incomingMessage->bindingTableIndex would consistently return 0xFF?


Posts: 202
Registered: ‎02-05-2014

Re: How to look up EUID of sending device in  emberAfPreMessageReceivedCallback()?

Although the long address (EUI64) can be included in the headers for the incoming message, it's optional and rarely is included.  If it's available in the headers, you can get it by calling emberGetSenderEui64(), described in app/framework/util/util.h.  If it's not available in the headers but the stack on your device has it cached in a table somewhere (binding table, child table, neighbor table, parent info, trust center info), you can ask the stack to grab it from this cache using emberLookupEui64ByNodeId(), described in stack/include/stack-info.h.  If that still doesn't work, you'll need to query the network to ask for it, which can be done with emberAfFindIeeeAddress() from app/framework/include/af.h.



The views represented in this post are the independent views of the author and don't necessarily represent the official views of Silicon Labs.