Firmware SDK
|
Radio implementation. More...
Data Structures | |
struct | twr_radio_sub_t |
struct | twr_radio_peer_t |
Typedefs | |
typedef struct twr_radio_sub_t | twr_radio_sub_t |
Enumerations | |
enum | twr_radio_mode_t { TWR_RADIO_MODE_UNKNOWN = 0 , TWR_RADIO_MODE_GATEWAY = 1 , TWR_RADIO_MODE_NODE_LISTENING = 2 , TWR_RADIO_MODE_NODE_SLEEPING = 3 } |
Radio mode. More... | |
enum | twr_radio_event_t { TWR_RADIO_EVENT_INIT_FAILURE = 0 , TWR_RADIO_EVENT_INIT_DONE = 1 , TWR_RADIO_EVENT_ATTACH = 2 , TWR_RADIO_EVENT_ATTACH_FAILURE = 3 , TWR_RADIO_EVENT_DETACH = 4 , TWR_RADIO_EVENT_SCAN_FIND_DEVICE = 5 , TWR_RADIO_EVENT_PAIRED = 6 , TWR_RADIO_EVENT_UNPAIRED = 7 , TWR_RADIO_EVENT_TX_DONE = 8 , TWR_RADIO_EVENT_TX_ERROR = 9 } |
enum | twr_radio_header_t { TWR_RADIO_HEADER_PAIRING = 0x00 , TWR_RADIO_HEADER_PUB_PUSH_BUTTON = 0x01 , TWR_RADIO_HEADER_PUB_TEMPERATURE = 0x02 , TWR_RADIO_HEADER_PUB_HUMIDITY = 0x03 , TWR_RADIO_HEADER_PUB_LUX_METER = 0x04 , TWR_RADIO_HEADER_PUB_BAROMETER = 0x05 , TWR_RADIO_HEADER_PUB_CO2 = 0x06 , TWR_RADIO_HEADER_PUB_BUFFER = 0x07 , TWR_RADIO_HEADER_NODE_ATTACH = 0x08 , TWR_RADIO_HEADER_NODE_DETACH = 0x09 , TWR_RADIO_HEADER_PUB_BATTERY = 0x0a , TWR_RADIO_HEADER_PUB_INFO = 0x0b , TWR_RADIO_HEADER_PUB_ACCELERATION = 0x0d , TWR_RADIO_HEADER_PUB_TOPIC_STRING = 0x0e , TWR_RADIO_HEADER_PUB_TOPIC_UINT32 = 0x0f , TWR_RADIO_HEADER_PUB_TOPIC_BOOL = 0x10 , TWR_RADIO_HEADER_PUB_TOPIC_INT = 0x11 , TWR_RADIO_HEADER_PUB_TOPIC_FLOAT = 0x12 , TWR_RADIO_HEADER_PUB_EVENT_COUNT = 0x13 , TWR_RADIO_HEADER_PUB_STATE = 0x14 , TWR_RADIO_HEADER_NODE_STATE_SET = 0x15 , TWR_RADIO_HEADER_NODE_STATE_GET = 0x16 , TWR_RADIO_HEADER_NODE_BUFFER = 0x17 , TWR_RADIO_HEADER_NODE_LED_STRIP_COLOR_SET = 0x18 , TWR_RADIO_HEADER_NODE_LED_STRIP_BRIGHTNESS_SET = 0x19 , TWR_RADIO_HEADER_NODE_LED_STRIP_COMPOUND_SET = 0x1a , TWR_RADIO_HEADER_NODE_LED_STRIP_EFFECT_SET = 0x1b , TWR_RADIO_HEADER_NODE_LED_STRIP_THERMOMETER_SET = 0x1c , TWR_RADIO_HEADER_SUB_DATA = 0x1d , TWR_RADIO_HEADER_PUB_VALUE_INT = 0x1e , TWR_RADIO_HEADER_SUB_REG = 0x20 , TWR_RADIO_HEADER_ACK = 0xaa } |
enum | twr_radio_sub_pt_t { TWR_RADIO_SUB_PT_BOOL = 0 , TWR_RADIO_SUB_PT_INT = 1 , TWR_RADIO_SUB_PT_FLOAT = 2 , TWR_RADIO_SUB_PT_STRING = 3 , TWR_RADIO_SUB_PT_NULL = 4 } |
Subscribe payload type. | |
enum | { TWR_RADIO_NODE_STATE_LED = TWR_RADIO_PUB_STATE_LED , TWR_RADIO_NODE_STATE_RELAY_MODULE_0 = TWR_RADIO_PUB_STATE_RELAY_MODULE_0 , TWR_RADIO_NODE_STATE_RELAY_MODULE_1 = TWR_RADIO_PUB_STATE_RELAY_MODULE_1 , TWR_RADIO_NODE_STATE_POWER_MODULE_RELAY = TWR_RADIO_PUB_STATE_POWER_MODULE_RELAY } |
enum | twr_radio_node_led_strip_effect_t { TWR_RADIO_NODE_LED_STRIP_EFFECT_TEST = 0 , TWR_RADIO_NODE_LED_STRIP_EFFECT_RAINBOW = 1 , TWR_RADIO_NODE_LED_STRIP_EFFECT_RAINBOW_CYCLE = 2 , TWR_RADIO_NODE_LED_STRIP_EFFECT_THEATER_CHASE_RAINBOW = 3 , TWR_RADIO_NODE_LED_STRIP_EFFECT_COLOR_WIPE = 4 , TWR_RADIO_NODE_LED_STRIP_EFFECT_THEATER_CHASE = 5 , TWR_RADIO_NODE_LED_STRIP_EFFECT_STROBOSCOPE = 6 , TWR_RADIO_NODE_LED_STRIP_EFFECT_ICICLE = 7 , TWR_RADIO_NODE_LED_STRIP_EFFECT_PULSE_COLOR = 8 } |
enum | { TWR_RADIO_PUB_CHANNEL_R1_I2C0_ADDRESS_DEFAULT = 0x00 , TWR_RADIO_PUB_CHANNEL_R1_I2C0_ADDRESS_ALTERNATE = 0x01 , TWR_RADIO_PUB_CHANNEL_R1_I2C1_ADDRESS_DEFAULT = 0x80 , TWR_RADIO_PUB_CHANNEL_R1_I2C1_ADDRESS_ALTERNATE = 0x81 , TWR_RADIO_PUB_CHANNEL_R2_I2C0_ADDRESS_DEFAULT = 0x02 , TWR_RADIO_PUB_CHANNEL_R2_I2C0_ADDRESS_ALTERNATE = 0x03 , TWR_RADIO_PUB_CHANNEL_R2_I2C1_ADDRESS_DEFAULT = 0x82 , TWR_RADIO_PUB_CHANNEL_R2_I2C1_ADDRESS_ALTERNATE = 0x83 , TWR_RADIO_PUB_CHANNEL_R3_I2C0_ADDRESS_DEFAULT = 0x04 , TWR_RADIO_PUB_CHANNEL_R3_I2C0_ADDRESS_ALTERNATE = 0x05 , TWR_RADIO_PUB_CHANNEL_R3_I2C1_ADDRESS_DEFAULT = 0x84 , TWR_RADIO_PUB_CHANNEL_R3_I2C1_ADDRESS_ALTERNATE = 0x85 , TWR_RADIO_PUB_CHANNEL_R4_I2C0_ADDRESS_DEFAULT = 0x06 , TWR_RADIO_PUB_CHANNEL_R4_I2C0_ADDRESS_ALTERNATE = 0x07 , TWR_RADIO_PUB_CHANNEL_R4_I2C1_ADDRESS_DEFAULT = 0x86 , TWR_RADIO_PUB_CHANNEL_R4_I2C1_ADDRESS_ALTERNATE = 0x87 , TWR_RADIO_PUB_CHANNEL_A = 0xf0 , TWR_RADIO_PUB_CHANNEL_B = 0xf1 , TWR_RADIO_PUB_CHANNEL_SET_POINT = 0xf2 , TWR_RADIO_PUB_CHANNEL_NONE = 0xff } |
enum | { TWR_RADIO_PUB_EVENT_PUSH_BUTTON = 0 , TWR_RADIO_PUB_EVENT_PIR_MOTION = 1 , TWR_RADIO_PUB_EVENT_LCD_BUTTON_LEFT = 2 , TWR_RADIO_PUB_EVENT_LCD_BUTTON_RIGHT = 3 , TWR_RADIO_PUB_EVENT_ACCELEROMETER_ALERT = 4 , TWR_RADIO_PUB_EVENT_HOLD_BUTTON = 5 } |
enum | { TWR_RADIO_PUB_STATE_LED = 0 , TWR_RADIO_PUB_STATE_RELAY_MODULE_0 = 1 , TWR_RADIO_PUB_STATE_RELAY_MODULE_1 = 2 , TWR_RADIO_PUB_STATE_POWER_MODULE_RELAY = 3 } |
enum | { TWR_RADIO_PUB_VALUE_HOLD_DURATION_BUTTON = 0 } |
Functions | |
void | twr_radio_init (twr_radio_mode_t mode) |
Initialize radio. More... | |
void | twr_radio_set_event_handler (void(*event_handler)(twr_radio_event_t, void *), void *event_param) |
void | twr_radio_listen (twr_tick_t timeout) |
void | twr_radio_pairing_request (const char *firmware, const char *version) |
void | twr_radio_pairing_mode_start (void) |
void | twr_radio_pairing_mode_stop (void) |
bool | twr_radio_peer_device_add (uint64_t id) |
bool | twr_radio_peer_device_remove (uint64_t id) |
bool | twr_radio_peer_device_purge_all (void) |
void | twr_radio_get_peer_id (uint64_t *id, int length) |
void | twr_radio_scan_start (void) |
void | twr_radio_scan_stop (void) |
void | twr_radio_automatic_pairing_start (void) |
void | twr_radio_automatic_pairing_stop (void) |
uint64_t | twr_radio_get_my_id (void) |
uint64_t | twr_radio_get_event_id (void) |
bool | twr_radio_is_peer_device (uint64_t id) |
bool | twr_radio_pub_queue_put (const void *buffer, size_t length) |
void | twr_radio_pub_queue_clear () |
Clear the publish message queue. | |
void | twr_radio_set_subs (twr_radio_sub_t *subs, int length) |
bool | twr_radio_send_sub_data (uint64_t *id, uint8_t order, void *payload, size_t size) |
void | twr_radio_set_rx_timeout_for_sleeping_node (twr_tick_t timeout) |
twr_radio_peer_t * | twr_radio_get_peer_device (uint64_t id) |
uint8_t * | twr_radio_id_to_buffer (uint64_t *id, uint8_t *buffer) |
uint8_t * | twr_radio_bool_to_buffer (bool *value, uint8_t *buffer) |
uint8_t * | twr_radio_int_to_buffer (int *value, uint8_t *buffer) |
uint8_t * | twr_radio_uint16_to_buffer (uint16_t *value, uint8_t *buffer) |
uint8_t * | twr_radio_uint32_to_buffer (uint32_t *value, uint8_t *buffer) |
uint8_t * | twr_radio_float_to_buffer (float *value, uint8_t *buffer) |
uint8_t * | twr_radio_data_to_buffer (void *data, size_t length, uint8_t *buffer) |
uint8_t * | twr_radio_id_from_buffer (uint8_t *buffer, uint64_t *id) |
uint8_t * | twr_radio_bool_from_buffer (uint8_t *buffer, bool *value, bool **pointer) |
uint8_t * | twr_radio_int_from_buffer (uint8_t *buffer, int *value, int **pointer) |
uint8_t * | twr_radio_uint16_from_buffer (uint8_t *buffer, uint16_t *value, uint16_t **pointer) |
uint8_t * | twr_radio_uint32_from_buffer (uint8_t *buffer, uint32_t *value, uint32_t **pointer) |
uint8_t * | twr_radio_float_from_buffer (uint8_t *buffer, float *value, float **pointer) |
uint8_t * | twr_radio_data_from_buffer (uint8_t *buffer, void *data, size_t length) |
void | twr_radio_init_pairing_button () |
bool | twr_radio_node_state_set (uint64_t *id, uint8_t state_id, bool *state) |
Send request for set new state. More... | |
bool | twr_radio_node_state_get (uint64_t *id, uint8_t state_id) |
Send request for get actual state. More... | |
bool | twr_radio_node_buffer (uint64_t *id, void *buffer, size_t length) |
Send data to node. More... | |
bool | twr_radio_node_led_strip_color_set (uint64_t *id, uint32_t color) |
Send data to node. More... | |
bool | twr_radio_node_led_strip_brightness_set (uint64_t *id, uint8_t brightness) |
Send data to node. More... | |
bool | twr_radio_node_led_strip_compound_set (uint64_t *id, uint8_t *compound, size_t length) |
Send data to node. More... | |
bool | twr_radio_node_led_strip_effect_set (uint64_t *id, twr_radio_node_led_strip_effect_t type, uint16_t wait, uint32_t color) |
Send data to node. More... | |
bool | twr_radio_node_led_strip_thermometer_set (uint64_t *id, float temperature, int8_t min, int8_t max, uint8_t white_dots, float *set_point, uint32_t set_point_color) |
Send data to node. More... | |
void | twr_radio_node_decode (uint64_t *id, uint8_t *buffer, size_t length) |
Internal decode function for twr_radio.c. More... | |
bool | twr_radio_pub_event_count (uint8_t event_id, uint16_t *event_count) |
Publish event count. More... | |
bool | twr_radio_pub_push_button (uint16_t *event_count) |
Publish push button event count, same as use twr_radio_pub_event_count with TWR_RADIO_PUB_EVENT_PUSH_BUTTON. More... | |
bool | twr_radio_pub_temperature (uint8_t channel, float *celsius) |
Publish temperature. More... | |
bool | twr_radio_pub_humidity (uint8_t channel, float *percentage) |
Publish humidity. More... | |
bool | twr_radio_pub_luminosity (uint8_t channel, float *lux) |
Publish luminosity. More... | |
bool | twr_radio_pub_barometer (uint8_t channel, float *pascal, float *meter) |
Publish barometer. More... | |
bool | twr_radio_pub_co2 (float *concentration) |
Publish co2. More... | |
bool | twr_radio_pub_battery (float *voltage) |
Publish battery. More... | |
bool | twr_radio_pub_acceleration (float *x_axis, float *y_axis, float *z_axis) |
Publish acceleration. More... | |
bool | twr_radio_pub_buffer (void *buffer, size_t length) |
Publish buffer. More... | |
bool | twr_radio_pub_state (uint8_t state_id, bool *state) |
Publish battery. More... | |
bool | twr_radio_pub_value_int (uint8_t value_id, int *value) |
Publish int value. More... | |
bool | twr_radio_pub_bool (const char *subtopic, bool *value) |
Publish bool value in custom topic. More... | |
bool | twr_radio_pub_int (const char *subtopic, int *value) |
Publish int value in custom topic. More... | |
bool | twr_radio_pub_uint32 (const char *subtopic, uint32_t *value) |
Publish uint32 value in custom topic. More... | |
bool | twr_radio_pub_float (const char *subtopic, float *value) |
Publish float value in custom topic. More... | |
bool | twr_radio_pub_string (const char *subtopic, const char *value) |
Publish string value in custom topic. More... | |
void | twr_radio_pub_decode (uint64_t *id, uint8_t *buffer, size_t length) |
Internal decode function for twr_radio.c. More... | |
Radio implementation.
Radio implementation send to gateway.
Radio implementation send to node.
anonymous enum |
Definition at line 10 of file twr_radio_pub.h.
enum twr_radio_mode_t |
Radio mode.
Definition at line 37 of file twr_radio.h.
void twr_radio_init | ( | twr_radio_mode_t | mode | ) |
Initialize radio.
[in] | mode |
Definition at line 89 of file twr_radio.c.
bool twr_radio_node_buffer | ( | uint64_t * | id, |
void * | buffer, | ||
size_t | length | ||
) |
Send data to node.
[in] | id | Pointer to node id |
[in] | buffer | Pointer to buffer from which data will be send |
[in] | length | Number of bytes to be send, max value is in TWR_RADIO_NODE_MAX_BUFFER_SIZE |
Definition at line 41 of file twr_radio_node.c.
void twr_radio_node_decode | ( | uint64_t * | id, |
uint8_t * | buffer, | ||
size_t | length | ||
) |
Internal decode function for twr_radio.c.
[in] | id | Pointer on own id |
[in] | buffer | Pointer to RX buffer |
[in] | length | RX buffer length |
Definition at line 148 of file twr_radio_node.c.
bool twr_radio_node_led_strip_brightness_set | ( | uint64_t * | id, |
uint8_t | brightness | ||
) |
Send data to node.
[in] | id | Pointer to node id |
[in] | brightness |
Definition at line 71 of file twr_radio_node.c.
bool twr_radio_node_led_strip_color_set | ( | uint64_t * | id, |
uint32_t | color | ||
) |
Send data to node.
[in] | id | Pointer to node id |
[in] | color | Color in RGBW format |
Definition at line 58 of file twr_radio_node.c.
bool twr_radio_node_led_strip_compound_set | ( | uint64_t * | id, |
uint8_t * | compound, | ||
size_t | length | ||
) |
Send data to node.
[in] | id | Pointer to node id |
[in] | compound | Pointer to compound buffer |
[in] | length | Number of bytes to be send, must be modulo 5, max value is in TWR_RADIO_NODE_MAX_COMPOUND_BUFFER_SIZE |
Definition at line 84 of file twr_radio_node.c.
bool twr_radio_node_led_strip_effect_set | ( | uint64_t * | id, |
twr_radio_node_led_strip_effect_t | type, | ||
uint16_t | wait, | ||
uint32_t | color | ||
) |
Send data to node.
[in] | id | Pointer to node id |
[in] | type | Effect type |
[in] | wait | Interval between refresh |
[in] | color | Color in RGBW format |
Definition at line 102 of file twr_radio_node.c.
bool twr_radio_node_led_strip_thermometer_set | ( | uint64_t * | id, |
float | temperature, | ||
int8_t | min, | ||
int8_t | max, | ||
uint8_t | white_dots, | ||
float * | set_point, | ||
uint32_t | set_point_color | ||
) |
Send data to node.
[in] | id | Pointer to node id |
[in] | temperature | |
[in] | min | Temperature on thermometer |
[in] | max | Temperature on thermometer |
[in] | white_dots | |
[in] | set_point | Pointer to set point temperature, if NULL set_point and set_point_color not used |
[in] | set_point_color | Color in RGBW format |
Definition at line 120 of file twr_radio_node.c.
bool twr_radio_node_state_get | ( | uint64_t * | id, |
uint8_t | state_id | ||
) |
Send request for get actual state.
[in] | id | Pointer to node id |
[in] | state_id | State id from enum |
Definition at line 28 of file twr_radio_node.c.
bool twr_radio_node_state_set | ( | uint64_t * | id, |
uint8_t | state_id, | ||
bool * | state | ||
) |
Send request for set new state.
[in] | id | Pointer to node id |
[in] | state_id | State id from enum |
[in] | state | Pointer to state which will be send |
Definition at line 13 of file twr_radio_node.c.
bool twr_radio_pub_acceleration | ( | float * | x_axis, |
float * | y_axis, | ||
float * | z_axis | ||
) |
Publish acceleration.
[in] | x_axis | Pointer to value, can be null |
[in] | y_axis | Pointer to value, can be null |
[in] | x_az_axisxis | Pointer to value, can be null |
Definition at line 112 of file twr_radio_pub.c.
bool twr_radio_pub_barometer | ( | uint8_t | channel, |
float * | pascal, | ||
float * | meter | ||
) |
Publish barometer.
[in] | channel | Channel id from enum TWR_RADIO_PUB_CHANNEL_* |
[in] | pascal | Pointer to value, can be null |
[in] | meter | Pointer to value, can be null |
Definition at line 77 of file twr_radio_pub.c.
bool twr_radio_pub_battery | ( | float * | voltage | ) |
Publish battery.
[in] | voltage | Pointer to value, can be null |
Definition at line 101 of file twr_radio_pub.c.
bool twr_radio_pub_bool | ( | const char * | subtopic, |
bool * | value | ||
) |
Publish bool value in custom topic.
[in] | subtopic | Subtopic (example: node/{id}/{subtopic}) |
[in] | value | Pointer to value, can be null |
Definition at line 167 of file twr_radio_pub.c.
bool twr_radio_pub_buffer | ( | void * | buffer, |
size_t | length | ||
) |
Publish buffer.
[in] | buffer | Pointer to buffer from which data will be send |
[in] | length | Number of bytes to be send, max value is in TWR_RADIO_NODE_MAX_BUFFER_SIZE |
Definition at line 127 of file twr_radio_pub.c.
bool twr_radio_pub_co2 | ( | float * | concentration | ) |
Publish co2.
[in] | concentration | Pointer to value, can be null |
Definition at line 90 of file twr_radio_pub.c.
void twr_radio_pub_decode | ( | uint64_t * | id, |
uint8_t * | buffer, | ||
size_t | length | ||
) |
Internal decode function for twr_radio.c.
[in] | id | Pointer on sender id |
[in] | buffer | Pointer to RX buffer |
[in] | length | RX buffer length |
Definition at line 267 of file twr_radio_pub.c.
bool twr_radio_pub_event_count | ( | uint8_t | event_id, |
uint16_t * | event_count | ||
) |
Publish event count.
[in] | event_id | Event id is from enum TWR_RADIO_PUB_EVENT_* |
[in] | event_count | Pointer to value, can be null |
Definition at line 24 of file twr_radio_pub.c.
Referenced by twr_radio_pub_push_button().
bool twr_radio_pub_float | ( | const char * | subtopic, |
float * | value | ||
) |
Publish float value in custom topic.
[in] | subtopic | Subtopic (example: node/{id}/{subtopic}) |
[in] | value | Pointer to value, can be null |
Definition at line 227 of file twr_radio_pub.c.
bool twr_radio_pub_humidity | ( | uint8_t | channel, |
float * | percentage | ||
) |
Publish humidity.
[in] | channel | Channel id from enum TWR_RADIO_PUB_CHANNEL_* |
[in] | percentage | Pointer to value, can be null |
Definition at line 53 of file twr_radio_pub.c.
bool twr_radio_pub_int | ( | const char * | subtopic, |
int * | value | ||
) |
Publish int value in custom topic.
[in] | subtopic | Subtopic (example: node/{id}/{subtopic}) |
[in] | value | Pointer to value, can be null |
Definition at line 187 of file twr_radio_pub.c.
bool twr_radio_pub_luminosity | ( | uint8_t | channel, |
float * | lux | ||
) |
Publish luminosity.
[in] | channel | Channel id from enum TWR_RADIO_PUB_CHANNEL_* |
[in] | lux | Pointer to value, can be null |
Definition at line 65 of file twr_radio_pub.c.
bool twr_radio_pub_push_button | ( | uint16_t * | event_count | ) |
Publish push button event count, same as use twr_radio_pub_event_count with TWR_RADIO_PUB_EVENT_PUSH_BUTTON.
[in] | event_count | Pointer to value, can be null |
Definition at line 36 of file twr_radio_pub.c.
bool twr_radio_pub_state | ( | uint8_t | state_id, |
bool * | state | ||
) |
Publish battery.
[in] | state_id | State id from enum TWR_RADIO_PUB_STATE_* |
[in] | state | Pointer to value, can be null |
Definition at line 143 of file twr_radio_pub.c.
bool twr_radio_pub_string | ( | const char * | subtopic, |
const char * | value | ||
) |
Publish string value in custom topic.
[in] | subtopic | Subtopic (example: node/{id}/{subtopic}) |
[in] | value | Pointer to value, can be null |
Definition at line 247 of file twr_radio_pub.c.
bool twr_radio_pub_temperature | ( | uint8_t | channel, |
float * | celsius | ||
) |
Publish temperature.
[in] | channel | Channel id from enum TWR_RADIO_PUB_CHANNEL_* |
[in] | celsius | Pointer to value, can be null |
Definition at line 41 of file twr_radio_pub.c.
bool twr_radio_pub_uint32 | ( | const char * | subtopic, |
uint32_t * | value | ||
) |
Publish uint32 value in custom topic.
[in] | subtopic | Subtopic (example: node/{id}/{subtopic}) |
[in] | value | Pointer to value, can be null |
Definition at line 207 of file twr_radio_pub.c.
bool twr_radio_pub_value_int | ( | uint8_t | value_id, |
int * | value | ||
) |
Publish int value.
[in] | value_id | State id from enum TWR_RADIO_PUB_VALUE_* |
[in] | value | Pointer to value, can be null |
Definition at line 155 of file twr_radio_pub.c.