DM BT APIs

[中文]

Important

The DM BT API v1.0 is the lastest stable DM BT APIs. All new applications should use DM BT API v1.0.

DM BT API Categories

Most of DM BT APIs can be categoried as:

  • BT common interface

  • BT A2DP Sink interface

Application Example

Check projects/lvgl/soundbar folder, which contains the following application:

  • There is a A2DP sink client demo. This demo can be discovered and connected by A2DP source device and receive the audio stream from remote device

API Reference

Header File

Functions

bt_err_t bk_bt_gap_set_event_callback(bt_event_cb_t func)

sets BT event callback function

Parameters

func[in] : callback

Returns

  • BK_ERR_BT_SUCCESS : Succeed

  • BK_ERR_BT_FAIL: others

bt_err_t bk_bt_gap_linkkey_reply(uint8_t is_exist, bk_bt_linkkey_storage_t *key)

send linkkey when peer need authentication

Attention

key->addr must be valued

Parameters
  • is_exist[in] : if linkkey exist. If no exist, peer may trigger pair procedure

  • key[in] : linkkey,

Returns

  • BK_ERR_BT_SUCCESS : Succeed

  • BK_ERR_BT_FAIL: others

bt_err_t bk_bt_gap_set_visibility(bk_bt_conn_mode_t conn_mode, bk_bt_disc_mode_t disc_mode)

sets the Bluetooth connectable, discoverable

Parameters
  • conn_mode[in] : one of the enums of bk_bt_conn_mode_t

  • disc_mode[in] : one of the enums of bk_bt_disc_mode_t

Returns

  • BK_ERR_BT_SUCCESS : Succeed

  • BK_ERR_BT_FAIL: others

bt_err_t bk_bt_gap_set_device_class(uint32_t cod)

set the class of device

See also

enum common_cod_t)

Parameters

cod, :[in] Class of Device for the device(

Returns

  • BK_ERR_BT_SUCCESS: succeed

  • others: fail

bt_err_t bk_bt_gap_set_local_name(uint8_t *name, uint8_t len)

set the local name

Parameters
  • name, :[in] pointer of name

  • len, :[in] the length of name

Returns

  • BK_ERR_BT_SUCCESS: succeed

  • others: fail

API Typedefs

Header File

Structures

struct bk_bt_linkkey_storage_t

bt link key storage

Public Members

uint16_t size

this struct size

uint8_t addr[6]

bt addr

bt link key

Type Definitions

typedef uint32_t (*bt_event_cb_t)(bt_event_enum_t event, void *param)

for async dm_bt api event.

bt event report.

Param event, :

event id. see bt_event_enum_t

  • param: param

Enumerations

enum bk_bt_conn_mode_t

Discoverability and Connectability mode.

Values:

enumerator BK_BT_NON_CONNECTABLE

Non-connectable

enumerator BK_BT_CONNECTABLE

Connectable

enum bk_bt_disc_mode_t

Values:

enumerator BK_BT_NON_DISCOVERABLE

Non-discoverable

enumerator BK_BT_DISCOVERABLE

Discoverable

enum common_cod_t

Values:

enumerator COD_PHONE
enumerator COD_SOUNDBAR
enumerator COD_HEADSET
enum bt_event_enum_t

Values:

enumerator BK_DM_BT_EVENT_INQUIRY_RESULT

inquiry result, not used now

enumerator BK_DM_BT_EVENT_DISCONNECT

disconnect completed, not used now

enumerator BK_DM_BT_EVENT_CONNECTION_COMPLETE

connection completed, not used now

enumerator BK_DM_BT_EVENT_LINKKEY_NOTIFY

recv cb when pair success and get link key, param bk_bt_linkkey_storage_t

enumerator BK_DM_BT_EVENT_LINKKEY_REQ

recv cb when peer need user to input link key, param bd_addr_t