The latest development version of this page may be more current than this released 2.3-beta.1 version.

Bluetooth Controller

The WM-IoT-SDK Bluetooth controller encompasses the implementation of baseband management, link control, link management, and the HCI interface, supporting the Bluetooth 4.2 standard. The WM-IoT-SDK Bluetooth controller is presented in the form of a library, allowing users to access it through the provided APIs.

API Reference

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
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
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
enum wm_bt_log_level_t

Values:

enumerator WM_BT_LOG_NONE
enumerator WM_BT_LOG_ERROR
enumerator WM_BT_LOG_WARNING
enumerator WM_BT_LOG_API
enumerator WM_BT_LOG_EVENT
enumerator WM_BT_LOG_DEBUG
enumerator WM_BT_LOG_VERBOSE
enum wm_sco_data_path_t

Values:

enumerator WM_AUDIO_OVER_HCI
enumerator WM_AUDIO_INTERNAL_MODE

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

Parameters:
Returns:

wm_bt_status_t

wm_bt_status_t wm_bt_ctrl_disable(void)

disable the bluetooth controller stack

Returns:

wm_bt_status_t

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

Note

power_type, supports WM_BLE_PWR_TYPE_DEFAULT only.

Parameters:
  • 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

Returns:

wm_bt_status_t

int8_t wm_ble_get_tx_power(wm_ble_power_type_t power_type)

get the ble emit power of different ble handle type

Note

power_type, supports WM_BLE_PWR_TYPE_DEFAULT only.

Parameters:

power_type[in] wm_ble_power_type_t

Return values:

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

Parameters:
  • min_power_level[in] power level[1,13]dBm

  • max_power_level[in] power level[1,13]dBm

Returns:

wm_bt_status_t

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

Parameters:
  • *min_power_level[in] pointer on min_power_level

  • *max_power_level[in] pointer on max_power_level

Returns:

wm_bt_status_t

wm_bt_status_t wm_bredr_sco_datapath_set(wm_sco_data_path_t data_path)

configure the voice output path

Parameters:

data_path[in] wm_sco_data_path_t

Returns:

wm_bt_status_t

uint32_t wm_bt_ctrl_get_status(void)

get controller stack status

Return values:

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

Parameters:
  • *data[in] hci formated message

  • len[in] command length

Returns:

wm_bt_ctrl_status_t

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

Parameters:

p_host_if[in] wm_bt_host_if_t

Returns:

wm_bt_ctrl_status_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

Returns:

wm_bt_ctrl_status_t

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

Parameters:

enable[in] bool value

Returns:

wm_bt_ctrl_status_t

bool wm_bt_ctrl_is_sleep(void)

this function look up the controller is in sleep mode or not

Returns:

bool value

wm_bt_status_t wm_bt_ctrl_wakeup(void)

this function wake up the controller, in other words exit sleep mode

Returns:

wm_bt_ctrl_status_t

bool wm_bt_host_check_send_available(void)

this function check controller can handle hci commands yes or no

Returns:

bool value

wm_bt_status_t wm_bt_disable_test_mode(void)

this function exit bluetooth test mode

Returns:

wm_bt_ctrl_status_t

wm_bt_status_t wm_bt_enable_test_mode(wm_bt_hci_if_t *p_hci_if)

this function enable bluetooth test mode

Parameters:

p_hci_if[in] : specific the uart port property

Returns:

wm_bt_ctrl_status_t

void wm_bt_rf_mode(uint8_t enable)

this function configure rf work mode

Parameters:

enable[in] : 1 bluetooth only mode, 0 wifi-bluetooth coexist mode

Return values:

None

wm_bt_status_t wm_bt_set_mesh_mode(uint8_t enable)

this function configure mesh feature of controller

Parameters:

enable[in] : 1 turn on mesh mode, 0 turn off mesh mode

Return values:

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

Parameters:
  • sleep_enter_func[in] : sleep starting callback;

  • sleep_exit_func[in] : sleep exiting callback

Return values:

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.

Parameters:

pending_func[in] blocking operation function pointer

Return values:

always – WM_BT_STATUS_SUCCESS;

struct wm_bt_hci_if_t
struct wm_bt_host_if_t