DM BT APIs

[English]

重要

DM BT API v1.0 是最新稳定的 DM BT API。所有新应用程序都应使用 DM BT API v1.0。

DM BT API 类别

大多数 DM BT API 可分为:

  • BT 通用接口

  • BT A2DP Sink 接口

应用程序示例

示例工程 projects/lvgl/soundbar ,其中包含以下应用程序:

  • 一个 A2DP 接收器客户端 Demo,可以被 A2DP Source 设备发现并连接,并从远程设备接收音频流。

API 接口定义

Header File

Functions

bt_err_t bk_bt_gap_set_event_callback(bt_event_cb_t func)

sets BT event callback function

参数

func[in] : callback

返回

  • 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

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

  • key[in] : linkkey,

返回

  • 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

参数
  • 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

返回

  • 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

参见

enum common_cod_t)

参数

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

返回

  • 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

参数
  • name, :[in] pointer of name

  • len, :[in] the length of name

返回

  • BK_ERR_BT_SUCCESS: succeed

  • others: fail

API 类型定义

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

参考链接

API 参考手册: 介绍了蓝牙API接口

开发者指南: 介绍了蓝牙常用使用场景

样例演示: 介绍了蓝牙示例的使用和操作

蓝牙工程: 介绍了蓝牙相关工程