Z-Wave Protocol Controller Reference
zwapi_init.h
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
20#ifndef ZWAPI_INIT_H
21#define ZWAPI_INIT_H
22
23#include <stdint.h>
24#include <stdbool.h>
25#include "sl_status.h"
27#include "zwave_rf_region.h"
28#ifdef __cplusplus
29extern "C" {
30#endif
31
46typedef enum {
48 = 0x01,
55 = 0x07,
61
66typedef enum {
68 = 0x00,
73
74#define ZWAPI_MAXIMUM_BITMASK_LENGTH (255 / 8)
77#define GET_INIT_DATA_FLAG_END_NODE_API 0x01
78#define GET_INIT_DATA_FLAG_TIMER_SUPPORT 0x02
80#define GET_INIT_DATA_FLAG_CONTROLLER_STATUS 0x04
81#define GET_INIT_DATA_FLAG_SECONDARY_CTRL 0x04
82#define GET_INIT_DATA_FLAG_IS_SUC 0x08
84
89typedef struct {
90 uint8_t chip_type;
91 uint8_t chip_revision;
104 uint16_t product_type;
107 uint16_t product_id;
109 uint8_t supported_bitmask[ZWAPI_MAXIMUM_BITMASK_LENGTH];
111 uint8_t supported_setup_bitmask[ZWAPI_MAXIMUM_BITMASK_LENGTH];
120
121// Size of a git commit hash
122#define GIT_COMMIT_HASH_SIZE 16
123
124/* Protocol version structure used in zwapi_get_protocol_version() */
126 uint8_t type; // Type is a strange field that is not really used
130 uint16_t build_number;
133
173 uint8_t rx_status,
174 zwave_node_id_t destination_node_id,
175 zwave_node_id_t source_node_id,
176 const uint8_t *received_frame,
177 uint8_t received_frame_length,
178 int8_t rssi_value);
179
184 zwave_node_id_t destination_node_id,
185 uint8_t payload_length,
186 const uint8_t *payload,
187 uint8_t protocol_metadata_length,
188 const uint8_t *const protocol_metadata,
189 uint8_t use_supervision,
190 uint8_t session_id);
191
255 uint8_t status,
257 const uint8_t *zwave_nif,
258 uint8_t zwave_nif_length,
259 zwave_home_id_t nwi_home_id);
260
270typedef struct zwapi_callbacks {
275 void (*zwapi_started)(const uint8_t *pData, uint8_t pLen);
276 void (*poll_request)();
278
292sl_status_t zwapi_init(const char *serial_port,
293 int *serial_fd,
295
301void zwapi_destroy(void);
302
315sl_status_t zwapi_log_to_file_enable(const char *filename);
316
325
345bool zwapi_poll(void);
346
359bool zwapi_support_command_func(uint8_t func_id);
360
376
389
414 uint8_t *capabilities,
415 uint8_t *len,
416 zwave_nodemask_t node_list,
417 uint8_t *chip_type,
418 uint8_t *chip_version);
419
432
443void zwapi_get_chip_type_version(uint8_t *type, uint8_t *version);
444
453void zwapi_get_app_version(uint8_t *major, uint8_t *minor);
454
463void zwapi_get_chip_data(zwapi_chip_data_t *user_chip_data);
464
473
482 zwapi_protocol_version_information_t *protocol_version);
483
490
504
511
519
526
527// CLEANUP: Moved form sdk_versioning.h
538const char *
539 zwapi_generate_sdk_version_from_protocol_version(const char *version_string);
540
551const char *
552 zwapi_generate_nvm_id_from_sdk_version(const char *sdk_ver,
553 zwapi_library_type_t library_type);
554
556
557#ifdef __cplusplus
558}
559#endif
560
561#endif // ZWAPI_INIT_H
serial_api_setup_cmd_t
Bitflag definitions for FUNC_ID_SERIAL_API_SETUP command.
Definition: zwapi_protocol_basis.h:42
const char * zwapi_generate_sdk_version_from_protocol_version(const char *version_string)
Convert protocol version string to Z-Wave SDK version string.
Definition: zwapi_init.c:389
bool zwapi_support_command_func(uint8_t func_id)
Check if a command is supported by the connected Z-Wave module.
Definition: zwapi_init.c:49
sl_status_t zwapi_log_to_file_enable(const char *filename)
Enable logging of serial data to a file.
Definition: zwapi_init.c:121
struct _zwapi_protocol_version_information_t_ zwapi_protocol_version_information_t
struct zwapi_callbacks zwapi_callbacks_t
Structure holding the application callback functions.
sl_status_t zwapi_log_to_file_disable()
Disable/stop logging serial data to file.
Definition: zwapi_init.c:126
zwapi_library_type_t zwapi_get_library_type()
returns the cached value of the library type for the module
Definition: zwapi_init.c:346
zwapi_callbacks_t * zwave_api_get_callbacks()
Returns the pointer to the callbacks registered at init.
Definition: zwapi_init.c:591
sl_status_t zwapi_set_zwave_lr_channel(zwave_lr_channel_t new_channel)
Sets the desired Z-Wave Long Range Channel configuration.
Definition: zwapi_init.c:612
sl_status_t zwapi_init(const char *serial_port, int *serial_fd, const zwapi_callbacks_t *callbacks)
Definition: zwapi_init.c:94
bool zwapi_support_setup_func(serial_api_setup_cmd_t setup_cmd)
Check if one of the serial API setup commands is supported.
Definition: zwapi_init.c:69
#define ZWAPI_MAXIMUM_BITMASK_LENGTH
Definition: zwapi_init.h:74
void(* application_command_handler_function)(uint8_t rx_status, zwave_node_id_t destination_node_id, zwave_node_id_t source_node_id, const uint8_t *received_frame, uint8_t received_frame_length, int8_t rssi_value)
Application command handler function type definition.
Definition: zwapi_init.h:172
void zwapi_destroy(void)
Shut down the Z-Wave API and close the communication ports.
Definition: zwapi_init.c:116
sl_status_t zwapi_get_node_list(zwave_nodemask_t node_list)
Refresh the node list from the Z-Wave protocol and copy in into the node_list pointer.
Definition: zwapi_init.c:313
void(* protocol_cc_encryption_command_handler_function)(zwave_node_id_t destination_node_id, uint8_t payload_length, const uint8_t *payload, uint8_t protocol_metadata_length, const uint8_t *const protocol_metadata, uint8_t use_supervision, uint8_t session_id)
Definition: zwapi_init.h:183
void zwapi_get_chip_data(zwapi_chip_data_t *user_chip_data)
Return all information known about the chip after initialization.
Definition: zwapi_init.c:341
zwave_lr_channel_t zwapi_get_zwave_lr_channel()
Reads the currently configured Z-Wave Long Range Channel.
Definition: zwapi_init.c:596
#define GIT_COMMIT_HASH_SIZE
Definition: zwapi_init.h:122
sl_status_t zwapi_refresh_capabilities(void)
Refresh the whole zwapi_chip_data_t structure from the Z-Wave module.
Definition: zwapi_init.c:149
zwapi_library_type_t
Definition: zwapi_init.h:46
void zwapi_set_awaiting_zwave_api_started(bool value)
Sets the value of "awaiting a Z-Wave API started callback".
Definition: zwapi_init.c:586
zwave_lr_channel_t
Definition: zwapi_init.h:66
bool zwapi_poll(void)
Main poll loop for the Z-Wave API.
Definition: zwapi_init.c:131
void zwapi_get_app_version(uint8_t *major, uint8_t *minor)
Get the application version of the serial API on the Z-Wave module.
Definition: zwapi_init.c:329
const char * zwapi_generate_nvm_id_from_sdk_version(const char *sdk_ver, zwapi_library_type_t library_type)
Convert Z-Wave SDK version to the NVM ID.
Definition: zwapi_init.c:486
void zwapi_get_chip_type_version(uint8_t *type, uint8_t *version)
Look up the cached chip type and chip version.
Definition: zwapi_init.c:335
void(* application_controller_update_function)(uint8_t status, zwave_node_id_t node_id, const uint8_t *zwave_nif, uint8_t zwave_nif_length, zwave_home_id_t nwi_home_id)
Application controller update function type definition.
Definition: zwapi_init.h:254
bool zwapi_is_awaiting_zwave_api_started()
Checks if we are waiting for a Z-Wave API started message.
Definition: zwapi_init.c:581
sl_status_t zwapi_get_protocol_version(zwapi_protocol_version_information_t *protocol_version)
Retrieves versioning data from the Z-Wave API Module.
Definition: zwapi_init.c:352
sl_status_t zwapi_get_init_data(uint8_t *ver, uint8_t *capabilities, uint8_t *len, zwave_nodemask_t node_list, uint8_t *chip_type, uint8_t *chip_version)
Get zwave_api initialization data from the remote side (Enhanced Z-Wave module).
Definition: zwapi_init.c:255
@ ZWAVE_LIBRARY_TYPE_CONTROLLER_BRIDGE
aka ZW_LIB_CONTROLLER_BRIDGE
Definition: zwapi_init.h:54
@ ZWAVE_LIBRARY_TYPE_END_NODE_ROUTING
aka ZW_LIB_SLAVE_ROUTING
Definition: zwapi_init.h:53
@ ZWAVE_LIBRARY_TYPE_CONTROLLER_STATIC
aka ZW_LIB_CONTROLLER_STATIC
Definition: zwapi_init.h:47
@ ZWAVE_LIBRARY_TYPE_END_NODE
aka ZW_LIB_SLAVE
Definition: zwapi_init.h:51
@ ZWAVE_LIBRARY_TYPE_DUT
aka ZW_LIB_DUT
Definition: zwapi_init.h:56
@ ZWAVE_LIBRARY_TYPE_AVREMOTE
aka ZW_LIB_AVREMOTE
Definition: zwapi_init.h:57
@ ZWAVE_LIBRARY_TYPE_INSTALLER
aka ZW_LIB_INSTALLER
Definition: zwapi_init.h:52
@ ZWAVE_LIBRARY_TYPE_AVDEVICE
aka ZW_LIB_AVDEVICE
Definition: zwapi_init.h:58
@ ZWAVE_LIBRARY_TYPE_END_NODE_ENHANCED
aka ZW_LIB_SLAVE_ENHANCED
Definition: zwapi_init.h:50
@ ZWAVE_LIBRARY_TYPE_CONTROLLER
aka ZW_LIB_CONTROLLER
Definition: zwapi_init.h:49
@ ZWAVE_LONG_RANGE_CHANNEL_A
Z-Wave Long Range Channel A.
Definition: zwapi_init.h:69
@ ZWAVE_LONG_RANGE_CHANNEL_B
Z-Wave Long Range Channel B.
Definition: zwapi_init.h:70
@ ZWAVE_LONG_RANGE_CHANNEL_NOT_SUPPORTED
Z-Wave LR is not supported.
Definition: zwapi_init.h:67
uint32_t sl_status_t
Definition: sl_status.h:139
uint32_t zwave_home_id_t
Z-Wave HomeID type.
Definition: zwave_node_id_definitions.h:87
uint8_t zwave_nodemask_t[ZW_LR_MAX_NODEMASK_LENGTH]
Node mask.
Definition: zwave_node_id_definitions.h:81
uint16_t zwave_node_id_t
Z-Wave NodeID type.
Definition: zwave_node_id_definitions.h:84
zwave_rf_region_t
Definition: zwave_rf_region.h:31
SL Status Codes.
Definition: zwapi_init.h:125
uint8_t revision_version
Definition: zwapi_init.h:129
uint16_t build_number
Definition: zwapi_init.h:130
uint8_t minor_version
Definition: zwapi_init.h:128
uint8_t major_version
Definition: zwapi_init.h:127
uint8_t git_commit[GIT_COMMIT_HASH_SIZE]
Definition: zwapi_init.h:131
uint8_t type
Definition: zwapi_init.h:126
Structure holding the application callback functions.
Definition: zwapi_init.h:270
application_controller_update_function application_controller_update
Definition: zwapi_init.h:272
application_command_handler_function application_command_handler
Definition: zwapi_init.h:271
void(* zwapi_started)(const uint8_t *pData, uint8_t pLen)
Definition: zwapi_init.h:275
application_command_handler_function application_command_handler_bridge
Definition: zwapi_init.h:273
protocol_cc_encryption_command_handler_function protocol_cc_encryption_request
Definition: zwapi_init.h:274
void(* poll_request)()
Definition: zwapi_init.h:276
Definition: zwapi_init.h:89
uint8_t chip_revision
Major version number for the Z-Wave module API software.
Definition: zwapi_init.h:91
uint8_t version_minor
Library type of the software running the Z-Wave API.
Definition: zwapi_init.h:95
uint8_t capability_flag
List of existing nodes in the network.
Definition: zwapi_init.h:115
zwapi_library_type_t library_type
Definition: zwapi_init.h:97
uint16_t product_id
Bitmask of supported FUNC_ID for the Z-Wave API.
Definition: zwapi_init.h:107
zwave_nodemask_t node_list
Definition: zwapi_init.h:117
uint8_t version_major
Minor version number for the Z-Wave module API software.
Definition: zwapi_init.h:93
zwave_rf_region_t rf_region
Z-Wave module capabilities.
Definition: zwapi_init.h:113
uint16_t manufacturer_id
Definition: zwapi_init.h:100
uint16_t product_type
Definition: zwapi_init.h:104
uint8_t chip_type
Represents the chip hardware.
Definition: zwapi_init.h:90
const zwave_node_id_t node_id
Z-Wave API for basis controller/end node application interface.
static int serial_fd
Definition: zwapi_serial.c:33
static zwave_s2_network_callbacks_t callbacks
Definition: zwave_s2_network.c:30