API  2.2
TSmarT Software Library
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
tsmart_xbee_zb.h
1 
12 #ifndef TSMART_XBEE_ZB_H_
13 #define TSMART_XBEE_ZB_H_
14 
15 
16 #include "ts_xbee_if.h"
17 
18 
31 #define PR_TSMART_XBEE_ZB_AES_KEY_SIZE 16
32 #define PR_TSMART_XBEE_ZB_NKEY_SIZE 16
33 #define PR_TSMART_XBEE_ZB_MAX_API_PAYLOAD 100
35 #define TSMART_XBEE_ZB_FAULT_CODE_1 -1
36 #define TSMART_XBEE_ZB_FAULT_CODE_2 -2
37 #define TSMART_XBEE_ZB_FAULT_CODE_3 -3
38 #define TSMART_XBEE_ZB_FAULT_CODE_4 -4
39 #define TSMART_XBEE_ZB_FAULT_CODE_5 -5
40 #define TSMART_XBEE_ZB_FAULT_CODE_6 -6
41 #define TSMART_XBEE_ZB_FAULT_CODE_7 -7
42 #define TSMART_XBEE_ZB_FAULT_CODE_8 -8
43 #define TSMART_XBEE_ZB_FAULT_CODE_9 -9
44 #define TSMART_XBEE_ZB_FAULT_CODE_10 -10
45 #define TSMART_XBEE_ZB_FAULT_CODE_11 -11
46 #define TSMART_XBEE_ZB_FAULT_CODE_12 -12
47 #define TSMART_XBEE_ZB_FAULT_CODE_13 -13
48 #define TSMART_XBEE_ZB_FAULT_CODE_14 -14
49 #define TSMART_XBEE_ZB_FAULT_CODE_15 -15
50 #define TSMART_XBEE_ZB_FAULT_CODE_16 -16
51 #define TSMART_XBEE_ZB_FAULT_CODE_17 -17
52 #define TSMART_XBEE_ZB_FAULT_CODE_18 -18
53 #define TSMART_XBEE_ZB_FAULT_CODE_19 -19
54 #define TSMART_XBEE_ZB_FAULT_CODE_20 -20
55 #define TSMART_XBEE_ZB_FAULT_CODE_21 -21
56 #define TSMART_XBEE_ZB_FAULT_CODE_22 -22
57 #define TSMART_XBEE_ZB_FAULT_CODE_23 -23
58 #define TSMART_XBEE_ZB_FAULT_CODE_24 -24
59 #define TSMART_XBEE_ZB_FAULT_CODE_25 -25
60 #define TSMART_XBEE_ZB_FAULT_CODE_26 -26
61 #define TSMART_XBEE_ZB_FAULT_CODE_27 -27
74 enum{
75  TSMART_XBEE_ZB_FC_NONE = USART_HardwareFlowControl_None,
76  TSMART_XBEE_ZB_FC_RTS = USART_HardwareFlowControl_RTS,
77  TSMART_XBEE_ZB_FC_CTS = USART_HardwareFlowControl_CTS,
78  TSMART_XBEE_ZB_FC_RTS_CTS = USART_HardwareFlowControl_RTS_CTS
79 };
80 
81 
85 typedef struct{
86  int8_t delivery_status;
112  int8_t retries;
113  uint16_t network_address;
116 
120 typedef enum{
123 
127 typedef struct{
128  uint8_t frame_id;
129  uint32_t high_addr_dest;
130  uint32_t low_addr_dest;
133  uint8_t opt;
137  uint8_t payload[PR_TSMART_XBEE_ZB_MAX_API_PAYLOAD];
138  uint32_t payload_size;
141 
142 
143 
147 typedef struct{
148  uint8_t data[PR_TSMART_XBEE_ZB_MAX_API_PAYLOAD];
149  uint32_t high_addr_source;
150  uint32_t low_addr_source;
152  uint8_t opt;
161 
162 
163 
167 typedef enum{
185 
189 typedef enum{
194 
198 typedef struct{
199  uint16_t my;
200  uint32_t high_addr;
201  uint32_t low_addr;
205 
209 typedef enum{
213 
214 
218 typedef enum{
230 
231 
235 typedef enum {
239 
240 
244 typedef enum{
248 
249 
253 typedef enum{
259 
260 
264 typedef enum{
270 
271 
275 typedef struct {
276  uint32_t baud_rate;
284  uint16_t flow_control;
291  uint8_t priority;
296 
297 
298 
299 
303 typedef struct{
304  uint32_t high_pan_id;
307  uint32_t low_pan_id;
310  uint8_t baud_rate;
331  uint8_t power_level;
362  uint8_t unicast_nhops;
370  uint8_t broadcast_nhops;
375  int16_t n_scan_channels;
423  uint8_t profile;
428  uint8_t time_to_join;
460  uint8_t aes_key[PR_TSMART_XBEE_ZB_AES_KEY_SIZE];
463  uint8_t aes_key_size;
466  uint8_t network_key[PR_TSMART_XBEE_ZB_NKEY_SIZE];
472  uint8_t encryption_opt;
487  uint8_t n_sleep_periods;
492  uint16_t sp;
498  uint16_t st;
505  uint8_t sleep_opt;
514  uint8_t wake_host;
522  uint8_t polling_rate;
535 
536 
537 
538 
548 typedef struct {
549  ts_xbee_if_t *xbee_if;
550  uint8_t *rx_buf;
551  uint32_t rx_buf_sz;
555  uint8_t n_packet_lost;
556  xQueueHandle data_queue;
557  xQueueHandle command_queue;
558  xQueueHandle status_queue;
559  xSemaphoreHandle bitmap_protection;
560  xTaskHandle reception_task;
579 int8_t TSMART_XBEE_ZB_Init(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_config_t *TSMART_XBEE_ZB_config);
580 int8_t TSMART_XBEE_ZB_InitStructEndDevice(tsmart_xbee_zb_config_device_t *TSMART_XBEE_ZB_config_device);
581 int8_t TSMART_XBEE_ZB_InitStructCoordinator(tsmart_xbee_zb_config_device_t *TSMART_XBEE_ZB_config_device);
582 int8_t TSMART_XBEE_ZB_InitStructRouter(tsmart_xbee_zb_config_device_t *TSMART_XBEE_ZB_config_device);
583 int8_t TSMART_XBEE_ZB_Config(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_config_device_t *TSMART_XBEE_ZB_config_device);
584 int8_t TSMART_XBEE_ZB_SendAtCommandApiConfiguration(tsmart_xbee_zb_t *TSMART_XBEE_ZB, uint8_t *TSMART_XBEE_ZB_answer_buffer, uint8_t TSMART_XBEE_ZB_frame_id ,uint8_t *TSMART_XBEE_ZB_payload, uint8_t TSMART_XBEE_ZB_payload_size, portTickType TSMART_XBEE_ZB_timeout);
585 tsmart_xbee_zb_status_message_t TSMART_XBEE_ZB_ReadSatus(tsmart_xbee_zb_t *TSMART_XBEE_ZB, portTickType TSMART_XBEE_ZB_timeout);
588 int8_t TSMART_XBEE_ZB_NetworkReset(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_rts_network_type TSMART_XBEE_ZB_type);
589 int8_t TSMART_XBEE_ZB_DiscoverNodes(tsmart_xbee_zb_t *TSMART_XBEE_ZB, uint8_t TSMART_XBEE_ZB_max_nodes, tsmart_xbee_zb_discovered_node_t *TSMART_XBEE_ZB_discovered_node, uint8_t TSMART_XBEE_ZB_Timeout);
591 int32_t TSMART_XBEE_ZB_ReceiveApiFrame(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_data_received_t *TSMART_XBEE_ZB_data, portTickType TSMART_XBEE_ZB_xticks);
592 tsmart_xbee_zb_tx_status_t TSMART_XBEE_ZB_SendApiFrame(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_data_to_send_t *TSMART_XBEE_ZB_data, portTickType TSMART_XBEE_ZB_xticks);
593 uint32_t TSMART_XBEE_ZB_ReadHighAddress(tsmart_xbee_zb_t *TSMART_XBEE_ZB);
594 uint32_t TSMART_XBEE_ZB_ReadLowAddress(tsmart_xbee_zb_t *TSMART_XBEE_ZB);
595 uint16_t TSMART_XBEE_ZB_ReadNetworkAddress(tsmart_xbee_zb_t *TSMART_XBEE_ZB);
596 int8_t TSMART_XBEE_ZB_HWSleep(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_flag_t TSMART_XBEE_ZB_flag);
597 int8_t TSMART_XBEE_ZB_CheckOnSleep(tsmart_xbee_zb_t *TSMART_XBEE_ZB);
610 #endif /* TSMART_XBEE_ZB_H_ */
611 
612 
uint8_t wake_host
Definition: tsmart_xbee_zb.h:514
tsmart_xbee_zb_status_message_t
Label to report about status messages.
Definition: tsmart_xbee_zb.h:218
Definition: tsmart_xbee_zb.h:245
uint32_t TSMART_XBEE_ZB_ReadLowAddress(tsmart_xbee_zb_t *TSMART_XBEE_ZB)
Reads the low XBee address.
Definition: tsmart_xbee_zb.c:1854
int16_t n_scan_channels
Definition: tsmart_xbee_zb.h:375
Definition: tsmart_xbee_zb.h:219
Discovered node structure.
Definition: tsmart_xbee_zb.h:198
Definition: tsmart_xbee_zb.h:255
uint8_t opt
Definition: tsmart_xbee_zb.h:152
Status transmision structure.
Definition: tsmart_xbee_zb.h:85
Definition: tsmart_xbee_zb.h:265
Definition: tsmart_xbee_zb.h:170
Definition: tsmart_xbee_zb.h:190
uint8_t broadcast_nhops
Definition: tsmart_xbee_zb.h:370
tsmart_xbee_zb_flag_t aes_enable
Definition: tsmart_xbee_zb.h:454
tsmart_xbee_zb_report_t
Label to report about loss packets.
Definition: tsmart_xbee_zb.h:244
uint32_t payload_size
Definition: tsmart_xbee_zb.h:138
uint16_t flow_control
Definition: tsmart_xbee_zb.h:284
uint32_t high_addr_source
Definition: tsmart_xbee_zb.h:149
Definition: tsmart_xbee_zb.h:121
Definition: tsmart_xbee_zb.h:210
tsmart_xbee_zb_kind_dev_t type
Definition: tsmart_xbee_zb.h:203
uint8_t aes_key_size
Definition: tsmart_xbee_zb.h:463
xQueueHandle status_queue
Definition: tsmart_xbee_zb.h:558
uint8_t polling_rate
Definition: tsmart_xbee_zb.h:522
uint32_t high_addr
Definition: tsmart_xbee_zb.h:200
Definition: tsmart_xbee_zb.h:175
Definition: tsmart_xbee_zb.h:236
Definition: tsmart_xbee_zb.h:246
tsmart_xbee_zb_tx_status_t TSMART_XBEE_ZB_SendApiFrame(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_data_to_send_t *TSMART_XBEE_ZB_data, portTickType TSMART_XBEE_ZB_xticks)
Sends a ZigBee API frame.
Definition: tsmart_xbee_zb.c:1747
Definition: tsmart_xbee_zb.h:221
uint8_t n_sleep_periods
Definition: tsmart_xbee_zb.h:487
Data to send structure.
Definition: tsmart_xbee_zb.h:127
uint32_t low_addr
Definition: tsmart_xbee_zb.h:201
int8_t TSMART_XBEE_ZB_DiscoverNodes(tsmart_xbee_zb_t *TSMART_XBEE_ZB, uint8_t TSMART_XBEE_ZB_max_nodes, tsmart_xbee_zb_discovered_node_t *TSMART_XBEE_ZB_discovered_node, uint8_t TSMART_XBEE_ZB_Timeout)
Node Discovery Timeout.
Definition: tsmart_xbee_zb.c:1417
xTaskHandle reception_task
Definition: tsmart_xbee_zb.h:560
int8_t TSMART_XBEE_ZB_Config(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_config_device_t *TSMART_XBEE_ZB_config_device)
Configuration for XBee zigbee Device.
Definition: tsmart_xbee_zb.c:807
tsmart_xbee_zb_kind_dev_t
Label to configure kind of device in ZigBee protocol.
Definition: tsmart_xbee_zb.h:189
int8_t TSMART_XBEE_ZB_HWSleep(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_flag_t TSMART_XBEE_ZB_flag)
Hardware Sleep.
Definition: tsmart_xbee_zb.c:1934
Definition: tsmart_xbee_zb.h:169
uint16_t sp
Definition: tsmart_xbee_zb.h:492
int8_t TSMART_XBEE_ZB_CheckOnSleep(tsmart_xbee_zb_t *TSMART_XBEE_ZB)
Checks OnSleep state.
Definition: tsmart_xbee_zb.c:1954
int8_t TSMART_XBEE_ZB_InitStructEndDevice(tsmart_xbee_zb_config_device_t *TSMART_XBEE_ZB_config_device)
Default configuration function for end device.
Definition: tsmart_xbee_zb.c:524
ts_xbee_if_t * xbee_if
Definition: tsmart_xbee_zb.h:549
Definition: tsmart_xbee_zb.h:75
tsmart_xbee_zb_rts_network_type
Label to select kind of reset for current network.
Definition: tsmart_xbee_zb.h:209
Definition: tsmart_xbee_zb.h:191
uint16_t TSMART_XBEE_ZB_ReadNetworkAddress(tsmart_xbee_zb_t *TSMART_XBEE_ZB)
Reads the MY XBee address.
Definition: tsmart_xbee_zb.c:1891
Definition: tsmart_xbee_zb.h:222
uint8_t * rx_buf
Definition: tsmart_xbee_zb.h:550
Definition: tsmart_xbee_zb.h:237
int8_t retries
Definition: tsmart_xbee_zb.h:112
uint16_t my
Definition: tsmart_xbee_zb.h:199
tsmart_xbee_zb_api_type_frame_t api_type_frame
Definition: tsmart_xbee_zb.h:139
tsmart_xbee_zb_api_type_frame_t
Label to select kind of API frame to build.
Definition: tsmart_xbee_zb.h:120
int8_t TSMART_XBEE_ZB_NumberRemainingChildren(tsmart_xbee_zb_t *TSMART_XBEE_ZB)
Number of Remaining Children.
Definition: tsmart_xbee_zb.c:1318
int8_t TSMART_XBEE_ZB_InitStructRouter(tsmart_xbee_zb_config_device_t *TSMART_XBEE_ZB_config_device)
Default configuration function for router.
Definition: tsmart_xbee_zb.c:595
Definition: tsmart_xbee_zb.h:76
Definition: tsmart_xbee_zb.h:183
xQueueHandle command_queue
Definition: tsmart_xbee_zb.h:557
xQueueHandle data_queue
Definition: tsmart_xbee_zb.h:556
Definition: tsmart_xbee_zb.h:181
Definition: tsmart_xbee_zb.h:224
int8_t TSMART_XBEE_ZB_NetworkReset(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_rts_network_type TSMART_XBEE_ZB_type)
Network reset.
Definition: tsmart_xbee_zb.c:1368
int8_t discovery_status
Definition: tsmart_xbee_zb.h:105
Definition: tsmart_xbee_zb.h:168
uint8_t frame_id
Definition: tsmart_xbee_zb.h:128
Configuration for XBee ZigBee device.
Definition: tsmart_xbee_zb.h:303
uint16_t network_watchdog_timeout
Definition: tsmart_xbee_zb.h:445
Definition: tsmart_xbee_zb.h:223
Definition: tsmart_xbee_zb.h:174
Definition: tsmart_xbee_zb.h:268
tsmart_xbee_zb_ai_t TSMART_XBEE_ZB_AssociationIndication(tsmart_xbee_zb_t *TSMART_XBEE_ZB)
Association Indication.
Definition: tsmart_xbee_zb.c:1516
tsmart_xbee_zb_status_message_t TSMART_XBEE_ZB_ReadSatus(tsmart_xbee_zb_t *TSMART_XBEE_ZB, portTickType TSMART_XBEE_ZB_timeout)
Reads one status message.
Definition: tsmart_xbee_zb.c:1254
uint8_t scan_channels_time
Definition: tsmart_xbee_zb.h:401
Definition: tsmart_xbee_zb.h:179
uint32_t low_addr_dest
Definition: tsmart_xbee_zb.h:130
Definition: tsmart_xbee_zb.h:256
Definition: tsmart_xbee_zb.h:211
tsmart_xbee_zb_kind_dev_t kind_dev
Definition: tsmart_xbee_zb.h:529
int8_t TSMART_XBEE_ZB_Init(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_config_t *TSMART_XBEE_ZB_config)
Initialize the XBee module.
Definition: tsmart_xbee_zb.c:467
uint16_t network_address
Definition: tsmart_xbee_zb.h:113
uint8_t opt
Definition: tsmart_xbee_zb.h:133
int8_t TSMART_XBEE_ZB_InitStructCoordinator(tsmart_xbee_zb_config_device_t *TSMART_XBEE_ZB_config_device)
Default configuration function for coordinator.
Definition: tsmart_xbee_zb.c:561
Definition: tsmart_xbee_zb.h:172
int8_t delivery_status
Definition: tsmart_xbee_zb.h:86
uint16_t network_addr_16bit
Definition: tsmart_xbee_zb.h:151
tsmart_xbee_zb_sleep_mode_t sleep_mode
Definition: tsmart_xbee_zb.h:479
Definition: tsmart_xbee_zb.h:177
uint16_t st
Definition: tsmart_xbee_zb.h:498
Definition: tsmart_xbee_zb.h:182
tsmart_xbee_zb_kind_dev_t kind_device
Definition: tsmart_xbee_zb.h:561
Definition: tsmart_xbee_zb.h:228
Definition: tsmart_xbee_zb.h:220
uint8_t unicast_nhops
Definition: tsmart_xbee_zb.h:362
tsmart_xbee_zb_flag_t
Standard label for XBee ZB device.
Definition: tsmart_xbee_zb.h:235
uint8_t sleep_opt
Definition: tsmart_xbee_zb.h:505
Definition: tsmart_xbee_zb.h:176
tsmart_xbee_zb_sleep_mode_t
Sleep modes for XBee ZigBee device.
Definition: tsmart_xbee_zb.h:264
int8_t TSMART_XBEE_ZB_PowerSignalReceived(tsmart_xbee_zb_t *TSMART_XBEE_ZB)
Reports the RF power signal (RSSI) of last received packet.
Definition: tsmart_xbee_zb.c:1278
Definition: tsmart_xbee_zb.h:192
Definition: tsmart_xbee_zb.h:78
Definition: tsmart_xbee_zb.h:178
uint8_t profile
Definition: tsmart_xbee_zb.h:423
uint32_t high_addr_dest
Definition: tsmart_xbee_zb.h:129
uint16_t parent_network_addr
Definition: tsmart_xbee_zb.h:202
uint8_t baud_rate
Definition: tsmart_xbee_zb.h:310
uint8_t encryption_opt
Definition: tsmart_xbee_zb.h:472
tsmart_xbee_zb_flow_control_t
Enum to select flow control mode.
Definition: tsmart_xbee_zb.h:253
tsmart_xbee_zb_ai_t
Label to report about the association indications.
Definition: tsmart_xbee_zb.h:167
uint8_t priority
Definition: tsmart_xbee_zb.h:291
Definition: tsmart_xbee_zb.h:266
Definition: tsmart_xbee_zb.h:173
tsmart_xbee_zb_t tsmart_xbee_zb
Definition: tsmart_xbee_zb.c:67
int8_t TSMART_XBEE_ZB_SendAtCommandApiConfiguration(tsmart_xbee_zb_t *TSMART_XBEE_ZB, uint8_t *TSMART_XBEE_ZB_answer_buffer, uint8_t TSMART_XBEE_ZB_frame_id, uint8_t *TSMART_XBEE_ZB_payload, uint8_t TSMART_XBEE_ZB_payload_size, portTickType TSMART_XBEE_ZB_timeout)
Sends a configuration command.
Definition: tsmart_xbee_zb.c:706
tsmart_xbee_zb_flag_t ch_verification
Definition: tsmart_xbee_zb.h:437
uint8_t network_key_size
Definition: tsmart_xbee_zb.h:469
uint8_t time_to_join
Definition: tsmart_xbee_zb.h:428
uint8_t broadcast_radius
Definition: tsmart_xbee_zb.h:132
Definition: tsmart_xbee_zb.h:77
uint32_t low_addr_source
Definition: tsmart_xbee_zb.h:150
Data structure to receive.
Definition: tsmart_xbee_zb.h:147
uint8_t power_level
Definition: tsmart_xbee_zb.h:331
xSemaphoreHandle bitmap_protection
Definition: tsmart_xbee_zb.h:559
Definition: tsmart_xbee_zb.h:267
XBee ZB configuration structure.
Definition: tsmart_xbee_zb.h:275
Definition: tsmart_xbee_zb.h:225
Definition: tsmart_xbee_zb.h:257
Definition: tsmart_xbee_zb.h:171
Definition: tsmart_xbee_zb.h:180
uint32_t rx_buf_sz
Definition: tsmart_xbee_zb.h:551
tsmart_xbee_zb_flow_control_t flow_control
Definition: tsmart_xbee_zb.h:321
XBee ZigBee handler structure.
Definition: tsmart_xbee_zb.h:548
uint8_t n_packet_lost
Definition: tsmart_xbee_zb.h:555
uint32_t high_pan_id
Definition: tsmart_xbee_zb.h:304
uint32_t baud_rate
Definition: tsmart_xbee_zb.h:276
int32_t TSMART_XBEE_ZB_ReceiveApiFrame(tsmart_xbee_zb_t *TSMART_XBEE_ZB, tsmart_xbee_zb_data_received_t *TSMART_XBEE_ZB_data, portTickType TSMART_XBEE_ZB_xticks)
Receives ZigBee API frame.
Definition: tsmart_xbee_zb.c:1643
uint16_t network_addr_16bit
Definition: tsmart_xbee_zb.h:131
Definition: tsmart_xbee_zb.h:227
uint32_t TSMART_XBEE_ZB_ReadHighAddress(tsmart_xbee_zb_t *TSMART_XBEE_ZB)
Reads the high XBee address.
Definition: tsmart_xbee_zb.c:1816
uint32_t low_pan_id
Definition: tsmart_xbee_zb.h:307
tsmart_xbee_zb_report_t packet_lost
Definition: tsmart_xbee_zb.h:552
Definition: tsmart_xbee_zb.h:254