Z-Wave Protocol Controller Reference
zwapi_init.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "zwapi_init.h"
#include "zwapi_func_ids.h"
#include "zwapi_protocol_basis.h"
#include "zwapi_session.h"
#include "zwapi_serial.h"
#include "zwapi_internal.h"
#include "sl_log.h"
Include dependency graph for zwapi_init.c:

Macros

#define LOG_TAG   "zwapi_init"
 

Functions

static void zwapi_init_local_variables ()
 
bool zwapi_support_command_func (uint8_t func_id)
 Check if a command is supported by the connected Z-Wave module. More...
 
static bool is_bit_num_set_in_byte (uint8_t bit_num, uint8_t byte)
 
bool zwapi_support_setup_func (serial_api_setup_cmd_t setup_cmd)
 Check if one of the serial API setup commands is supported. More...
 
sl_status_t zwapi_init (const char *serial_port, int *serial_fd, const zwapi_callbacks_t *_callbacks)
 
void zwapi_destroy (void)
 Shut down the Z-Wave API and close the communication ports. More...
 
sl_status_t zwapi_log_to_file_enable (const char *filename)
 Enable logging of serial data to a file. More...
 
sl_status_t zwapi_log_to_file_disable ()
 Disable/stop logging serial data to file. More...
 
bool zwapi_poll ()
 Main poll loop for the Z-Wave API. More...
 
sl_status_t zwapi_refresh_capabilities (void)
 Refresh the whole zwapi_chip_data_t structure from the Z-Wave module. More...
 
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). More...
 
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. More...
 
void zwapi_get_app_version (uint8_t *major, uint8_t *minor)
 Get the application version of the serial API on the Z-Wave module. More...
 
void zwapi_get_chip_type_version (uint8_t *type, uint8_t *version)
 Look up the cached chip type and chip version. More...
 
void zwapi_get_chip_data (zwapi_chip_data_t *user_chip_data)
 Return all information known about the chip after initialization. More...
 
zwapi_library_type_t zwapi_get_library_type ()
 returns the cached value of the library type for the module More...
 
sl_status_t zwapi_get_protocol_version (zwapi_protocol_version_information_t *protocol)
 Retrieves versioning data from the Z-Wave API Module. More...
 
const char * zwapi_generate_sdk_version_from_protocol_version (const char *version_string)
 Convert protocol version string to Z-Wave SDK version string. More...
 
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. More...
 
sl_status_t zwapi_send_command (uint8_t command, const uint8_t *payload_buffer, uint8_t payload_buffer_length)
 Verifies that the command is supported by the Z-Wave module. More...
 
sl_status_t zwapi_send_command_with_response (uint8_t command, const uint8_t *payload_buffer, uint8_t payload_buffer_length, uint8_t *response_buffer, uint8_t *response_length)
 Send a command to the Z-Wave module and waits for an ACK. More...
 
sl_status_t zwapi_send_command_no_ack (uint8_t command, const uint8_t *payload_buffer, uint8_t payload_buffer_length)
 Send a command to the Z-Wave module without waiting for any ACK. More...
 
bool zwapi_is_awaiting_zwave_api_started ()
 Checks if we are waiting for a Z-Wave API started message. More...
 
void zwapi_set_awaiting_zwave_api_started (bool value)
 Sets the value of "awaiting a Z-Wave API started callback". More...
 
zwapi_callbacks_tzwave_api_get_callbacks ()
 Returns the pointer to the callbacks registered at init. More...
 
zwave_lr_channel_t zwapi_get_zwave_lr_channel ()
 Reads the currently configured Z-Wave Long Range Channel. More...
 
sl_status_t zwapi_set_zwave_lr_channel (zwave_lr_channel_t new_channel)
 Sets the desired Z-Wave Long Range Channel configuration. More...
 

Variables

static zwapi_chip_data_t chip
 
const char * zw_lib_names []
 
static zwapi_callbacks_tcallbacks
 
static bool awaiting_zwave_api_started
 

Macro Definition Documentation

◆ LOG_TAG

#define LOG_TAG   "zwapi_init"

Function Documentation

◆ is_bit_num_set_in_byte()

static bool is_bit_num_set_in_byte ( uint8_t  bit_num,
uint8_t  byte 
)
static
Here is the caller graph for this function:

◆ zwapi_init_local_variables()

static void zwapi_init_local_variables ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_send_command()

sl_status_t zwapi_send_command ( uint8_t  command,
const uint8_t *  payload_buffer,
uint8_t  payload_buffer_length 
)

Verifies that the command is supported by the Z-Wave module.

Parameters
commandZ-Wave Serial API Command (zwapi_func_ids.h)
payload_bufferByte array with serial API command parameters
payload_buffer_lengthLength in bytes of parameter array
Returns
SL_STATUS_OK if the frame is supported by the Z-Wave module, sent and Ack'ed by the module. SL_STATUS_NOT_SUPPORTED if the particular command is not supported by the Z-Wave API. SL_STATUS_FAIL in all other error cases.

Sends the command data frame to the Z-Wave module and waits for ACK.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_send_command_no_ack()

sl_status_t zwapi_send_command_no_ack ( uint8_t  command,
const uint8_t *  payload_buffer,
uint8_t  payload_buffer_length 
)

Send a command to the Z-Wave module without waiting for any ACK.

Parameters
commandZ-Wave Serial API Command (zwapi_func_ids.h)
payload_bufferByte array with serial API command parameters
payload_buffer_lengthLength in bytes of parameter array
Returns
SL_STATUS_OK if the frame is supported by the Z-Wave module. SL_STATUS_FAIL otherwise

Verifies that the command is supported by the Z-Wave module, sends the command data frame to the Z-Wave module but does not wait for any ACK

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_send_command_with_response()

sl_status_t zwapi_send_command_with_response ( uint8_t  command,
const uint8_t *  payload_buffer,
uint8_t  payload_buffer_length,
uint8_t *  response_buffer,
uint8_t *  response_length 
)

Send a command to the Z-Wave module and waits for an ACK.

Parameters
commandZ-Wave Serial API Command (zwapi_func_ids.h)
payload_bufferByte array with serial API command parameters
payload_buffer_lengthLength in bytes of parameter array
response_bufferOutput Buffer to hold response (buffer MUST be large enough to hold SERIAL_BUFFER_SIZE bytes).
response_lengthOuput Length of response copied to response_buf.
Returns
SL_STATUS_OK if the frame is supported by the Z-Wave module, sent, Ack'ed by the module and the corresponding Response frame has been received. SL_STATUS_NOT_SUPPORTED if the particular command is not supported by the Z-Wave API. SL_STATUS_FAIL if an error occurred.

Verifies that the command is supported by the Z-Wave module, sends the command data frame to the Z-Wave module, wait for ACK and a Response frame returning a status of the requested operation/command.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ awaiting_zwave_api_started

bool awaiting_zwave_api_started
static

◆ callbacks

zwapi_callbacks_t* callbacks
static

◆ chip

zwapi_chip_data_t chip
static

◆ zw_lib_names

const char* zw_lib_names[]
Initial value:
= {
"Unknown",
"Static Controller Node",
"Bridge Controller Node library",
"Portable Controller Node library",
"Enhanced End Node library",
"End Node library",
"Installer library",
}