API  2.2
TSmarT Software Library
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
tsmart_xbee_802.h
1 
12 #ifndef TSMART_XBEE_802_H_
13 #define TSMART_XBEE_802_H_
14 
15 
16 #include "ts_xbee_if.h"
17 
18 
32 #define PR_TSMART_XBEE_802_AES_KEY_SIZE 16
33 #define PR_TSMART_XBEE_802_MAX_API_PAYLOAD 100
34 #define PR_TSMART_XBEE_802_MAX_CHANNLES_SCAN 16
36 #define TSMART_XBEE_802_FLEX0 (uint8_t)1
37 #define TSMART_XBEE_802_FLEX1 (uint8_t)2
38 #define TSMART_XBEE_802_FLEX2 (uint8_t)4
39 #define TSMART_XBEE_802_FLEX3 (uint8_t)8
41 #define TSMART_XBEE_802_FAULT_CODE_1 -1
42 #define TSMART_XBEE_802_FAULT_CODE_2 -2
43 #define TSMART_XBEE_802_FAULT_CODE_3 -3
44 #define TSMART_XBEE_802_FAULT_CODE_4 -4
45 #define TSMART_XBEE_802_FAULT_CODE_5 -5
46 #define TSMART_XBEE_802_FAULT_CODE_6 -6
47 #define TSMART_XBEE_802_FAULT_CODE_7 -7
48 #define TSMART_XBEE_802_FAULT_CODE_8 -8
49 #define TSMART_XBEE_802_FAULT_CODE_9 -9
50 #define TSMART_XBEE_802_FAULT_CODE_10 -10
51 #define TSMART_XBEE_802_FAULT_CODE_11 -11
52 #define TSMART_XBEE_802_FAULT_CODE_12 -12
53 #define TSMART_XBEE_802_FAULT_CODE_13 -13
54 #define TSMART_XBEE_802_FAULT_CODE_14 -14
55 #define TSMART_XBEE_802_FAULT_CODE_15 -15
56 #define TSMART_XBEE_802_FAULT_CODE_16 -16
57 #define TSMART_XBEE_802_FAULT_CODE_17 -17
58 #define TSMART_XBEE_802_FAULT_CODE_18 -18
59 #define TSMART_XBEE_802_FAULT_CODE_19 -19
60 #define TSMART_XBEE_802_FAULT_CODE_20 -20
61 #define TSMART_XBEE_802_FAULT_CODE_21 -21
62 #define TSMART_XBEE_802_FAULT_CODE_22 -22
63 #define TSMART_XBEE_802_FAULT_CODE_23 -23
64 #define TSMART_XBEE_802_FAULT_CODE_24 -24
65 #define TSMART_XBEE_802_FAULT_CODE_25 -25
66 #define TSMART_XBEE_802_FAULT_CODE_26 -26
82 typedef enum{
85  ASSOCIATED = 2,
90  FAILURE = -1,
92 
96 enum{
97  TSMART_XBEE_802_FC_NONE = USART_HardwareFlowControl_None,
98  TSMART_XBEE_802_FC_RTS = USART_HardwareFlowControl_RTS,
99  TSMART_XBEE_802_FC_CTS = USART_HardwareFlowControl_CTS,
100  TSMART_XBEE_802_FC_RTS_CTS = USART_HardwareFlowControl_RTS_CTS
101 };
102 
103 
110 typedef struct {
111  /* Energy */
112  uint8_t energy[PR_TSMART_XBEE_802_MAX_CHANNLES_SCAN];
114 
118 typedef struct {
119  /* Information about channels Scanned */
120  uint32_t coord_addr_high;
121  uint32_t coord_addr_low;
122  uint16_t my;
125  uint8_t size_addr;
128  uint32_t pan_id;
129  uint16_t channel;
130  uint8_t security;
131  uint8_t assoc_premitted;
134  uint8_t rssi;
136 
140 typedef struct{
141  uint16_t my;
145 
146 
150 typedef struct{
151  uint8_t data[PR_TSMART_XBEE_802_MAX_API_PAYLOAD];
152  uint32_t high_addr_source;
153  uint32_t low_addr_source;
154  uint8_t rssi;
156 
157 
161 typedef enum{
165 
166 
170 typedef struct{
171  uint8_t frame_id;
172  uint32_t high_addr_dest;
173  uint32_t low_addr_dest;
174  uint8_t payload[PR_TSMART_XBEE_802_MAX_API_PAYLOAD];
175  uint32_t payload_size;
180 
184 typedef enum{
188 
189 
193 typedef enum {
197 
198 
202 typedef enum{
210 
211 
215 typedef enum{
219 
223 typedef enum{
229 
233 typedef struct {
234  /* XBee configuration */
247  uint8_t channel;
267  uint16_t pan_id;
268  uint8_t baud_rate;
289  uint8_t power_level;
313  uint8_t aes_key[PR_TSMART_XBEE_802_AES_KEY_SIZE];
316  uint8_t aes_key_size;
319  uint32_t dest_addr_h;
322  uint32_t dest_addr_l;
325  uint16_t my;
332  uint8_t tx_retries;
351  uint16_t cyclic_period;
360  int16_t n_scan_channels;
405  uint32_t eflexibility;
430  uint32_t cflexibility;
452 
453 
454 
458 typedef struct {
459  uint32_t baud_rate;
467  uint16_t flow_control;
474  uint8_t priority;
479 
480 
490 typedef struct {
491  ts_xbee_if_t *xbee_if;
492  uint8_t *rx_buf;
493  uint32_t rx_buf_sz;
497  uint8_t n_packet_lost;
498  uint8_t api_enable;
499  xQueueHandle data_queue;
500  xQueueHandle command_queue;
501  xQueueHandle status_queue;
502  xQueueHandle mode_queue;
503  xSemaphoreHandle bitmap_protection;
504  xTaskHandle reception_task;
523 int8_t TSMART_XBEE_802_Init(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_config_t *TSMART_XBEE_802_config);
524 int8_t TSMART_XBEE_802_InitStruct(tsmart_xbee_802_config_device_t *TSMART_XBEE_802_config_device);
525 int8_t TSMART_XBEE_802_Config(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_config_device_t *TSMART_XBEE_802_config_device);
526 int8_t TSMART_XBEE_802_AtCommandMode(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_flag_t TSMART_XBEE_802_flag);
527 int32_t TSMART_XBEE_802_Send(tsmart_xbee_802_t *TSMART_XBEE_802, uint8_t *TSMART_XBEE_802_buf, uint32_t TSMART_XBEE_802_nbytes, portTickType TSMART_XBEE_802_xticks);
528 int32_t TSMART_XBEE_802_Receive(tsmart_xbee_802_t *TSMART_XBEE_802, uint8_t *TSMART_XBEE_802_buf, uint32_t TSMART_XBEE_802_nbytes, portTickType TSMART_XBEE_802_xticks);
529 int8_t TSMART_XBEE_802_TransparentMode(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_flag_t TSMART_XBEE_802_flag);
530 int8_t TSMART_XBEE_802_ReceiveApiFrame(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_data_received_t *TSMART_XBEE_802_data, portTickType TSMART_XBEE_802_xticks);
531 int8_t TSMART_XBEE_802_SendApiFrame(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_data_to_send_t *TSMART_XBEE_802_data, portTickType TSMART_XBEE_802_xticks);
533 int8_t TSMART_XBEE_802_HwSleep(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_flag_t TSMART_XBEE_802_flag);
534 int8_t TSMART_XBEE_802_DiscoverNodes(tsmart_xbee_802_t *TSMART_XBEE_802, uint8_t TSMART_XBEE_802_max_nodes, tsmart_xbee_802_discovered_node_t *TSMART_XBEE_802_nodes, uint8_t TSMART_XBEE_802_timeout);
535 int8_t TSMART_XBEE_802_ScanNetworks(tsmart_xbee_802_t *TSMART_XBEE_802, uint8_t TSMART_XBEE_802_max_networks,tsmart_xbee_802_scan_net_t *TSMART_XBEE_802_networks);
536 int8_t TSMART_XBEE_802_EnergyScan(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_energy_scan_t *TSMART_XBEE_802_energy_scan);
538 int8_t TSMART_XBEE_802_ReadSatus(tsmart_xbee_802_t *TSMART_XBEE_802, portTickType TSMART_XBEE_802_timeout);
539 uint32_t TSMART_XBEE_802_ReadLowAddress(tsmart_xbee_802_t *TSMART_XBEE_802);
540 uint32_t TSMART_XBEE_802_ReadHighAddress(tsmart_xbee_802_t *TSMART_XBEE_802);
541 uint32_t TSMART_XBEE_802_FirmwareVersion(tsmart_xbee_802_t *TSMART_XBEE_802);
554 #endif /* TSMART_XBEE_802_H_ */
tsmart_xbee_802_t tsmart_xbee_802
Definition: tsmart_xbee_802.c:67
Definition: tsmart_xbee_802.h:194
Definition: tsmart_xbee_802.h:99
int8_t TSMART_XBEE_802_SendApiFrame(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_data_to_send_t *TSMART_XBEE_802_data, portTickType TSMART_XBEE_802_xticks)
Sends a frame using API mode.
Definition: tsmart_xbee_802.c:1055
uint16_t timer_before_sleep
Definition: tsmart_xbee_802.h:354
Definition: tsmart_xbee_802.h:90
int8_t TSMART_XBEE_802_Init(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_config_t *TSMART_XBEE_802_config)
Initialize the XBee module.
Definition: tsmart_xbee_802.c:856
int16_t n_scan_channels
Definition: tsmart_xbee_802.h:360
Definition: tsmart_xbee_802.h:83
uint32_t eflexibility
Definition: tsmart_xbee_802.h:405
xQueueHandle data_queue
Definition: tsmart_xbee_802.h:499
Definition: tsmart_xbee_802.h:206
uint32_t payload_size
Definition: tsmart_xbee_802.h:175
uint16_t my
Definition: tsmart_xbee_802.h:122
Configuration for XBee 802.
Definition: tsmart_xbee_802.h:233
ts_xbee_if_t * xbee_if
Definition: tsmart_xbee_802.h:491
XBee 802 configuration structure.
Definition: tsmart_xbee_802.h:458
uint32_t TSMART_XBEE_802_ReadLowAddress(tsmart_xbee_802_t *TSMART_XBEE_802)
Reads the low part of the local XBee address.
Definition: tsmart_xbee_802.c:1933
uint8_t * rx_buf
Definition: tsmart_xbee_802.h:492
tsmart_xbee_802_kind_dev_t kind_dev
Definition: tsmart_xbee_802.h:241
xQueueHandle mode_queue
Definition: tsmart_xbee_802.h:502
Definition: tsmart_xbee_802.h:207
Definition: tsmart_xbee_802.h:87
Data structure to receive.
Definition: tsmart_xbee_802.h:150
uint32_t dest_addr_h
Definition: tsmart_xbee_802.h:319
uint16_t my
Definition: tsmart_xbee_802.h:141
Definition: tsmart_xbee_802.h:185
Definition: tsmart_xbee_802.h:205
uint32_t high_addr_dest
Definition: tsmart_xbee_802.h:172
tsmart_xbee_802_api_type_frame_t api_type_frame
Definition: tsmart_xbee_802.h:176
uint32_t high_addr_source
Definition: tsmart_xbee_802.h:152
int8_t TSMART_XBEE_802_ReceiveApiFrame(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_data_received_t *TSMART_XBEE_802_data, portTickType TSMART_XBEE_802_xticks)
Receives a frame using API mode.
Definition: tsmart_xbee_802.c:1103
uint8_t tx_retries
Definition: tsmart_xbee_802.h:332
uint8_t baud_rate
Definition: tsmart_xbee_802.h:268
uint8_t scan_channels_time
Definition: tsmart_xbee_802.h:384
int8_t TSMART_XBEE_802_PowerSignalReceived(tsmart_xbee_802_t *TSMART_XBEE_802)
Reports the RF power signal (RSSI) of last received packet.
Definition: tsmart_xbee_802.c:1553
Definition: tsmart_xbee_802.h:98
uint8_t priority
Definition: tsmart_xbee_802.h:474
uint8_t rssi
Definition: tsmart_xbee_802.h:154
uint16_t pan_id
Definition: tsmart_xbee_802.h:267
int8_t TSMART_XBEE_802_ReadSatus(tsmart_xbee_802_t *TSMART_XBEE_802, portTickType TSMART_XBEE_802_timeout)
Read one status message.
Definition: tsmart_xbee_802.c:1909
uint8_t frame_id
Definition: tsmart_xbee_802.h:171
tsmart_xbee_802_api_type_frame_t
Label to select kind of addressing to use in XBee 802 module.
Definition: tsmart_xbee_802.h:161
tsmart_xbee_802_report_t
Label to report about loss packets.
Definition: tsmart_xbee_802.h:184
Definition: tsmart_xbee_802.h:203
Definition: tsmart_xbee_802.h:163
uint32_t dest_addr_l
Definition: tsmart_xbee_802.h:322
uint32_t cflexibility
Definition: tsmart_xbee_802.h:430
uint32_t baud_rate
Definition: tsmart_xbee_802.h:459
Definition: tsmart_xbee_802.h:100
uint32_t node_discovered_addr_h
Definition: tsmart_xbee_802.h:142
int32_t TSMART_XBEE_802_Send(tsmart_xbee_802_t *TSMART_XBEE_802, uint8_t *TSMART_XBEE_802_buf, uint32_t TSMART_XBEE_802_nbytes, portTickType TSMART_XBEE_802_xticks)
Sends data to remote XBee module.
Definition: tsmart_xbee_802.c:589
int8_t TSMART_XBEE_802_InitStruct(tsmart_xbee_802_config_device_t *TSMART_XBEE_802_config_device)
Initializes tsmart_xbee_802_config_device_t structure function.
Definition: tsmart_xbee_802.c:918
uint8_t aes_key_size
Definition: tsmart_xbee_802.h:316
uint8_t power_level
Definition: tsmart_xbee_802.h:289
XBee 802 energy scan structure.
Definition: tsmart_xbee_802.h:110
uint8_t assoc_premitted
Definition: tsmart_xbee_802.h:131
Definition: tsmart_xbee_802.h:162
uint16_t cyclic_period
Definition: tsmart_xbee_802.h:351
tsmart_xbee_802_kind_dev_t
Label to configure kind of device in 802.15.4 protocol.
Definition: tsmart_xbee_802.h:215
Definition: tsmart_xbee_802.h:227
Definition: tsmart_xbee_802.h:225
tsmart_xbee_802_flag_t sleep_option
Definition: tsmart_xbee_802.h:346
uint32_t TSMART_XBEE_802_ReadHighAddress(tsmart_xbee_802_t *TSMART_XBEE_802)
Reads the high part of the local XBee address.
Definition: tsmart_xbee_802.c:1973
uint16_t flow_control
Definition: tsmart_xbee_802.h:467
Definition: tsmart_xbee_802.h:217
uint8_t api_enable
Definition: tsmart_xbee_802.h:498
tsmart_xbee_802_flag_t
Standard label for XBEE 802 device.
Definition: tsmart_xbee_802.h:193
uint8_t rssi
Definition: tsmart_xbee_802.h:134
Definition: tsmart_xbee_802.h:208
xQueueHandle status_queue
Definition: tsmart_xbee_802.h:501
uint16_t channel
Definition: tsmart_xbee_802.h:129
Definition: tsmart_xbee_802.h:224
int32_t TSMART_XBEE_802_Receive(tsmart_xbee_802_t *TSMART_XBEE_802, uint8_t *TSMART_XBEE_802_buf, uint32_t TSMART_XBEE_802_nbytes, portTickType TSMART_XBEE_802_xticks)
Receives data from the XBee module.
Definition: tsmart_xbee_802.c:606
tsmart_xbee_802_flow_control_t
Enum to select Flow control mode.
Definition: tsmart_xbee_802.h:223
tsmart_xbee_802_status_t TSMART_XBEE_802_DisassociateNode(tsmart_xbee_802_t *TSMART_XBEE_802)
Disassociate node.
Definition: tsmart_xbee_802.c:1862
uint8_t size_addr
Definition: tsmart_xbee_802.h:125
xTaskHandle reception_task
Definition: tsmart_xbee_802.h:504
XBee 802 scan channel structure. Maximum Network available to look for: 5.
Definition: tsmart_xbee_802.h:118
Definition: tsmart_xbee_802.h:88
uint32_t low_addr_dest
Definition: tsmart_xbee_802.h:173
int8_t TSMART_XBEE_802_AtCommandMode(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_flag_t TSMART_XBEE_802_flag)
Enters or exits from the AT command mode.
Definition: tsmart_xbee_802.c:959
Definition: tsmart_xbee_802.h:86
Definition: tsmart_xbee_802.h:97
Definition: tsmart_xbee_802.h:216
tsmart_xbee_802_status_t
Status messages.
Definition: tsmart_xbee_802.h:82
uint32_t coord_addr_high
Definition: tsmart_xbee_802.h:120
Definition: tsmart_xbee_802.h:89
uint32_t TSMART_XBEE_802_FirmwareVersion(tsmart_xbee_802_t *TSMART_XBEE_802)
Reads the Firmware version of the local XBee address.
Definition: tsmart_xbee_802.c:2013
int8_t TSMART_XBEE_802_HwSleep(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_flag_t TSMART_XBEE_802_flag)
Hardware Sleep.
Definition: tsmart_xbee_802.c:1600
tsmart_xbee_802_flow_control_t flow_control
Definition: tsmart_xbee_802.h:279
int8_t TSMART_XBEE_802_Config(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_config_device_t *TSMART_XBEE_802_config_device)
Configures a XBEE 802.15.4 Device.
Definition: tsmart_xbee_802.c:1151
Data to send structure.
Definition: tsmart_xbee_802.h:170
uint32_t node_discovered_addr_l
Definition: tsmart_xbee_802.h:143
uint32_t coord_addr_low
Definition: tsmart_xbee_802.h:121
xQueueHandle command_queue
Definition: tsmart_xbee_802.h:500
XBee 802 handler structure.
Definition: tsmart_xbee_802.h:490
int8_t TSMART_XBEE_802_EnergyScan(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_energy_scan_t *TSMART_XBEE_802_energy_scan)
Scans energy.
Definition: tsmart_xbee_802.c:1820
uint32_t pan_id
Definition: tsmart_xbee_802.h:128
tsmart_xbee_802_flag_t api
Definition: tsmart_xbee_802.h:235
uint32_t low_addr_source
Definition: tsmart_xbee_802.h:153
Discovered node structure.
Definition: tsmart_xbee_802.h:140
int8_t TSMART_XBEE_802_TransparentMode(tsmart_xbee_802_t *TSMART_XBEE_802, tsmart_xbee_802_flag_t TSMART_XBEE_802_flag)
Enters/Exits from transparent mode to receive or send data.
Definition: tsmart_xbee_802.c:1012
uint16_t my
Definition: tsmart_xbee_802.h:325
uint8_t n_packet_lost
Definition: tsmart_xbee_802.h:497
Definition: tsmart_xbee_802.h:195
Definition: tsmart_xbee_802.h:85
Definition: tsmart_xbee_802.h:84
int8_t TSMART_XBEE_802_ScanNetworks(tsmart_xbee_802_t *TSMART_XBEE_802, uint8_t TSMART_XBEE_802_max_networks, tsmart_xbee_802_scan_net_t *TSMART_XBEE_802_networks)
Scans networks.
Definition: tsmart_xbee_802.c:1721
tsmart_xbee_802_sleep_mode_t
Sleep modes for XBee 802 device.
Definition: tsmart_xbee_802.h:202
xSemaphoreHandle bitmap_protection
Definition: tsmart_xbee_802.h:503
Definition: tsmart_xbee_802.h:204
Definition: tsmart_xbee_802.h:186
uint8_t security
Definition: tsmart_xbee_802.h:130
Definition: tsmart_xbee_802.h:226
tsmart_xbee_802_report_t packet_lost
Definition: tsmart_xbee_802.h:494
int8_t TSMART_XBEE_802_DiscoverNodes(tsmart_xbee_802_t *TSMART_XBEE_802, uint8_t TSMART_XBEE_802_max_nodes, tsmart_xbee_802_discovered_node_t *TSMART_XBEE_802_nodes, uint8_t TSMART_XBEE_802_timeout)
Discovery nodes.
Definition: tsmart_xbee_802.c:1637
uint8_t channel
Definition: tsmart_xbee_802.h:247
uint32_t rx_buf_sz
Definition: tsmart_xbee_802.h:493
tsmart_xbee_802_flag_t aes_enable
Definition: tsmart_xbee_802.h:307
tsmart_xbee_802_sleep_mode_t sleep
Definition: tsmart_xbee_802.h:336