Skip to content

BLE Controller

btble_controller_resource_config(conf)

Configure BLE controller resources (memory/EM)

Return value: None

btble_controller_set_task_stack_size(stack_size)

Set the controller task stack size

Return value: None

btble_controller_init(task_priority)

Initialize the BLE controller (radio and link layer)

Return value: None

btblecontroller_main(pvParameters)

BLE controller main entry (firmware internal)

Return value: None

btblecontroller_proc(data)

BLE controller processing function (firmware internal)

Return value: None

btble_controller_deinit()

Deinitialize the BLE controller

Return value: None

btble_controller_sleep(max_sleep_cycles)

Put the BLE controller to sleep

Return value: see the SDK header

btble_controller_sleep_restore()

Wake up the BLE controller

Return value: None

btble_controller_get_state()

Get the BLE controller state

Return value: see the SDK header

btble_controller_reset()

Reset the BLE controller

Return value: None

btble_controller_lp_fw_activity_restore(restore)

Restore a BLE activity after LPFW returns control to the APP.

Return value: 0 on success, otherwise an error code.

btble_controller_get_event_priority(event)

Get the priority of a specific BLE event

Parameters:

  • event:The BLE event type to get priority for

Return value: uint32_t Event priority value (0-15) or 0xFFFFFFFF if event is invalid

btble_controller_set_event_priority(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btblecontroller_set_private_key(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btblecontroller_del_private_key(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_controller_remaining_mem(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_controller_set_cs2(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_controller_set_local_sdk_ver(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_controller_sleep_init(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_controller_get_tx_pwr(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_set_before_sleep_callback(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_set_after_sleep_callback(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_set_sleep_aborted_callback(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_controller_sco_codec_callback_register(event, priority)

Set the priority for a specific BLE event

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

btble_controller_get_lp_fw_info()

Get the low-power firmware info

Return value: Pointer to the recorded LPFW handoff information.

btble_controller_get_lib_ver(event, priority)

Get the BLE controller library version

Parameters:

  • event:The BLE event type to set priority for
  • priority:Priority value to set (0-15, where 15 is highest priority)

Return value: int 0 on success, -1 if event or priority is invalid

HCI Driver

bt_recv(buf)

Receive data from the controller/HCI driver. This is the main function through which the HCI driver provides the host with data from the controller. The buffer needs to have its type set with the help of bt_buf_set_type() before calling this API. This API should not be used for so-called high priority HCI events, which should instead be delivered to the host stack through bt_recv_prio().

Return value: see the SDK header

bt_recv_prio(buf)

Receive high priority data from the controller/HCI driver. This is the same as bt_recv(), except that it should be used for so-called high priority HCI events. There's a separate bt_hci_evt_is_prio() helper that can be used to identify which events are high priority. As with bt_recv(), the buffer needs to have its type set with the help of bt_buf_set_type() before calling this API. The only exception is so called high priority HCI events which should be delivered to the host stack through bt_recv_prio() instead.

Return value: see the SDK header

bt_hci_driver_register(drv)

Register a new HCI driver to the Bluetooth stack. This needs to be called before any application code runs. The bt_enable() API will fail if there is no driver registered.

Parameters:

  • drv:A bt_hci_driver struct representing the driver.

Return value: 0 on success or negative error number on failure.

bt_hci_transport_setup(dev)

Setup the HCI transport, which usually means to reset the Bluetooth IC.

Parameters:

  • dev:The device structure for the bus connecting to the IC

📎 Device name lookup: Supported Device Names (BL616)

Return value: 0 on success, negative error value on failure

hci_driver_enque_recvq(buf)

enqueue buffer to hci received queue.

Parameters:

  • buf:Buffer containing data received from firmware.

Return value: None

hci_driver_init(buf)

enqueue buffer to hci received queue.

Parameters:

  • buf:Buffer containing data received from firmware.

Return value: see the SDK header

BLE Host (GAP)

bt_enable(cb)

Enable Bluetooth Enable Bluetooth. Must be the called before any calls that require communication with the local Bluetooth hardware.

Parameters:

  • cb:Callback to notify completion or NULL to perform the

Return value: Zero on success or (negative) error code otherwise.

bt_set_name(name)

Set Bluetooth Device Name Set Bluetooth GAP Device Name.

Parameters:

  • name:New name

📎 Device name lookup: Supported Device Names (BL616)

Return value: Zero on success or (negative) error code otherwise.

bt_set_id_addr(addr)

Set the local Identity Address Allows setting the local Identity Address from the application. This API must be called before calling bt_enable(). Calling it at any other time will cause it to fail. In most cases the application doesn't need to use this API, however there are a few valid cases where it can be useful (such as for testing). At the moment, the given address must be a static random address. In the future support for public addresses may be added.

Return value: Zero on success or (negative) error code otherwise.

bt_id_get(addrs, count)

Get the currently configured identities. Returns an array of the currently configured identity addresses. To make sure all available identities can be retrieved, the number of elements in the @a addrs array should be CONFIG_BT_ID_MAX. The identity identifier that some APIs expect (such as advertising parameters) is simply the index of the identity in the @a addrs array. Note: Deleted identities may show up as BT_LE_ADDR_ANY in the returned array.

Parameters:

  • addrs:Array where to store the configured identities.
  • count:Should be initialized to the array size. Once the function

Return value: None

bt_id_create(addrs, count)

Create a new identity. Create a new identity using the given address and IRK. This function can be called before calling bt_enable(), in which case it can be used to override the controller's public address (in case it has one). However, the new identity will only be stored persistently in flash when this API is used after bt_enable(). The reason is that the persistent settings are loaded after bt_enable() and would therefore cause potential conflicts with the stack blindly overwriting what's stored in flash. The identity will also not be written to flash in case a pre-defined address is provided, since in such a situation the app clearly has some place it got the address from and will be able to repeat the procedure on every power cycle, i.e. it would be redundant to also store the information in flash. If the application wants to have the stack randomly generate identities and store them in flash for later recovery, the way to do it would be to first initialize the stack (using bt_enable), then call settings_load(), and after that check with bt_id_get() how many identities were recovered. If an insufficient amount of identities were recovered the app may then call bt_id_create() to create new ones.

Parameters:

  • addrs:Array where to store the configured identities.
  • count:Should be initialized to the array size. Once the function

Return value: see the SDK header

bt_id_reset(id, addr, irk)

Reset/reclaim an identity for reuse. The semantics of the @a addr and @a irk parameters of this function are the same as with bt_id_create(). The difference is the first

Parameters:

  • id:Existing identity identifier.
  • addr:Address to use for the new identity. If NULL or initialized
  • irk:Identity Resolving Key (16 bytes) to be used with this

Return value: Identity identifier (>= 0) in case of success, or a negative

bt_id_delete(id)

Delete an identity. When given a valid identity this function will disconnect any connections created using it, remove any pairing keys or other data associated with it, and then flag is as deleted, so that it can not be used for any operations. To take back into use the slot the identity was occupying the bt_id_reset() API needs to be used. Note: the default identity (BT_ID_DEFAULT) cannot be deleted, i.e. this API will return an error if asked to do that.

Parameters:

  • id:Existing identity identifier.

Return value: 0 in case of success, or a negative error code on failure.

bt_le_adv_start(id)

Start advertising Set advertisement data, scan response data, advertisement parameters and start advertising.

Parameters:

  • id:Existing identity identifier.

Return value: 0 in case of success, or a negative error code on failure.

bt_le_adv_update_data(ad, ad_len, sd, sd_len)

Update advertising Update advertisement and scan response data.

Parameters:

  • ad:Data to be used in advertisement packets.
  • ad_len:Number of elements in ad
  • sd:Data to be used in scan response packets.
  • sd_len:Number of elements in sd

Return value: Zero on success or (negative) error code otherwise.

bt_le_adv_stop()

Stop advertising Stops ongoing advertising.

Return value: see the SDK header

bt_le_pts_scan_start(param, cb)

Start (LE) scanning Start LE scanning with given parameters and provide results through the specified callback.

Parameters:

  • param:Scan parameters.
  • cb:Callback to notify scan results.

Return value: Zero on success or error code otherwise, positive in case

bt_le_scan_start(param, cb)

Start (LE) scanning Start LE scanning with given parameters and provide results through the specified callback.

Return value: Zero on success or (negative) error code otherwise.

bt_le_scan_stop()

Stop (LE) scanning. Stops ongoing LE scanning.

Return value: Zero on success or error code otherwise, positive in case

bt_le_whitelist_add(addr)

Add device (LE) to whitelist. Add peer device LE address to the whitelist.

Parameters:

  • addr:Bluetooth LE identity address.

Return value: Zero on success or error code otherwise, positive in case

bt_le_whitelist_rem(addr)

Remove device (LE) from whitelist. Remove peer device LE address from the whitelist.

Parameters:

  • addr:Bluetooth LE identity address.

Return value: Zero on success or error code otherwise, positive in case

bt_le_whitelist_clear()

Clear whitelist. Clear all devices from the whitelist.

Return value: Zero on success or error code otherwise, positive in case

bt_le_set_chan_map(chan_map)

Set (LE) channel map.

Parameters:

  • chan_map:Channel map.

Return value: Zero on success or error code otherwise, positive in case

bt_le_oob_get_local(id, oob)

Get LE local Out Of Band information This function allows to get local information that are useful for Out Of Band pairing or connection creation process. If privacy is enabled this will result in generating new Resolvable Private Address that is valid for CONFIG_BT_RPA_TIMEOUT seconds. This address will be used for advertising, active scanning and connection creation.

Parameters:

  • id:Local identity, in most cases BT_ID_DEFAULT.
  • oob:LE related information

Return value: Zero on success or error code otherwise, positive in case

bt_br_discovery_start(param, results, count, cb)

Start BR/EDR discovery Start BR/EDR discovery (inquiry) and provide results through the specified callback. When bt_br_discovery_cb_t is called it indicates that discovery has completed. If more inquiry results were received during session than fits in provided result storage, only ones with highest RSSI will be reported.

Return value: see the SDK header

bt_br_discovery_stop()

Stop BR/EDR discovery. Stops ongoing BR/EDR discovery. If discovery was stopped by this call results won't be reported

Return value: Zero on success or error code otherwise, positive in case

bt_disable()

Disable Bluetooth Disable Bluetooth. Can't be called before bt_enable has completed and shall exit the Connection State/ Advertising State/Scanning State and transition to the Standby State. This API will clear all configured identities and keys that are not persistently stored with @kconfig{CONFIG_BT_SETTINGS}. These can be restored with settings_load() before reenabling the stack. This API does not clear previously registered callbacks like @ref bt_le_scan_cb_register, @ref bt_conn_cb_register AND @ref bt_br_discovery_cb_register. That is, the application shall not re-register them when the Bluetooth subsystem is re-enabled later. Close and release HCI resources. Result is architecture dependent.

Return value: Zero on success or (negative) error code otherwise.

bt_force_disable()

Force Disable Bluetooth Force Disable Bluetooth. This API will call HCI Reset command and force exit the Connection State/ Advertising State/Scanning State and transition to the Standby State. This API will clear all configured identities and keys that are not persistently stored with @kconfig{CONFIG_BT_SETTINGS}. These can be restored with settings_load() before reenabling the stack. This API does not clear previously registered callbacks like @ref bt_le_scan_cb_register, @ref bt_conn_cb_register AND @ref bt_br_discovery_cb_register. That is, the application shall not re-register them when the Bluetooth subsystem is re-enabled later. If call this API at Connection state, it will clear all connection related resource, Disconnection err code: BT_HCI_ERR_UNSPECIFIED. Close and release HCI resources. Result is architecture dependent.

Return value: Zero on success or (negative) error code otherwise.

bt_br_oob_get_local(oob)

Get BR/EDR local Out Of Band information This function allows to get local controller information that are useful for Out Of Band pairing or connection creation process.

Parameters:

  • oob:Out Of Band information

Return value: see the SDK header

bt_addr_from_str(str, addr)

Convert Bluetooth address from string to binary.

Return value: Zero on success or (negative) error code otherwise.

bt_addr_le_from_str(str, type, addr)

Convert LE Bluetooth address from string to binary.

Return value: Zero on success or (negative) error code otherwise.

bt_br_set_discoverable(enable)

Enable/disable set controller in discoverable state. Allows make local controller to listen on INQUIRY SCAN channel and responds to devices making general inquiry. To enable this state it's mandatory to first be in connectable state.

Parameters:

  • enable:Value allowing/disallowing controller to become discoverable.

Return value: Negative if fail set to requested state or requested state has been

bt_br_set_connectable(enable)

Enable/disable set controller in connectable state. Allows make local controller to be connectable. It means the controller start listen to devices requests on PAGE SCAN channel. If disabled also resets discoverability if was set.

Parameters:

  • enable:Value allowing/disallowing controller to be connectable.

Return value: Negative if fail set to requested state or requested state has been

bt_unpair(id, addr)

Clear pairing information.

Parameters:

  • id:Local identity (mostly just BT_ID_DEFAULT).
  • addr:Remote address, NULL or BT_ADDR_LE_ANY to clear all remote

Return value: 0 on success or negative error value on failure.

bt_br_write_local_name(name)

write local name.

📎 Device name lookup: Supported Device Names (BL616)

Return value: see the SDK header

bt_br_write_eir(fec, data)

write extern inquiry response.

Return value: see the SDK header

bt_br_internal_update_a2dp_status(conHandle, status)

Update a2dp status to controller.

Parameters:

  • conHandle:connection handle
  • status:current a2dp status(only a2dp stream start or suspend)

Return value: see the SDK header

bt_br_set_a2dp_stream_duty(DutyValue)

It's used to set the duty cycle of the a2dp stream.

Parameters:

  • DutyValue:the range is 0-100

Return value: see the SDK header

bt_br_set_min_enc_key_size(KeySize)

It's used to set min encryption key size.

Parameters:

  • KeySize:the range is 1-16

Return value: see the SDK header

bt_br_set_tx_pwr(br_power, edr_power)

It's used to set min encryption key size.

Parameters:

  • br_power:the range is 0-10, 0xff: use default power
  • edr_power:the range is 0-8, 0xff: use default power

Return value: see the SDK header

bt_get_name()

Get the local BLE device name

Return value: Bluetooth Device Name

Connection

bt_conn_unref(conn)

Decrement a connection's reference count. Decrement the reference count of a connection object.

Parameters:

  • conn:Connection object.

Return value: None

le_check_valid_conn(id, peer)

Look up an existing connection by address. Look up an existing connection based on the remote address.

Parameters:

  • id:Local identity (in most cases BT_ID_DEFAULT).
  • peer:Remote address.

Return value: Connection object or NULL if not found. The caller gets a

notify_disconnected(id, peer)

Look up an existing connection by address. Look up an existing connection based on the remote address.

Parameters:

  • id:Local identity (in most cases BT_ID_DEFAULT).
  • peer:Remote address.

Return value: Connection object or NULL if not found. The caller gets a

notify_remote_version(id, peer)

Look up an existing connection by address. Look up an existing connection based on the remote address.

Parameters:

  • id:Local identity (in most cases BT_ID_DEFAULT).
  • peer:Remote address.

Return value: Connection object or NULL if not found. The caller gets a

bt_conn_cleanup_all(id, peer)

Look up an existing connection by address. Look up an existing connection based on the remote address.

Parameters:

  • id:Local identity (in most cases BT_ID_DEFAULT).
  • peer:Remote address.

Return value: Connection object or NULL if not found. The caller gets a

bt_conn_index(conn)

Get array index of a connection This function maps a connection to its index in the corresponding LE or BR/EDR connection pool.

Parameters:

  • conn:Connection object.

Return value: Index of the connection object.

bt_conn_get_info(conn, info)

Get connection info

Parameters:

  • conn:Connection object.
  • info:Connection info object.

Return value: Zero on success or (negative) error code on failure.

bt_conn_get_remote_dev_info(info, type)

Get connected devices' info

Parameters:

  • info:Connection info object.
  • type:Exact connection type to query (BT_CONN_TYPE_LE or

Return value: Connected device number or (negative) error code on failure.

pts_bt_conn_le_param_update(conn, param)

Update the connection parameters.

Parameters:

  • conn:Connection object.
  • param:Updated connection parameters.

Return value: Zero on success or (negative) error code on failure.

bt_conn_le_param_update(conn, param)

Update the connection parameters.

Parameters:

  • conn:Connection object.
  • param:Updated connection parameters.

Return value: Zero on success or (negative) error code on failure.

bt_conn_disconnect(conn, reason)

Disconnect from a remote device or cancel pending connection. Disconnect an active connection with the specified reason code or cancel pending outgoing connection.

Parameters:

  • conn:Connection to disconnect.
  • reason:Reason code for the disconnection.

Return value: Zero on success or (negative) error code on failure.

bt_conn_create_auto_le(param)

Automatically connect to remote devices in whitelist. This uses the Auto Connection Establishment procedure.

Parameters:

  • param:Initial connection parameters.

Return value: Zero on success or (negative) error code on failure.

bt_conn_create_auto_stop()

Stop automatic connect creation.

Return value: Zero on success or (negative) error code on failure.

bt_le_set_auto_conn(addr, param)

Automatically connect to remote device if it's in range. This function enables/disables automatic connection initiation. Every time the device loses the connection with peer, this connection will be re-established if connectable advertisement from peer is received. Note: Auto connect is disabled during explicit scanning.

Parameters:

  • addr:Remote Bluetooth address.
  • param:If non-NULL, auto connect is enabled with the given

Return value: Zero on success or error code otherwise.

bt_conn_set_security(conn, sec)

Set security level for a connection. This function enable security (encryption) for a connection. If device is already paired with sufficiently strong key encryption will be enabled. If link is already encrypted with sufficiently strong key this function does nothing. If device is not paired pairing will be initiated. If device is paired and keys are too weak but input output capabilities allow for strong enough keys pairing will be initiated. This function may return error if required level of security is not possible to achieve due to local or remote device limitation (e.g., input output capabilities), or if the maximum number of paired devices has been reached. This function may return error if the pairing procedure has already been initiated by the local device or the peer device.

Parameters:

  • conn:Connection object.
  • sec:Requested security level.

Return value: 0 on success or negative error

bt_conn_get_security(conn)

Get security level for a connection.

Return value: Connection security level

bt_conn_enc_key_size(conn)

Get encryption key size. This function gets encryption key size. If there is no security (encryption) enabled 0 will be returned.

Parameters:

  • conn:Existing connection object.

Return value: Encryption key size.

bt_set_mitm(conn, level, err)

The security level of a connection has changed. This callback notifies the application that the security level of a connection has changed.

Parameters:

  • conn:Connection object.
  • level:New security level of the connection.
  • err:Security error. Zero for success, non-zero otherwise.

Return value: None

bt_set_smpflag(conn, level, err)

The security level of a connection has changed. This callback notifies the application that the security level of a connection has changed.

Parameters:

  • conn:Connection object.
  • level:New security level of the connection.
  • err:Security error. Zero for success, non-zero otherwise.

Return value: None

bt_clear_smpflag(conn, level, err)

The security level of a connection has changed. This callback notifies the application that the security level of a connection has changed.

Parameters:

  • conn:Connection object.
  • level:New security level of the connection.
  • err:Security error. Zero for success, non-zero otherwise.

Return value: None

bt_conn_cb_register(cb)

Register connection callbacks. Register callbacks to monitor the state of connections.

Return value: None

bt_conn_cb_unregister(cb)

Register connection callbacks. Register callbacks to monitor the state of connections.

Parameters:

  • cb:Callback struct.

Return value: None

bt_conn_cb_clear(cb)

Register connection callbacks. Register callbacks to monitor the state of connections.

Parameters:

  • cb:Callback struct.

Return value: None

bt_set_bondable(enable)

Enable/disable bonding.

Parameters:

  • enable:Value allowing/disallowing to be bondable.

Return value: None

bt_set_oob_data_flag(enable)

Allow/disallow remote OOB data to be used for pairing.

Parameters:

  • enable:Value allowing/disallowing remote OOB data.

Return value: None

bt_le_oob_set_sc_data(conn, oobd_local, oobd_remote)

Set OOB data during LE SC pairing procedure This function allows to set OOB data during the LE SC pairing procedure. The function should only be called in response to the oob_data_request() callback provided that LE SC method is used for pairing. The user should submit OOB data according to the information received in the callback. This may yield three different configurations: with only local OOB data present, with only remote OOB data present or with both local and remote OOB data present.

Parameters:

  • conn:Connection object
  • oobd_local:Local OOB data or NULL if not present
  • oobd_remote:Remote OOB data or NULL if not present

Return value: Zero on success or error code otherwise, positive in case

bt_le_oob_get_sc_data(conn, oobd_local, oobd_remote)

Get OOB data used for LE SC pairing procedure This function allows to get OOB data during the LE SC pairing procedure that were set by the bt_le_oob_set_sc_data() API. Note: The OOB data will only be available as long as the connection object associated with it is valid.

Parameters:

  • conn:Connection object
  • oobd_local:Local OOB data or NULL if not set
  • oobd_remote:Remote OOB data or NULL if not set

Return value: Zero on success or error code otherwise, positive in case

bt_passkey_set(passkey)

Set a fixed passkey to be used for pairing. This API is only available when the CONFIG_BT_FIXED_PASSKEY configuration option has been enabled. Sets a fixed passkey to be used for pairing. If set, the pairing_confim() callback will be called for all incoming pairings.

Parameters:

  • passkey:A valid passkey (0 - 999999) or BT_PASSKEY_INVALID

Return value: 0 on success or a negative error code on failure.

bt_conn_auth_cb_register(cb)

Register authentication callbacks. Register callbacks to handle authenticated pairing. Passing NULL unregisters a previous callbacks structure.

Parameters:

  • cb:Callback struct.

Return value: Zero on success or negative error code otherwise

bt_conn_auth_passkey_entry(conn, passkey)

Reply with entered passkey. This function should be called only after passkey_entry callback from bt_conn_auth_cb structure was called.

Parameters:

  • conn:Connection where pairing is currently active.
  • passkey:Passkey to show to the user.

Return value: see the SDK header

bt_conn_auth_cancel(conn)

Cancel ongoing authenticated pairing. This function allows to cancel ongoing authenticated pairing.

Parameters:

  • conn:Connection where pairing is currently active.

Return value: see the SDK header

bt_conn_auth_passkey_confirm(conn)

Reply if passkey was confirmed to match by user. This function should be called only after passkey_confirm callback from bt_conn_auth_cb structure was called.

Parameters:

  • conn:Connection where pairing is currently active.

Return value: see the SDK header

bt_conn_auth_pairing_confirm(conn)

Reply if incoming pairing was confirmed by user. This function should be called only after pairing_confirm callback from bt_conn_auth_cb structure was called if user confirmed incoming pairing.

Parameters:

  • conn:Connection where pairing is currently active.

Return value: see the SDK header

bt_conn_auth_pincode_entry(conn)

Reply with entered PIN code. This function should be called only after PIN code callback from bt_conn_auth_cb structure was called. It's for legacy 2.0 devices.

Parameters:

  • conn:Connection where pairing is currently active.

Return value: see the SDK header

bt_br_conn_enter_sniff(conn, min_interval, max_interval)

Put a BR/EDR connection into sniff mode. Intervals are in 0.625ms slots (e.g. 160 = 100ms). Sniff mode reduces the radio time an idle/low-rate link consumes, freeing bandwidth for active links in a multi-connection scenario.

Parameters:

  • conn:BR/EDR connection object.
  • min_interval:Minimum sniff interval in 0.625ms slots.
  • max_interval:Maximum sniff interval in 0.625ms slots.

Return value: 0 on success or negative value on error.

bt_br_conn_exit_sniff(conn)

Exit sniff mode, returning the connection to active mode.

Parameters:

  • conn:BR/EDR connection object.

Return value: 0 on success or negative value on error.

bt_conn_set_peripheral_pref_params(param)

Set peripheral preferred connection parameters

Parameters:

  • param:the preferred connection parameters to be set.

Return value: 0 in case of success or negative value in case of error.

bt_conn_get_peripheral_pref_params(param)

Get peripheral preferred connection parameters

Parameters:

  • param:this API will assign peripheral preferred connection parameters.

Return value: 0 in case of success or negative value in case of error.

bt_conn_enable_peripheral_pref_param_update(conn, enable)

Enable or disable peripheral preferred connection parameters udpate

Parameters:

  • conn:Connection object.
  • enable:true:enable,false:disable

Return value: 0 in case of success or negative value in case of error.

bt_conn_set_scan_parameters_in_general_conn_establish(scan_interval, scan_window)

Set scan interval and scan window in scanning procedure of ble general conection establishement.

Parameters:

  • scan_interval:scan interval.
  • scan_window:scan window.

Return value: 0 in case of success or negative value in case of error.

bt_conn_ref(conn)

Increment the connection object reference count

Parameters:

  • conn:Connection object.

Return value: Connection object with incremented reference count.

bt_conn_lookup_addr_le(id, peer)

Look up a connection by BLE address

Parameters:

  • id:Local identity (in most cases BT_ID_DEFAULT).
  • peer:Remote address.

Return value: Connection object or NULL if not found. The caller gets a

bt_conn_get_dst(conn)

Get the destination address of a connection

Parameters:

  • conn:Connection object.

Return value: Destination address.

bt_conn_get(conn)

Get the current default connection object

Parameters:

  • conn:Connection object.

Return value: Destination address.

bt_conn_create_sco(peer)

Create a SCO connection

Parameters:

  • peer:Remote address.

Return value: Valid connection object on success or NULL otherwise.

GATT

bt_gatt_service_register(svc)

Register GATT service. Register GATT service. Applications can make use of macros such as BT_GATT_PRIMARY_SERVICE, BT_GATT_CHARACTERISTIC, BT_GATT_DESCRIPTOR, etc.

Parameters:

  • svc:Service containing the available attributes

Return value: 0 in case of success or negative value in case of error.

bt_gatt_service_unregister(svc)

Unregister GATT service. *

Parameters:

  • svc:Service to be unregistered.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_find_attr(handle)

Get GATT attribute via attribute handle. *

Parameters:

  • handle:attribute handle.

Return value: attrubte pointer in case of success or NULL in case of error.

bt_gatt_foreach_attr_type(start_handle, end_handle, uuid, attr_data, num_matches, func, user_data)

Attribute iterator by type. Iterate attributes in the given range matching given UUID and/or data.

Parameters:

  • start_handle:Start handle.
  • end_handle:End handle.
  • uuid:UUID to match, passing NULL skips UUID matching.
  • attr_data:Attribute data to match, passing NULL skips data matching.
  • num_matches:Number matches, passing 0 makes it unlimited.
  • func:Callback function.
  • user_data:Data to pass to the callback.

Return value: None

bt_gatt_attr_value_handle(attr)

Get the handle of the characteristic value descriptor.

Parameters:

  • attr:A Characteristic Attribute

Return value: the handle of the corresponding Characteristic Value. The

bt_gatt_attr_read(conn, attr, buf, buf_len, offset, value, value_len)

Generic Read Attribute value helper. Read attribute value from local database storing the result into buffer.

Parameters:

  • conn:Connection object.
  • attr:Attribute to read.
  • buf:Buffer to store the value.
  • buf_len:Buffer length.
  • offset:Start offset.
  • value:Attribute value.
  • value_len:Length of the attribute value.

Return value: int number of bytes read in case of success or negative values in

bt_gatt_attr_read_service(conn, attr, buf, len, offset)

Read Service Attribute helper. Read service attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_uuid.

Parameters:

  • conn:Connection object.
  • attr:Attribute to read.
  • buf:Buffer to store the value read.
  • len:Buffer length.
  • offset:Start offset.

Return value: int number of bytes read in case of success or negative values in

bt_gatt_attr_read_included(conn, attr, buf, len, offset)

Read Include Attribute helper. Read include service attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_gatt_include.

Parameters:

  • conn:Connection object.
  • attr:Attribute to read.
  • buf:Buffer to store the value read.
  • len:Buffer length.
  • offset:Start offset.

Return value: int number of bytes read in case of success or negative values in

bt_gatt_attr_read_chrc(conn, attr, buf, len, offset)

Read Characteristic Attribute helper. Read characteristic attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_gatt_chrc.

Parameters:

  • conn:Connection object.
  • attr:Attribute to read.
  • buf:Buffer to store the value read.
  • len:Buffer length.
  • offset:Start offset.

Return value: number of bytes read in case of success or negative values in

bt_gatt_attr_read_ccc(conn, attr, buf, len, offset)

Read Client Characteristic Configuration Attribute helper. Read CCC attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a _bt_gatt_ccc.

Parameters:

  • conn:Connection object.
  • attr:Attribute to read.
  • buf:Buffer to store the value read.
  • len:Buffer length.
  • offset:Start offset.

Return value: number of bytes read in case of success or negative values in

bt_gatt_attr_write_ccc(conn, attr, buf, len, offset, flags)

Write Client Characteristic Configuration Attribute helper. Write value in the buffer into CCC attribute. NOTE: Only use this with attributes which user_data is a _bt_gatt_ccc.

Parameters:

  • conn:Connection object.
  • attr:Attribute to read.
  • buf:Buffer to store the value read.
  • len:Buffer length.
  • offset:Start offset.
  • flags:Write flags.

Return value: number of bytes written in case of success or negative values in

bt_gatt_attr_read_cep(conn, attr, buf, len, offset)

Read Characteristic Extended Properties Attribute helper Read CEP attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_gatt_cep.

Parameters:

  • conn:Connection object
  • attr:Attribute to read
  • buf:Buffer to store the value read
  • len:Buffer length
  • offset:Start offset

Return value: number of bytes read in case of success or negative values in

bt_gatt_attr_read_cud(conn, attr, buf, len, offset)

Read Characteristic User Description Descriptor Attribute helper Read CUD attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a NULL-terminated C string.

Parameters:

  • conn:Connection object
  • attr:Attribute to read
  • buf:Buffer to store the value read
  • len:Buffer length
  • offset:Start offset

Return value: number of bytes read in case of success or negative values in

bt_gatt_attr_read_cpf(conn, attr, buf, len, offset)

Read Characteristic Presentation format Descriptor Attribute helper Read CPF attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_gatt_pf.

Parameters:

  • conn:Connection object
  • attr:Attribute to read
  • buf:Buffer to store the value read
  • len:Buffer length
  • offset:Start offset

Return value: number of bytes read in case of success or negative values in

bt_gatt_notify_at_cb(conn, params, attr_handle)

Notification Value callback user data

Return value: see the SDK header

bt_gatt_notify_cb(conn, params)

Notify attribute value change. This function works in the same way as @ref bt_gatt_notify. With the addition that after sending the notification the callback function will be called. The callback is run from System Workqueue context. Alternatively it is possible to notify by UUID by setting it on the parameters, when using this method the attribute given is used as the start range when looking up for possible matches.

Parameters:

  • conn:Connection object.
  • params:Notification parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_indicate(conn, attr, data, len)

Indicate attribute value change. Send an indication of attribute value change. if connection is NULL indicate all peer that have notification enabled via CCC otherwise do a direct indication only the given connection. The attribute object on the parameters can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC. The callback is run from System Workqueue context. Alternatively it is possible to indicate by UUID by setting it on the parameters, when using this method the attribute given is used as the start range when looking up for possible matches. Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:

  • conn:Connection object.
  • attr:Characteristic or Characteristic Value attribute.
  • data:Pointer to Attribute data.
  • len:Attribute value length.

Return value: 0 in case of success or negative value in case of error.

service_change_test(conn, params)

Indicate attribute value change. Send an indication of attribute value change. if connection is NULL indicate all peer that have notification enabled via CCC otherwise do a direct indication only the given connection. The attribute object on the parameters can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC. The callback is run from System Workqueue context. Alternatively it is possible to indicate by UUID by setting it on the parameters, when using this method the attribute given is used as the start range when looking up for possible matches. Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:

  • conn:Connection object.
  • params:Indicate parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_is_subscribed(conn, attr, ccc_value)

Check if connection have subscribed to attribute Check if connection has subscribed to attribute value change. The attribute object can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC, or the Client Characteristic Configuration Descriptor (CCCD) which is created by BT_GATT_CCC.

Parameters:

  • conn:Connection object.
  • attr:Attribute object.
  • ccc_value:The subscription type, either notifications or indications.

Return value: true if the attribute object has been subscribed.

bt_gatt_get_mtu(conn)

Get ATT MTU for a connection Get negotiated ATT connection MTU, note that this does not equal the largest amount of attribute data that can be transferred within a single packet.

Parameters:

  • conn:Connection object.

Return value: MTU in bytes

bt_gatt_set_mtu(conn)

Get ATT MTU for a connection Get negotiated ATT connection MTU, note that this does not equal the largest amount of attribute data that can be transferred within a single packet.

Parameters:

  • conn:Connection object.

Return value: MTU in bytes

bt_gatt_exchange_mtu(conn, params)

Exchange MTU This client procedure can be used to set the MTU to the maximum possible size the buffers can hold. NOTE: Shall only be used once per connection.

Parameters:

  • conn:Connection object.
  • params:Exchange MTU parameters.

Return value: 0 in case of success or negative value in case of error.

bt_at_gatt_exchange_mtu(conn, params)

Exchange MTU This client procedure can be used to set the MTU to the maximum possible size the buffers can hold. NOTE: Shall only be used once per connection.

Parameters:

  • conn:Connection object.
  • params:Exchange MTU parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_discover(conn, params)

GATT Discover function This procedure is used by a client to discover attributes on a server. Primary Service Discovery: Procedure allows to discover specific Primary Service based on UUID. Include Service Discovery: Procedure allows to discover all Include Services within specified range. Characteristic Discovery: Procedure allows to discover all characteristics within specified handle range as well as discover characteristics with specified UUID. Descriptors Discovery: Procedure allows to discover all characteristic descriptors within specified range. For each attribute found the callback is called which can then decide whether to continue discovering or stop. Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:

  • conn:Connection object.
  • params:Exchange MTU parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_read(conn, params)

Read Attribute Value by handle This procedure read the attribute value and return it to the callback. When reading attributes by UUID the callback can be called multiple times depending on how many instances of given the UUID exists with the start_handle being updated for each instance. If an instance does contain a long value which cannot be read entirely the caller will need to read the remaining data separately using the handle and offset. Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:

  • conn:Connection object.
  • params:Discover parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_write(conn, params)

Write Attribute Value by handle This procedure write the attribute value and return the result in the callback. Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:

  • conn:Connection object.
  • params:Read parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_cancle_prepare_writes(conn, params)

Write Attribute Value by handle This procedure write the attribute value and return the result in the callback. Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:

  • conn:Connection object.
  • params:Write parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_prepare_write(conn, params)

Write Attribute Value by handle This procedure write the attribute value and return the result in the callback. Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:

  • conn:Connection object.
  • params:Write parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_write_without_response_cb(conn, handle, data, length, sign, func, user_data)

Write Attribute Value by handle without response with callback. This function works in the same way as @ref bt_gatt_write_without_response. With the addition that after sending the write the callback function will be called. The callback is run from System Workqueue context. Note: By using a callback it also disable the internal flow control which would prevent sending multiple commands without waiting for their transmissions to complete, so if that is required the caller shall not submit more data until the callback is called.

Parameters:

  • conn:Connection object.
  • handle:Attribute handle.
  • data:Data to be written.
  • length:Data length.
  • sign:Whether to sign data
  • func:Transmission complete callback.
  • user_data:User data to be passed back to callback.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_subscribe(conn, handle, data, length, sign)

Subscribe Attribute Value Notification This procedure subscribe to value notification using the Client Characteristic Configuration handle. If notification received subscribe value callback is called to return notified value. One may then decide whether to unsubscribe directly from this callback. Notification callback with NULL data will not be called if subscription was removed by this method. Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:

  • conn:Connection object.
  • handle:Attribute handle.
  • data:Data to be written.
  • length:Data length.
  • sign:Whether to sign data

Return value: 0 in case of success or negative value in case of error.

bt_gatt_unsubscribe(conn, params)

Unsubscribe Attribute Value Notification This procedure unsubscribe to value notification using the Client Characteristic Configuration handle. Notification callback with NULL data will be called if subscription was removed by this call, until then the parameters cannot be reused.

Parameters:

  • conn:Connection object.
  • params:Subscribe parameters.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_cancel(conn, params)

Cancel GATT pending request

Parameters:

  • conn:Connection object.
  • params:Requested params address.

Return value: None

bt_gatt_register_mtu_callback(conn, params)

Cancel GATT pending request

Parameters:

  • conn:Connection object.
  • params:Requested params address.

Return value: None

bt_gatt_discover_status_set(conn, params)

Cancel GATT pending request

Parameters:

  • conn:Connection object.
  • params:Requested params address.

Return value: None

bt_gatt_register_notification_callback(conn, params)

Cancel GATT pending request

Parameters:

  • conn:Connection object.
  • params:Requested params address.

Return value: None

bt_gatt_ccc_load(void, void)

load gatt ccc from flash

Parameters:

  • void:.
  • void:.

Return value: None

bt_gatt_sc_indicate(start, end)

Send service changed indication.

Parameters:

  • start:start attribute handle.
  • end:end attribute handle.

Return value: None

bt_gatts_get_dync_attr_handle(start, end)

Get a Dynamic attrubute hanle(chrc_handle,vaule_handle,descriptor)

Parameters:

  • start:start attribute handle.
  • end:end attribute handle.

Return value: see the SDK header

bt_gatts_add_serv_attr(start, end)

Add service

Parameters:

  • start:start attribute handle.
  • end:end attribute handle.

Return value: see the SDK header

bt_gatts_add_char(start, end)

Add characteristics and characteristic value

Parameters:

  • start:start attribute handle.
  • end:end attribute handle.

Return value: see the SDK header

bt_gatts_add_desc(start, end)

Add descriptor

Parameters:

  • start:start attribute handle.
  • end:end attribute handle.

Return value: see the SDK header

bt_gatts_get_service_simple_info(svc_id, info, info_num)

Get simple service information.

Parameters:

  • svc_id:ID of the service.
  • info:Pointer to a simple service information structure.
  • info_num:Number of Simple Service Information Structures.

Return value: 0 in case of success or negative value in case of error.

bt_gatts_get_service_char(svc_id, info, info_num)

Get service characteristics.

Parameters:

  • svc_id:ID of the service.
  • info:Pointer to service characteristics information structure.
  • info_num:Number of service characteristics.

Return value: 0 in case of success or negative value in case of error.

bt_gatts_get_service_desc(svc_id, info, info_num)

Get service characteristics descriptor.

Parameters:

  • svc_id:ID of the service.
  • info:Pointer to service characteristics descriptor information structure.
  • info_num:Number of service characteristics descriptor.

Return value: 0 in case of success or negative value in case of error.

bt_gatts_add_service()

Register service.

Return value: service id(>0) in case of success.

bt_gatts_del_service(svc_id, desp_attr)

Add Unregister service.

Parameters:

  • svc_id:ID of the service.
  • desp_attr:characteristics attribution.

Return value: 0 in case of success or negative value in case of error.

bt_gatt_attr_next(attr)

Iterate to the next GATT attribute

Parameters:

  • attr:Current Attribute.

Return value: The next attribute or NULL if it cannot be found.

ATOMIC_DEFINE(flags, BT_GATT_SUBSCRIBE_NUM_FLAGS)

Macro: define an atomic variable (internal)

Return value: see the SDK header

L2CAP

bt_l2cap_server_register(server)

Register L2CAP server. Register L2CAP server for a PSM, each new connection is authorized using the accept() callback which in case of success shall allocate the channel structure to be used by the new connection. For fixed, SIG-assigned PSMs (in the range 0x0001-0x007f) the PSM should be assigned to server->psm before calling this API. For dynamic PSMs (in the range 0x0080-0x00ff) server->psm may be pre-set to a given value (this is however not recommended) or be left as 0, in which case upon return a newly allocated value will have been assigned to it. For dynamically allocated values the expectation is that it's exposed through a GATT service, and that's how L2CAP clients discover how to connect to the server.

Return value: see the SDK header

bt_l2cap_br_server_register(server)

Register L2CAP server on BR/EDR oriented connection. Register L2CAP server for a PSM, each new connection is authorized using the accept() callback which in case of success shall allocate the channel structure to be used by the new connection.

Parameters:

  • server:Server structure.

Return value: 0 in case of success or negative value in case of error.

bt_l2cap_chan_connect(conn, chan, psm)

Connect L2CAP channel Connect L2CAP channel by PSM, once the connection is completed channel connected() callback will be called. If the connection is rejected disconnected() callback is called instead. Channel object passed (over an address of it) as second parameter shouldn't be instantiated in application as standalone. Instead of, application should create transport dedicated L2CAP objects, i.e. type of bt_l2cap_le_chan for LE and/or type of bt_l2cap_br_chan for BR/EDR. Then pass to this API the location (address) of bt_l2cap_chan type object which is a member of both transport dedicated objects.

Parameters:

  • conn:Connection object.
  • chan:Channel object.
  • psm:Channel PSM to connect to.

Return value: 0 in case of success or negative value in case of error.

bt_l2cap_chan_disconnect(chan)

Disconnect L2CAP channel Disconnect L2CAP channel, if the connection is pending it will be canceled and as a result the channel disconnected() callback is called. Regarding to input parameter, to get details see reference description to bt_l2cap_chan_connect() API above.

Parameters:

  • chan:Channel object.

Return value: 0 in case of success or negative value in case of error.

bt_l2cap_chan_send(chan, buf)

Send data to L2CAP channel Send data from buffer to the channel. If credits are not available, buf will be queued and sent as and when credits are received from peer. Regarding to first input parameter, to get details see reference description to bt_l2cap_chan_connect() API above.

Return value: Bytes sent in case of success or negative value in case of error.

bt_l2cap_chan_recv_complete(chan)

Complete receiving L2CAP channel data Complete the reception of incoming data. This shall only be called if the channel recv callback has returned -EINPROGRESS to process some incoming data. The buffer shall contain the original user_data as that is used for storing the credits/segments used by the packet.

Parameters:

  • chan:The channel requesting a buffer.

Return value: Allocated buffer.

bt_l2cap_disconnect(chan, buf)

Complete receiving L2CAP channel data Complete the reception of incoming data. This shall only be called if the channel recv callback has returned -EINPROGRESS to process some incoming data. The buffer shall contain the original user_data as that is used for storing the credits/segments used by the packet.

Parameters:

  • chan:Channel object.
  • buf:Buffer containing the data.

Return value: 0 in case of success or negative value in case of error.

bt_l2cap_br_echo_req(chan, buf)

Complete receiving L2CAP channel data Complete the reception of incoming data. This shall only be called if the channel recv callback has returned -EINPROGRESS to process some incoming data. The buffer shall contain the original user_data as that is used for storing the credits/segments used by the packet.

Parameters:

  • chan:Channel object.
  • buf:Buffer containing the data.

Return value: 0 in case of success or negative value in case of error.

ATOMIC_DEFINE(status, BT_L2CAP_NUM_STATUS)

Macro: define an atomic variable (internal)

Return value: see the SDK header

GAP

bt_gap_set_local_device_appearance(device_appearance)

Bluetooth Generic Access Profile defines and Assigned Numbers.

Return value: None

Address

bt_addr_le_create_nrpa(addr)

Bluetooth LE Device Address

Return value: see the SDK header

bt_addr_le_create_static(addr)

Bluetooth LE Device Address

Return value: see the SDK header

UUID

bt_uuid_cmp(u1, u2)

Compare Bluetooth UUIDs. Compares 2 Bluetooth UUIDs, if the types are different both UUIDs are first converted to 128 bits format before comparing.

Parameters:

  • u1:First Bluetooth UUID to compare
  • u2:Second Bluetooth UUID to compare

Return value: negative value if @a u1 < @a u2, 0 if @a u1 == @a u2, else positive

bt_uuid_create(uuid, data, data_len)

Create a bt_uuid from a little-endian data buffer. Create a bt_uuid from a little-endian data buffer. The data_len parameter is used to determine whether the UUID is in 16, 32 or 128 bit format (length 2, 4 or 16). Note: 32 bit format is not allowed over the air.

Parameters:

  • uuid:Pointer to the bt_uuid variable
  • data:pointer to UUID stored in little-endian data buffer
  • data_len:length of the UUID in the data buffer

Return value: true if the data was valid and the UUID was successfully created.

bt_uuid_to_str(uuid, str, len)

Convert Bluetooth UUID to string. Converts Bluetooth UUID to string. UUID has to be in 16 bits or 128 bits format.

Parameters:

  • uuid:Bluetooth UUID
  • str:pointer where to put converted string
  • len:length of str

Return value: N/A

bt_uuid_str_real(uuid, str, len)

Convert a UUID to a readable string (actual implementation)

Parameters:

  • uuid:Bluetooth UUID
  • str:pointer where to put converted string
  • len:length of str

Return value: N/A

BLE Crypto

bt_rand(buf, len)

Generate random data. A random number generation helper which utilizes the Bluetooth controller's own RNG.

Parameters:

  • buf:Buffer to insert the random data
  • len:Length of random data to generate

Return value: Zero on success or error code otherwise, positive in case

bt_encrypt_le(key, plaintext, enc_data)

AES encrypt little-endian data. An AES encrypt helper is used to request the Bluetooth controller's own hardware to encrypt the plaintext using the key and returns the encrypted data.

Parameters:

  • key:128 bit LS byte first key for the encryption of the plaintext
  • plaintext:128 bit LS byte first plaintext data block to be encrypted
  • enc_data:128 bit LS byte first encrypted data block

Return value: Zero on success or error code otherwise.

bt_encrypt_be(key, plaintext, enc_data)

AES encrypt big-endian data. An AES encrypt helper is used to request the Bluetooth controller's own hardware to encrypt the plaintext using the key and returns the encrypted data.

Parameters:

  • key:128 bit MS byte first key for the encryption of the plaintext
  • plaintext:128 bit MS byte first plaintext data block to be encrypted
  • enc_data:128 bit MS byte first encrypted data block

Return value: Zero on success or error code otherwise.

HCI Host

bt_hci_cmd_send(opcode, param_len)

Send a HCI command asynchronously.

Parameters:

  • opcode:Command OpCode.
  • param_len:Length of command parameters.

Return value: Newly allocated buffer.

bt_hci_cmd_send_sync(opcode, param_len)

Send a HCI command synchronously.

Parameters:

  • opcode:Command OpCode.
  • param_len:Length of command parameters.

Return value: Newly allocated buffer.

bt_hci_get_conn_handle(opcode, buf, rsp)

Get connection handle for a connection.

Parameters:

  • opcode:Command OpCode.
  • buf:Command buffer or NULL (if no parameters).
  • rsp:Place to store a reference to the command response. May

Return value: 0 on success or negative error value on failure.

bt_hci_register_vnd_evt_cb(conn, conn_handle)

Register user callback for HCI Vendor-Specific Events

Parameters:

  • conn:Connection object.
  • conn_handle:Place to store the Connection handle.

Return value: 0 on success or negative error value on failure.

bt_hci_cmd_create(opcode, param_len)

Create an HCI command buffer

Parameters:

  • opcode:Command OpCode.
  • param_len:Length of command parameters.

Return value: Newly allocated buffer.

Have questions?

For any other questions, visit the unified Q&A and discussion board: Ai-Thinker Discussions

Released under the MIT License. Build Time 2026-09-11 14:52:23