Macros | |
| #define | zb_address_lock(ref) zb_address_lock_func(TRACE_ADDR_CALL ref) |
| #define | zb_address_unlock(ref) zb_address_unlock_func(TRACE_ADDR_CALL ref) |
Typedefs | |
| typedef zb_uint8_t | zb_address_pan_id_ref_t |
| typedef zb_uint8_t | zb_address_ieee_ref_t |
Detailed Description
Macro Definition Documentation
◆ zb_address_lock
| #define zb_address_lock | ( | ref | ) | zb_address_lock_func(TRACE_ADDR_CALL ref) |
Increase address lock counter, when it used in some table. Address must be already locked.
- Parameters
-
ref - IEEE/network address pair reference
- Returns
- RET_OK or RET_ERROR
◆ zb_address_unlock
| #define zb_address_unlock | ( | ref | ) | zb_address_unlock_func(TRACE_ADDR_CALL ref) |
Unlock address counter. Decrease lock counter.
- Parameters
-
ref - IEEE/network address pair reference
Typedef Documentation
◆ zb_address_ieee_ref_t
| typedef zb_uint8_t zb_address_ieee_ref_t |
IEEE address reference
Should be used inside protocol tables instead of 64/16-bit IEEE.
◆ zb_address_pan_id_ref_t
| typedef zb_uint8_t zb_address_pan_id_ref_t |
Pan ID reference
Should be used inside protocol tables instead of 64-bit Pan ID
Function Documentation
◆ zb_address_by_ieee()
| zb_ret_t zb_address_by_ieee | ( | const zb_ieee_addr_t | ieee, |
| zb_bool_t | create, | ||
| zb_bool_t | lock, | ||
| zb_address_ieee_ref_t * | ref_p | ||
| ) |
Get address ref by long address, optionally create if not exist, optionally lock. Update address alive time if not locked.
- Parameters
-
ieee - IEEE device address create - if TRUE, create address entry if it does not exist lock - if TRUE, lock address entry ref_p - (out) address reference
- Note
- : never call zb_address_by_ieee() with empty (zero) ieee_address
- Returns
- RET_OK or error code
Example
void test_get_short_addr(zb_uint8_t param){ zb_address_ieee_ref_t ref_p; zb_bufid_t buf = ZB_BUF_FROM_REF(param); { ... }}
◆ zb_address_by_ref()
| void zb_address_by_ref | ( | zb_ieee_addr_t | ieee_address, |
| zb_uint16_t * | short_address_p, | ||
| zb_address_ieee_ref_t | ref | ||
| ) |
Get address with address reference.
Get existing IEEE (long) and short addresses with address reference. Update address alive time if it not locked.
- Parameters
-
ieee_address - (out) long address short_address_p - (out) short address ref - address reference
Example
zb_address_ieee_ref_t addr_ref;zb_nlme_join_indication_t *resp = ZB_BUF_GET_PARAM((zb_bufid_t )ZB_BUF_FROM_REF(param), zb_nlme_join_indication_t);zb_address_by_ref(resp->extended_address, &resp->network_address, addr_ref);
◆ zb_address_by_short()
| zb_ret_t zb_address_by_short | ( | zb_uint16_t | short_address, |
| zb_bool_t | create, | ||
| zb_bool_t | lock, | ||
| zb_address_ieee_ref_t * | ref_p | ||
| ) |
Get address reference with long address. Create the reference if it does not exist. Optionally, lock the address. Update address alive time if not locked.
- Parameters
-
short_address - 16bit device address create - if TRUE, create address entry if it does not exist lock - if TRUE, lock address entry ref_p - (out) address reference
- Note
- Never call zb_address_by_short() with empty (-1) short_address
- Returns
- RET_OK or error code
Example
{ zb_bufid_t buf = param; zb_zdo_mgmt_leave_param_t *req_param; zb_address_ieee_ref_t addr_ref; { req_param = ZB_BUF_GET_PARAM(buf, zb_zdo_mgmt_leave_param_t); ZB_BZERO(req_param, sizeof(zb_zdo_mgmt_leave_param_t)); req_param->dst_addr = short_addr; req_param->rejoin = (rejoin_flag ? 1 : 0); zdo_mgmt_leave_req(param, NULL); } else { TRACE_MSG(TRACE_APP1, "tried to remove 0x%xd, but device is already left", (FMT__D, short_addr)); zb_buf_free(buf); } }
◆ zb_address_cmp_pan_id_by_ref()
| zb_bool_t zb_address_cmp_pan_id_by_ref | ( | zb_address_pan_id_ref_t | pan_id_ref, |
| zb_ext_pan_id_t | pan_id | ||
| ) |
Compare Pan ID in the source form with Pan ID reference.
- Parameters
-
pan_id_ref - Pan ID ref pan_id - Pan ID (64-bit)
- Returns
- ZB_TRUE if addresses are equal, ZB_FALSE otherwise
Example
for (i = 0 ; i < ZG->nwk.neighbor.ext_neighbor_used ; ++i) { for (j = 0 ; j < n_nwk_dsc && !zb_address_cmp_pan_id_by_ref(ZG->nwk.neighbor.ext_neighbor[i].panid_ref, network_descriptor[j].extended_pan_id) ; ++j) { ... } }
◆ zb_address_delete()
| zb_ret_t zb_address_delete | ( | zb_address_ieee_ref_t | ref | ) |
Delete address.
- Returns
- RET_OK or RET_ERROR
- Parameters
-
ref - IEEE/network address pair reference
◆ zb_address_get_pan_id_ref()
| zb_ret_t zb_address_get_pan_id_ref | ( | zb_ext_pan_id_t | pan_id, |
| zb_address_pan_id_ref_t * | ref | ||
| ) |
Get Pan ID reference with extended Pan ID.
- Parameters
-
pan_id - Pan ID ref - (output) reference to Pan ID
- Returns
- RET_OK - when success, error code otherwise.
Example
zb_address_pan_id_ref_t my_panid_ref;{ TRACE_ARG_64(ZB_NIB_EXT_PAN_ID())));}
◆ zb_address_get_short_pan_id()
| void zb_address_get_short_pan_id | ( | zb_address_pan_id_ref_t | pan_id_ref, |
| zb_uint16_t * | pan_id_p | ||
| ) |
Get short Pan ID with reference.
- Parameters
-
pan_id_ref - reference to Pan ID pan_id_p - (output) Pan ID.
Example
zb_uint16_t nt_panid;zb_address_get_short_pan_id(ZG->nwk.neighbor.ext_neighbor[i].panid_ref, &nt_panid);if (nt_panid == pan_id){ TRACE_MSG(TRACE_NWK1, "pan_id %d is on ch %hd", (FMT__D_H, pan_id, channel)); unique_pan_id = 0;}
◆ zb_address_ieee_by_ref()
| void zb_address_ieee_by_ref | ( | zb_ieee_addr_t | ieee_address, |
| zb_address_ieee_ref_t | ref | ||
| ) |
Get IEEE address with address reference.
Get existing IEEE address(long address) with address reference. Update address alive time if it not locked.
- Parameters
-
ieee_address - (out) long address ref - address reference
Example
void func(zb_neighbor_tbl_ent_t *nbt){ zb_ieee_addr_t ieee_addr; zb_address_ieee_by_ref(ieee_addr, nbt->addr_ref); ...}
◆ zb_address_ieee_by_short()
| zb_ret_t zb_address_ieee_by_short | ( | zb_uint16_t | short_addr, |
| zb_ieee_addr_t | ieee_address | ||
| ) |
Get IEEE address (long) with short address.
- Parameters
-
short_addr - short address ieee_address - (out)long address
- Returns
- RET_OK or RET_NOT_FOUND
Example
zb_uint8_t i; zb_ieee_addr_t ieee_addr; { TRACE_MSG(TRACE_ERROR, "get ieee address by short failed", (FMT__0)); zb_buf_free(buf_ref); return; }
◆ zb_address_is_locked()
| zb_bool_t zb_address_is_locked | ( | zb_address_ieee_ref_t | ref | ) |
Check that address is locked (has lock counter > 0)
- Parameters
-
ref - IEEE/network address pair reference
- Returns
- ZB_TRUE if address is locked
◆ zb_address_short_by_ieee()
| zb_uint16_t zb_address_short_by_ieee | ( | zb_ieee_addr_t | ieee_address | ) |
Get short address by IEEE address (long).
- Parameters
-
ieee_address - long address
- Returns
- short address if ok, -1 otherwise.
- Example
- zb_uint16_t thermostat_client_short_addr = 0xFFFF;if (ZB_BDB_COMM_BIND_SUCCESS == status&& ZB_ZCL_CLUSTER_ID_THERMOSTAT == cluster){dst_endpoint = ep;thermostat_client_short_addr = zb_address_short_by_ieee(addr);ZB_SCHEDULE_APP_CALLBACK(send_thermostat_cmd, thermostat_cmd_type);}
◆ zb_address_short_by_ref()
| void zb_address_short_by_ref | ( | zb_uint16_t * | short_address_p, |
| zb_address_ieee_ref_t | ref | ||
| ) |
Get short address by address reference.
Get existing short address with address reference. Update address alive time if it not locked.
- Parameters
-
short_address_p - (out) short address ref - address reference
Example
zb_neighbor_tbl_ent_t *nbt;if(zb_nwk_neighbor_with_address_conflict(&nbt)==RET_OK){ zb_uint16_t addr; zb_address_short_by_ref(&addr, nbt->addr_ref); func(addr);}
◆ zb_address_update()
| zb_ret_t zb_address_update | ( | zb_ieee_addr_t | ieee_address, |
| zb_uint16_t | short_address, | ||
| zb_bool_t | lock, | ||
| zb_address_ieee_ref_t * | ref_p | ||
| ) |
Update long/short address pair. Create the pair if not exist. Optionally, lock. Reaction on device announce etc. Long and short addresses are present. Must synchronize the address translation table with this information.
- Note
- Never call zb_address_update() with empty (zero) ieee_address or empty (-1) short_address.
- Parameters
-
ieee_address - long address short_address - short address lock - if TRUE, lock address entry ref_p - (out) address reference
- Returns
- RET_OK or error code
Example
zb_address_ieee_ref_t addr_ref;zb_uint16_t nwk_addr;{ ZB_LETOH64(ieee_addr, resp->ieee_addr); ZB_LETOH16(&nwk_addr, &resp->nwk_addr); zb_address_update(ieee_addr, nwk_addr, ZB_TRUE, &addr_ref);}