Developer World
Spresense SDK Library v1.4.2-3df2e9d
bt_common.h File Reference

Bluetooth generic API. More...

#include <stdint.h>
#include <bluetooth/bluetooth.h>

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  bt_common_ops_s
 Bluetooth Common application callbacks. More...
 
struct  ble_common_ops_s
 Bluetooth LE Common application callbacks. More...
 

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 call 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 call 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 This is Spresense side address and should be call before bt_enable. More...
 
int ble_get_address (BT_ADDR *addr)
 Get Bluetooth LE module address. More...
 
int ble_set_name (char *name)
 Set Bluetooth LE module name This name visible for other devices and should be call before bt_enable. More...
 
int ble_get_name (char *name)
 Get Bluetooth LE module name. 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 (void)
 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...
 

Detailed Description

Bluetooth generic API.

Author
Sony Semiconductor Solutions Corporation

This API is generic functions for bluetooth operations

Enumeration Type Documentation

◆ BT_CONNECT_STATUS

BT profile connection status.

Enumerator
BT_DISCONNECTED 

Disconnected

BT_DISCONNECTING 

Disconnect operation working

BT_CONNECTING 

Connect operation working

BT_CONNECTED 

Connected

Function Documentation

◆ bt_init()

int bt_init ( void  )

Bluetooth module initialize For initialize a pin config, NV storage, UART, etc.

Return values
errorcode

◆ bt_finalize()

int bt_finalize ( void  )

Bluetooth module finalize.

Return values
errorcode

◆ bt_set_address()

int bt_set_address ( BT_ADDR addr)

Set Bluetooth module address This is Spresense side address and should be call before bt_enable.

Parameters
[in]addrBluetooth device address BT_ADDR
Return values
errorcode

◆ bt_get_address()

int bt_get_address ( BT_ADDR addr)

Get Bluetooth module address.

Parameters
[out]addrBluetooth device address BT_ADDR
Return values
errorcode

◆ bt_set_name()

int bt_set_name ( char *  name)

Set Bluetooth module name This name visible for other devices and should be call before bt_enable.

Parameters
[in]nameBluetooth device name
Return values
errorcode

◆ bt_get_name()

int bt_get_name ( char *  name)

Get Bluetooth module name.

Parameters
[out]nameBluetooth device name
Return values
errorcode

◆ bt_enable()

int bt_enable ( void  )

Bluetooth module enable Bluetooth set power on(and download firmware, etc).

Return values
errorcode

◆ bt_disable()

int bt_disable ( void  )

Bluetooth module disable Bluetooth set power off.

Return values
errorcode

◆ bt_pairing_enable()

int bt_pairing_enable ( void  )

Bluetooth pairing enable Entering bluetooth pairing mode.

Return values
errorcode

◆ bt_paring_disable()

int bt_paring_disable ( void  )

Bluetooth pairing disable Escaping bluetooth pairing mode.

Return values
errorcode

◆ bt_get_bond_list()

int bt_get_bond_list ( BT_ADDR addr,
int *  num 
)

Bluetooth get bond device list Get bond devices list with BD_ADDR.

Parameters
[in]addrDevice address list BT_ADDR
[in]numNumber of BD_ADDR
Return values
errorcode

◆ bt_unbond()

int bt_unbond ( BT_ADDR addr)

Bluetooth unbond by BD_ADDR Unbond device by BD_ADDR.

Parameters
[out]addrUnbond device BD_ADDR BT_ADDR
Return values
errorcode

◆ bt_set_visibility()

int bt_set_visibility ( BT_VISIBILITY  visibility)

Bluetooth set visible Visible this device from others.

Parameters
[in]visibilityDevice visibility parameter BT_VISIBILITY
Return values
errorcode

◆ bt_start_inquiry()

int bt_start_inquiry ( void  )

Bluetooth inquiry start Start to inquiry for connect peer device.

Return values
errorcode

◆ bt_cancel_inquiry()

int bt_cancel_inquiry ( void  )

Bluetooth inquiry cancel Cancel to inquiry.

Return values
errorcode

◆ bt_register_common_cb()

int bt_register_common_cb ( struct bt_common_ops_s bt_common_ops)

Bluetooth register common callbacks Register Connect/Pairing/Inquiry callback.

Parameters
[in]bt_common_opsApplication callback bt_common_ops_s
Return values
errorcode

◆ ble_set_address()

int ble_set_address ( BT_ADDR addr)

Set Bluetooth LE module address This is Spresense side address and should be call before bt_enable.

Parameters
[in]addrBluetooth LE device address BT_ADDR
Return values
errorcode

◆ ble_get_address()

int ble_get_address ( BT_ADDR addr)

Get Bluetooth LE module address.

Parameters
[out]addrBluetooth LE device address BT_ADDR
Return values
errorcode

◆ ble_set_name()

int ble_set_name ( char *  name)

Set Bluetooth LE module name This name visible for other devices and should be call before bt_enable.

Parameters
[in]nameBluetooth LE device name
Return values
errorcode

◆ ble_get_name()

int ble_get_name ( char *  name)

Get Bluetooth LE module name.

Parameters
[out]nameBluetooth LE device name
Return values
errorcode

◆ ble_enable()

int ble_enable ( void  )

Bluetooth LE enable.

Return values
errorcode

◆ ble_disable()

int ble_disable ( void  )

Bluetooth LE disable.

Return values
errorcode

◆ ble_connect()

int ble_connect ( struct ble_state_s ble_state)

Bluetooth LE connect for Central.

Parameters
[in]ble_stateBluetooth context ble_state_s
Return values
errorcode

◆ ble_disconnect()

int ble_disconnect ( struct ble_state_s ble_state)

Bluetooth LE dicsonnect for Central.

Parameters
[in]ble_stateBluetooth context ble_state_s
Return values
errorcode

◆ ble_start_advertise()

int ble_start_advertise ( void  )

Bluetooth LE start advertise Start BLE advertise mode.

Return values
errorcode

◆ ble_cancel_advertise()

int ble_cancel_advertise ( void  )

Bluetooth LE cancel advertise Cancel BLE advertise mode.

Return values
errorcode

◆ ble_start_scan()

int ble_start_scan ( void  )

Bluetooth LE start scan Start BLE scan mode.

Return values
errorcode

◆ ble_cancel_scan()

int ble_cancel_scan ( void  )

Bluetooth LE cancel scan Cancel BLE scan mode.

Return values
errorcode

◆ ble_register_common_cb()

int ble_register_common_cb ( struct ble_common_ops_s ble_common_ops)

Bluetooth LE register common callbacks Register Connect/Advertise/Scan callback.

Parameters
[in]ble_common_opsApplication callback ble_common_ops_s
Return values
errorcode