Binding in ZigBee is managed by the APS layer. In addition to binding table management, the APS layer also provides group table management, fast address search, and other service functions. The application layer cannot directly call the data service in the APS layer to transmit data. It can only use the ad_datarequest function encapsulated in the AF layer to transmit data.
After reading many related documents, I mentioned that the bound service defines the same cluster ID in the simple descriptors of two different nodes and has the opposite direction (one in the output cluster, to successfully establish the binding.
The size of APS bound tables is limited by the size of static RAM, which is specified by parameters in f8wconfig. cfg.
In the default configuration, there are four bound table entries, each of which can have four cluster IDs.
To configure the BIND table, you need to define the reflector macro (configured in f8wconfig. cfg)
Table binding
Operations on a table are nothing more than addition, deletion, modification, and query.
1. add a function prototype for binding table entries: bytes * bindaddentry (byte srcepint, comment * dstaddr, byte dstepint, byte numclusterids, uint16 * clusterids) srcepint: Source endpoint dstaddr: Destination Address dstepint: destination endpoint numclusterids: number of clusters clusterids: the pointer to the newly added bound table is returned after the cluster list is successful. If the pointer to the newly added bound table fails, null2. function prototype: byte bindremoveentry (bindingentry_t * pbind) pbind: pointer to the binding table to be deleted. Return true3. removed the cluster command from the binding entry. function prototype: byte bindremoveclusteridfromlist (bindingentry_t * entry, uint16 Clusterid) entry: bind table entry clusterid: the cluster ID to be deleted returns trur, at least one for the cluster ID. If not, return false4. Add the cluster function prototype in the bound table entry: byte bindaddclusteridtolist (bindingentry_t * entry, uint16 clusterid) entry: bind table entry clusterid: returns true if the ID of the cluster to be added is successful, and false5if the cluster fails to be added, finds an existing source endpoint to the destination address. Function Type: bindingentry_t * bindfindexisting (byte srcepint, zaddrtype_t, byte dstepint) srcepint: Source endpoint dstaddr: Destination Address type dsteint: Destination Address endpoint number
When using flash, you need to set the compilation option nv_restore [f8wconfig. cfg] To save the binding table. We recommend that you use the bindwritenv function.
Group Management
A group is used to aggregate a series of nodes to a single-address entity, and send data requests to this address. The requests can reach each node in the group.
The first struct is the group structure bidding documents, and the second struct is the group list description.
Group operation functions include:
Add an endpoint to a group: extern zstatus_t aps_addgroup (uint8 endpoint, aps_group_t * group );
Usage:
Define a group: aps_group_t sampleapp_group;
Initialization group information:
Sampleapp_group.id = sampleapp_flash_group;
Osal_memcpy (sampleapp_group.name, "group 1", 7 );
Add an endpoint to a group:
Aps_addgroup (sampleapp_endpoint, & sampleapp_group );
Locate the group index from the group table based on the endpoint and group ID
Aps_group_t * GRP;
GRP = aps_findgroup (sampleapp_endpoint, sampleapp_flash_group );
Remove the endpoint based on the group ID.
Aps_removegroup (sampleapp_endpoint, sampleapp_flash_group );
Quick address search
APS provides functions for fast address translation between IEEE and network addresses.
Uint8 apsme_lookupextaddr (uint16 nwkaddr, uint8 * extaddr); obtain the IEEE address based on the network address
Uint8 apsme_lookupnwkaddr (uint8 * extaddr, uint16 * nwkaddr); obtain the nwk address based on the IEEE address