Developing with ZBOSS for Zigbee

Data Structures

union  zb_addr_u_t
 
union  zb_addr_u
 Union to address either long or short address. More...
 

Macros

#define ZB_STDC_90
 
#define ZB_32BIT_WORD
 
#define ZB_XDATA
 
#define ZB_CODE
 
#define ZB_IAR_CODE
 
#define ZB_REGISTER   register
 
#define ZB_VOID_ARGLIST   void
 
#define ZB_CONST   const
 
#define ZB_INLINE
 
#define ZB_BITFIELD_CAST(x)   (x)
 
#define ZB_CPP_STR2(x)   #x
 
#define ZB_CPP_STR(x)   ZB_CPP_STR2(x)
 
#define ZB_FALSE   0U
 
#define ZB_TRUE   1U
 
#define ZB_FALSE_U   ZB_FALSE
 
#define ZB_TRUE_U   ZB_TRUE
 
#define ZB_B2U(b)   (((b) != ZB_FALSE) ? (1U) : (0U))
 
#define ZB_U2B(u)   (((u) != 0U) ? (ZB_TRUE) : (ZB_FALSE))
 
#define ZB_INT8_MIN   (-127 - 1)
 
#define ZB_INT8_MAX   127
 
#define ZB_UINT8_MIN   0U
 
#define ZB_UINT8_MAX   255U
 
#define ZB_INT16_MIN   (-32767 - 1)
 
#define ZB_INT16_MAX   32767
 
#define ZB_UINT16_MIN   0U
 
#define ZB_UINT16_MAX   65535U
 
#define ZB_INT32_MIN   (-2147483647L - 1)
 
#define ZB_INT32_MAX   2147483647L
 
#define ZB_UINT32_MIN   0UL
 
#define ZB_UINT32_MAX   4294967295UL
 
#define ZB_UINT_MIN   0UL
 
#define ZB_SHORT_MIN   ZB_INT32_MIN
 
#define ZB_SHORT_MAX   ZB_INT32_MAX
 
#define ZB_USHORT_MAX   ZB_UINT32_MAX
 
#define ZB_INT_MIN   ZB_INT32_MIN
 
#define ZB_INT_MAX   ZB_INT32_MAX
 
#define ZB_UINT_MAX   ZB_UINT32_MAX
 
#define ZB_INT_MASK   0x7fffffffU
 
#define ZB_PACKED_STRUCT
 
#define ZB_PACKED_PRE
 
#define ZB_WEAK_PRE
 
#define ZB_WEAK
 
#define ZB_ALIGNED_PRE
 
#define ZB_DEPRECATED
 
#define ZB_IS_64BIT_ADDR_UNKNOWN(addr)   (ZB_MEMCMP((addr), (void const*)g_unknown_ieee_addr, 8) == 0)
 
#define ZB_64BIT_ADDR_UNKNOWN(addr)   ZB_MEMSET((addr), -1, 8)
 
#define ZB_EXTPANID_IS_ZERO   ZB_IS_64BIT_ADDR_ZERO
 
#define ZB_EXTPANID_ZERO   ZB_64BIT_ADDR_ZERO
 
#define ZB_EXTPANID_COPY   ZB_64BIT_ADDR_COPY
 
#define ZB_EXTPANID_CMP   ZB_64BIT_ADDR_CMP
 
#define ZB_IEEE_ADDR_IS_ZERO   ZB_IS_64BIT_ADDR_ZERO
 
#define ZB_IEEE_ADDR_IS_UNKNOWN   ZB_IS_64BIT_ADDR_UNKNOWN
 
#define ZB_IEEE_ADDR_ZERO   ZB_64BIT_ADDR_ZERO
 
#define ZB_IEEE_ADDR_UNKNOWN   ZB_64BIT_ADDR_UNKNOWN
 
#define ZB_IEEE_ADDR_COPY   ZB_64BIT_ADDR_COPY
 
#define ZB_IEEE_ADDR_CMP   ZB_64BIT_ADDR_CMP
 
#define ZB_CCM_KEY_IS_ZERO(k)   (ZB_IS_64BIT_ADDR_ZERO((zb_uint8_t*)(k)) && ZB_IS_64BIT_ADDR_ZERO(((zb_uint8_t*)(k)) + 8U))
 
#define ZB_IEEE_ADDR_IS_VALID(addr)   !(ZB_IEEE_ADDR_IS_ZERO(addr)||ZB_IEEE_ADDR_IS_UNKNOWN(addr))
 
#define ZB_ADDR_CMP(addr_mode, addr1, addr2)
 
#define ZB_INT8_C(c)   c
 
#define ZB_UINT8_C(c)   c ## U
 
#define ZB_INT16_C(c)   c
 
#define ZB_UINT16_C(c)   c ## U
 
#define ZB_INT32_C(c)   c ## L
 
#define ZB_UINT32_C(c)   c ## UL
 
#define ZB_OFFSETOF(t, f)   ((zb_size_t)(&((t *)NULL)->f))
 
#define ZB_OFFSETOF_VAR(s, f)   (zb_size_t)(((zb_int8_t *)(&(s)->f)) - ((zb_int8_t *)(s)))
 
#define ZB_SIZEOF_FIELD(type, field)   (sizeof(((type*)0)->field))
 
#define ZB_ARRAY_SIZE(arr)   (sizeof((arr))/sizeof((arr)[0]))
 
#define ZB_SIGNED_SHIFT(v, s)   ((zb_int_t)(v) >> (s))
 
#define ZB_ASSERT_IF_NOT_ALIGNED(data_type, length)   ZB_ASSERT_COMPILE_DECL(((sizeof(data_type) % (length)) == 0U))
 
#define ZB_ASSERT_IF_NOT_ALIGNED_TO_4(data_type)   ZB_ASSERT_IF_NOT_ALIGNED(data_type,4U)
 
#define ZB_ASSERT_VALUE_ALIGNED(const_expr, length)   ZB_ASSERT_COMPILE_DECL((((const_expr) % (length)) == 0U))
 
#define ZB_ASSERT_VALUE_ALIGNED_TO_4(const_expr)   ZB_ASSERT_VALUE_ALIGNED(const_expr, 4U)
 
#define ZB_GET_LOW_BYTE(val)   (zb_uint8_t)((val) & 0xFFU)
 
#define ZB_GET_HI_BYTE(val)   (zb_uint8_t)(((val) >> 8U) & 0xFFU)
 
#define ZB_SET_LOW_BYTE(res, val)   (res) = ((((zb_uint16_t)res) & 0xFF00U) | (((zb_uint16_t)val) & 0xFFU))
 
#define ZB_SET_HI_BYTE(res, val)   (res) = (((((zb_uint16_t)val) << 8U) & 0xFF00U) | (((zb_uint16_t)res) & 0xFFU))
 
#define ZB_PKT_16B_ZERO_BYTE   0U
 
#define ZB_PKT_16B_FIRST_BYTE   1U
 
#define ZB_ASSIGN_UINT16(ptr, vp)   *((zb_uint16_t*)(ptr)) = *(zb_uint16_t*)(vp)
 
#define ZB_ASSIGN_INT16(ptr, vp)   *((zb_int16_t*)(ptr)) = *(zb_int16_t*)(vp)
 
#define ZB_COPY_UINT24(ptr, vp)   *((zb_uint24_t*)(ptr)) = *(zb_uint24_t*)(vp)
 
#define ZB_COPY_INT24(ptr, vp)   *((zb_int24_t*)(ptr)) = *(zb_int24_t*)(vp)
 
#define ZB_ASSIGN_UINT32(ptr, vp)   *((zb_uint32_t*)(ptr)) = *(zb_uint32_t*)(vp)
 
#define ZB_ASSIGN_INT32(ptr, vp)   *((zb_int32_t*)(ptr)) = *(zb_int32_t*)(vp)
 
#define ZB_REVERSE16(ptr, val)
 
#define ZB_REVERSE64(ptr, val)
 
#define ZB_ARRAY_IDX_BY_ELEM(ar, el)   ((el) - (ar))
 
#define ZB_ARRAY_IDX_BY_STRUCT_ELEM(ar, el, el_size)   ( ((zb_size_t)(el) - (zb_size_t)(ar)) / (el_size) )
 
#define MIN_SIGNED_24BIT_VAL   (-8388607LL) /* (0xFF800001LL) */
 
#define MAX_SIGNED_24BIT_VAL   (0x7FFFFF)
 
#define MAX_UNSIGNED_24BIT_VAL   (0xFFFFFFU)
 
#define MIN_SIGNED_48BIT_VAL   (-140737488355327LL) /* (0xFFFF800000000001LL) */
 
#define MAX_SIGNED_48BIT_VAL   (0x7FFFFFFFFFFF)
 
#define MAX_UNSIGNED_48BIT_VAL   (0xFFFFFFFFFFFFU)
 
#define ZB_S64_FROM_S48(x)   ((x & 0xFFFFFFFFFFFF) | ((x & 0x800000000000) ? 0xFFFF000000000000 : 0x0))
 
#define ZB_S64_TO_S48(x)   ((zb_int64_t)(x & 0xFFFFFFFFFFFF))
 
#define ZB_S32_FROM_S24(x)   ((x & 0xFFFFFF) | ((x & 0x800000) ? 0xFF000000 : 0x0))
 
#define ZB_S32_TO_S24(x)   ((zb_int32_t)(x & 0xFFFFFF))
 

Typedefs

typedef zb_uint32_t zb_lbitfield_t
 
typedef long long zb_int64_t
 
typedef unsigned long long zb_uint64_t
 
typedef zb_ushort_t zb_uindex_t
 
typedef zb_uint8_t zb_64bit_data_t[8]
 
typedef union zb_addr_u_t zb_addr_u
 
typedef zb_int32_t zb_ret_t
 Return type for ZB functions returning execution status. More...
 

Enumerations

enum  zb_param_e { ZB_UNUSED_PARAM = 0 }
 General purpose parameter type.
 

Variables

ZB_CONST zb_64bit_addr_t g_zero_addr
 
ZB_CONST zb_64bit_addr_t g_unknown_ieee_addr
 
zb_uint16_t zb_addr_u_t::addr_short
 
zb_ieee_addr_t zb_addr_u_t::addr_long
 

Endian change API.

Macros to change words endian and access words at potentially non-aligned pointers.

Zigbee uses little endian, see ZB spec, subclause 1.2.1.3.

void zb_htole16 (zb_uint8_t ZB_XDATA *ptr, zb_uint8_t ZB_XDATA *val)
 
void zb_htole32 (zb_uint8_t ZB_XDATA *ptr, zb_uint8_t ZB_XDATA *val)
 
void * zb_put_next_htole16 (zb_uint8_t *dst, zb_uint16_t val)
 
void * zb_put_next_htole32 (zb_uint8_t *dst, zb_uint32_t val1)
 
void zb_get_next_letoh16 (zb_uint16_t *dst, zb_uint8_t **src)
 
void * zb_put_next_2_htole16 (zb_uint8_t *dst, zb_uint16_t val1, zb_uint16_t val2)
 
void * zb_put_next_2_htole32 (zb_uint8_t *dst, zb_uint32_t val1, zb_uint32_t val2)
 
#define ZB_8BIT_SIZE   1U
 
#define ZB_16BIT_SIZE   2U
 
#define ZB_24BIT_SIZE   3U
 
#define ZB_32BIT_SIZE   4U
 
#define ZB_48BIT_SIZE   6U
 
#define ZB_64BIT_SIZE   8U
 
#define ZB_HTOLE16(ptr, val)   zb_htole16((zb_uint8_t*)(ptr), (zb_uint8_t*)(val))
 
#define ZB_HTOLE16_ONPLACE(val)
 
#define ZB_HTOLE32_ONPLACE(val)   { zb_uint32_t _v = (val); ZB_HTOLE32(&(val), &_v); }
 
#define ZB_HTOLE32(ptr, val)   zb_htole32((zb_uint8_t*)(ptr), (zb_uint8_t*)(val))
 
#define ZB_HTOBE32(ptr, val)   ZB_MEMCPY(ptr, val, 4U)
 
#define ZB_HTOBE16(ptr, val)   (*(zb_uint16_t *)(ptr)) = *((zb_uint16_t *)(val))
 
#define ZB_HTOBE16_VAL(ptr, val)   ((zb_uint16_t *)(ptr))[0] = (val)
 
#define ZB_HTOLE64(ptr, val)   zb_memcpy8(ptr, val)
 
#define ZB_HTOLE32_VAL(ptr, val)
 
#define ZB_HTOLE16_VAL(ptr, val)
 
#define ZB_PUT_NEXT_HTOLE16(ptr, val)
 
#define ZB_PUT_NEXT_HTOLE32(ptr, val)   (ptr) = zb_put_next_htole32((ptr), (val))
 
#define ZB_LETOH64(dst, src)   zb_memcpy8((zb_uint8_t*)dst, (zb_uint8_t*)src)
 
#define ZB_LETOH16   ZB_HTOLE16
 
#define ZB_LETOH24   ZB_HTOLE24
 
#define ZB_LETOH48   ZB_HTOLE48
 
#define ZB_LETOH32   ZB_HTOLE32
 
#define ZB_BETOH16   ZB_HTOBE16
 
#define ZB_BETOH32   ZB_HTOBE32
 
#define ZB_LETOH16_ONPLACE   ZB_HTOLE16_ONPLACE
 
#define ZB_LETOH32_ONPLACE   ZB_HTOLE32_ONPLACE
 

Base types.

typedef char zb_char_t
 Project-local char type.
 
typedef unsigned char zb_uchar_t
 Project-local unsigned char type.
 
typedef unsigned char zb_uint8_t
 Project-local 1-byte unsigned int type.
 
typedef signed char zb_int8_t
 Project-local 1-byte signed int type.
 
typedef unsigned short zb_uint16_t
 Project-local 2-byte unsigned int type.
 
typedef signed short zb_int16_t
 Project-local 2-byte signed int type.
 
typedef unsigned int zb_uint32_t
 Project-local 4-byte unsigned int type.
 
typedef signed int zb_int32_t
 Project-local 4-byte signed int type.
 
typedef zb_uint32_t zb_bitfield_t
 Type to be used for unsigned bit fields inside structure.
 
typedef zb_int32_t zb_sbitfield_t
 Type to be used for signed bit fields inside structure.
 
typedef zb_uint32_t zb_size_t
 Project-local size_t type.
 
typedef int zb_short_t
 Short int (can fit into single CPU register).
 
typedef unsigned int zb_ushort_t
 Short unsigned int (can fit into single CPU register).
 
typedef int zb_int_t
 Int (at least 2 bytes).
 
typedef unsigned int zb_uint_t
 Unsigned int (at least 2 bytes).
 
typedef zb_int_t zb_long_t
 Long int (at least 4 bytes).
 
typedef zb_uint_t zb_ulong_t
 Unsigned long int (at least 4 bytes).
 
typedef zb_uint8_t zb_bool_t
 General purpose boolean type. For C90, 'zb_bool_t' is an alias of 'zb_uint8_t'. For C99, the availabilty of the 'stdbool.h' standard header is expected and 'zb_bool_t' is an alias of 'bool'. ZB_FALSE and ZB_TRUE are defined as macros for both standards. More...
 
typedef zb_bitfield_t zb_bitbool_t
 Type to be used for boolean bit fields inside structure.
 

Address types and API.

typedef zb_uint8_t zb_64bit_addr_t[8]
 8-bytes address (xpanid or long device address) base type.
 
typedef zb_64bit_addr_t zb_ieee_addr_t
 Long (64-bit) device address.
 
typedef zb_64bit_addr_t zb_ext_pan_id_t
 Long (64-bit) extended Pan ID.
 
#define ZB_IS_64BIT_ADDR_ZERO(addr)   (ZB_MEMCMP((addr), (void const*)g_zero_addr, 8) == 0)
 Checks that long address is a zero one. More...
 
#define ZB_64BIT_ADDR_ZERO(addr)   ZB_MEMSET((addr), 0, 8)
 Clears long address. More...
 
#define ZB_64BIT_ADDR_COPY(dst, src)   ZB_MEMCPY(dst, src, sizeof(zb_64bit_addr_t))
 Copy long address. More...
 
#define ZB_64BIT_ADDR_CMP(one, two)   (ZB_MEMCMP((one), (two), 8) == 0)
 Check two long addresses are equal. More...
 

Detailed Description

Macro Definition Documentation

◆ ZB_64BIT_ADDR_CMP

#define ZB_64BIT_ADDR_CMP (   one,
  two 
)    (ZB_MEMCMP((one), (two), 8) == 0)

Check two long addresses are equal.

Parameters
oneaddress to compare.
twoaddress to compare to.
Returns
ZB_TRUE if addresses are equal, ZB_FALSE otherwise.

◆ ZB_64BIT_ADDR_COPY

#define ZB_64BIT_ADDR_COPY (   dst,
  src 
)    ZB_MEMCPY(dst, src, sizeof(zb_64bit_addr_t))

Copy long address.

Parameters
dstwhere to copy the address.
srcaddress to copy.

◆ ZB_64BIT_ADDR_ZERO

#define ZB_64BIT_ADDR_ZERO (   addr)    ZB_MEMSET((addr), 0, 8)

Clears long address.

Parameters
addraddress to clear.

◆ ZB_ADDR_CMP

#define ZB_ADDR_CMP (   addr_mode,
  addr1,
  addr2 
)
Value:
((addr_mode == ZB_ADDR_16BIT_DEV_OR_BROADCAST) ? \
(addr1.addr_short == addr2.addr_short) : ZB_64BIT_ADDR_CMP(addr1.addr_long, addr2.addr_long))

◆ ZB_CPP_STR

#define ZB_CPP_STR (   x)    ZB_CPP_STR2(x)

Create a string at compile time, like 0 - "0"

◆ ZB_FALSE

#define ZB_FALSE   0U

False value literal.

◆ ZB_HTOLE16_ONPLACE

#define ZB_HTOLE16_ONPLACE (   val)
Value:
{ \
zb_uint8_t *pval = (zb_uint8_t*)(&(val)); \
zb_uint8_t a = pval[0]; \
pval[0] = pval[1]; \
pval[1] = a; \
}

◆ ZB_HTOLE16_VAL

#define ZB_HTOLE16_VAL (   ptr,
  val 
)
Value:
{ \
zb_uint16_t tmp_val = (val); \
ZB_HTOLE16((ptr), &tmp_val); \
}

◆ ZB_HTOLE32_VAL

#define ZB_HTOLE32_VAL (   ptr,
  val 
)
Value:
{ \
zb_uint32_t tmp_val = (val); \
ZB_HTOLE32((ptr), &tmp_val); \
}

◆ ZB_IS_64BIT_ADDR_ZERO

#define ZB_IS_64BIT_ADDR_ZERO (   addr)    (ZB_MEMCMP((addr), (void const*)g_zero_addr, 8) == 0)

Checks that long address is a zero one.

Parameters
addraddress to check.
Returns
ZB_TRUE if address is zero, ZB_FALSE otherwise.

◆ ZB_LETOH16

#define ZB_LETOH16   ZB_HTOLE16

Convert 16-bits integer from the little endian to the host endian

Parameters
ptr- destination pointer. It is ok if it not aligned to 2.
val- source pointer. It is ok if it not aligned to 2.

◆ ZB_PUT_NEXT_HTOLE16

#define ZB_PUT_NEXT_HTOLE16 (   ptr,
  val 
)
Value:
{ \
*((ptr)++) = (zb_uint8_t)(((val) >> 8U) & 0xffU); \
*((ptr)++) = (zb_uint8_t)((val) & 0xffU); \
}

◆ ZB_REVERSE16

#define ZB_REVERSE16 (   ptr,
  val 
)
Value:
(((zb_uint8_t *)(ptr))[0] = ((zb_uint8_t *)(val))[1], \
((zb_uint8_t *)(ptr))[1] = ((zb_uint8_t *)(val))[0])

◆ ZB_REVERSE64

#define ZB_REVERSE64 (   ptr,
  val 
)
Value:
*((zb_uint8_t*)(ptr)+7) = *((zb_uint8_t*)(val) ), \
*((zb_uint8_t*)(ptr)+6) = *((zb_uint8_t*)(val)+1), \
*((zb_uint8_t*)(ptr)+5) = *((zb_uint8_t*)(val)+2), \
*((zb_uint8_t*)(ptr)+4) = *((zb_uint8_t*)(val)+3), \
*((zb_uint8_t*)(ptr)+3) = *((zb_uint8_t*)(val)+4), \
*((zb_uint8_t*)(ptr)+2) = *((zb_uint8_t*)(val)+5), \
*((zb_uint8_t*)(ptr)+1) = *((zb_uint8_t*)(val)+6), \
*((zb_uint8_t*)(ptr) ) = *((zb_uint8_t*)(val)+7)

◆ ZB_TRUE

#define ZB_TRUE   1U

True value literal.

Typedef Documentation

◆ zb_bool_t

General purpose boolean type. For C90, 'zb_bool_t' is an alias of 'zb_uint8_t'. For C99, the availabilty of the 'stdbool.h' standard header is expected and 'zb_bool_t' is an alias of 'bool'. ZB_FALSE and ZB_TRUE are defined as macros for both standards.

Boolean type can be ZB_TRUE or ZB_FALSE.

To ensure that zb_bool_t always has the same size of one byte, static compile time assertions were added. See 'zb_common.h'.

◆ zb_ret_t

Return type for ZB functions returning execution status.

See also
RET_OK.

Function Documentation

◆ zb_put_next_htole16()

void* zb_put_next_htole16 ( zb_uint8_t dst,
zb_uint16_t  val 
)

Put next 2-bite value into buffer, move pointer

To be used for headers compose.

Parameters
dst- (in/out) address of the buffer pointer As a side effect it will be incremented by 2.
val- value
ZB_64BIT_ADDR_CMP
#define ZB_64BIT_ADDR_CMP(one, two)
Check two long addresses are equal.
zb_uint8_t
unsigned char zb_uint8_t
Project-local 1-byte unsigned int type.
Definition: zb_types.h:145