upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
aci.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, Nordic Semiconductor ASA
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in all
11  * copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19  * SOFTWARE.
20  */
21 
54 #ifndef ACI_H__
55 #define ACI_H__
56 
70 #ifdef __GNUC__
71 # if __GNUC__ >= 4
72 # define _aci_packed_ __attribute__((__packed__))
73 # else
74 # error "older g++ versions don't handle packed attribute in typedefs"
75 # endif
76 #else
77 # define _aci_packed_
78 #endif
79 
80 #include <stdint.h>
81 #include <cstddef>
82 #include <string.h>
83 #include <unistd.h>
84 
85 /*
86  * Define a macro that compares the size of the first parameter to the integer
87  * value of the second parameter. If they do not match, a compile time error
88  * for negative array size occurs (even gnu chokes on negative array size).
89  *
90  * This compare is done by creating a typedef for an array. No variables are
91  * created and no memory is consumed with this check. The created type is
92  * used for checking only and is not for use by any other code. The value
93  * of 10 in this macro is arbitrary, it just needs to be a value larger
94  * than one to result in a positive number for the array size.
95  */
96 #define ACI_ASSERT_SIZE(x,y) typedef char x ## _assert_size_t[-1+10*(sizeof(x) == (y))]
97 
104 #define ACI_VERSION (0x02)
105 
109 #define BTLE_DEVICE_ADDRESS_SIZE (6)
110 
114 #define ACI_PACKET_MAX_LEN (32)
115 
119 #define ACI_ECHO_DATA_MAX_LEN (ACI_PACKET_MAX_LEN - 3)
120 
124 #define ACI_DEVICE_MAX_PIPES (62)
125 
129 #define ACI_PIPE_TX_DATA_MAX_LEN (20)
130 
134 #define ACI_PIPE_RX_DATA_MAX_LEN (22)
135 
139 #define ACI_GAP_DEVNAME_MAX_LEN (20)
140 
144 #define ACI_AD_PACKET_MAX_LEN (31)
145 
149 #define ACI_AD_PACKET_MAX_USER_LEN (31 - 3)
150 
154 #define ACI_PIPE_INVALID (0xFF)
155 
160 typedef enum
161 {
162  ACI_STORE_INVALID = 0x0,
163  ACI_STORE_LOCAL= 0x01,
164  ACI_STORE_REMOTE= 0x02
165 } _aci_packed_ aci_pipe_store_t;
166 
171 typedef enum
172 {
173  ACI_TX_BROADCAST = 0x0001,
174  ACI_TX = 0x0002,
175  ACI_TX_ACK = 0x0004,
176  ACI_RX = 0x0008,
177  ACI_RX_ACK = 0x0010,
178  ACI_TX_REQ = 0x0020,
179  ACI_RX_REQ = 0x0040,
180  ACI_SET = 0x0080,
181  ACI_TX_SIGN = 0x0100,
182  ACI_RX_SIGN = 0x0200,
183  ACI_RX_ACK_AUTO = 0x0400
184 } _aci_packed_ aci_pipe_type_t;
185 
186 ACI_ASSERT_SIZE(aci_pipe_type_t, 2);
187 
192 typedef enum
193 {
194  ACI_BD_ADDR_TYPE_INVALID = 0x00,
195  ACI_BD_ADDR_TYPE_PUBLIC = 0x01,
196  ACI_BD_ADDR_TYPE_RANDOM_STATIC = 0x02,
197  ACI_BD_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE = 0x03,
198  ACI_BD_ADDR_TYPE_RANDOM_PRIVATE_UNRESOLVABLE = 0x04
199 } _aci_packed_ aci_bd_addr_type_t;
200 
205 typedef enum
206 {
211 } _aci_packed_ aci_device_output_power_t;
212 
217 typedef enum
218 {
219  ACI_DEVICE_INVALID =0x00,
220  ACI_DEVICE_TEST =0x01,
221  ACI_DEVICE_SETUP =0x02,
222  ACI_DEVICE_STANDBY =0x03,
223  ACI_DEVICE_SLEEP =0x04
224 } _aci_packed_ aci_device_operation_mode_t;
225 
230 typedef enum
231 {
233  ACI_REASON_BAD_TIMING =0x02 /*<Use this to disconnect and inform the peer, that the timing on the link is not acceptable for the device, you need to wait for the "disconnected" event */
234 } _aci_packed_ aci_disconnect_reason_t;
235 
240 typedef enum
241 {
242  ACI_TEST_MODE_DTM_UART = 0x01,
243  ACI_TEST_MODE_DTM_ACI = 0x02,
244  ACI_TEST_MODE_EXIT = 0xFF
245 
246 } _aci_packed_ aci_test_mode_change_t;
247 
248 ACI_ASSERT_SIZE(aci_test_mode_change_t, 1);
249 
254 typedef enum
255 {
256  ACI_PERMISSIONS_NONE =0x00,
257  ACI_PERMISSIONS_LINK_AUTHENTICATED =0x01
258 } _aci_packed_ aci_permissions_t;
259 
265 #define ACI_VS_UUID_128_MAX_COUNT 64
271 typedef struct
272 {
273  uint16_t min_conn_interval;
274  #define ACI_PPCP_MIN_CONN_INTVL_NONE 0xFFFF
275  #define ACI_PPCP_MIN_CONN_INTVL_MIN 0x0006
276  #define ACI_PPCP_MIN_CONN_INTVL_MAX 0x0C80
277  uint16_t max_conn_interval;
278  #define ACI_PPCP_MAX_CONN_INTVL_NONE 0xFFFF
279  #define ACI_PPCP_MAX_CONN_INTVL_MIN 0x0006
280  #define ACI_PPCP_MAX_CONN_INTVL_MAX 0x0C80
281  uint16_t slave_latency;
282  #define ACI_PPCP_SLAVE_LATENCY_MAX 0x03E8
283  uint16_t timeout_mult;
284  #define ACI_PPCP_TIMEOUT_MULT_NONE 0xFFFF
285  #define ACI_PPCP_TIMEOUT_MULT_MIN 0x000A
286  #define ACI_PPCP_TIMEOUT_MULT_MAX 0x0C80
287 } _aci_packed_ aci_ll_conn_params_t;
288 
293 #define aci_gap_ppcp_t aci_ll_conn_params_t
294 
300 #define ACI_AD_LOC_SVCUUID_16_MAX_COUNT 5
301 
307 #define ACI_AD_LOC_SVCUUID_128_MAX_COUNT 1
308 
314 #define ACI_AD_SOL_SVCUUID_16_MAX_COUNT 5
315 
321 #define ACI_AD_SOL_SVCUUID_128_MAX_COUNT 1
322 
327 #define ACI_SEC_ENCKEY_SIZE_MIN 7
328 
332 #define ACI_SEC_ENCKEY_SIZE_MAX 16
333 
337 #define ACI_CUSTOM_AD_TYPE_MAX_COUNT 8
338 
342 #define ACI_CUSTOM_AD_TYPE_MAX_DATA_LENGTH 20
343 
348 typedef struct
349 {
350  uint8_t pipe_number;
351  uint8_t aci_data[ACI_PIPE_TX_DATA_MAX_LEN];
352 } _aci_packed_ aci_tx_data_t;
353 
354 ACI_ASSERT_SIZE(aci_tx_data_t, ACI_PIPE_TX_DATA_MAX_LEN + 1);
355 
360 typedef struct
361 {
362  uint8_t pipe_number;
363  uint8_t aci_data[ACI_PIPE_RX_DATA_MAX_LEN];
364 } _aci_packed_ aci_rx_data_t;
365 
366 ACI_ASSERT_SIZE(aci_rx_data_t, ACI_PIPE_RX_DATA_MAX_LEN + 1);
367 
372 typedef enum
373 {
374  ACI_HW_ERROR_NONE = 0x00,
375  ACI_HW_ERROR_FATAL = 0x01
376 } _aci_packed_ aci_hw_error_t;
377 
382 typedef enum
383 {
384  ACI_CLOCK_ACCURACY_500_PPM = 0x00,
385  ACI_CLOCK_ACCURACY_250_PPM = 0x01,
386  ACI_CLOCK_ACCURACY_150_PPM = 0x02,
387  ACI_CLOCK_ACCURACY_100_PPM = 0x03,
388  ACI_CLOCK_ACCURACY_75_PPM = 0x04,
389  ACI_CLOCK_ACCURACY_50_PPM = 0x05,
390  ACI_CLOCK_ACCURACY_30_PPM = 0x06,
391  ACI_CLOCK_ACCURACY_20_PPM = 0x07
392 } _aci_packed_ aci_clock_accuracy_t;
393 
398 typedef enum
399 {
400  ACI_APP_LATENCY_DISABLE = 0,
401  ACI_APP_LATENCY_ENABLE = 1
402 } _aci_packed_ aci_app_latency_mode_t;
403 
408 typedef enum
409 {
414  ACI_GATT_FORMAT_UINT8 = 0x04,
415  ACI_GATT_FORMAT_UINT12 = 0x05,
416  ACI_GATT_FORMAT_UINT16 = 0x06,
417  ACI_GATT_FORMAT_UINT24 = 0x07,
418  ACI_GATT_FORMAT_UINT32 = 0x08,
419  ACI_GATT_FORMAT_UINT48 = 0x09,
420  ACI_GATT_FORMAT_UINT64 = 0x0A,
421  ACI_GATT_FORMAT_UINT128 = 0x0B,
422  ACI_GATT_FORMAT_SINT8 = 0x0C,
423  ACI_GATT_FORMAT_SINT12 = 0x0D,
424  ACI_GATT_FORMAT_SINT16 = 0x0E,
425  ACI_GATT_FORMAT_SINT24 = 0x0F,
426  ACI_GATT_FORMAT_SINT32 = 0x10,
427  ACI_GATT_FORMAT_SINT48 = 0x11,
428  ACI_GATT_FORMAT_SINT64 = 0x12,
429  ACI_GATT_FORMAT_SINT128 = 0x13,
430  ACI_GATT_FORMAT_FLOAT32 = 0x14,
431  ACI_GATT_FORMAT_FLOAT64 = 0x15,
432  ACI_GATT_FORMAT_SFLOAT = 0x16,
433  ACI_GATT_FORMAT_FLOAT = 0x17,
434  ACI_GATT_FORMAT_DUINT16 = 0x18,
435  ACI_GATT_FORMAT_UTF8S = 0x19,
436  ACI_GATT_FORMAT_UTF16S = 0x1A,
437  ACI_GATT_FORMAT_STRUCT = 0x1B
438 } _aci_packed_ aci_gatt_format_t;
439 
443 typedef enum
444 {
445  ACI_GATT_NAMESPACE_INVALID = 0x00,
447 } _aci_packed_ aci_gatt_namespace_t;
448 
452 typedef enum
453 {
454  ACI_KEY_TYPE_INVALID = 0x00,
455  ACI_KEY_TYPE_PASSKEY = 0x01
456 } _aci_packed_ aci_key_type_t;
457 
462 typedef enum
463 {
516 
517 } _aci_packed_ aci_bond_status_code_t;
518 
519 ACI_ASSERT_SIZE(aci_bond_status_code_t, 1);
520 
525 typedef enum
526 {
527  ACI_BOND_STATUS_SOURCE_INVALID = 0x00,
528  ACI_BOND_STATUS_SOURCE_LOCAL = 0x01,
529  ACI_BOND_STATUS_SOURCE_REMOTE = 0x02
530 
531 } _aci_packed_ aci_bond_status_source_t;
532 
537 typedef enum
538 {
663 
664 } _aci_packed_ aci_status_code_t;
665 
666 ACI_ASSERT_SIZE(aci_status_code_t, 1);
667 
672 #endif // ACI_H__
Definition: aci.h:618
Definition: aci.h:562
uint16_t min_conn_interval
Definition: aci.h:273
Definition: aci.h:232
Definition: aci.h:662
#define ACI_PIPE_RX_DATA_MAX_LEN
Maximum length in bytes of a reception data pipe packet.
Definition: aci.h:134
Definition: aci.h:582
Definition: aci.h:471
Definition: aci.h:554
Definition: aci.h:610
Definition: aci.h:542
Definition: aci.h:658
Definition: aci.h:606
Definition: aci.h:566
Definition: aci.h:411
uint16_t slave_latency
Definition: aci.h:281
uint16_t max_conn_interval
Definition: aci.h:277
Definition: aci.h:630
Definition: aci.h:614
Definition: aci.h:574
Definition: aci.h:598
Definition: aci.h:602
Definition: aci.h:546
Definition: aci.h:413
Definition: aci.h:622
Definition: aci.h:634
Definition: aci.h:638
Definition: aci.h:467
#define ACI_PIPE_TX_DATA_MAX_LEN
Maximum length in bytes of a transmission data pipe packet.
Definition: aci.h:129
Definition: aci.h:590
Definition: aci.h:210
Definition: aci.h:412
Definition: aci.h:558
Definition: aci.h:550
Definition: aci.h:446
Structure for the ACI_CMD_SET_LOCAL_DATA ACI command parameters.
Definition: aci.h:271
Definition: aci.h:410
uint16_t timeout_mult
Definition: aci.h:283
Definition: aci.h:586