BLE
This module includes the platform abstraction for BLE Host communication.
Summary
The platform needs to implement Bluetooth LE 4.2 or higher.
Typedefs |
|
|---|---|
otBleLinkCapabilities
|
typedefstruct otBleLinkCapabilities
Represent BLE link capabilities. |
otBleRadioPacket
|
typedefstruct otBleRadioPacket
Represents a BLE packet. |
Functions |
|
|---|---|
otPlatBleDisable(otInstance *aInstance)
|
Disable the Bluetooth Low Energy radio.
|
otPlatBleEnable(otInstance *aInstance)
|
Enable the Bluetooth Low Energy radio.
|
otPlatBleGapAdvSetData(otInstance *aInstance, uint8_t *aAdvertisementData, uint16_t aAdvertisementLen)
|
Sets BLE Advertising data.
|
otPlatBleGapAdvStart(otInstance *aInstance, uint16_t aInterval)
|
Starts BLE Advertising procedure.
|
otPlatBleGapAdvStop(otInstance *aInstance)
|
Stops BLE Advertising procedure.
|
otPlatBleGapAdvUpdateData(otInstance *aInstance, uint8_t *aAdvertisementData, uint16_t aAdvertisementLen)
|
Updates BLE Advertising data.
|
otPlatBleGapDisconnect(otInstance *aInstance)
|
Disconnects BLE connection.
|
otPlatBleGapOnConnected(otInstance *aInstance, uint16_t aConnectionId)
|
void
The BLE driver calls this function to notify OpenThread that a BLE Central Device has been connected.
|
otPlatBleGapOnDisconnected(otInstance *aInstance, uint16_t aConnectionId)
|
void
The BLE driver calls this function to notify OpenThread that the BLE Central Device has been disconnected.
|
otPlatBleGattMtuGet(otInstance *aInstance, uint16_t *aMtu)
|
Reads currently used value of ATT_MTU from the platform BLE driver.
|
otPlatBleGattOnMtuUpdate(otInstance *aInstance, uint16_t aMtu)
|
void
The BLE driver calls this function to notify OpenThread that ATT_MTU has been updated.
|
otPlatBleGattServerIndicate(otInstance *aInstance, uint16_t aHandle, const otBleRadioPacket *aPacket)
|
Sends ATT Handle Value Indication.
|
otPlatBleGattServerOnWriteRequest(otInstance *aInstance, uint16_t aHandle, const otBleRadioPacket *aPacket)
|
void
The BLE driver calls this function to notify OpenThread that an ATT Write Request packet has been received.
|
otPlatBleGetAdvertisementBuffer(otInstance *aInstance, uint8_t **aAdvertisementBuffer)
|
Gets a platform-provided buffer for BLE advertising data.
|
otPlatBleGetLinkCapabilities(otInstance *aInstance, otBleLinkCapabilities *aBleLinkCapabilities)
|
void
Retrieve BLE link capabilities from the platform.
|
otPlatBleSupportsMultiRadio(otInstance *aInstance)
|
bool
Check if the platform has multi-radio support for BLE and IEEE 802.15.4.
|
Macros |
|
|---|---|
OT_BLE_ADV_INTERVAL_DEFAULT 160
|
Default interval for advertising packet in OT_BLE_ADV_INTERVAL_UNIT units (100 ms).
|
OT_BLE_ADV_INTERVAL_MAX 0x4000
|
Maximum allowed interval for advertising packet in OT_BLE_ADV_INTERVAL_UNIT units (10.24s).
|
OT_BLE_ADV_INTERVAL_MIN 0x0020
|
Minimum allowed interval for advertising packet in OT_BLE_ADV_INTERVAL_UNIT units (20ms).
|
OT_BLE_ADV_INTERVAL_UNIT OT_BLE_TIMESLOT_UNIT
|
Unit used to calculate interval duration (0.625ms).
|
OT_BLE_ATT_MTU_DEFAULT 23
|
Default ATT MTU size (used if no MTU indication is given yet, or none can be given).
|
OT_BLE_ATT_MTU_MAX 67
|
Maximum allowed ATT MTU size (MUST be >= OT_BLE_ATT_MTU_MIN).
|
OT_BLE_ATT_MTU_MIN 23
|
Minimum allowed ATT MTU size (MUST be 23).
|
OT_BLE_DEFAULT_POWER 0
|
Default Tx power value for BLE in dBm.
|
OT_BLE_TIMESLOT_UNIT 625
|
Time slot duration on PHY layer in microseconds (0.625ms).
|
OT_TOBLE_SERVICE_UUID 0xfffb
|
ToBLE service UUID (a GATT service UUID for Thread over BLE)
|
Structs |
|
|---|---|
| otBleLinkCapabilities |
Represent BLE link capabilities. |
| otBleRadioPacket |
Represents a BLE packet. |
Typedefs
otBleLinkCapabilities
struct otBleLinkCapabilities otBleLinkCapabilities
Represent BLE link capabilities.
Functions
otPlatBleDisable
otError otPlatBleDisable( otInstance *aInstance )
Disable the Bluetooth Low Energy radio.
When disabled, the BLE stack will flush event queues and not generate new events. The BLE peripheral is turned off or put into a low power sleep state. Any dynamic memory used by the stack should be released, but static memory may remain reserved.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otPlatBleEnable
otError otPlatBleEnable( otInstance *aInstance )
Enable the Bluetooth Low Energy radio.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otPlatBleGapAdvSetData
otError otPlatBleGapAdvSetData( otInstance *aInstance, uint8_t *aAdvertisementData, uint16_t aAdvertisementLen )
Sets BLE Advertising data.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||||
| Return Values |
|
otPlatBleGapAdvStart
otError otPlatBleGapAdvStart( otInstance *aInstance, uint16_t aInterval )
Starts BLE Advertising procedure.
The BLE device shall use undirected advertising with no filter applied. A single BLE Advertising packet must be sent on all advertising channels (37, 38 and 39). The advertising shall remain active until either otPlatBleGapAdvStop() is called or a BLE Central Device connects (otPlatBleGapOnConnected()). The BLE platform is not obliged to exactly match the requested interval between subsequent advertising packets: it is a requested/desired value.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||
| Return Values |
|
otPlatBleGapAdvStop
otError otPlatBleGapAdvStop( otInstance *aInstance )
Stops BLE Advertising procedure.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otPlatBleGapAdvUpdateData
otError otPlatBleGapAdvUpdateData( otInstance *aInstance, uint8_t *aAdvertisementData, uint16_t aAdvertisementLen )
Updates BLE Advertising data.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||||
| Return Values |
|
otPlatBleGapDisconnect
otError otPlatBleGapDisconnect( otInstance *aInstance )
Disconnects BLE connection.
The BLE device shall use the Remote User Terminated Connection (0x13) reason code when disconnecting from the peer BLE device.
This function only triggers the disconnection procedure. When OT_ERROR_NONE is returned, the platform MUST report completion of the disconnection asynchronously, by invoking otPlatBleGapOnDisconnected().
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otPlatBleGapOnConnected
void otPlatBleGapOnConnected( otInstance *aInstance, uint16_t aConnectionId )
The BLE driver calls this function to notify OpenThread that a BLE Central Device has been connected.
The BLE driver MUST stop advertising before calling this function.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
otPlatBleGapOnDisconnected
void otPlatBleGapOnDisconnected( otInstance *aInstance, uint16_t aConnectionId )
The BLE driver calls this function to notify OpenThread that the BLE Central Device has been disconnected.
The BLE driver MUST NOT start advertising before or after this call: this is controlled explicitly via otPlatBleGapAdvStart().
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
otPlatBleGattMtuGet
otError otPlatBleGattMtuGet( otInstance *aInstance, uint16_t *aMtu )
Reads currently used value of ATT_MTU from the platform BLE driver.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otPlatBleGattOnMtuUpdate
void otPlatBleGattOnMtuUpdate( otInstance *aInstance, uint16_t aMtu )
The BLE driver calls this function to notify OpenThread that ATT_MTU has been updated.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
otPlatBleGattServerIndicate
otError otPlatBleGattServerIndicate( otInstance *aInstance, uint16_t aHandle, const otBleRadioPacket *aPacket )
Sends ATT Handle Value Indication.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
||||||||
| Return Values |
|
otPlatBleGattServerOnWriteRequest
void otPlatBleGattServerOnWriteRequest( otInstance *aInstance, uint16_t aHandle, const otBleRadioPacket *aPacket )
The BLE driver calls this function to notify OpenThread that an ATT Write Request packet has been received.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
otPlatBleGetAdvertisementBuffer
otError otPlatBleGetAdvertisementBuffer( otInstance *aInstance, uint8_t **aAdvertisementBuffer )
Gets a platform-provided buffer for BLE advertising data.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
||||
| Return Values |
|
otPlatBleGetLinkCapabilities
void otPlatBleGetLinkCapabilities( otInstance *aInstance, otBleLinkCapabilities *aBleLinkCapabilities )
Retrieve BLE link capabilities from the platform.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
otPlatBleSupportsMultiRadio
bool otPlatBleSupportsMultiRadio( otInstance *aInstance )
Check if the platform has multi-radio support for BLE and IEEE 802.15.4.
| Details | |||
|---|---|---|---|
| Parameters |
|
||
| Returns |
TRUE if the platform supports simultaneous BLE and IEEE 802.15.4 operation, FALSE otherwise.
|
Macros
OT_BLE_ADV_INTERVAL_DEFAULT
OT_BLE_ADV_INTERVAL_DEFAULT 160
Default interval for advertising packet in OT_BLE_ADV_INTERVAL_UNIT units (100 ms).
OT_BLE_ADV_INTERVAL_MAX
OT_BLE_ADV_INTERVAL_MAX 0x4000
Maximum allowed interval for advertising packet in OT_BLE_ADV_INTERVAL_UNIT units (10.24s).
OT_BLE_ADV_INTERVAL_MIN
OT_BLE_ADV_INTERVAL_MIN 0x0020
Minimum allowed interval for advertising packet in OT_BLE_ADV_INTERVAL_UNIT units (20ms).
OT_BLE_ADV_INTERVAL_UNIT
OT_BLE_ADV_INTERVAL_UNIT OT_BLE_TIMESLOT_UNIT
Unit used to calculate interval duration (0.625ms).
OT_BLE_ATT_MTU_DEFAULT
OT_BLE_ATT_MTU_DEFAULT 23
Default ATT MTU size (used if no MTU indication is given yet, or none can be given).
It MUST be 23.
OT_BLE_ATT_MTU_MAX
OT_BLE_ATT_MTU_MAX 67
Maximum allowed ATT MTU size (MUST be >= OT_BLE_ATT_MTU_MIN).
OT_BLE_ATT_MTU_MIN
OT_BLE_ATT_MTU_MIN 23
Minimum allowed ATT MTU size (MUST be 23).
OT_BLE_DEFAULT_POWER
OT_BLE_DEFAULT_POWER 0
Default Tx power value for BLE in dBm.
OT_BLE_TIMESLOT_UNIT
OT_BLE_TIMESLOT_UNIT 625
Time slot duration on PHY layer in microseconds (0.625ms).
OT_TOBLE_SERVICE_UUID
OT_TOBLE_SERVICE_UUID 0xfffb
ToBLE service UUID (a GATT service UUID for Thread over BLE)
Resources
OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.