|
Z-Wave Protocol Controller Reference
|
#include <assert.h>#include <string.h>#include <stdlib.h>#include "zwapi_session.h"#include "zwapi_connection.h"#include "zwapi_timestamp.h"#include "sl_log.h"Classes | |
| struct | list_elem |
Macros | |
| #define | LOG_TAG "zwapi_session" |
| #define | TIMEOUT_TIME 1600 |
| #define | MAX_RX_QUEUE_LENGTH 30 |
| #define | MAX_TRANSMISSION_RETRIES 20 |
| #define | MAX_RX_FRAMES_WAITING_FOR_RESPONSE 3 |
| #define | MAX_TX_TIMEOUTS 3 |
Typedefs | |
| typedef struct list_elem | zwapi_session_list_elem_t |
Functions | |
| static int | zwapi_session_get_rx_queue_length (void) |
| static void | zwapi_session_enqueue_frame (void) |
| static zwapi_connection_status_t | zwapi_session_wait_for_response (void) |
| 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... | |
| 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_enqueue_rx_frames () |
| Loads the received frames from the serial device into the zwapi_session receive queue. 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_flush_queue (void) |
| Flush the zwapi_session receive queue. More... | |
Variables | |
| static zwapi_session_list_elem_t * | zwapi_session_rx_queue |
| #define LOG_TAG "zwapi_session" |
| #define MAX_RX_FRAMES_WAITING_FOR_RESPONSE 3 |
| #define MAX_RX_QUEUE_LENGTH 30 |
| #define MAX_TRANSMISSION_RETRIES 20 |
| #define MAX_TX_TIMEOUTS 3 |
| #define TIMEOUT_TIME 1600 |
| typedef struct list_elem zwapi_session_list_elem_t |
| bool zwapi_session_dequeue_frame | ( | uint8_t ** | frame_ptr, |
| uint8_t * | frame_len | ||
| ) |
Get the next frame from the zwapi_session receive queue.
| 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 |
aka DequeueFrame
|
static |
Enqueue a new element in the zwapi_session_rx_queue from the zwapi_connection buffer. Only REQUEST type frames will be enqueued, others will be ignored TODO: Get rid of malloc
| void zwapi_session_enqueue_rx_frames | ( | void | ) |
Loads the received frames from the serial device into the zwapi_session receive queue.
aka DrainRX
| void zwapi_session_flush_queue | ( | void | ) |
Flush the zwapi_session receive queue.
aka SerialFlushQueue
|
static |
Give the number of outstanding packets in zwapi_session_rx_queue
| int zwapi_session_init | ( | const char * | serial_port | ) |
Initialize a zwapi_session with the Z-Wave module.
| serial_port | String representing the serial device path |
| int zwapi_session_restart | ( | ) |
Closes and re-initializes the zwapi_session to the Z-Wave module.
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.
| 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.
| 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 |
| 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.
| 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 |
Does not wait for any ACK. Can be used e.g. if the Z-Wave module is expected to restart
| 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.
| 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 |
aka SendFrameWithResponse
| void zwapi_session_shutdown | ( | ) |
Close the zwapi_session with the Z-Wave module.
|
static |
Wait for a acknowledgement (ACK, NAK, CAN) or possibly another SOF (REQ/RES) frame from the Z-Wave serial device.
|
static |