nRF5 SDK for Thread and Zigbee v3.2.0
Data Structures | Macros | Typedefs | Enumerations | Functions

Data Structures

struct  zb_production_config_hdr_t
 
struct  zb_production_config_s
 

Macros

#define ZB_INVALID_TX_POWER_VALUE   0x7F
 
#define ZB_PRODUCTION_CONFIG_MAX_SIZE   128
 

Typedefs

typedef enum
zb_nvram_dataset_types_e 
zb_nvram_dataset_types_t
 
typedef void(* zb_nvram_read_app_data_t )(zb_uint8_t page, zb_uint32_t pos, zb_uint16_t payload_length)
 
typedef zb_ret_t(* zb_nvram_write_app_data_t )(zb_uint8_t page, zb_uint32_t pos)
 
typedef zb_uint16_t(* zb_nvram_get_app_data_size_t )(void)
 
typedef struct
zb_production_config_hdr_t 
zb_production_config_hdr_t
 
typedef struct
zb_production_config_s 
zb_production_config_t
 

Enumerations

enum  zb_nvram_dataset_types_e {
  ZB_NVRAM_RESERVED = 0, ZB_NVRAM_COMMON_DATA = 1, ZB_NVRAM_HA_DATA = 2, ZB_NVRAM_ZCL_REPORTING_DATA = 3,
  ZB_NVRAM_APS_SECURE_DATA_GAP = 4, ZB_NVRAM_APS_BINDING_DATA_GAP = 5, ZB_NVRAM_HA_POLL_CONTROL_DATA = 6, ZB_IB_COUNTERS = 7,
  ZB_NVRAM_DATASET_GRPW_DATA = 8, ZB_NVRAM_APP_DATA1 = 9, ZB_NVRAM_APP_DATA2 = 10, ZB_NVRAM_ADDR_MAP = 11,
  ZB_NVRAM_NEIGHBOUR_TBL = 12, ZB_NVRAM_INSTALLCODES = 13, ZB_NVRAM_APS_SECURE_DATA = 14, ZB_NVRAM_APS_BINDING_DATA = 15,
  ZB_NVRAM_DATASET_GP_PRPOXYT = 16, ZB_NVRAM_DATASET_GP_SINKT = 17, ZB_NVRAM_DATASET_GP_CLUSTER = 18, ZB_NVRAM_APS_GROUPS_DATA = 19,
  ZB_NVRAM_DATASET_NUMBER, ZB_NVRAM_DATA_SET_TYPE_PAGE_HDR = 0x1e
}
 

Functions

void zb_nvram_register_app1_read_cb (zb_nvram_read_app_data_t cb)
 
void zb_nvram_register_app2_read_cb (zb_nvram_read_app_data_t cb)
 
void zb_nvram_register_app1_write_cb (zb_nvram_write_app_data_t wcb, zb_nvram_get_app_data_size_t gcb)
 
void zb_nvram_register_app2_write_cb (zb_nvram_write_app_data_t wcb, zb_nvram_get_app_data_size_t gcb)
 
void zb_nvram_write_dataset (zb_nvram_dataset_types_t t)
 
zb_void_t zb_set_nvram_erase_at_start (zb_bool_t erase)
 
void zb_nvram_transaction_start (void)
 
void zb_nvram_transaction_commit (void)
 

Detailed Description

There are two predefined dataset IDs for a user application: ZB_NVRAM_APP_DATA1 and ZB_NVRAM_APP_DATA2. It is up to the application to decide what data to store in NVRAM. However, the total data size (all datasets) stored in the NVRAM storage should be less than one virtual page size. To start using NVRAM in the application, the following steps should be done in the application:

Typedef Documentation

Enum All NVRAM dataset types

ZB_NVRAM_DATASET_NUMBER - count of dataset types. Not a real dataset type!

typedef zb_uint16_t(* zb_nvram_get_app_data_size_t)(void)

Returns size of application datasets

Returns
- size of application dataset in bytes
typedef void(* zb_nvram_read_app_data_t)(zb_uint8_t page, zb_uint32_t pos, zb_uint16_t payload_length)

Declares application callback used for reading application datasets from NVRAM.

Parameters
page- page in NVRAM from data will be read
pos- offset in page
payload_length- number of bytes to read
typedef zb_ret_t(* zb_nvram_write_app_data_t)(zb_uint8_t page, zb_uint32_t pos)

Declares application callback used for writing application datasets into NVRAM.

Parameters
page- page in NVRAM where data will be stotred
pos- offset in page
Returns
- RET_OK on successful write

Enumeration Type Documentation

Enum All NVRAM dataset types

ZB_NVRAM_DATASET_NUMBER - count of dataset types. Not a real dataset type!

Enumerator
ZB_NVRAM_COMMON_DATA 

Dataset, contains common ZigBee data

ZB_NVRAM_HA_DATA 

Dataset, contains HA profile ZigBee data

ZB_NVRAM_ZCL_REPORTING_DATA 

Dataset, contains ZCL reporting data

ZB_NVRAM_HA_POLL_CONTROL_DATA 

Dataset, contains HA POLL CONTROL data

ZB_IB_COUNTERS 

Dataset, contains NIB outgoing frame counter

ZB_NVRAM_DATASET_GRPW_DATA 

Green Power dataset

ZB_NVRAM_APP_DATA1 

Application-specific data #1

ZB_NVRAM_APP_DATA2 

Application-specific data #2

ZB_NVRAM_ADDR_MAP 

Dataset stores address map info

ZB_NVRAM_NEIGHBOUR_TBL 

Dataset stores Neighbour table info

ZB_NVRAM_INSTALLCODES 

Dataset contains APS installcodes data

ZB_NVRAM_APS_SECURE_DATA 

Dataset, contains APS secure keys data

ZB_NVRAM_APS_BINDING_DATA 

Dataset, contains APS binding data

ZB_NVRAM_DATASET_GP_PRPOXYT 

Green Power Proxy table

ZB_NVRAM_DATASET_GP_SINKT 

Green Power Sink table

ZB_NVRAM_DATASET_GP_CLUSTER 

Green Power Cluster data

ZB_NVRAM_APS_GROUPS_DATA 

Dataset, contains APS groups data

ZB_NVRAM_DATASET_NUMBER 

Count of Dataset

ZB_NVRAM_DATA_SET_TYPE_PAGE_HDR 

Special internal dataset type

Function Documentation

void zb_nvram_register_app1_read_cb ( zb_nvram_read_app_data_t  cb)

Register application callback for reading ZB_NVRAM_APP_DATA1 from NVRAM

Parameters
cb- callback that will be called upon reading dataset
void zb_nvram_register_app1_write_cb ( zb_nvram_write_app_data_t  wcb,
zb_nvram_get_app_data_size_t  gcb 
)

Register application callback for writing ZB_NVRAM_APP_DATA1 to NVRAM

Parameters
wcb- callback that will be called upon writing
gcb- this callback will be called upon writing to determine dataset size
void zb_nvram_register_app2_read_cb ( zb_nvram_read_app_data_t  cb)

Register application callback for reading ZB_NVRAM_APP_DATA2 from NVRAM

Parameters
cb- callback that will be called upon reading dataset
void zb_nvram_register_app2_write_cb ( zb_nvram_write_app_data_t  wcb,
zb_nvram_get_app_data_size_t  gcb 
)

Register application callback for writing ZB_NVRAM_APP_DATA2 to NVRAM

Parameters
wcb- callback that will be called upon writing
gcb- this callback will be called upon writing to determine dataset size
void zb_nvram_transaction_commit ( void  )

Commit NVRAM transaction.

Finish writing multiple datasets at once. A transaction must started by calling zb_nvram_transaction_start().

void zb_nvram_transaction_start ( void  )

Start NVRAM transaction.

Start writing multiple datasets at once. A transaction must finished by calling zb_nvram_transaction_commit().

void zb_nvram_write_dataset ( zb_nvram_dataset_types_t  t)

Write specified dataset into NVRAM

Parameters
t- dataset index, see zb_nvram_dataset_types_e

Example #1:


Example #2 (Using application callbacks):
Define user dataset type:

struct ZB_PACKED_PRE thcx_nvram_app_dataset_s
{
zb_uint32_t current_test_step;
} ZB_PACKED_STRUCT;
typedef struct thcx_nvram_app_dataset_s thcx_nvram_app_dataset_t;

Callback prototypes:

static void read_thc_app_data_cb(zb_uint8_t page, zb_uint32_t pos, zb_uint16_t payload_length);
static zb_ret_t write_thc_app_data_cb(zb_uint8_t page, zb_uint32_t pos);
static zb_uint16_t thc_nvram_get_app_data_size_cb();

Register application callbacks:

zb_nvram_register_app1_read_cb(read_thc_app_data_cb);
zb_nvram_register_app1_write_cb(write_thc_app_data_cb, thc_nvram_get_app_data_size_cb);

Callback implementation and usage:

static void save_test_state()
{
TRACE_MSG(TRACE_APS3, ">>save_test_state: saved value = %d", (FMT__D, s_step_idx + 1));
TRACE_MSG(TRACE_APS3, "<<save_test_state", (FMT__0));
}
static void read_thc_app_data_cb(zb_uint8_t page, zb_uint32_t pos, zb_uint16_t payload_length)
{
zb_ret_t ret;
thcx_nvram_app_dataset_t ds;
if (payload_length == sizeof(ds))
{
ret = zb_osif_nvram_read(page, pos, (zb_uint8_t*)&ds, sizeof(ds));
if (ret == RET_OK)
{
s_step_idx = ds.current_test_step;
}
else
{
TRACE_MSG(TRACE_ERROR, "read_thc_app_data_cb: nvram read error %d", (FMT__D, ret));
}
}
else
{
TRACE_MSG(TRACE_ERROR, "read_thc_app_data_cb ds mismatch: got %d wants %d",
(FMT__D_D, payload_length, sizeof(ds)));
}
}
static zb_ret_t write_thc_app_data_cb(zb_uint8_t page, zb_uint32_t pos)
{
zb_ret_t ret = RET_OK;
thcx_nvram_app_dataset_t ds;
TRACE_MSG(TRACE_APS3, ">>write_thc_app_data_cb", (FMT__0));
ds.current_test_step = (zb_uint32_t) s_step_idx + 1;
ret = zb_osif_nvram_write(page, pos, (zb_uint8_t*)&ds, sizeof(ds));
TRACE_MSG(TRACE_APS3, "<<write_thc_app_data_cb ret %d", (FMT__D, ret));
return ret;
}
static zb_uint16_t thc_nvram_get_app_data_size_cb()
{
return sizeof(thcx_nvram_app_dataset_t);
}

See CN-NSA-TC-02

zb_void_t zb_set_nvram_erase_at_start ( zb_bool_t  erase)

Enable or disable NVRAM erasing on every application startup.

Parameters
erase- 1 to enable erasing; 0 - disable. Erasing is disabled by default.

Documentation feedback | Developer Zone | Subscribe | Updated