As explained previously, groups provide a filter for data indications. If an endpoint doesn't belong to the group, it doesn't receive the incoming over-the-air message.
In addition to matching the group ID, APS also matches the profile ID for that endpoint. If both IDs match, the message is sent through to the endpoint. If not, the packet is dropped. When debugging, if you see a packet going over-the-air, but the packet is not received at the data indication, check both these fields first. Having the wrong group or profile ID has caused me debugging grief a number of times.
BeeStack keeps track of groups in a small table, the size of which is defined by the BeeKit property gApsMaxGroups_c found in BeeStackConfiguration.h.
The local commands for manipulating groups are shown in Table 4.14.
Table 4.14: APS Group Management Commands
These commands are pretty self-explanatory. The ApsmeAddGroup() function adds a group to an endpoint. ApsmeRemoveGroup() function removes a group from an endpoint. ApsmeRemoveAllGroups() function removes all groups from an endpoint. The ApsGroupIsMemberOfEndpoint() checks to see whether an endpoint is a member of a particular group.
In addition to the APS local group management functions, there are over-the-air commands group management functions as part of the ZigBee Cluster Library. These commands include AddGroup, RemoveGroup, RemoveAllGroups, AddGroupIfIdentifying and others, and are described in Chapter 6, "The ZigBee Cluster Library."
APS provides local group commands. ZCL provides over-the-air group commands.
4.7.4 APS Address Map
The APS layer contains a table called the address map. This table associates the 16-bit ZigBee NwkAddr with the 64-bit IEEE (or MAC) address, as shown in Table 4.15.
Table 4.15: APS Address Map
Some ZigBee commands, such as binding, use only the IEEE address, but ZigBee needs the 16-bit NwkAddr to communicate, so it must somehow associate these two addresses internally. Also, some nodes may be mobile in a ZigBee network, such as ZigBee End-Devices, and these mobile devices may change their 16-bit NwkAddr. If they do, they announce this fact to the network with a Device Announce command. Every node then updates its internal tables and the binding is preserved.
The size of the address map table is set with the gApsMaxAddrMapEntries_c property found in BeeStackConfiguration.h in the Freescale solution.
In BeeStack, there is no reason to add entries to the address map directly. Instead, use the ZDP commands ZDP.IEEE_addr_req or ZDP.NWK_addr_req, either of which will add that entry into the address map, if it is not there already. The application may need to clear unused entries from the address map if it will be speaking to many different nodes over time. Usually, though, an application is commissioned to talk to a small set of nodes, and stays that way for years, possibly the lifetime of the network.
In BeeStack, if you'd like to manipulate the address map, use:
addrMapIndex_t APS_AddToAddressMap(zbIeeeAddr_t aExtAddr, zbNwkAddr_t aNwkAddr);
void APS_RemoveFromAddressMap(zbIeeeAddr_t aExtAddr);
addrMapIndex_t APS_FindIeeeInAddressMap(zbIeeeAddr_t aExtAddr);
The zbIeeeAddr_t is the 64-bit MAC address. The zbNwkAddr_t is the 16-bit NwkAddr. The addrMapIndex_t returns the index (0-n) in the address map for the entry, or gNotInAddressMap_c if not found, or gAddressMapFull_c if it couldn't be added.