![]() |
nRF5 SDK for Thread and Zigbee v1.0.0
|
Choose documentation: | nRF5 SDK | S112 SoftDevice API | S132 SoftDevice API | S140 SoftDevice API | S212 SoftDevice API |
Data Structures | |
struct | log_ctx_t |
struct | ping_reply_s |
The row of the table which holds the replies which are to be sent. More... | |
struct | attr_query_s |
The row of the table which holds the requests which were sent. More... | |
struct | tsn_ctx_t |
struct | configure_reporting_req_t |
Macros | |
#define | NRF_LOG_SUBMODULE_NAME ping |
Name of the submodule used for logger messaging. | |
#define | ATTRIBUTE_TABLE_SIZE 20 |
#define | ATTRIBUTE_ROW_TIMEOUT_S 10 |
#define | ZIGBEE_CLI_CONFIGURE_REPORT_TSN 3 |
#define | ZIGBEE_CLI_CONFIGURE_REPORT_RESP_TIMEOUT 5 |
#define | ZIGBEE_CLI_CONFIGURE_REPORT_DEFAULT_MIN_INTERVAL 1 |
#define | ZIGBEE_CLI_CONFIGURE_REPORT_DEFAULT_MAX_INTERVAL 60 |
#define | ZIGBEE_CLI_CONFIGURE_REPORT_DEFAULT_VALUE_CHANGE NULL |
#define | ZIGBEE_CLI_CONFIGURE_REPORT_OFF_MIN_INTERVAL 0x000F |
#define | ZIGBEE_CLI_CONFIGURE_REPORT_OFF_MAX_INTERVAL 0xFFFF |
#define | NRF_LOG_SUBMODULE_NAME report |
Name of the submodule used for logger messaging. | |
Typedefs | |
typedef struct ping_reply_s | ping_reply_t |
The row of the table which holds the replies which are to be sent. More... | |
typedef enum attr_type_e | attr_req_type_t |
typedef struct attr_query_s | attr_query_t |
The row of the table which holds the requests which were sent. More... | |
Enumerations | |
enum | attr_type_e { ATTR_READ_REQUEST, ATTR_WRITE_REQUEST } |
Functions | |
NRF_LOG_INSTANCE_REGISTER (zigbee, ping, ZIGBEE_CLI_CONFIG_INFO_COLOR, ZIGBEE_CLI_CONFIG_DEBUG_COLOR, ZIGBEE_CLI_CONFIG_LOG_INIT_FILTER_LEVEL, ZIGBEE_CLI_CONFIG_LOG_ENABLED?ZIGBEE_CLI_CONFIG_LOG_LEVEL:NRF_LOG_SEVERITY_NONE) | |
static zb_uint32_t | get_request_duration (ping_request_t *p_request) |
Get time difference, in microseconds between ping request identified by row number and current time. More... | |
ping_request_t * | zb_ping_acquire_request (void) |
zb_void_t | zb_ping_release_request (ping_request_t *p_reply) |
static ping_reply_t * | ping_aquire_reply (void) |
Acquire ping reply context. More... | |
zb_void_t | ping_release_reply (ping_reply_t *p_reply) |
Release ping reply context. More... | |
static zb_void_t | invalidate_row_cb (zb_uint8_t row) |
Invalidate Ping Request row after the timeout - ZBOSS callback. More... | |
static ping_request_t * | find_request_by_short (zb_uint16_t addr_short) |
Get the first row with request sent to addr_short, return NULL if none. More... | |
static ping_request_t * | find_request_by_sn (zb_uint8_t seqnum) |
Get the taken row with the selected seq_num, return NULL if none. More... | |
static zb_int8_t | get_request_row (ping_request_t *p_request) |
Get row number for the ping request. More... | |
static time_abs_t | abs_time_now (void) |
Get current abs time. | |
static zb_void_t | dispatch_user_callback (zb_uint8_t param) |
static void | ping_cli_evt_handler (ping_time_evt_t evt, zb_uint32_t delay_us, ping_request_t *p_request) |
Default ping event handler. Prints out measured time on the CLI and exits. More... | |
zb_void_t | ping_request_send (ping_request_t *p_request) |
static zb_void_t | ping_reply_send (ping_reply_t *p_reply) |
Actually construct the Ping Reply frame and send it. More... | |
static zb_uint8_t | cli_agent_ep_handler_ping (zb_uint8_t param) |
The Handler to 'intercept' every frame coming to the endpoint. More... | |
static void | cmd_zb_ping (nrf_cli_t const *p_cli, size_t argc, char **argv) |
ping over ZCL More... | |
NRF_SECTION_ITEM_REGISTER (zb_ep_handlers, zb_device_handler_t const CONCAT_2(zb_ep_, ping)) | |
Endpoint handlers. | |
NRF_CLI_CMD_REGISTER (ping, NULL,"ping over ZCL", cmd_zb_ping) | |
Command set array. | |
static zb_int8_t | get_free_row_attr_table () |
Get the first free row in the attributes table, return -1 if none. | |
static zb_int8_t | get_attr_table_row_by_sn (zb_uint8_t sernum) |
Get the taken row with the selected seq_num, return -1 if none. More... | |
static zb_void_t | invalidate_row (zb_uint8_t row) |
Invaidate row after the timeout. More... | |
static zb_bool_t | is_response (zb_zcl_parsed_hdr_t *p_hdr, attr_query_t *p_row) |
Check if the frame we received is the response to our request in the table. More... | |
static void | print_read_attr_response (zb_buf_t *p_zcl_cmd_buf, attr_query_t *p_row) |
Print the Read Attribute Response. More... | |
static void | print_write_attr_response (zb_buf_t *p_zcl_cmd_buf, attr_query_t *p_row) |
Print the Write Attribute Response. More... | |
static zb_uint8_t | cli_agent_ep_handler_attr (zb_uint8_t param) |
The Handler to 'intercept' every frame coming to the endpoint. More... | |
static zb_void_t | readattr_send (zb_uint8_t param, zb_uint16_t cb_param) |
Actually construct the Read Attribute frame and send it. More... | |
static zb_void_t | writeattr_send (zb_uint8_t param, zb_uint16_t cb_param) |
Actually construct the Write Attribute frame and send it. More... | |
static void | cmd_zb_readattr (nrf_cli_t const *p_cli, size_t argc, char **argv) |
Retrieve the attribute value of the remote node. More... | |
static void | cmd_zb_writeattr (nrf_cli_t const *p_cli, size_t argc, char **argv) |
Write the attribute value to the remote node. More... | |
NRF_SECTION_ITEM_REGISTER (zb_ep_handlers, zb_device_handler_t const CONCAT_2(zb_ep_, attr)) | |
Endpoint handlers. | |
NRF_CLI_CMD_REGISTER (readattr, NULL,"readattr", cmd_zb_readattr) | |
Command set array. | |
NRF_CLI_CMD_REGISTER (writeattr, NULL,"writeattr", cmd_zb_writeattr) | |
NRF_LOG_INSTANCE_REGISTER (zigbee, report, ZIGBEE_CLI_CONFIG_INFO_COLOR, ZIGBEE_CLI_CONFIG_DEBUG_COLOR, ZIGBEE_CLI_CONFIG_LOG_INIT_FILTER_LEVEL, ZIGBEE_CLI_CONFIG_LOG_ENABLED?ZIGBEE_CLI_CONFIG_LOG_LEVEL:NRF_LOG_SEVERITY_NONE) | |
static tsn_ctx_t * | get_ctx_by_tsn (uint8_t tsn) |
Return a pointer to context with the given transaction sequence number. More... | |
static tsn_ctx_t * | get_free_tsn_ctx (void) |
Get a pointer to a free context. More... | |
static void | invalidate_ctx (tsn_ctx_t *p_tsn_ctx) |
static void | cmd_zb_subscribe_unsubscribe_timeout (zb_uint8_t param) |
Handles timeout error and invalidates configure reporting transaction. More... | |
static void | cmd_zb_subscribe_unsubscribe_cb (tsn_ctx_t *p_tsn_ctx, zb_uint8_t param) |
Print the Configure Reporting Response. More... | |
static void | print_attr_update (zb_zcl_parsed_hdr_t *p_zcl_hdr, zb_uint8_t param) |
Print the Report Attribute Command. More... | |
static zb_uint8_t | cli_agent_ep_handler_report (zb_uint8_t param) |
The Handler to 'intercept' every frame coming to the endpoint. More... | |
static void | cmd_zb_subscribe (nrf_cli_t const *p_cli, size_t argc, char **argv) |
Subscribe to the attribute changes on the remote node. More... | |
static void | cmd_zb_unsubscribe (nrf_cli_t const *p_cli, size_t argc, char **argv) |
Unsubscribe from attribute reports. More... | |
NRF_SECTION_ITEM_REGISTER (zb_ep_handlers, zb_device_handler_t const CONCAT_2(zb_ep_, report)) | |
Endpoint handlers. | |
NRF_CLI_CMD_REGISTER (subscribe, NULL,"subscribe to remote attribute changes", cmd_zb_subscribe) | |
Command set array. | |
NRF_CLI_CMD_REGISTER (unsubscribe, NULL,"unsubscribe from remote attribute changes", cmd_zb_unsubscribe) | |
Variables | |
static ping_request_t | m_ping_request_table [10] |
static ping_reply_t | m_ping_reply_table [10] |
static uint8_t | m_ping_seq_num |
static log_ctx_t | m_log |
static attr_query_t | m_attr_table [20] |
static log_ctx_t | m_log |
static tsn_ctx_t | m_tsn_ctx [3] |
typedef struct attr_query_s attr_query_t |
The row of the table which holds the requests which were sent.
We compare the incoming responses with the rows contents to determine if it is the answer. The structure corresponds to both read and write requests. The key parameter is the sequence number.
typedef struct ping_reply_s ping_reply_t |
The row of the table which holds the replies which are to be sent.
We use the table to temporarily store the parameters of the ping reply while it is traversing the ZBOSS callback system. The key parameter is the sequence number.
|
static |
The Handler to 'intercept' every frame coming to the endpoint.
param | Reference to a ZBOSS buffer |
|
static |
The Handler to 'intercept' every frame coming to the endpoint.
param | Reference to a ZBoss buffer |
|
static |
The Handler to 'intercept' every frame coming to the endpoint.
param[in] | Reference to a ZBOSS buffer |
|
static |
ping over ZCL
Example:
Issue a ping-style command to another CLI device of the address dst_addr
by using payload_size
bytes of payload.
Optionally, the device can request an APS acknowledgement (--aps-ack
) or ask destination not to sent ping reply (--no-echo
).
To implement the ping-like functionality, a new custom cluster has been defined with ID 64. There are four custom commands defined inside it, each with its own ID.
See the following flow graphs for details.
Case 1: Ping with echo, without the APS acknowledgement (default mode):
In this default mode, the ping
command measures the time needed for a Zigbee frame to travel between two nodes in the network (there and back again). The command uses a custom "overloaded" ZCL frame, which is constructed as a ZCL frame of the new custom ping ZCL cluster (ID 64).
|
static |
Retrieve the attribute value of the remote node.
Read the value of the attribute attr_id
in the cluster cluster
. The cluster belongs to the profile profile
, which resides on the endpoint ep
of the remote node dst_addr
.
|
static |
Subscribe to the attribute changes on the remote node.
Enable reporting on the node identified by eui64
, with the endpoint ep
that uses the profile profile
of the attribute attr ID
with the type attr type
in the cluster cluster
.
Reports must be generated in intervals not shorter than min interval
(1 second by default) and not longer than max interval
(60 seconds by default).
|
static |
Print the Configure Reporting Response.
p_zcl_cmd_buf[in] | Pointer to a ZBOSS buffer |
p_row[in] | Pointer to a row in attr table |
|
static |
Handles timeout error and invalidates configure reporting transaction.
[in] | param | ZBOSS transaction sequence number |
|
static |
Unsubscribe from attribute reports.
Disable reporting on the node identified by eui64
, with the endpoint ep
that uses the profile profile
of the attribute attr ID
with the type attr type
in the cluster cluster
.
|
static |
Write the attribute value to the remote node.
Write the attr_value
value of the attribute attr_id
of the type attr_type
in the cluster cluster
. The cluster belongs to the profile profile
, which resides on the endpoint ep
of the remote node dst_addr
.
attr_value
value must be in hexadecimal format, unless it is a string (attr_type == 42
), then it must be a string.
|
static |
Default handler for incoming ping request APS acknowledgements.
If there is a user callback defined for the acknowledged request, the callback with PING_EVT_ACK_RECEIVED event will be called.
[in] | param | Reference to a ZBoss buffer containing APC ACK data, |
|
static |
Get the first row with request sent to addr_short, return NULL if none.
addr_short | Short network address to look for. |
|
static |
Get the taken row with the selected seq_num, return NULL if none.
seqnum | Sequence Number to look for |
|
static |
Get the taken row with the selected seq_num, return -1 if none.
sernum | Sequence Number to look for |
|
static |
Return a pointer to context with the given transaction sequence number.
[in] | tsn | ZBOSS transaction sequence number |
|
static |
Get a pointer to a free context.
|
static |
Get time difference, in microseconds between ping request identified by row number and current time.
[in] | p_row | Pointer to the ping request structure, from which the time difference should be calculated. |
|
static |
Get row number for the ping request.
[in] | p_row | Pointer to the ping request context. |
|
static |
Invalidate context.
[in] | p_tsn_ctx | a pointer to transaction context. |
|
static |
Invaidate row after the timeout.
row | Number of row to invalidate |
|
static |
Invalidate Ping Request row after the timeout - ZBOSS callback.
row | Number of row to invalidate |
|
static |
Check if the frame we received is the response to our request in the table.
p_hdr | Pointer to the parsed header of the frame |
p_row | Pointer to the row in the table to check against |
|
static |
Acquire ping reply context.
|
static |
Default ping event handler. Prints out measured time on the CLI and exits.
[in] | evt_type | Type of received ping acknowledgment |
[in] | delay_us | Time, in microseconds, between ping request and the event. |
[in] | p_request | Pointer to the ongoing ping request context structure. |
zb_void_t ping_release_reply | ( | ping_reply_t * | p_reply | ) |
Release ping reply context.
p_reply | Pointer to the reply context structure to release. |
|
static |
Actually construct the Ping Reply frame and send it.
p_row | Pointer to the ping reply context structure. |
|
static |
Print the Report Attribute Command.
p_zcl_cmd_buf[in] | Pointer to a ZBOSS buffer |
p_row[in] | Pointer to a row in attr table |
|
static |
Print the Read Attribute Response.
p_zcl_cmd_buf | Pointer to a ZBOSS buffer |
p_row | Pointer to a row in attr table |
|
static |
Print the Write Attribute Response.
p_zcl_cmd_buf | Pointer to a ZBOSS buffer |
p_row | Pointer to a row in attr table |
|
static |
Actually construct the Read Attribute frame and send it.
param | ZBOSS buffer to fill. |
cb_param | Row of the read attribute table to refer to. |
|
static |
Actually construct the Write Attribute frame and send it.
param | ZBOSS buffer to fill. |
cb_param | Row of the read attribute table to refer to. |
|
static |
|
static |