|
HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
|
ESP32 Bluetooth implementation class. More...
#include <EspBluetooth.h>
Public Member Functions | |
| EspBluetooth () | |
| Constructor. | |
| virtual | ~EspBluetooth () |
| Destructor. | |
| hf_bluetooth_err_t | Initialize (hf_bluetooth_mode_t mode) noexcept override |
| Initialize the Bluetooth subsystem. | |
| hf_bluetooth_err_t | Deinitialize () noexcept override |
| Deinitialize the Bluetooth subsystem. | |
| bool | IsInitialized () const noexcept override |
| Check if Bluetooth is initialized. | |
| hf_bluetooth_err_t | Enable () noexcept override |
| Enable Bluetooth. | |
| hf_bluetooth_err_t | Disable () noexcept override |
| Disable Bluetooth. | |
| bool | IsEnabled () const noexcept override |
| Check if Bluetooth is enabled. | |
| hf_bluetooth_err_t | SetMode (hf_bluetooth_mode_t mode) noexcept override |
| Set Bluetooth operating mode. | |
| hf_bluetooth_mode_t | GetMode () const noexcept override |
| Get current Bluetooth operating mode. | |
| hf_bluetooth_err_t | GetLocalAddress (hf_bluetooth_address_t &address) const noexcept override |
| Get local Bluetooth address. | |
| hf_bluetooth_err_t | SetDeviceName (const std::string &name) noexcept override |
| Set local device name. | |
| std::string | GetDeviceName () const noexcept override |
| Get local device name. | |
| hf_bluetooth_err_t | StartScan (uint32_t duration_ms=0, hf_bluetooth_scan_type_t type=hf_bluetooth_scan_type_t::HF_BLUETOOTH_SCAN_TYPE_ACTIVE) noexcept override |
| Start device discovery/scanning. | |
| hf_bluetooth_err_t | StopScan () noexcept override |
| Stop device discovery/scanning. | |
| bool | IsScanning () const noexcept override |
| Check if currently scanning. | |
| hf_bluetooth_err_t | GetDiscoveredDevices (std::vector< hf_bluetooth_device_info_t > &devices) noexcept override |
| Get list of discovered devices. | |
| hf_bluetooth_err_t | ClearDiscoveredDevices () noexcept override |
| Clear discovered devices list. | |
| hf_bluetooth_err_t | StartAdvertising () noexcept override |
| Start BLE advertising. | |
| hf_bluetooth_err_t | StopAdvertising () noexcept override |
| Stop BLE advertising. | |
| bool | IsAdvertising () const noexcept override |
| Check if currently advertising. | |
| hf_bluetooth_err_t | Connect (const hf_bluetooth_address_t &address, uint32_t timeout_ms=0) noexcept override |
| Connect to a remote device. | |
| hf_bluetooth_err_t | Disconnect (const hf_bluetooth_address_t &address) noexcept override |
| Disconnect from a remote device. | |
| bool | IsConnected (const hf_bluetooth_address_t &address) const noexcept override |
| Check if connected to a device. | |
| hf_bluetooth_err_t | GetConnectedDevices (std::vector< hf_bluetooth_device_info_t > &devices) noexcept override |
| Get list of connected devices. | |
| hf_bluetooth_err_t | Pair (const hf_bluetooth_address_t &address, const std::string &pin="") noexcept override |
| Pair with a remote device. | |
| hf_bluetooth_err_t | Unpair (const hf_bluetooth_address_t &address) noexcept override |
| Unpair from a remote device. | |
| bool | IsPaired (const hf_bluetooth_address_t &address) const noexcept override |
| Check if paired with a device. | |
| hf_bluetooth_err_t | SendData (const hf_bluetooth_address_t &address, const std::vector< uint8_t > &data) noexcept override |
| Send data to a connected device. | |
| int | GetAvailableData (const hf_bluetooth_address_t &address) const noexcept override |
| Check if data is available to read. | |
| hf_bluetooth_err_t | ReadData (const hf_bluetooth_address_t &address, std::vector< uint8_t > &data, size_t max_bytes=0) noexcept override |
| Read available data from a connected device. | |
| hf_bluetooth_err_t | DiscoverServices (const hf_bluetooth_address_t &address, std::vector< hf_bluetooth_gatt_service_t > &services) noexcept override |
| Discover GATT services on a connected device. | |
| hf_bluetooth_err_t | DiscoverCharacteristics (const hf_bluetooth_address_t &address, const std::string &service_uuid, std::vector< hf_bluetooth_gatt_characteristic_t > &characteristics) noexcept override |
| Discover GATT characteristics for a service. | |
| hf_bluetooth_err_t | ReadCharacteristic (const hf_bluetooth_address_t &address, const std::string &service_uuid, const std::string &characteristic_uuid, std::vector< uint8_t > &value) noexcept override |
| Read GATT characteristic value. | |
| hf_bluetooth_err_t | WriteCharacteristic (const hf_bluetooth_address_t &address, const std::string &service_uuid, const std::string &characteristic_uuid, const std::vector< uint8_t > &value, bool with_response=true) noexcept override |
| Write GATT characteristic value. | |
| hf_bluetooth_err_t | SubscribeCharacteristic (const hf_bluetooth_address_t &address, const std::string &service_uuid, const std::string &characteristic_uuid, bool enable) noexcept override |
| Subscribe to GATT characteristic notifications. | |
| hf_bluetooth_state_t | GetState () const noexcept override |
| Get current Bluetooth state. | |
| int8_t | GetRssi (const hf_bluetooth_address_t &address) const noexcept override |
| Get signal strength for a connected device. | |
| hf_bluetooth_err_t | RegisterEventCallback (hf_bluetooth_event_callback_t callback) noexcept override |
| Register event callback function. | |
| hf_bluetooth_err_t | RegisterDataCallback (hf_bluetooth_data_callback_t callback) noexcept override |
| Register data callback function. | |
| hf_bluetooth_err_t | UnregisterEventCallback () noexcept override |
| Unregister event callback function. | |
| hf_bluetooth_err_t | UnregisterDataCallback () noexcept override |
| Unregister data callback function. | |
| hf_bluetooth_err_t | ConfigureClassic (const hf_bluetooth_classic_config_t &config) noexcept override |
| Configure Bluetooth Classic parameters. | |
| hf_bluetooth_err_t | SetDiscoverable (bool discoverable, uint32_t timeout_ms=0) noexcept override |
| Make device discoverable. | |
| bool | IsDiscoverable () const noexcept override |
| Check if device is discoverable. | |
| hf_bluetooth_err_t | ConfigureBle (const hf_bluetooth_ble_config_t &config) noexcept override |
| Configure Bluetooth Low Energy parameters. | |
| hf_bluetooth_err_t | GetPairedDevices (std::vector< hf_bluetooth_device_info_t > &devices) noexcept override |
| Get list of paired devices. | |
| std::string | GetImplementationInfo () const |
| Get implementation-specific information. | |
| uint32_t | GetSupportedFeatures () const |
| Get supported features for current target. | |
Public Member Functions inherited from BaseBluetooth | |
| virtual | ~BaseBluetooth () noexcept=default |
| Virtual destructor for proper cleanup of derived classes. | |
Private Member Functions | |
| void | TriggerEvent (hf_bluetooth_event_t event, const void *data=nullptr) |
| hf_bluetooth_err_t | ValidateAddress (const hf_bluetooth_address_t &address) const |
| std::string | AddressToString (const hf_bluetooth_address_t &address) const |
| hf_bluetooth_address_t | StringToAddress (const std::string &address_str) const |
Private Attributes | |
| bool | m_initialized |
| bool | m_enabled |
| hf_bluetooth_mode_t | m_mode |
| hf_bluetooth_state_t | m_state |
| std::vector< hf_bluetooth_device_info_t > | m_discovered_devices |
| std::map< std::string, hf_bluetooth_device_info_t > | m_connected_devices |
| hf_bluetooth_ble_config_t | m_ble_config |
| PlatformMutex | m_device_mutex |
| PlatformMutex | m_state_mutex |
| hf_bluetooth_event_callback_t | m_event_callback |
| hf_bluetooth_data_callback_t | m_data_callback |
| void * | m_callback_context |
Additional Inherited Members | |
Static Public Member Functions inherited from BaseBluetooth | |
| static std::string_view | GetErrorString (hf_bluetooth_err_t error) |
| Get error description string. | |
Protected Member Functions inherited from BaseBluetooth | |
| BaseBluetooth ()=default | |
| Protected constructor - only derived classes can instantiate. | |
| BaseBluetooth (const BaseBluetooth &)=delete | |
| Copy constructor - deleted to prevent copying. | |
| BaseBluetooth & | operator= (const BaseBluetooth &)=delete |
| Assignment operator - deleted to prevent copying. | |
ESP32 Bluetooth implementation class.
This class provides ESP32-specific Bluetooth functionality with conditional compilation for different ESP32 variants:
| EspBluetooth::EspBluetooth | ( | ) |
Constructor.
|
virtual |
Destructor.
|
private |
|
overridevirtualnoexcept |
Clear discovered devices list.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Configure Bluetooth Low Energy parameters.
| config | BLE configuration |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Configure Bluetooth Classic parameters.
| config | Classic configuration |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Connect to a remote device.
| address | Remote device address |
| timeout_ms | Connection timeout in milliseconds (0 for default) |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Deinitialize the Bluetooth subsystem.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Disable Bluetooth.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Disconnect from a remote device.
| address | Remote device address |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Discover GATT characteristics for a service.
| address | Remote device address |
| service_uuid | Service UUID |
| characteristics | Vector to store discovered characteristics |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Discover GATT services on a connected device.
| address | Remote device address |
| services | Vector to store discovered services |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Enable Bluetooth.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Check if data is available to read.
| address | Remote device address |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Get list of connected devices.
| devices | Vector to store connected devices |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Get list of discovered devices.
| devices | Vector to store discovered devices |
Implements BaseBluetooth.
| std::string EspBluetooth::GetImplementationInfo | ( | ) | const |
Get implementation-specific information.
|
overridevirtualnoexcept |
Get local Bluetooth address.
| address | Reference to store the local address |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Get list of paired devices.
| devices | Vector to store paired devices |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Get signal strength for a connected device.
| address | Remote device address |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
| uint32_t EspBluetooth::GetSupportedFeatures | ( | ) | const |
Get supported features for current target.
|
overridevirtualnoexcept |
Initialize the Bluetooth subsystem.
| mode | Bluetooth operating mode |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Check if currently advertising.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Check if connected to a device.
| address | Remote device address |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Check if device is discoverable.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Check if Bluetooth is initialized.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Check if paired with a device.
| address | Remote device address |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Pair with a remote device.
| address | Remote device address |
| pin | PIN code (for Classic, empty for BLE) |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Read GATT characteristic value.
| address | Remote device address |
| service_uuid | Service UUID |
| characteristic_uuid | Characteristic UUID |
| value | Vector to store characteristic value |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Read available data from a connected device.
| address | Remote device address |
| data | Vector to store received data |
| max_bytes | Maximum bytes to read (0 for all available) |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Register data callback function.
| callback | Callback function |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Register event callback function.
| callback | Callback function |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Send data to a connected device.
| address | Remote device address |
| data | Data to send |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Set local device name.
| name | Device name string |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Make device discoverable.
| discoverable | True to make discoverable, false otherwise |
| timeout_ms | Discoverable timeout in milliseconds (0 for indefinite) |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Set Bluetooth operating mode.
| mode | Bluetooth operating mode |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Start BLE advertising.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Start device discovery/scanning.
| duration_ms | Scan duration in milliseconds (0 for indefinite) |
| type | Scan type (BLE only) |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Stop BLE advertising.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Stop device discovery/scanning.
Implements BaseBluetooth.
|
private |
|
overridevirtualnoexcept |
Subscribe to GATT characteristic notifications.
| address | Remote device address |
| service_uuid | Service UUID |
| characteristic_uuid | Characteristic UUID |
| enable | True to enable notifications, false to disable |
Implements BaseBluetooth.
|
private |
|
overridevirtualnoexcept |
Unpair from a remote device.
| address | Remote device address |
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Unregister data callback function.
Implements BaseBluetooth.
|
overridevirtualnoexcept |
Unregister event callback function.
Implements BaseBluetooth.
|
private |
|
overridevirtualnoexcept |
Write GATT characteristic value.
| address | Remote device address |
| service_uuid | Service UUID |
| characteristic_uuid | Characteristic UUID |
| value | Value to write |
| with_response | True to wait for write response |
Implements BaseBluetooth.
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |