Bluetooth generic API. More...
Go to the source code of this file.
Classes | |
struct | bt_common_state_s |
Bluetooth base context. More... | |
struct | bt_acl_state_s |
Bluetooth ACL context. More... | |
struct | ble_state_s |
Bluetooth LE context. More... | |
struct | ble_addr_s |
BLE address. More... | |
struct | ble_idkey_s |
struct | ble_cccd_s |
struct | ble_bondinfo_s |
Bluetooth LE bonding information. More... | |
struct | ble_scan_param_s |
struct | ble_conn_param_s |
struct | bt_common_ops_s |
Bluetooth Common application callbacks. More... | |
struct | ble_common_ops_s |
Bluetooth LE Common application callbacks. More... | |
struct | bt_eir_s |
The format of one data in advertising data. More... | |
Macros | |
#define | BT_ADV_DATA_MAX_LEN (255) |
#define | BT_ADV_DATA_LEN_LEN (1) |
#define | BT_ADV_DATA_TYPE_LEN (1) |
#define | BT_EIR_LEN |
#define | BLE_IRK_LEN (16) |
#define | BLE_CSRK_LEN (16) |
#define | BLE_LTK_LEN (16) |
#define | BLE_RAND_LEN (8) |
#define | BLE_SCAN_PARAM_INTERVAL_MSEC(t) ((t) * 1000 / 625) |
#define | BLE_SCAN_PARAM_WINDOW_MSEC(t) ((t) * 1000 / 625) |
#define | BLE_SCAN_PARAM_TIMEOUT_MSEC(t) ((t) * 1000 / 10000) |
#define | BLE_CONN_PARAM_INTERVAL_MSEC(t) ((t) * 1000 / 1250) |
#define | BLE_CONN_PARAM_TIMEOUT_MSEC(t) ((t) * 1000 / 10000) |
#define | BLESTAT_SUCCESS 0x00 |
#define | BLESTAT_MEMCAP_EXCD 0x07 |
#define | BLESTAT_CONNECT_TIMEOUT 0x08 |
#define | BLESTAT_PEER_TERMINATED 0x13 |
#define | BLESTAT_PEER_TERM_LOWRES 0x14 |
#define | BLESTAT_PEER_TERM_POFF 0x15 |
#define | BLESTAT_TERMINATED 0x16 |
#define | BLESTAT_UNSPEC_ERR 0x1F |
#define | BLESTAT_DEVICE_BUSY 0x3A |
#define | BLESTAT_PARAM_REJECTED 0x3B |
#define | BLESTAT_CONNECT_FAILED 0x3E |
#define | EXTERN extern "C" |
Enumerations | |
enum | BT_CONNECT_STATUS { BT_DISCONNECTED = 0 , BT_DISCONNECTING = 1 , BT_CONNECTING = 2 , BT_CONNECTED = 3 } |
BT profile connection status. More... | |
Functions | |
int | bt_init (void) |
Bluetooth module initialize For initialize a pin config, NV storage, UART, etc. More... | |
int | bt_finalize (void) |
Bluetooth module finalize. More... | |
int | bt_set_address (BT_ADDR *addr) |
Set Bluetooth module address This is Spresense side address and should be called before bt_enable. More... | |
int | bt_get_address (BT_ADDR *addr) |
Get Bluetooth module address. More... | |
int | bt_set_name (char *name) |
Set Bluetooth module name This name visible for other devices and should be called before bt_enable. More... | |
int | bt_get_name (char *name) |
Get Bluetooth module name. More... | |
int | bt_enable (void) |
Bluetooth module enable Bluetooth set power on(and download firmware, etc). More... | |
int | bt_disable (void) |
Bluetooth module disable Bluetooth set power off. More... | |
int | bt_pairing_enable (void) |
Bluetooth pairing enable Entering bluetooth pairing mode. More... | |
int | bt_paring_disable (void) |
Bluetooth pairing disable Escaping bluetooth pairing mode. More... | |
int | bt_get_bond_list (BT_ADDR *addr, int *num) |
Bluetooth get bond device list Get bond devices list with BD_ADDR. More... | |
int | bt_unbond (BT_ADDR *addr) |
Bluetooth unbond by BD_ADDR Unbond device by BD_ADDR. More... | |
int | bt_set_visibility (BT_VISIBILITY visibility) |
Bluetooth set visible Visible this device from others. More... | |
int | bt_start_inquiry (void) |
Bluetooth inquiry start Start to inquiry for connect peer device. More... | |
int | bt_cancel_inquiry (void) |
Bluetooth inquiry cancel Cancel to inquiry. More... | |
int | bt_register_common_cb (struct bt_common_ops_s *bt_common_ops) |
Bluetooth register common callbacks Register Connect/Pairing/Inquiry callback. More... | |
int | ble_set_address (BT_ADDR *addr) |
Set Bluetooth LE module address of the random static address type. This is Spresense side address and should be called before bt_enable. More... | |
int | ble_get_address (BT_ADDR *addr) |
Get Bluetooth LE module address. More... | |
int | ble_set_public_address (BT_ADDR *addr) |
Set Bluetooth LE module address of the public address type. This is Spresense side address and should be called before bt_enable. More... | |
uint8_t | ble_get_address_type (void) |
Get Bluetooth LE module address type. More... | |
int | ble_set_name (char *name) |
Set Bluetooth LE module name This name visible for other devices and should be called before bt_enable. More... | |
int | ble_get_name (char *name) |
Get Bluetooth LE module name. More... | |
int | ble_set_appearance (BLE_APPEARANCE appearance) |
Set Bluetooth LE module appearance. More... | |
int | ble_enable (void) |
Bluetooth LE enable. More... | |
int | ble_disable (void) |
Bluetooth LE disable. More... | |
int | ble_connect (struct ble_state_s *ble_state) |
Bluetooth LE connect for Central. More... | |
int | ble_disconnect (struct ble_state_s *ble_state) |
Bluetooth LE dicsonnect for Central. More... | |
int | ble_start_advertise (void) |
Bluetooth LE start advertise Start BLE advertise mode. More... | |
int | ble_cancel_advertise (void) |
Bluetooth LE cancel advertise Cancel BLE advertise mode. More... | |
int | ble_start_scan (bool duplicate_filter) |
Bluetooth LE start scan Start BLE scan mode. More... | |
int | ble_cancel_scan (void) |
Bluetooth LE cancel scan Cancel BLE scan mode. More... | |
int | ble_register_common_cb (struct ble_common_ops_s *ble_common_ops) |
Bluetooth LE register common callbacks Register Connect/Advertise/Scan callback. More... | |
uint16_t | ble_set_request_mtusize (uint16_t sz) |
Set MTU size that application requests. More... | |
uint16_t | ble_get_request_mtusize (void) |
Get MTU size that application requests. More... | |
int | ble_get_negotiated_mtusize (uint16_t handle) |
Get negotiated MTU size. More... | |
int | ble_set_tx_power (int8_t tx_power) |
Set Tx power. More... | |
int | ble_set_scan_param (struct ble_scan_param_s *param) |
Set scan parameter. More... | |
int | ble_set_conn_param (struct ble_conn_param_s *param) |
Set connection parameter. More... | |
int | ble_pairing (uint16_t handle) |
Execute pairing. More... | |
int | ble_parse_advertising_data (BLE_AD_TYPE target, uint8_t *adv_data, uint8_t adv_len, struct bt_eir_s *eir) |
Parse advertise data. More... | |
Bluetooth generic API.
This API is generic functions for bluetooth operations
#define BT_EIR_LEN |
#define BLESTAT_SUCCESS 0x00 |
BLE status code Success
#define BLESTAT_MEMCAP_EXCD 0x07 |
Memory Capacity Exceeded
#define BLESTAT_CONNECT_TIMEOUT 0x08 |
Connection Timeout
#define BLESTAT_PEER_TERMINATED 0x13 |
Peer Device Terminated Connection
#define BLESTAT_PEER_TERM_LOWRES 0x14 |
Peer Device Terminated Connection due to Low Resources
#define BLESTAT_PEER_TERM_POFF 0x15 |
Peer Device Terminated Connection due to Power Off
#define BLESTAT_TERMINATED 0x16 |
Connection Terminated By Own device
#define BLESTAT_UNSPEC_ERR 0x1F |
Unspecified Error
#define BLESTAT_DEVICE_BUSY 0x3A |
Controller Busy
#define BLESTAT_PARAM_REJECTED 0x3B |
Unacceptable Connection Parameters
#define BLESTAT_CONNECT_FAILED 0x3E |
Connection Failed to be Established / Synchronization Timeout
enum BT_CONNECT_STATUS |
int bt_init | ( | void | ) |
Bluetooth module initialize For initialize a pin config, NV storage, UART, etc.
error | code |
int bt_finalize | ( | void | ) |
Bluetooth module finalize.
error | code |
int bt_set_address | ( | BT_ADDR * | addr | ) |
Set Bluetooth module address This is Spresense side address and should be called before bt_enable.
[in] | addr | Bluetooth device address BT_ADDR |
error | code |
int bt_get_address | ( | BT_ADDR * | addr | ) |
Get Bluetooth module address.
[out] | addr | Bluetooth device address BT_ADDR |
error | code |
int bt_set_name | ( | char * | name | ) |
Set Bluetooth module name This name visible for other devices and should be called before bt_enable.
[in] | name | Bluetooth device name |
error | code |
int bt_get_name | ( | char * | name | ) |
Get Bluetooth module name.
[out] | name | Bluetooth device name |
error | code |
int bt_enable | ( | void | ) |
Bluetooth module enable Bluetooth set power on(and download firmware, etc).
error | code |
int bt_disable | ( | void | ) |
Bluetooth module disable Bluetooth set power off.
error | code |
int bt_pairing_enable | ( | void | ) |
Bluetooth pairing enable Entering bluetooth pairing mode.
error | code |
int bt_paring_disable | ( | void | ) |
Bluetooth pairing disable Escaping bluetooth pairing mode.
error | code |
int bt_get_bond_list | ( | BT_ADDR * | addr, |
int * | num | ||
) |
Bluetooth get bond device list Get bond devices list with BD_ADDR.
[in] | addr | Device address list BT_ADDR |
[in] | num | Number of BD_ADDR |
error | code |
int bt_unbond | ( | BT_ADDR * | addr | ) |
Bluetooth unbond by BD_ADDR Unbond device by BD_ADDR.
[out] | addr | Unbond device BD_ADDR BT_ADDR |
error | code |
int bt_set_visibility | ( | BT_VISIBILITY | visibility | ) |
Bluetooth set visible Visible this device from others.
[in] | visibility | Device visibility parameter BT_VISIBILITY |
error | code |
int bt_start_inquiry | ( | void | ) |
Bluetooth inquiry start Start to inquiry for connect peer device.
error | code |
int bt_cancel_inquiry | ( | void | ) |
Bluetooth inquiry cancel Cancel to inquiry.
error | code |
int bt_register_common_cb | ( | struct bt_common_ops_s * | bt_common_ops | ) |
Bluetooth register common callbacks Register Connect/Pairing/Inquiry callback.
[in] | bt_common_ops | Application callback bt_common_ops_s |
error | code |
int ble_set_address | ( | BT_ADDR * | addr | ) |
Set Bluetooth LE module address of the random static address type. This is Spresense side address and should be called before bt_enable.
[in] | addr | Bluetooth LE device address BT_ADDR |
error | code |
int ble_get_address | ( | BT_ADDR * | addr | ) |
Get Bluetooth LE module address.
[out] | addr | Bluetooth LE device address BT_ADDR |
error | code |
int ble_set_public_address | ( | BT_ADDR * | addr | ) |
Set Bluetooth LE module address of the public address type. This is Spresense side address and should be called before bt_enable.
[in] | addr | Bluetooth LE device address BT_ADDR |
error | code |
uint8_t ble_get_address_type | ( | void | ) |
Get Bluetooth LE module address type.
Bluetooth | LE device address type |
int ble_set_name | ( | char * | name | ) |
Set Bluetooth LE module name This name visible for other devices and should be called before bt_enable.
[in] | name | Bluetooth LE device name |
error | code |
int ble_get_name | ( | char * | name | ) |
Get Bluetooth LE module name.
[out] | name | Bluetooth LE device name |
error | code |
int ble_set_appearance | ( | BLE_APPEARANCE | appearance | ) |
Set Bluetooth LE module appearance.
[in] | appearance | Bluetooth LE device appearance |
error | code |
int ble_enable | ( | void | ) |
Bluetooth LE enable.
error | code |
int ble_disable | ( | void | ) |
Bluetooth LE disable.
error | code |
int ble_connect | ( | struct ble_state_s * | ble_state | ) |
Bluetooth LE connect for Central.
[in] | ble_state | Bluetooth context ble_state_s |
error | code |
int ble_disconnect | ( | struct ble_state_s * | ble_state | ) |
Bluetooth LE dicsonnect for Central.
[in] | ble_state | Bluetooth context ble_state_s |
error | code |
int ble_start_advertise | ( | void | ) |
Bluetooth LE start advertise Start BLE advertise mode.
error | code |
int ble_cancel_advertise | ( | void | ) |
Bluetooth LE cancel advertise Cancel BLE advertise mode.
error | code |
int ble_start_scan | ( | bool | duplicate_filter | ) |
Bluetooth LE start scan Start BLE scan mode.
[in] | duplicate_filter | true means that duplicate scan results are filtered out. |
error | code |
int ble_cancel_scan | ( | void | ) |
Bluetooth LE cancel scan Cancel BLE scan mode.
error | code |
int ble_register_common_cb | ( | struct ble_common_ops_s * | ble_common_ops | ) |
Bluetooth LE register common callbacks Register Connect/Advertise/Scan callback.
[in] | ble_common_ops | Application callback ble_common_ops_s |
error | code |
uint16_t ble_set_request_mtusize | ( | uint16_t | sz | ) |
Set MTU size that application requests.
[in] | sz | MTU size that application requests |
Accepted | MTU size |
uint16_t ble_get_request_mtusize | ( | void | ) |
Get MTU size that application requests.
Accepted | MTU size |
int ble_get_negotiated_mtusize | ( | uint16_t | handle | ) |
Get negotiated MTU size.
[in] | handle | connection handle |
Positive | value measn Negotiated MTU size, otherwise errno. |
int ble_set_tx_power | ( | int8_t | tx_power | ) |
Set Tx power.
[in] | tx_power | Tx power [dBm] |
BLE_SUCCESS | or negated errno. |
int ble_set_scan_param | ( | struct ble_scan_param_s * | param | ) |
Set scan parameter.
[in] | param | scan parameter |
error | code |
int ble_set_conn_param | ( | struct ble_conn_param_s * | param | ) |
Set connection parameter.
[in] | param | connection parameter |
error | code |
int ble_pairing | ( | uint16_t | handle | ) |
Execute pairing.
[in] | handle | connection handle |
BLE_SUCCESS | or negated errno. |
int ble_parse_advertising_data | ( | BLE_AD_TYPE | target, |
uint8_t * | adv_data, | ||
uint8_t | adv_len, | ||
struct bt_eir_s * | eir | ||
) |
Parse advertise data.
[in] | target | parse target EIR type |
[in] | adv_data | advertising data |
[in] | adv_len | length of advertising data |
[in] | eir | parse result |