蓝牙控制器
wm-iot-sdk 蓝牙控制器包含了基带管理、链路控制、链路管理及HCI接口的实现,支持蓝牙4.2标准。wm-iot-sdk 蓝牙控制器以库的形式展现,用户通过提供的api访问。
API 参考
- group bt_ctrl
Bluetooth Controller.
Typedefs
-
typedef void (*wm_bt_controller_sleep_enter_func_ptr)(uint32_t sleep_duration_ms)
-
typedef void (*wm_bt_controller_sleep_exit_func_ptr)(void)
-
typedef void (*wm_bt_app_pending_process_func_ptr)(void)
Enums
-
enum wm_bt_status_t
Bluetooth Error Status
Values:
-
enumerator WM_BT_STATUS_SUCCESS
success
-
enumerator WM_BT_STATUS_FAIL
-
enumerator WM_BT_STATUS_NOT_READY
-
enumerator WM_BT_STATUS_NOMEM
alloc memory failed
-
enumerator WM_BT_STATUS_BUSY
-
enumerator WM_BT_STATUS_DONE
request already completed
-
enumerator WM_BT_STATUS_UNSUPPORTED
-
enumerator WM_BT_STATUS_PARM_INVALID
-
enumerator WM_BT_STATUS_UNHANDLED
-
enumerator WM_BT_STATUS_AUTH_FAILURE
-
enumerator WM_BT_STATUS_RMT_DEV_DOWN
-
enumerator WM_BT_STATUS_AUTH_REJECTED
-
enumerator WM_BT_STATUS_THREAD_FAILED
create internal thread failed
-
enumerator WM_BT_STATUS_INTERNAL_ERROR
controller stack internal error
-
enumerator WM_BT_STATUS_CTRL_ENABLE_FAILED
-
enumerator WM_BT_STATUS_HOST_ENABLE_FAILED
-
enumerator WM_BT_STATUS_CTRL_DISABLE_FAILED
-
enumerator WM_BT_STATUS_HOST_DISABLE_FAILED
-
enumerator WM_BT_STATUS_SUCCESS
-
enum wm_bt_ctrl_status_t
Values:
-
enumerator WM_BT_CTRL_IDLE
-
enumerator WM_BT_CTRL_ENABLED
-
enumerator WM_BT_CTRL_SLEEPING
-
enumerator WM_BT_CTRL_BLE_ROLE_MASTER
-
enumerator WM_BT_CTRL_BLE_ROLE_SLAVE
-
enumerator WM_BT_CTRL_BLE_ROLE_END
-
enumerator WM_BT_CTRL_BLE_STATE_IDLE
-
enumerator WM_BT_CTRL_BLE_STATE_ADVERTISING
-
enumerator WM_BT_CTRL_BLE_STATE_SCANNING
-
enumerator WM_BT_CTRL_BLE_STATE_INITIATING
-
enumerator WM_BT_CTRL_BLE_STATE_STOPPING
-
enumerator WM_BT_CTRL_BLE_STATE_TESTING
-
enumerator WM_BT_CTRL_IDLE
-
enum wm_ble_power_type_t
Values:
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL0
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL1
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL2
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL3
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL4
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL5
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL6
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL7
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL8
-
enumerator WM_BLE_PWR_TYPE_ADV
-
enumerator WM_BLE_PWR_TYPE_SCAN
-
enumerator WM_BLE_PWR_TYPE_DEFAULT
-
enumerator WM_BLE_PWR_TYPE_CONN_HDL0
Functions
-
wm_bt_status_t wm_bt_ctrl_enable(wm_bt_hci_if_t *p_hci_if, wm_bt_log_level_t log_level)
enable the bluetooth controller stack
- 参数:
*p_hci_if – [in] pointer on uart property
log_level – [in] wm_bt_log_level_t
- 返回:
-
wm_bt_status_t wm_bt_ctrl_disable(void)
disable the bluetooth controller stack
- 返回:
-
wm_bt_status_t wm_ble_set_tx_power(wm_ble_power_type_t power_type, int8_t power_level_index)
configure the ble emit power of different ble handle type
备注
power_type, supports WM_BLE_PWR_TYPE_DEFAULT only.
- 参数:
power_type – [in] wm_ble_power_type_t
power_level_index – [in] [1,2,3,4,5] map to[1,4,7,10,13]dBm
- 返回:
-
int8_t wm_ble_get_tx_power(wm_ble_power_type_t power_type)
get the ble emit power of different ble handle type
备注
power_type, supports WM_BLE_PWR_TYPE_DEFAULT only.
- 参数:
power_type – [in] wm_ble_power_type_t
- 返回值:
power – value db
-
wm_bt_status_t wm_bredr_set_tx_power(int8_t min_power_level, int8_t max_power_level)
configure the classic/enhanced bluetooth transmit power
- 参数:
min_power_level – [in] power level[1,13]dBm
max_power_level – [in] power level[1,13]dBm
- 返回:
-
wm_bt_status_t wm_bredr_get_tx_power(int8_t *min_power_level, int8_t *max_power_level)
get the classic/enhanced bluetooth transmit power level
- 参数:
*min_power_level – [in] pointer on min_power_level
*max_power_level – [in] pointer on max_power_level
- 返回:
-
wm_bt_status_t wm_bredr_sco_datapath_set(wm_sco_data_path_t data_path)
configure the voice output path
- 参数:
data_path – [in] wm_sco_data_path_t
- 返回:
-
uint32_t wm_bt_ctrl_get_status(void)
get controller stack status
- 返回值:
controller – status(bit mapped)
-
wm_bt_status_t wm_bt_host_send_packet(uint8_t *data, uint16_t len)
this function receive the hci message from host hci_h4 inteface
- 参数:
*data – [in] hci formated message
len – [in] command length
- 返回:
-
wm_bt_status_t wm_bt_ctrl_if_register(const wm_bt_host_if_t *p_host_if)
this function register the host stack receive message function and indication the controller receive hci command avaiable
- 参数:
p_host_if – [in] wm_bt_host_if_t
- 返回:
-
wm_bt_status_t wm_bt_ctrl_if_unregister(void)
this function unregister the host stack receive message function and indication the controller receive hci command avaiable
-
wm_bt_status_t wm_bt_ctrl_sleep(bool enable)
this function configure the controller enter into sleep mode when controller is in idle mode
- 参数:
enable – [in] bool value
- 返回:
-
bool wm_bt_ctrl_is_sleep(void)
this function look up the controller is in sleep mode or not
- 返回:
bool value
-
wm_bt_status_t wm_bt_ctrl_wakeup(void)
this function wake up the controller, in other words exit sleep mode
-
bool wm_bt_host_check_send_available(void)
this function check controller can handle hci commands yes or no
- 返回:
bool value
-
wm_bt_status_t wm_bt_disable_test_mode(void)
this function exit bluetooth test mode
-
wm_bt_status_t wm_bt_enable_test_mode(wm_bt_hci_if_t *p_hci_if)
this function enable bluetooth test mode
- 参数:
p_hci_if – [in] : specific the uart port property
- 返回:
-
void wm_bt_rf_mode(uint8_t enable)
this function configure rf work mode
- 参数:
enable – [in] : 1 bluetooth only mode, 0 wifi-bluetooth coexist mode
- 返回值:
None –
-
wm_bt_status_t wm_bt_set_mesh_mode(uint8_t enable)
this function configure mesh feature of controller
- 参数:
enable – [in] : 1 turn on mesh mode, 0 turn off mesh mode
- 返回值:
always – WM_BT_STATUS_SUCCESS
-
wm_bt_status_t wm_bt_register_sleep_callback(wm_bt_controller_sleep_enter_func_ptr sleep_enter_func, wm_bt_controller_sleep_exit_func_ptr sleep_exit_func)
this function register callback function when controller entering or exiting sleep mode
- 参数:
sleep_enter_func – [in] : sleep starting callback;
sleep_exit_func – [in] : sleep exiting callback
- 返回值:
WM_BT_STATUS_SUCCESS – or WM_BT_STATUS_UNSUPPORTED;
-
wm_bt_status_t wm_bt_register_pending_process_callback(wm_bt_app_pending_process_func_ptr pending_func)
this function register blocking operation function.
- 参数:
pending_func – [in] blocking operation function pointer
- 返回值:
always – WM_BT_STATUS_SUCCESS;
-
struct wm_bt_hci_if_t
-
struct wm_bt_host_if_t
-
typedef void (*wm_bt_controller_sleep_enter_func_ptr)(uint32_t sleep_duration_ms)