![]() |
BSB Developer Docs
|
Public ble api. More...
Go to the source code of this file.
Data Structures | |
| struct | BleState |
| Depicts current ble state. More... | |
Macros | |
| #define | RECORD_BLE "ble" |
| BLE FURI record identifier. | |
| #define | MAX_TX_CHUNK_SIZE (237) |
| Defines max data size for characteristics. | |
| #define | BLE_REMOTE_DEVICE_ADDRESS_STRING_SIZE (18) |
| Ble device address string size. | |
Typedefs | |
| typedef struct Ble | Ble |
| Opaque Ble type declaration. | |
Enumerations | |
| enum | BleServiceStatus { BleServiceStatusReset , BleServiceStatusInitialization , BleServiceStatusReady , BleServiceStatusAdvertising , BleServiceStatusConnectable , BleServiceStatusConnected , BleServiceStatusError , BleServiceStatusCount } |
| Enumeration of ble service statuses. More... | |
| enum | BleUartChannel { BleUartChannelNordic , BleUartChannelHM10 , BleUartChannelCount } |
| Enumeration of ble uart channels which public ble uart api sets in order to read/write data. More... | |
Functions | |
| bool | ble_get_state (Ble *ble, BleState *const output) |
| Get ble state. | |
| bool | ble_start (Ble *ble) |
| Enable ble by sending BleCommandEnable. | |
| bool | ble_stop (Ble *ble) |
| Disable ble by sending BleCommandDisable. | |
| bool | ble_forget (Ble *ble) |
| Forget current pairing with remote device. | |
| FuriPubSub * | ble_get_pubsub (Ble *ble) |
| Get pubsub in order to subscribe on ble events. | |
| void | ble_uart_set_rx_callback (Ble *ble, BleUartChannel channel, BleDataUpdatedCallback rx_cb, void *ctx) |
| Register callback function for ble uart rx characteristic. | |
| void | ble_uart_set_tx_done_callback (Ble *ble, BleUartChannel channel, BleDataTransmitDoneCallback tx_done_cb, void *ctx) |
| Register callback function for ble uart tx characteristic. | |
| void | ble_uart_tx_data (Ble *ble, BleUartChannel channel, const void *data, const size_t data_size) |
| Send data over ble uart. | |
| void | ble_uart_set_session_callback (Ble *ble, BleDataUpdatedCallback session_update_cb, void *ctx) |
| Register session callback function for Nordic Uart service. | |
| void | ble_uart_session_set_value (Ble *ble, const uint32_t session) |
| Set session value for Nordic Uart Session characteristic. | |
Public ble api.
| #define MAX_TX_CHUNK_SIZE (237) |
Defines max data size for characteristics.
Used by ble_http_repeater.h and ble_streaming.h
| enum BleServiceStatus |
Enumeration of ble service statuses.
| enum BleUartChannel |
Enumeration of ble uart channels which public ble uart api sets in order to read/write data.
| Enumerator | |
|---|---|
| BleUartChannelNordic | Points to Nordic Uart ble service, which is used by ble_http_repeater.h. |
| BleUartChannelHM10 | Points to HM10 Uart ble service, which is used by ble_streaming.h. |
| BleUartChannelCount | Total amount of channels. |
| bool ble_forget | ( | Ble * | ble | ) |
Forget current pairing with remote device.
This is a blocking API.
| [in] | ble | pointer to the ble instance |
| FuriPubSub * ble_get_pubsub | ( | Ble * | ble | ) |
Get pubsub in order to subscribe on ble events.
| [in] | ble | pointer to the ble instance |
Get ble state.
This is a blocking API.
| [in] | ble | pointer to the ble instance |
| [in,out] | output | state struct filled with current ble state. |
| bool ble_start | ( | Ble * | ble | ) |
Enable ble by sending BleCommandEnable.
This is a blocking API.
After this command device starts advertising with its name and public or random address depending on pairing state.
| [in] | ble | pointer to the ble instance |
| bool ble_stop | ( | Ble * | ble | ) |
Disable ble by sending BleCommandDisable.
This is a blocking API.
| [in] | ble | pointer to the ble instance |
| void ble_uart_session_set_value | ( | Ble * | ble, |
| const uint32_t | session ) |
Set session value for Nordic Uart Session characteristic.
This api is used for Nordic Uart channel. This is non-blocking API, and it works in same way as ble_uart_tx_data
| [in] | ble | pointer to the ble instance |
| [in] | session | new session value |
| void ble_uart_set_rx_callback | ( | Ble * | ble, |
| BleUartChannel | channel, | ||
| BleDataUpdatedCallback | rx_cb, | ||
| void * | ctx ) |
Register callback function for ble uart rx characteristic.
Callback and context can be set only once, after that any attempts to set new callback will be ignored until NULL value will be provided for callback and context, this will reset callback and new callback can be set after
| [in] | ble | pointer to the ble instance |
| [in] | channel | channel to which callback will be set |
| [in] | rx_cb | pointer to callback function |
| [in] | ctx | pointer to callback function context |
| void ble_uart_set_session_callback | ( | Ble * | ble, |
| BleDataUpdatedCallback | session_update_cb, | ||
| void * | ctx ) |
Register session callback function for Nordic Uart service.
This api is used for Nordic Uart channel only
| [in] | ble | pointer to the ble instance |
| [in] | session_update_cb | pointer to callback function from ble_callback_types.h |
| [in] | ctx | pointer to callback function context |
| void ble_uart_set_tx_done_callback | ( | Ble * | ble, |
| BleUartChannel | channel, | ||
| BleDataTransmitDoneCallback | tx_done_cb, | ||
| void * | ctx ) |
Register callback function for ble uart tx characteristic.
| [in] | ble | pointer to the ble instance |
| [in] | channel | channel to which callback will be set |
| [in] | tx_done_cb | pointer to callback function |
| [in] | ctx | pointer to callback function context |
| void ble_uart_tx_data | ( | Ble * | ble, |
| BleUartChannel | channel, | ||
| const void * | data, | ||
| const size_t | data_size ) |
Send data over ble uart.
Copies payload to tx characteristic of choosen uart channel and triggers ble service to do the rest. This is non-blocking API, synchronisation primitives must be used externally in order to wait for transmission complete. Before that a proper callback must be registered using ble_uart_set_tx_done_callback.
| [in] | ble | pointer to the ble instance |
| [in] | channel | channel to which callback will be set |
| [in] | data | payload to be send |
| [in] | data_size | payload size |