Developer World
Spresense SDK Library v3.2.0-ebc0364
bluetooth.h File Reference

Bluetooth common header for SDK on Spresense. More...

#include <sdk/config.h>
#include <debug.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  BT_ADDR
 BT address types. More...
 
struct  BT_UUID
 128-bit UUID types More...
 

Macros

#define BLUETOOTH_DEBUG
 
#define _err(format, ...)   printf(format, ##__VA_ARGS__)
 
#define _info(format, ...)   printf(format, ##__VA_ARGS__)
 
BT success code
#define BT_SUCCESS   0
 
BT fail code
#define BT_FAIL   -1
 
BT Address Length
#define BT_ADDR_LEN   6
 
BT Name Length
#define BT_NAME_LEN   28
 
BT UUID Length
#define BT_UUID128_LEN   16
 
Flags bits in advertising data
#define BLE_ADV_FLAGS_LIMITED_DISC_MODE   (0x01)
 
#define BLE_ADV_FLAGS_GENERAL_DISC_MODE   (0x02)
 
#define BLE_ADV_FLAGS_BR_EDR_NOT_SUPPORTED   (0x04)
 
#define BLE_ADV_FLAGS_LE_BR_EDR_CONTROLLER   (0x08)
 
#define BLE_ADV_FLAGS_LE_BR_EDR_HOST   (0x10)
 
The length of UUID string
#define BLE_UUID_128BIT_STRING_LENGTH   (36)
 
#define BLE_UUID_16BIT_STRING_LENGTH   (4)
 
#define BLE_UUID_128BIT_STRING_BUFSIZE   (BLE_UUID_128BIT_STRING_LENGTH + 1)
 
#define BLE_UUID_16BIT_STRING_BUFSIZE   (BLE_UUID_16BIT_STRING_LENGTH + 1)
 

Enumerations

enum  BT_CMD_STATUS {
  BT_COMMAND_STATUS_SUCCESS = 0 , BT_COMMAND_STATUS_IN_PROGRESS , BT_COMMAND_STATUS_ALREADY_CONNECTED , BT_COMMAND_STATUS_NOT_CONNECTED ,
  BT_COMMAND_STATUS_BAD_HANDLE , BT_COMMAND_STATUS_WRONG_STATE , BT_COMMAND_STATUS_INVALID_ARGS , BT_COMMAND_STATUS_FAILED ,
  BT_COMMAND_STATUS_UNKNOWN_GROUP , BT_COMMAND_STATUS_UNKNOWN_COMMAND , BT_COMMAND_STATUS_CLIENT_NOT_REGISTERED , BT_COMMAND_STATUS_OUT_OF_MEMORY ,
  BT_COMMAND_STATUS_DISALLOWED
}
 BT hci command status. More...
 
enum  BT_PAIR_STATUS {
  BT_PAIR_SUCCESS , BT_PAIR_PASSKEY_ENTRY_FAILURE , BT_PAIR_OOB_FAILURE , BT_PAIR_PAIRING_AUTHENTICATION_FAILURE ,
  BT_PAIR_CONFIRM_VALUE_FAILURE , BT_PAIR_PAIRING_NOT_SUPPORTED , BT_PAIR_ENCRYPTION_KEY_SIZE_FAILURE , BT_PAIR_INVALID_COMMAND ,
  BT_PAIR_PAIRING_FAILURE_UNKNOWN , BT_PAIR_REPEATED_ATTEMPTS , BT_PAIR_INTERNAL_PAIRING_ERROR , BT_PAIR_UNKNOWN_IO_CAPABILITIES ,
  BT_PAIR_SMP_INITIALIZATION_FAILURE , BT_PAIR_CONFIRMATION_FAILRUE , BT_PAIR_SMP_BUSY , BT_PAIR_ENCRYPTION_FAILURE ,
  BT_PAIR_BONDING_STARTED , BT_PAIR_RESPONSE_TIMEOUT , BT_PAIR_GENERIC_FAILURE , BT_PAIR_CONNECTION_TIMEOUT
}
 BT pairing result. More...
 
enum  BT_CONNECT_FAIL_REASON_ID { BT_CONNECT_NO_SERVICE = 0 , BT_CONNECT_NO_DEVICE , BT_CONNECT_TIMEOUT , BT_CONNECT_OTHER }
 BT profile connection result. More...
 
enum  BT_VISIBILITY { BT_VIS_NO_DISCOVERY_NO_CONNECTABLE = 0 , BT_VIS_DISCOVERY_NO_CONNECTABLE = 1 , BT_VIS_NO_DISCOVERY_CONNECTABLE = 2 , BT_VIS_DISCOVERY_CONNECTABLE = 3 }
 BT visibility ID. More...
 
enum  BLE_APPEARANCE {
  BLE_APPEARANCE_GENERIC_PHONE = 64 , BLE_APPEARANCE_GENERIC_COMPUTER = 128 , BLE_APPEARANCE_GENERIC_WATCH = 192 , BLE_APPEARANCE_WATCH_SPORTS = 193 ,
  BLE_APPEARANCE_GENERIC_CLOCK = 256 , BLE_APPEARANCE_GENERIC_DISPLAY = 320 , BLE_APPEARANCE_GENERIC_REMOTE_CONTROL = 384 , BLE_APPEARANCE_GENERIC_EYE_GLASSES = 448 ,
  BLE_APPEARANCE_GENERIC_TAG = 512 , BLE_APPEARANCE_GENERIC_KEYRING = 576 , BLE_APPEARANCE_GENERIC_MEDIA_PLAYER = 640 , BLE_APPEARANCE_GENERIC_BARCODE_SCANNER = 704 ,
  BLE_APPEARANCE_GENERIC_THERMOMETER = 768 , BLE_APPEARANCE_THERMOMETER_EAR = 769 , BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR = 832 , BLE_APPEARANCE_HEART_RATE_BELT = 833 ,
  BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE = 896 , BLE_APPEARANCE_BLOOD_PRESSURE_ARM = 897 , BLE_APPEARANCE_BLOOD_PRESSURE_WRIST = 898 , BLE_APPEARANCE_GENERIC_HID_DEVICE = 960 ,
  BLE_APPEARANCE_HID_KEYBOARD = 961 , BLE_APPEARANCE_HID_MOUSE = 962 , BLE_APPEARANCE_HID_JOYSTICK = 963 , BLE_APPEARANCE_HID_GAMEPAD = 964 ,
  BLE_APPEARANCE_HID_DIGITIZER_TABLET = 965 , BLE_APPEARANCE_HID_CARD_READER = 966 , BLE_APPEARANCE_HID_DIGITAL_PEN = 967 , BLE_APPEARANCE_HID_BARCODE_SCANNER = 968 ,
  BLE_APPEARANCE_GENERIC_GLUCOSE_METER = 1024 , BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR = 1088 , BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE = 1089 , BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE = 1090 ,
  BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP = 1091 , BLE_APPEARANCE_GENERIC_CYCLING = 1152 , BLE_APPEARANCE_CYCLING_COMPUTER = 1153 , BLE_APPEARANCE_CYCLING_SPEED_SENSOR = 1154 ,
  BLE_APPEARANCE_CYCLING_CADENCE_SENSOR = 1155 , BLE_APPEARANCE_CYCLING_POWER_SENSOR = 1156 , BLE_APPEARANCE_CYCLING_SPEED_AND_CADENCE_SENSOR = 1157
}
 BLE appearance ID.
 
enum  BLE_GAP_IO_CAP {
  BLE_GAP_IO_CAP_DISPLAY_ONLY = 0 , BLE_GAP_IO_CAP_DISPLAY_YESNO , BLE_GAP_IO_CAP_KEYBOARD_ONLY , BLE_GAP_IO_CAP_NO_INPUT_NO_OUTPUT ,
  BLE_GAP_IO_CAP_KEYBOARD_DISPLAY
}
 BLE IO capability. More...
 
enum  BLE_AD_TYPE {
  BLE_AD_TYPE_ADDRESS_TYPE = 0x00 , BLE_AD_TYPE_FLAGS = 0x01 , BLE_AD_TYPE_16BIT_SERVICE_UUID_INCOMPLETE = 0x02 , BLE_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE = 0x03 ,
  BLE_AD_TYPE_32BIT_SERVICE_UUID_INCOMPLETE = 0x04 , BLE_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE = 0x05 , BLE_AD_TYPE_128BIT_SERVICE_UUID_INCOMPLETE = 0x06 , BLE_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE = 0x07 ,
  BLE_AD_TYPE_SHORT_LOCAL_NAME = 0x08 , BLE_AD_TYPE_COMPLETE_LOCAL_NAME = 0x09 , BLE_AD_TYPE_TX_POWER_LEVEL = 0x0A , BLE_AD_TYPE_CLASS_OF_DEVICE = 0x0D ,
  BLE_AD_TYPE_SIMPLE_PAIRING_HASH_C = 0x0E , BLE_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R = 0x0F , BLE_AD_TYPE_SECURITY_MANAGER_TK_VALUE = 0x10 , BLE_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS = 0x11 ,
  BLE_AD_TYPE_CONNECTION_INTERVAL_RANGE = 0x12 , BLE_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT = 0x14 , BLE_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT = 0x15 , BLE_AD_TYPE_SERVICE_DATA = 0x16 ,
  BLE_AD_TYPE_PUBLIC_TARGET_ADDRESS = 0x17 , BLE_AD_TYPE_RANDOM_TARGET_ADDRESS = 0x18 , BLE_AD_TYPE_APPEARANCE = 0x19 , BLE_AD_TYPE_ADVERTISING_INTERVAL = 0x1A ,
  BLE_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS = 0x1B , BLE_AD_TYPE_LE_ROLE = 0x1C , BLE_AD_TYPE_SIMPLE_PAIRING_HASH_C256 = 0x1D , BLE_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256 = 0x1E ,
  BLE_AD_TYPE_SERVICE_DATA_32BIT_UUID = 0x20 , BLE_AD_TYPE_SERVICE_DATA_128BIT_UUID = 0x21 , BLE_AD_TYPE_LESC_CONFIRMATION_VALUE = 0x22 , BLE_AD_TYPE_LESC_RANDOM_VALUE = 0x23 ,
  BLE_AD_TYPE_URI = 0x24 , BLE_AD_TYPE_3D_INFORMATION_DATA = 0x3D , BLE_AD_TYPE_MANUFACTURER_SPECIFIC_DATA = 0xFF
}
 BLE data type of advertising data. More...
 
enum  BLE_ADDRESS_TYPE { BLE_ADDRTYPE_PUBLIC = 0x00 , BLE_ADDRTYPE_RAND_STATIC , BLE_ADDRTYPE_RAND_PRIV_RESOLVABLE , BLE_ADDRTYPE_RAND_PRIV_NONRESOLVABLE }
 BLE address type. More...
 

Detailed Description

Bluetooth common header for SDK on Spresense.

Author
Sony Semiconductor Solutions Corporation

This header file includes bluetooth common definition between API and HAL I/F.

  • Error code
  • Length of parameter
  • Status

Macro Definition Documentation

◆ BLE_ADV_FLAGS_LIMITED_DISC_MODE

#define BLE_ADV_FLAGS_LIMITED_DISC_MODE   (0x01)

LE Limited Discoverable Mode

◆ BLE_ADV_FLAGS_GENERAL_DISC_MODE

#define BLE_ADV_FLAGS_GENERAL_DISC_MODE   (0x02)

LE General Discoverable Mode

◆ BLE_ADV_FLAGS_BR_EDR_NOT_SUPPORTED

#define BLE_ADV_FLAGS_BR_EDR_NOT_SUPPORTED   (0x04)

BR/EDR not supported

◆ BLE_ADV_FLAGS_LE_BR_EDR_CONTROLLER

#define BLE_ADV_FLAGS_LE_BR_EDR_CONTROLLER   (0x08)

Simultaneous LE and BR/EDR capable(Controller)

◆ BLE_ADV_FLAGS_LE_BR_EDR_HOST

#define BLE_ADV_FLAGS_LE_BR_EDR_HOST   (0x10)

Simultaneous LE and BR/EDR capable(Host)

◆ BLE_UUID_128BIT_STRING_LENGTH

#define BLE_UUID_128BIT_STRING_LENGTH   (36)

The length of 128-bit UUID string

◆ BLE_UUID_16BIT_STRING_LENGTH

#define BLE_UUID_16BIT_STRING_LENGTH   (4)

The length of 16-bit UUID string

◆ BLE_UUID_128BIT_STRING_BUFSIZE

#define BLE_UUID_128BIT_STRING_BUFSIZE   (BLE_UUID_128BIT_STRING_LENGTH + 1)

The minimal buffer size for 128-bit UUID string

◆ BLE_UUID_16BIT_STRING_BUFSIZE

#define BLE_UUID_16BIT_STRING_BUFSIZE   (BLE_UUID_16BIT_STRING_LENGTH + 1)

The minimal buffer size for 16-bit UUID string

Enumeration Type Documentation

◆ BT_CMD_STATUS

BT hci command status.

Enumerator
BT_COMMAND_STATUS_SUCCESS 

Command success

BT_COMMAND_STATUS_IN_PROGRESS 

Command in progress

BT_COMMAND_STATUS_ALREADY_CONNECTED 

Already connected

BT_COMMAND_STATUS_NOT_CONNECTED 

Not connected

BT_COMMAND_STATUS_BAD_HANDLE 

Bad handle

BT_COMMAND_STATUS_WRONG_STATE 

Wrong state

BT_COMMAND_STATUS_INVALID_ARGS 

Invalid argument

BT_COMMAND_STATUS_FAILED 

Command failed

BT_COMMAND_STATUS_UNKNOWN_GROUP 

Unknown group

BT_COMMAND_STATUS_UNKNOWN_COMMAND 

Unknown command

BT_COMMAND_STATUS_CLIENT_NOT_REGISTERED 

HCI client not registered

BT_COMMAND_STATUS_OUT_OF_MEMORY 

Out of memory

BT_COMMAND_STATUS_DISALLOWED 

Command not allowed

◆ BT_PAIR_STATUS

BT pairing result.

Enumerator
BT_PAIR_SUCCESS 

Pairing success

BT_PAIR_PASSKEY_ENTRY_FAILURE 

Passkey entry failure

BT_PAIR_OOB_FAILURE 

Out of band failure

BT_PAIR_PAIRING_AUTHENTICATION_FAILURE 

Authentication failure

BT_PAIR_CONFIRM_VALUE_FAILURE 

Confirmation value failure

BT_PAIR_PAIRING_NOT_SUPPORTED 

Pairing not supported

BT_PAIR_ENCRYPTION_KEY_SIZE_FAILURE 

Encryption key size failure

BT_PAIR_INVALID_COMMAND 

Invalid pairing command

BT_PAIR_PAIRING_FAILURE_UNKNOWN 

Unknown pairing failure

BT_PAIR_REPEATED_ATTEMPTS 

Repeat attempts

BT_PAIR_INTERNAL_PAIRING_ERROR 

Internal error

BT_PAIR_UNKNOWN_IO_CAPABILITIES 

Unknown I/O capability

BT_PAIR_SMP_INITIALIZATION_FAILURE 

SMP initialization failure

BT_PAIR_CONFIRMATION_FAILRUE 

Confirmation failure

BT_PAIR_SMP_BUSY 

SMP busy

BT_PAIR_ENCRYPTION_FAILURE 

Encryption failure

BT_PAIR_BONDING_STARTED 

Bonding started

BT_PAIR_RESPONSE_TIMEOUT 

Response timeout

BT_PAIR_GENERIC_FAILURE 

Generic failure

BT_PAIR_CONNECTION_TIMEOUT 

Connection timeout

◆ BT_CONNECT_FAIL_REASON_ID

BT profile connection result.

Enumerator
BT_CONNECT_NO_SERVICE 

No service

BT_CONNECT_NO_DEVICE 

No device

BT_CONNECT_TIMEOUT 

Connection timeout

BT_CONNECT_OTHER 

Other reason

◆ BT_VISIBILITY

BT visibility ID.

Enumerator
BT_VIS_NO_DISCOVERY_NO_CONNECTABLE 

No discoverable and no connectable

BT_VIS_DISCOVERY_NO_CONNECTABLE 

Discoverable but no connectable

BT_VIS_NO_DISCOVERY_CONNECTABLE 

No discoverable but connectable

BT_VIS_DISCOVERY_CONNECTABLE 

Discoverable and connectable

◆ BLE_GAP_IO_CAP

BLE IO capability.

Enumerator
BLE_GAP_IO_CAP_DISPLAY_ONLY 

Display Only

BLE_GAP_IO_CAP_DISPLAY_YESNO 

Display and Yes/No entry

BLE_GAP_IO_CAP_KEYBOARD_ONLY 

Keyboard Only

BLE_GAP_IO_CAP_NO_INPUT_NO_OUTPUT 

No Input No Output

BLE_GAP_IO_CAP_KEYBOARD_DISPLAY 

Keyboard and Display

◆ BLE_AD_TYPE

BLE data type of advertising data.

Enumerator
BLE_AD_TYPE_ADDRESS_TYPE 

BLE address type

BLE_AD_TYPE_FLAGS 

Flags for discoverability.

BLE_AD_TYPE_16BIT_SERVICE_UUID_INCOMPLETE 

Partial list of 16 bit service UUIDs.

BLE_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 

Complete list of 16 bit service UUIDs.

BLE_AD_TYPE_32BIT_SERVICE_UUID_INCOMPLETE 

Partial list of 32 bit service UUIDs.

BLE_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 

Complete list of 32 bit service UUIDs.

BLE_AD_TYPE_128BIT_SERVICE_UUID_INCOMPLETE 

Partial list of 128 bit service UUIDs.

BLE_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 

Complete list of 128 bit service UUIDs.

BLE_AD_TYPE_SHORT_LOCAL_NAME 

Short local device name.

BLE_AD_TYPE_COMPLETE_LOCAL_NAME 

Complete local device name.

BLE_AD_TYPE_TX_POWER_LEVEL 

Transmit power level.

BLE_AD_TYPE_CLASS_OF_DEVICE 

Class of device.

BLE_AD_TYPE_SIMPLE_PAIRING_HASH_C 

Simple Pairing Hash C.

BLE_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 

Simple Pairing Randomizer R.

BLE_AD_TYPE_SECURITY_MANAGER_TK_VALUE 

Security Manager TK Value.

BLE_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 

Security Manager Out Of Band Flags.

BLE_AD_TYPE_CONNECTION_INTERVAL_RANGE 

Slave Connection Interval Range.

BLE_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 

List of 16-bit Service Solicitation UUIDs.

BLE_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 

List of 128-bit Service Solicitation UUIDs.

BLE_AD_TYPE_SERVICE_DATA 

Service Data - 16-bit UUID.

BLE_AD_TYPE_PUBLIC_TARGET_ADDRESS 

Public Target Address.

BLE_AD_TYPE_RANDOM_TARGET_ADDRESS 

Random Target Address.

BLE_AD_TYPE_APPEARANCE 

Appearance.

BLE_AD_TYPE_ADVERTISING_INTERVAL 

Advertising Interval.

BLE_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS 

LE Bluetooth Device Address.

BLE_AD_TYPE_LE_ROLE 

LE Role.

BLE_AD_TYPE_SIMPLE_PAIRING_HASH_C256 

Simple Pairing Hash C-256.

BLE_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256 

Simple Pairing Randomizer R-256.

BLE_AD_TYPE_SERVICE_DATA_32BIT_UUID 

Service Data - 32-bit UUID.

BLE_AD_TYPE_SERVICE_DATA_128BIT_UUID 

Service Data - 128-bit UUID.

BLE_AD_TYPE_LESC_CONFIRMATION_VALUE 

LE Secure Connections Confirmation Value

BLE_AD_TYPE_LESC_RANDOM_VALUE 

LE Secure Connections Random Value

BLE_AD_TYPE_URI 

URI

BLE_AD_TYPE_3D_INFORMATION_DATA 

3D Information Data.

BLE_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 

Manufacturer Specific Data.

◆ BLE_ADDRESS_TYPE

BLE address type.

Enumerator
BLE_ADDRTYPE_PUBLIC 

BLE public address

BLE_ADDRTYPE_RAND_STATIC 

BLE random static address

BLE_ADDRTYPE_RAND_PRIV_RESOLVABLE 

BLE random private resolvable address

BLE_ADDRTYPE_RAND_PRIV_NONRESOLVABLE 

BLE random private non-resolvable address