Z-Wave Protocol Controller Reference
zwapi_session.h File Reference

Session level handling such as retries and request/response for commands using the zwapi_connection. More...

#include <stdbool.h>
#include "sl_status.h"
Include dependency graph for zwapi_session.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

Z-Wave API frames indexes used for parsing
#define IDX_LEN   0
 
#define IDX_TYPE   1
 
#define IDX_CMD   2
 
#define IDX_DATA   3
 
Z-Wave API frame types
#define FRAME_TYPE_REQUEST   0x00
 
#define FRAME_TYPE_RESPONSE   0x01
 

Functions

int zwapi_session_init (const char *serial_port)
 Initialize a zwapi_session with the Z-Wave module. More...
 
void zwapi_session_shutdown ()
 Close the zwapi_session with the Z-Wave module. More...
 
int zwapi_session_restart ()
 Closes and re-initializes the zwapi_session to the Z-Wave module. More...
 
sl_status_t zwapi_session_send_frame (uint8_t command, const uint8_t *payload_buffer, uint8_t payload_buffer_length)
 Send data frame to Z-Wave chip via serial port and wait for ACK. More...
 
sl_status_t zwapi_session_send_frame_with_response (uint8_t command, const uint8_t *payload_buffer, uint8_t payload_buffer_length, uint8_t *response_buf, uint8_t *response_len)
 Send data frame to Z-Wave chip via serial API, wait for ACK and a RES frame. More...
 
sl_status_t zwapi_session_send_frame_no_ack (uint8_t command, const uint8_t *payload_buffer, uint8_t payload_buffer_length)
 Send data frame to Z-Wave chip via serial API without waiting for ACK. More...
 
void zwapi_session_enqueue_rx_frames (void)
 Loads the received frames from the serial device into the zwapi_session receive queue. More...
 
bool zwapi_session_dequeue_frame (uint8_t **frame_ptr, uint8_t *frame_len)
 Get the next frame from the zwapi_session receive queue. More...
 
void zwapi_session_flush_queue (void)
 Flush the zwapi_session receive queue. More...
 

Detailed Description

Session level handling such as retries and request/response for commands using the zwapi_connection.

Macro Definition Documentation

◆ FRAME_TYPE_REQUEST

#define FRAME_TYPE_REQUEST   0x00

◆ FRAME_TYPE_RESPONSE

#define FRAME_TYPE_RESPONSE   0x01

◆ IDX_CMD

#define IDX_CMD   2

◆ IDX_DATA

#define IDX_DATA   3

◆ IDX_LEN

#define IDX_LEN   0

◆ IDX_TYPE

#define IDX_TYPE   1

Function Documentation

◆ zwapi_session_dequeue_frame()

bool zwapi_session_dequeue_frame ( uint8_t **  frame_ptr,
uint8_t *  frame_len 
)

Get the next frame from the zwapi_session receive queue.

Parameters
frame_ptrPointer to frame data. This is set to NULL if no frame was available Must be deallocated with free() after use.
frame_lenlength of frame. This is set to 0 if no frame was available
Returns
true the receive queue still contains more frames
false the receive queue is now empty.

aka DequeueFrame

Here is the caller graph for this function:

◆ zwapi_session_enqueue_rx_frames()

void zwapi_session_enqueue_rx_frames ( void  )

Loads the received frames from the serial device into the zwapi_session receive queue.

aka DrainRX

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

◆ zwapi_session_flush_queue()

void zwapi_session_flush_queue ( void  )

Flush the zwapi_session receive queue.

aka SerialFlushQueue

Here is the caller graph for this function:

◆ zwapi_session_init()

int zwapi_session_init ( const char *  serial_port)

Initialize a zwapi_session with the Z-Wave module.

Parameters
serial_portString representing the serial device path
Returns
integer file descriptor for the serial device. the value will be greater than 0 if successful.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_session_restart()

int zwapi_session_restart ( )

Closes and re-initializes the zwapi_session to the Z-Wave module.

Returns
integer file descriptor for the serial device. the value will be greater than 0 if successful.

If no access to hard reset is available, it is recommended to issue a FUNC_ID_SERIAL_API_SOFT_RESET command to the Z-Wave module after restarting a session, and subsequently wait 1500ms before resuming operations.

Here is the call graph for this function:

◆ zwapi_session_send_frame()

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

Send data frame to Z-Wave chip via serial port and wait for 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 It may take up to RX_ACK_TIMEOUT_DEFAULT ms to receive a ACK from the Z-Wave module
Returns
SL_STATUS_OK if the frame sent and Ack'ed by the module. SL_STATUS_FAIL otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_session_send_frame_no_ack()

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

Send data frame to Z-Wave chip via serial API without waiting for 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 has been sent.

Does not wait for any ACK. Can be used e.g. if the Z-Wave module is expected to restart

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

◆ zwapi_session_send_frame_with_response()

sl_status_t zwapi_session_send_frame_with_response ( uint8_t  command,
const uint8_t *  payload_buffer,
uint8_t  payload_buffer_length,
uint8_t *  response_buf,
uint8_t *  response_len 
)

Send data frame to Z-Wave chip via serial API, wait for ACK and a RES frame.

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_bufoutput Buffer to hold response (buffer MUST be large enough to hold SERIAL_BUFFER_SIZE bytes).
response_lenouput Length of response copied to response_buf. It may take up to RX_ACK_TIMEOUT_DEFAULT ms to receive a ACK It may take up to RX_BYTE_TIMEOUT_DEFAULT ms to receive a RES frame
Returns
SL_STATUS_OK if the frame sent and Ack'ed by the module and the corresponding Response frame was received. SL_STATUS_FAIL otherwise

aka SendFrameWithResponse

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

◆ zwapi_session_shutdown()

void zwapi_session_shutdown ( )

Close the zwapi_session with the Z-Wave module.

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