8#ifndef ZIGBEE_ZB_NET_H_
9#define ZIGBEE_ZB_NET_H_
11#include <zigbee/zb_frame.h>
12#include <zigbee/zb_mac.h>
13#include <zigbee/znp_nv.h>
17 ZB_NV_EXTADDR = 0x0001,
18 ZB_NV_STARTUP_OPTION = 0x0003,
20 ZB_NV_EXTENDED_PAN_ID = 0x002D,
21 ZB_NV_BCAST_DELIVERY_TIME = 0x0030,
22 ZB_NV_CONCENTRATOR_ENABLE = 0x0032,
23 ZB_NV_CONCENTRATOR_DISCOVERY = 0x0033,
24 ZB_NV_CONCENTRATOR_RC = 0x0036,
25 ZB_NV_SRC_RTG_EXPIRY_TIME = 0x0038,
26 ZB_NV_NWK_ACTIVE_KEY_INFO = 0x003A,
27 ZB_NV_NWK_ALTERN_KEY_INFO = 0x003B,
28 ZB_NV_NWK_CHILD_AGE_ENABLE = 0x003E,
29 ZB_NV_APS_USE_EXT_PANID = 0x0047,
30 ZB_NV_APS_LINK_KEY_TABLE = 0x004C,
31 ZB_NV_BDB_NODE_IS_ON_NETWORK = 0x0055,
32 ZB_NV_MIGRATION_ID = 0x005F,
33 ZB_NV_HAS_CONFIGURED_ZSTACK3 = 0x0060,
34 ZB_NV_PRECFGKEY = 0x0062,
35 ZB_NV_PRECFGKEYS_ENABLE = 0x0063,
36 ZB_NV_NWKKEY = 0x0082,
38 ZB_NV_CHANLIST = 0x0084,
39 ZB_NV_LOGICAL_TYPE = 0x0087,
40 ZB_NV_ZDO_DIRECT_CB = 0x008F,
41 ZB_NV_TCLK_SEED = 0x0101,
43 ZB_NV_APS_FRAME_COUNTER = 0x0F20,
49 ZB_NVEX_TCLK_TABLE = 4,
50 ZB_NVEX_APS_KEY_DATA = 6,
51 ZB_NVEX_NWK_SEC_MATERIAL = 7,
55#define ZB_NWKKEY_LEN 24
56#define ZB_ADDRMGR_LEN 12
58#define ZB_APS_KEY_LEN 24
59#define ZB_SECMAT_LEN 12
60#define ZB_KEYDESC_LEN 17
61#define ZB_LINK_KEY_TABLE_ENTRIES 16
63#define ZB_NET_MAX_CHILDREN 32
64#define ZB_TABLE_ENTRIES 32
65#define ZB_SECMAT_ENTRIES 4
67#define ZB_ALL_CHANNELS 0x07FFF800U
70#define ZB_NIB_SECURITY_LEVEL 12
71#define ZB_NIB_DEV_ADDR 22
72#define ZB_NIB_CHANNEL 24
73#define ZB_NIB_COORD_ADDR 26
74#define ZB_NIB_COORD_EXT 28
75#define ZB_NIB_PAN_ID 36
76#define ZB_NIB_STATE 38
77#define ZB_NIB_CHANNEL_LIST 40
79#define ZB_NIB_KEY_LOADED 65
80#define ZB_NIB_MANAGER_ADDR 110
81#define ZB_NIB_UPDATE_ID 114
85#define ZB_NWK_ROUTER 8
90 ZB_DEV_COORD_STARTING = 8,
95 ZB_BDB_STEERING = 0x02,
96 ZB_BDB_FORMATION = 0x04,
101 ZB_BDB_IN_PROGRESS = 1,
102 ZB_BDB_FORMATION_FAILURE = 8,
106#define ZB_STARTUP_CLEAR_CONFIG BIT(0)
107#define ZB_STARTUP_CLEAR_STATE BIT(1)
126 uint16_t cluster, profile;
127 uint8_t src_ep, dst_ep;
140 uint8_t src_ep, dst_ep;
141 uint16_t cluster, profile;
152#define ZB_CONFIRM_OK 0x00
153#define ZB_CONFIRM_FAILURE 0x01
154#define ZB_CONFIRM_APS_NO_ACK 0xB7
155#define ZB_CONFIRM_NO_ROUTE 0xCD
156#define ZB_CONFIRM_CHANNEL_BUSY 0xE1
157#define ZB_CONFIRM_MAC_NO_ACK 0xE9
160#define ZB_APS_MAX_PAYLOAD 82
164 void (*state)(
void *ctx, uint8_t dev_state);
165 void (*bdb)(
void *ctx, uint8_t status, uint8_t mode, uint8_t remaining);
167 void (*beacons)(
void *ctx,
const struct zb_beacon_info *b,
size_t n);
168 void (*discovery_done)(
void *ctx, uint8_t status);
170 void (*energy_done)(
void *ctx,
int status, uint32_t mask,
const uint8_t *ed,
size_t n,
172 void (*permit)(
void *ctx, uint8_t duration);
174 void (*tc_join)(
void *ctx, uint16_t nwk,
const uint8_t ext[8], uint16_t parent);
176 void (*aps_rx)(
void *ctx,
const struct zb_aps_rx *rx);
178 void (*data_confirm)(
void *ctx, uint8_t status, uint32_t tag);
180 void (*trace)(
void *ctx,
const char *msg);
184#define ZB_APS_WAITS 6
224 uint32_t bdb_primary, bdb_secondary;
225 struct zb_child children[ZB_NET_MAX_CHILDREN];
230 uint8_t nwk_key[ZB_KEY_LEN];
232 uint8_t tc_link_key[ZB_KEY_LEN];
233 uint32_t nwk_fc, nwk_fc_limit;
234 uint32_t aps_fc, aps_fc_limit;
235 uint8_t nwk_seq, aps_counter;
236 int64_t next_link_status;
251int zb_net_boot(
struct zb_net *n,
const uint8_t default_eui[8]);
254void zb_nvdef_ensure(
struct znp_nv *nv,
const uint8_t eui[8],
bool reset_config);
256void zb_nvdef_clear_state(
struct znp_nv *nv);
259void zb_net_bdb_set_channel(
struct zb_net *n,
bool primary, uint32_t mask);
261int zb_net_bdb_start(
struct zb_net *n, uint8_t mode);
264int zb_net_permit(
struct zb_net *n, uint8_t seconds);
267int zb_net_discover(
struct zb_net *n, uint32_t mask, uint8_t exp);
269int zb_net_energy_scan(
struct zb_net *n, uint32_t mask, uint8_t exp, uint32_t tag);
276int zb_net_change_channel(
struct zb_net *n, uint8_t channel);
278int zb_net_set_channel_mask(
struct zb_net *n, uint32_t mask, uint16_t manager);
288int zb_net_child_add(
struct zb_net *n, uint16_t nwk,
const uint8_t ext[8], uint8_t cap);
289int zb_net_child_remove(
struct zb_net *n,
const uint8_t ext[8]);
292struct zb_child *zb_net_child_by_ext(
struct zb_net *n,
const uint8_t ext[8]);
293struct zb_child *zb_net_child_by_nwk(
struct zb_net *n, uint16_t nwk);
294size_t zb_net_child_count(
struct zb_net *n);
297const uint8_t *zb_net_eui(
const struct zb_net *n);
Definition zb_mac_frame.h:87