Developing with ZBOSS for Zigbee
NWK Address translation table access

Typedefs

typedef zb_uint8_t zb_address_pan_id_ref_t
 
typedef zb_uint8_t zb_address_ieee_ref_t
 

Functions

zb_ret_t zb_address_get_pan_id_ref (zb_ext_pan_id_t pan_id, zb_address_pan_id_ref_t *ref)
 
void zb_address_get_short_pan_id (zb_address_pan_id_ref_t pan_id_ref, zb_uint16_t *pan_id_p)
 
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)
 
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)
 
void zb_long_address_update_by_ref (zb_ieee_addr_t ieee_address, zb_address_ieee_ref_t ref)
 
void zb_address_by_ref (zb_ieee_addr_t ieee_address, zb_uint16_t *short_address_p, zb_address_ieee_ref_t ref)
 
void zb_address_ieee_by_ref (zb_ieee_addr_t ieee_address, zb_address_ieee_ref_t ref)
 
void zb_address_short_by_ref (zb_uint16_t *short_address_p, zb_address_ieee_ref_t ref)
 
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)
 
zb_uint16_t zb_address_short_by_ieee (zb_ieee_addr_t ieee_address)
 
zb_ret_t zb_address_ieee_by_short (zb_uint16_t short_addr, zb_ieee_addr_t ieee_address)
 
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)
 
zb_bool_t zb_address_is_locked (zb_address_ieee_ref_t ref)
 
zb_ret_t zb_address_lock (zb_address_ieee_ref_t ref)
 
void zb_address_unlock (zb_address_ieee_ref_t ref)
 
zb_ret_t zb_address_delete (zb_address_ieee_ref_t ref)
 

Detailed Description

Typedef Documentation

◆ 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

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_bufid_t buf = ZB_BUF_FROM_REF(param);
if (zb_address_by_ieee(g_ieee_addr_r2, ZB_TRUE, ZB_FALSE, &ref_p) == RET_OK)
{
...
}
}

See nwk_addr sample

◆ 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_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);

See nwk_addr sample

◆ 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

void simple_gw_send_leave_req(zb_uint8_t param, zb_uint16_t short_addr, zb_bool_t rejoin_flag)
{
zb_bufid_t buf = param;
if (zb_address_by_short(short_addr, ZB_FALSE, ZB_FALSE, &addr_ref) == RET_OK)
{
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));
}
}

See simple_gw sample

◆ 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

if ( zb_address_get_pan_id_ref(ZB_NIB_EXT_PAN_ID(), &my_panid_ref) != RET_OK )
{
TRACE_MSG(TRACE_NWK1, "Pan ID " TRACE_FORMAT_64 " not in Pan ID arr - ?", (FMT__A,
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);
...
}

See tp_pro_bv-32 sample

◆ 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_ieee_addr_t ieee_addr;
if (zb_address_ieee_by_short(dev_annce_params->device_short_addr, ieee_addr) != RET_OK)
{
TRACE_MSG(TRACE_ERROR, "get ieee address by short failed", (FMT__0));
zb_buf_free(buf_ref);
return;
}

See light_sample

◆ 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_lock()

zb_ret_t zb_address_lock ( zb_address_ieee_ref_t  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_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;
{
dst_endpoint = ep;
thermostat_client_short_addr = zb_address_short_by_ieee(addr);
ZB_SCHEDULE_APP_CALLBACK(send_thermostat_cmd, thermostat_cmd_type);
}

See thermostat sample

◆ 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_address_short_by_ref(&addr, nbt->addr_ref);
func(addr);
}

See tp_pro_bv-32 sample

◆ zb_address_unlock()

void zb_address_unlock ( zb_address_ieee_ref_t  ref)

Unlock address counter. Decrease lock counter.

Parameters
ref- IEEE/network address pair reference

◆ 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_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);
}

See nwk_addr sample

zb_zdo_nwk_addr_resp_head_s
NWK_addr_req response frame.
Definition: zboss_api_zdo.h:1225
zb_zdo_mgmt_leave_param_s::dst_addr
zb_uint16_t dst_addr
Definition: zboss_api_zdo.h:2409
zb_uint8_t
unsigned char zb_uint8_t
Project-local 1-byte unsigned int type.
Definition: zb_types.h:149
zb_zdo_nwk_addr_resp_head_s::nwk_addr
zb_uint16_t nwk_addr
Definition: zboss_api_zdo.h:1230
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)
zb_address_short_by_ref
void zb_address_short_by_ref(zb_uint16_t *short_address_p, zb_address_ieee_ref_t ref)
zb_bool_t
zb_uint8_t zb_bool_t
General purpose boolean type. For C90, 'zb_bool_t' is an alias of 'zb_uint8_t'. For C99,...
Definition: zb_types.h:367
ZB_SCHEDULE_APP_CALLBACK
#define ZB_SCHEDULE_APP_CALLBACK(func, param)
Definition: zboss_api_core.h:303
ZB_LETOH16
#define ZB_LETOH16
Definition: zb_types.h:790
zdo_mgmt_leave_req
zb_uint8_t zdo_mgmt_leave_req(zb_uint8_t param, zb_callback_t cb)
Sends Mgmt_Leave_req.
ZB_BUF_GET_PARAM
#define ZB_BUF_GET_PARAM(buf, type)
Definition: zboss_api_buf.h:456
ZB_TRUE
#define ZB_TRUE
Definition: zb_types.h:371
ZB_BDB_COMM_BIND_SUCCESS
@ ZB_BDB_COMM_BIND_SUCCESS
Definition: zboss_api_zcl.h:2079
zb_zdo_mgmt_leave_param_s::rejoin
zb_bitfield_t rejoin
Definition: zboss_api_zdo.h:2413
zb_address_ieee_by_short
zb_ret_t zb_address_ieee_by_short(zb_uint16_t short_addr, zb_ieee_addr_t ieee_address)
ZB_ZDP_STATUS_SUCCESS
#define ZB_ZDP_STATUS_SUCCESS
Definition: zboss_api_zdo.h:41
zb_buf_begin
#define zb_buf_begin(buf)
Definition: zboss_api_buf.h:344
zb_ieee_addr_t
zb_64bit_addr_t zb_ieee_addr_t
Long (64-bit) device address.
Definition: zb_types.h:550
RET_OK
#define RET_OK
Error codes for non-void stack functions. In general, function can return OK, BLOCKED or some error....
Definition: zb_errors.h:77
zb_address_ieee_ref_t
zb_uint8_t zb_address_ieee_ref_t
Definition: zb_address.h:64
zb_zdo_nwk_addr_resp_head_s::ieee_addr
zb_ieee_addr_t ieee_addr
Definition: zboss_api_zdo.h:1229
zb_address_pan_id_ref_t
zb_uint8_t zb_address_pan_id_ref_t
Definition: zb_address.h:56
zb_zdo_signal_device_annce_params_s::device_short_addr
zb_uint16_t device_short_addr
Definition: zboss_api_zdo.h:878
zb_uint16_t
unsigned short zb_uint16_t
Project-local 2-byte unsigned int type.
Definition: zb_types.h:153
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)
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)
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)
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)
zb_zdo_mgmt_leave_param_s
Request for Mgmt_Leave_req.
Definition: zboss_api_zdo.h:2406
zb_buf_free
#define zb_buf_free(buf)
Free packet buffer and put it into free list.
Definition: zboss_api_buf.h:334
ZB_FALSE
#define ZB_FALSE
Definition: zb_types.h:370
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)
zb_zdo_nwk_addr_resp_head_s::status
zb_uint8_t status
Definition: zboss_api_zdo.h:1228
zb_address_short_by_ieee
zb_uint16_t zb_address_short_by_ieee(zb_ieee_addr_t ieee_address)
zb_bufid_t
zb_uint8_t zb_bufid_t
Definition: zboss_api_buf.h:172
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)
zb_address_ieee_by_ref
void zb_address_ieee_by_ref(zb_ieee_addr_t ieee_address, zb_address_ieee_ref_t ref)
ZB_ZCL_CLUSTER_ID_THERMOSTAT
#define ZB_ZCL_CLUSTER_ID_THERMOSTAT
Definition: zb_zcl_common.h:242