Session level handling such as retries and request/response for commands using the zwapi_connection.
More...
#include <stdbool.h>
#include "sl_status.h"
Go to the source code of this file.
|
| 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...
|
| |
Session level handling such as retries and request/response for commands using the zwapi_connection.
◆ FRAME_TYPE_REQUEST
| #define FRAME_TYPE_REQUEST 0x00 |
◆ FRAME_TYPE_RESPONSE
| #define FRAME_TYPE_RESPONSE 0x01 |
◆ IDX_CMD
◆ IDX_DATA
◆ IDX_LEN
◆ IDX_TYPE
◆ 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_ptr | Pointer to frame data. This is set to NULL if no frame was available Must be deallocated with free() after use. |
| frame_len | length 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
◆ 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
◆ zwapi_session_flush_queue()
| void zwapi_session_flush_queue |
( |
void |
| ) |
|
Flush the zwapi_session receive queue.
aka SerialFlushQueue
◆ zwapi_session_init()
| int zwapi_session_init |
( |
const char * |
serial_port | ) |
|
Initialize a zwapi_session with the Z-Wave module.
- Parameters
-
| serial_port | String representing the serial device path |
- Returns
- integer file descriptor for the serial device. the value will be greater than 0 if successful.
◆ 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.
◆ 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
-
| command | Z-Wave Serial API Command (zwapi_func_ids.h) |
| payload_buffer | Byte array with serial API command parameters |
| payload_buffer_length | Length 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
◆ 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
-
| command | Z-Wave Serial API Command (zwapi_func_ids.h) |
| payload_buffer | Byte array with serial API command parameters |
| payload_buffer_length | Length 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
◆ 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
-
| command | Z-Wave Serial API Command (zwapi_func_ids.h) |
| payload_buffer | Byte array with serial API command parameters |
| payload_buffer_length | Length in bytes of parameter array |
| response_buf | output Buffer to hold response (buffer MUST be large enough to hold SERIAL_BUFFER_SIZE bytes). |
| response_len | ouput 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
◆ zwapi_session_shutdown()
| void zwapi_session_shutdown |
( |
| ) |
|
Close the zwapi_session with the Z-Wave module.