Developing with ZBOSS
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_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 (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_ret_t zb_address_lock (zb_address_ieee_ref_t ref)
 
zb_ret_t 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 ( 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_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()

zb_ret_t zb_address_unlock ( zb_address_ieee_ref_t  ref)

Unlock address counter. Decrease lock counter.

Parameters
ref- IEEE/network address pair reference
Returns
RET_OK or RET_ERROR

◆ 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