Developer World
Spresense SDK Library v3.3.0-375c679
bluetooth.h
Go to the documentation of this file.
1/****************************************************************************
2 * modules/include/bluetooth/bluetooth.h
3 *
4 * Copyright 2018 Sony Semiconductor Solutions Corporation
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
47#ifndef __MODULES_INCLUDE_BLUETOOTH_BLUETOOTH_H
48#define __MODULES_INCLUDE_BLUETOOTH_BLUETOOTH_H
49
50#define BLUETOOTH_DEBUG
51
52/****************************************************************************
53 * Included Files
54 ****************************************************************************/
55
56#include <sdk/config.h>
57
58#include <debug.h>
59#include <errno.h>
60#include <stdbool.h>
61#include <stdint.h>
62#ifdef BLUETOOTH_DEBUG
63#include <stdio.h>
64#endif
65
66/****************************************************************************
67 * Pre-processor Definitions
68 ****************************************************************************/
69
70#ifdef BLUETOOTH_DEBUG
71#undef _err
72#define _err(format, ...) printf(format, ##__VA_ARGS__)
73#undef _info
74#define _info(format, ...) printf(format, ##__VA_ARGS__)
75#endif
76
81#define BT_SUCCESS 0
88#define BT_FAIL -1
95#define BT_ADDR_LEN 6
102#define BT_NAME_LEN 28
109#define BT_UUID128_LEN 16
119#define BLE_ADV_FLAGS_LIMITED_DISC_MODE (0x01)
120
123#define BLE_ADV_FLAGS_GENERAL_DISC_MODE (0x02)
124
127#define BLE_ADV_FLAGS_BR_EDR_NOT_SUPPORTED (0x04)
128
131#define BLE_ADV_FLAGS_LE_BR_EDR_CONTROLLER (0x08)
132
135#define BLE_ADV_FLAGS_LE_BR_EDR_HOST (0x10)
136
146#define BLE_UUID_128BIT_STRING_LENGTH (36)
147
150#define BLE_UUID_16BIT_STRING_LENGTH (4)
151
154#define BLE_UUID_128BIT_STRING_BUFSIZE (BLE_UUID_128BIT_STRING_LENGTH + 1)
155
158#define BLE_UUID_16BIT_STRING_BUFSIZE (BLE_UUID_16BIT_STRING_LENGTH + 1)
159
162/****************************************************************************
163 * Public Types
164 ****************************************************************************/
165
170typedef struct
171{
172 uint8_t address[BT_ADDR_LEN];
173} BT_ADDR;
174
179typedef struct
180{
181 uint8_t uuid128[BT_UUID128_LEN];
182} BT_UUID;
183
188typedef enum
189{
204
209typedef enum
210{
232
237typedef enum
238{
244
249typedef enum
250{
256
261typedef enum
262{
263 BLE_APPEARANCE_UNKNOWN = 0,
264 BLE_APPEARANCE_GENERIC_PHONE = 64,
265 BLE_APPEARANCE_GENERIC_COMPUTER = 128,
266 BLE_APPEARANCE_GENERIC_WATCH = 192,
267 BLE_APPEARANCE_WATCH_SPORTS = 193,
268 BLE_APPEARANCE_GENERIC_CLOCK = 256,
269 BLE_APPEARANCE_GENERIC_DISPLAY = 320,
270 BLE_APPEARANCE_GENERIC_REMOTE_CONTROL = 384,
271 BLE_APPEARANCE_GENERIC_EYE_GLASSES = 448,
272 BLE_APPEARANCE_GENERIC_TAG = 512,
273 BLE_APPEARANCE_GENERIC_KEYRING = 576,
274 BLE_APPEARANCE_GENERIC_MEDIA_PLAYER = 640,
275 BLE_APPEARANCE_GENERIC_BARCODE_SCANNER = 704,
276 BLE_APPEARANCE_GENERIC_THERMOMETER = 768,
277 BLE_APPEARANCE_THERMOMETER_EAR = 769,
278 BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR = 832,
279 BLE_APPEARANCE_HEART_RATE_BELT = 833,
280 BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE = 896,
281 BLE_APPEARANCE_BLOOD_PRESSURE_ARM = 897,
282 BLE_APPEARANCE_BLOOD_PRESSURE_WRIST = 898,
283 BLE_APPEARANCE_GENERIC_HID_DEVICE = 960,
284 BLE_APPEARANCE_HID_KEYBOARD = 961,
285 BLE_APPEARANCE_HID_MOUSE = 962,
286 BLE_APPEARANCE_HID_JOYSTICK = 963,
287 BLE_APPEARANCE_HID_GAMEPAD = 964,
288 BLE_APPEARANCE_HID_DIGITIZER_TABLET = 965,
289 BLE_APPEARANCE_HID_CARD_READER = 966,
290 BLE_APPEARANCE_HID_DIGITAL_PEN = 967,
291 BLE_APPEARANCE_HID_BARCODE_SCANNER = 968,
292 BLE_APPEARANCE_GENERIC_GLUCOSE_METER = 1024,
293 BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR = 1088,
294 BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE = 1089,
295 BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE = 1090,
296 BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP = 1091,
297 BLE_APPEARANCE_GENERIC_CYCLING = 1152,
298 BLE_APPEARANCE_CYCLING_COMPUTER = 1153,
299 BLE_APPEARANCE_CYCLING_SPEED_SENSOR = 1154,
300 BLE_APPEARANCE_CYCLING_CADENCE_SENSOR = 1155,
301 BLE_APPEARANCE_CYCLING_POWER_SENSOR = 1156,
302 BLE_APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR = 1157,
304
309typedef enum {
316
322typedef enum {
326
330
334
338
342
346
350
354
358
362
366
370
374
378
382
386
390
394
398
402
406
410
414
418
422
426
430
434
438
442
446
450
454
458
463
469typedef enum
470{
474
478
482
487
488/****************************************************************************
489 * Private Data
490 ****************************************************************************/
491
492/****************************************************************************
493 * Public Function Prototypes
494 ****************************************************************************/
495
496#endif /* __MODULES_INCLUDE_BLUETOOTH_BLUETOOTH_H */
BLE_ADDRESS_TYPE
BLE address type.
Definition: bluetooth.h:470
@ BLE_ADDRTYPE_RAND_PRIV_RESOLVABLE
Definition: bluetooth.h:481
@ BLE_ADDRTYPE_RAND_STATIC
Definition: bluetooth.h:477
@ BLE_ADDRTYPE_PUBLIC
Definition: bluetooth.h:473
@ BLE_ADDRTYPE_RAND_PRIV_NONRESOLVABLE
Definition: bluetooth.h:485
BT_VISIBILITY
BT visibility ID.
Definition: bluetooth.h:250
@ BT_VIS_DISCOVERY_CONNECTABLE
Definition: bluetooth.h:254
@ BT_VIS_DISCOVERY_NO_CONNECTABLE
Definition: bluetooth.h:252
@ BT_VIS_NO_DISCOVERY_NO_CONNECTABLE
Definition: bluetooth.h:251
@ BT_VIS_NO_DISCOVERY_CONNECTABLE
Definition: bluetooth.h:253
BT_CONNECT_FAIL_REASON_ID
BT profile connection result.
Definition: bluetooth.h:238
@ BT_CONNECT_TIMEOUT
Definition: bluetooth.h:241
@ BT_CONNECT_NO_DEVICE
Definition: bluetooth.h:240
@ BT_CONNECT_NO_SERVICE
Definition: bluetooth.h:239
@ BT_CONNECT_OTHER
Definition: bluetooth.h:242
BT_PAIR_STATUS
BT pairing result.
Definition: bluetooth.h:210
@ BT_PAIR_PAIRING_AUTHENTICATION_FAILURE
Definition: bluetooth.h:214
@ BT_PAIR_RESPONSE_TIMEOUT
Definition: bluetooth.h:228
@ BT_PAIR_CONFIRM_VALUE_FAILURE
Definition: bluetooth.h:215
@ BT_PAIR_PASSKEY_ENTRY_FAILURE
Definition: bluetooth.h:212
@ BT_PAIR_SMP_BUSY
Definition: bluetooth.h:225
@ BT_PAIR_OOB_FAILURE
Definition: bluetooth.h:213
@ BT_PAIR_ENCRYPTION_KEY_SIZE_FAILURE
Definition: bluetooth.h:217
@ BT_PAIR_INTERNAL_PAIRING_ERROR
Definition: bluetooth.h:221
@ BT_PAIR_PAIRING_FAILURE_UNKNOWN
Definition: bluetooth.h:219
@ BT_PAIR_REPEATED_ATTEMPTS
Definition: bluetooth.h:220
@ BT_PAIR_CONNECTION_TIMEOUT
Definition: bluetooth.h:230
@ BT_PAIR_INVALID_COMMAND
Definition: bluetooth.h:218
@ BT_PAIR_GENERIC_FAILURE
Definition: bluetooth.h:229
@ BT_PAIR_SMP_INITIALIZATION_FAILURE
Definition: bluetooth.h:223
@ BT_PAIR_ENCRYPTION_FAILURE
Definition: bluetooth.h:226
@ BT_PAIR_SUCCESS
Definition: bluetooth.h:211
@ BT_PAIR_CONFIRMATION_FAILRUE
Definition: bluetooth.h:224
@ BT_PAIR_UNKNOWN_IO_CAPABILITIES
Definition: bluetooth.h:222
@ BT_PAIR_PAIRING_NOT_SUPPORTED
Definition: bluetooth.h:216
@ BT_PAIR_BONDING_STARTED
Definition: bluetooth.h:227
BT_CMD_STATUS
BT hci command status.
Definition: bluetooth.h:189
@ BT_COMMAND_STATUS_ALREADY_CONNECTED
Definition: bluetooth.h:192
@ BT_COMMAND_STATUS_FAILED
Definition: bluetooth.h:197
@ BT_COMMAND_STATUS_WRONG_STATE
Definition: bluetooth.h:195
@ BT_COMMAND_STATUS_OUT_OF_MEMORY
Definition: bluetooth.h:201
@ BT_COMMAND_STATUS_CLIENT_NOT_REGISTERED
Definition: bluetooth.h:200
@ BT_COMMAND_STATUS_SUCCESS
Definition: bluetooth.h:190
@ BT_COMMAND_STATUS_INVALID_ARGS
Definition: bluetooth.h:196
@ BT_COMMAND_STATUS_NOT_CONNECTED
Definition: bluetooth.h:193
@ BT_COMMAND_STATUS_IN_PROGRESS
Definition: bluetooth.h:191
@ BT_COMMAND_STATUS_DISALLOWED
Definition: bluetooth.h:202
@ BT_COMMAND_STATUS_UNKNOWN_GROUP
Definition: bluetooth.h:198
@ BT_COMMAND_STATUS_UNKNOWN_COMMAND
Definition: bluetooth.h:199
@ BT_COMMAND_STATUS_BAD_HANDLE
Definition: bluetooth.h:194
BLE_GAP_IO_CAP
BLE IO capability.
Definition: bluetooth.h:309
@ BLE_GAP_IO_CAP_NO_INPUT_NO_OUTPUT
Definition: bluetooth.h:313
@ BLE_GAP_IO_CAP_DISPLAY_YESNO
Definition: bluetooth.h:311
@ BLE_GAP_IO_CAP_KEYBOARD_ONLY
Definition: bluetooth.h:312
@ BLE_GAP_IO_CAP_DISPLAY_ONLY
Definition: bluetooth.h:310
@ BLE_GAP_IO_CAP_KEYBOARD_DISPLAY
Definition: bluetooth.h:314
BLE_APPEARANCE
BLE appearance ID.
Definition: bluetooth.h:262
BLE_AD_TYPE
BLE data type of advertising data.
Definition: bluetooth.h:322
@ BLE_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE
Definition: bluetooth.h:345
@ BLE_AD_TYPE_16BIT_SERVICE_UUID_INCOMPLETE
Definition: bluetooth.h:333
@ BLE_AD_TYPE_ADVERTISING_INTERVAL
Definition: bluetooth.h:417
@ BLE_AD_TYPE_RANDOM_TARGET_ADDRESS
Definition: bluetooth.h:409
@ BLE_AD_TYPE_PUBLIC_TARGET_ADDRESS
Definition: bluetooth.h:405
@ BLE_AD_TYPE_128BIT_SERVICE_UUID_INCOMPLETE
Definition: bluetooth.h:349
@ BLE_AD_TYPE_SERVICE_DATA_128BIT_UUID
Definition: bluetooth.h:441
@ BLE_AD_TYPE_FLAGS
Definition: bluetooth.h:329
@ BLE_AD_TYPE_SERVICE_DATA_32BIT_UUID
Definition: bluetooth.h:437
@ BLE_AD_TYPE_TX_POWER_LEVEL
Definition: bluetooth.h:365
@ BLE_AD_TYPE_COMPLETE_LOCAL_NAME
Definition: bluetooth.h:361
@ BLE_AD_TYPE_MANUFACTURER_SPECIFIC_DATA
Definition: bluetooth.h:461
@ BLE_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE
Definition: bluetooth.h:337
@ BLE_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS
Definition: bluetooth.h:385
@ BLE_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT
Definition: bluetooth.h:393
@ BLE_AD_TYPE_CLASS_OF_DEVICE
Definition: bluetooth.h:369
@ BLE_AD_TYPE_LESC_CONFIRMATION_VALUE
Definition: bluetooth.h:445
@ BLE_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS
Definition: bluetooth.h:421
@ BLE_AD_TYPE_CONNECTION_INTERVAL_RANGE
Definition: bluetooth.h:389
@ BLE_AD_TYPE_URI
Definition: bluetooth.h:453
@ BLE_AD_TYPE_ADDRESS_TYPE
Definition: bluetooth.h:325
@ BLE_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256
Definition: bluetooth.h:433
@ BLE_AD_TYPE_SERVICE_DATA
Definition: bluetooth.h:401
@ BLE_AD_TYPE_SIMPLE_PAIRING_HASH_C256
Definition: bluetooth.h:429
@ BLE_AD_TYPE_SECURITY_MANAGER_TK_VALUE
Definition: bluetooth.h:381
@ BLE_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R
Definition: bluetooth.h:377
@ BLE_AD_TYPE_LE_ROLE
Definition: bluetooth.h:425
@ BLE_AD_TYPE_3D_INFORMATION_DATA
Definition: bluetooth.h:457
@ BLE_AD_TYPE_SHORT_LOCAL_NAME
Definition: bluetooth.h:357
@ BLE_AD_TYPE_APPEARANCE
Definition: bluetooth.h:413
@ BLE_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT
Definition: bluetooth.h:397
@ BLE_AD_TYPE_LESC_RANDOM_VALUE
Definition: bluetooth.h:449
@ BLE_AD_TYPE_SIMPLE_PAIRING_HASH_C
Definition: bluetooth.h:373
@ BLE_AD_TYPE_32BIT_SERVICE_UUID_INCOMPLETE
Definition: bluetooth.h:341
@ BLE_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE
Definition: bluetooth.h:353
BT address types.
Definition: bluetooth.h:171
128-bit UUID types
Definition: bluetooth.h:180