HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
Bluetooth Module

All Bluetooth-related types, enums, and functions for wireless communication operations. More...

Files

file  BaseBluetooth.h
 Unified Bluetooth base class for all Bluetooth implementations.
 
file  EspBluetooth.h
 ESP32 Bluetooth implementation using NimBLE for BLE-only support (ESP32C6)
 
file  EspBluetooth.cpp
 ESP32 Bluetooth implementation using NimBLE for BLE-only support (ESP32C6)
 

Classes

struct  hf_bluetooth_address_t
 Bluetooth address structure (6 bytes) More...
 
struct  hf_bluetooth_device_info_t
 Bluetooth device information structure. More...
 
struct  hf_bluetooth_classic_config_t
 Bluetooth Classic configuration structure. More...
 
struct  hf_bluetooth_ble_config_t
 Bluetooth Low Energy configuration structure. More...
 
struct  hf_bluetooth_gatt_service_t
 GATT service structure. More...
 
struct  hf_bluetooth_gatt_characteristic_t
 GATT characteristic structure. More...
 
class  EspBluetooth
 ESP32 Bluetooth implementation class. More...
 
class  BaseBluetooth
 Abstract base class for Bluetooth functionality. More...
 

Macros

#define HF_BLUETOOTH_ERR_LIST(X)
 HardFOC Bluetooth error codes macro list.
 
#define X(name, value, desc)   name = value,
 Generate Bluetooth error enumeration using X-macro pattern.
 
#define X(NAME, VALUE, DESC)
 Generate Bluetooth error enumeration using X-macro pattern.
 
#define X(name, value, desc)
 Generate Bluetooth error enumeration using X-macro pattern.
 

Typedefs

using hf_bluetooth_event_callback_t
 Bluetooth event callback function type.
 
using hf_bluetooth_data_callback_t
 Data received callback function type.
 

Enumerations

enum class  hf_bluetooth_mode_t : hf_u8_t { hf_bluetooth_mode_t::HF_BLUETOOTH_MODE_DISABLED = 0 , hf_bluetooth_mode_t::HF_BLUETOOTH_MODE_CLASSIC = 1 , hf_bluetooth_mode_t::HF_BLUETOOTH_MODE_BLE = 2 , hf_bluetooth_mode_t::HF_BLUETOOTH_MODE_DUAL = 3 }
 Bluetooth operating modes. More...
 
enum class  hf_bluetooth_device_type_t : hf_u8_t { hf_bluetooth_device_type_t::HF_BLUETOOTH_DEVICE_TYPE_UNKNOWN = 0 , hf_bluetooth_device_type_t::HF_BLUETOOTH_DEVICE_TYPE_CLASSIC = 1 , hf_bluetooth_device_type_t::HF_BLUETOOTH_DEVICE_TYPE_BLE = 2 , hf_bluetooth_device_type_t::HF_BLUETOOTH_DEVICE_TYPE_DUAL = 3 }
 Bluetooth device types. More...
 
enum class  hf_bluetooth_state_t : hf_u8_t {
  hf_bluetooth_state_t::HF_BLUETOOTH_STATE_DISABLED = 0 , hf_bluetooth_state_t::HF_BLUETOOTH_STATE_ENABLED = 1 , hf_bluetooth_state_t::HF_BLUETOOTH_STATE_SCANNING = 2 , hf_bluetooth_state_t::HF_BLUETOOTH_STATE_CONNECTING = 3 ,
  hf_bluetooth_state_t::HF_BLUETOOTH_STATE_CONNECTED = 4 , hf_bluetooth_state_t::HF_BLUETOOTH_STATE_DISCONNECTING = 5 , hf_bluetooth_state_t::HF_BLUETOOTH_STATE_PAIRING = 6 , hf_bluetooth_state_t::HF_BLUETOOTH_STATE_PAIRED = 7
}
 Bluetooth connection states. More...
 
enum class  hf_bluetooth_security_t : hf_u8_t {
  hf_bluetooth_security_t::HF_BLUETOOTH_SECURITY_NONE = 0 , hf_bluetooth_security_t::HF_BLUETOOTH_SECURITY_UNAUTHENTICATED = 1 , hf_bluetooth_security_t::HF_BLUETOOTH_SECURITY_AUTHENTICATED = 2 , hf_bluetooth_security_t::HF_BLUETOOTH_SECURITY_AUTHORIZED = 3 ,
  hf_bluetooth_security_t::HF_BLUETOOTH_SECURITY_ENCRYPTED = 4 , hf_bluetooth_security_t::HF_BLUETOOTH_SECURITY_AUTHENTICATED_SC = 5
}
 Bluetooth security levels. More...
 
enum class  hf_bluetooth_scan_type_t : hf_u8_t { hf_bluetooth_scan_type_t::HF_BLUETOOTH_SCAN_TYPE_PASSIVE = 0 , hf_bluetooth_scan_type_t::HF_BLUETOOTH_SCAN_TYPE_ACTIVE = 1 }
 Bluetooth scan types. More...
 
enum class  hf_bluetooth_scan_mode_t : hf_u8_t { hf_bluetooth_scan_mode_t::HF_BLUETOOTH_SCAN_MODE_GENERAL_INQUIRY = 0 , hf_bluetooth_scan_mode_t::HF_BLUETOOTH_SCAN_MODE_LE_GENERAL = 1 , hf_bluetooth_scan_mode_t::HF_BLUETOOTH_SCAN_MODE_LE_LIMITED = 2 }
 Bluetooth scan modes. More...
 
enum class  hf_bluetooth_connection_type_t : hf_u8_t { hf_bluetooth_connection_type_t::HF_BLUETOOTH_CONNECTION_TYPE_AUTO = 0 , hf_bluetooth_connection_type_t::HF_BLUETOOTH_CONNECTION_TYPE_CLASSIC = 1 , hf_bluetooth_connection_type_t::HF_BLUETOOTH_CONNECTION_TYPE_BLE = 2 }
 Bluetooth connection types. More...
 
enum class  hf_bluetooth_connection_state_t : hf_u8_t {
  hf_bluetooth_connection_state_t::HF_BLUETOOTH_CONNECTION_STATE_DISCONNECTED = 0 , hf_bluetooth_connection_state_t::HF_BLUETOOTH_CONNECTION_STATE_CONNECTING = 1 , hf_bluetooth_connection_state_t::HF_BLUETOOTH_CONNECTION_STATE_CONNECTED = 2 , hf_bluetooth_connection_state_t::HF_BLUETOOTH_CONNECTION_STATE_ADVERTISING = 3 ,
  hf_bluetooth_connection_state_t::HF_BLUETOOTH_CONNECTION_STATE_SCANNING = 4
}
 Bluetooth connection states. More...
 
enum class  hf_bluetooth_event_t : hf_u8_t {
  hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_ENABLED = 0 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_DISABLED = 1 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_SCAN_START = 2 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_SCAN_STOP = 3 ,
  hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_DEVICE_FOUND = 4 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_PAIR_REQUEST = 5 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_PAIR_SUCCESS = 6 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_PAIR_FAILED = 7 ,
  hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_UNPAIR_SUCCESS = 8 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_CONNECT_SUCCESS = 9 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_CONNECT_FAILED = 10 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_DISCONNECT = 11 ,
  hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_DATA_RECEIVED = 12 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_DATA_SENT = 13 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_GATT_SERVICE_DISCOVERED = 14 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_GATT_CHARACTERISTIC_READ = 15 ,
  hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_GATT_CHARACTERISTIC_WRITE = 16 , hf_bluetooth_event_t::HF_BLUETOOTH_EVENT_GATT_NOTIFICATION = 17
}
 Bluetooth event types for callback functions. More...
 

Functions

constexpr std::string_view HfBluetoothErrToString (hf_bluetooth_err_t err) noexcept
 Convert hf_bluetooth_err_t to human-readable string.
 
static std::string_view BaseBluetooth::GetErrorString (hf_bluetooth_err_t error)
 Get error description string.
 
std::string hf_bluetooth_address_t::ToString () const
 Convert address to string format.
 

Detailed Description

All Bluetooth-related types, enums, and functions for wireless communication operations.

This module provides comprehensive Bluetooth functionality including:

Macro Definition Documentation

◆ HF_BLUETOOTH_ERR_LIST

#define HF_BLUETOOTH_ERR_LIST ( X)

HardFOC Bluetooth error codes macro list.

X-macro pattern for comprehensive error enumeration. Each entry contains: X(NAME, VALUE, DESCRIPTION)

◆ X [1/3]

#define X ( name,
value,
desc )   name = value,

Generate Bluetooth error enumeration using X-macro pattern.

◆ X [2/3]

#define X ( NAME,
VALUE,
DESC )
Value:
case hf_bluetooth_err_t::NAME: \
return DESC;

Generate Bluetooth error enumeration using X-macro pattern.

◆ X [3/3]

#define X ( name,
value,
desc )
Value:
case hf_bluetooth_err_t::name: \
return desc;

Generate Bluetooth error enumeration using X-macro pattern.

Typedef Documentation

◆ hf_bluetooth_data_callback_t

Initial value:
std::function<void(const hf_bluetooth_address_t& address, const std::vector<uint8_t>& data)>
Bluetooth address structure (6 bytes)
Definition BaseBluetooth.h:245

Data received callback function type.

◆ hf_bluetooth_event_callback_t

Initial value:
std::function<void(hf_bluetooth_event_t event, void* event_data)>
hf_bluetooth_event_t
Bluetooth event types for callback functions.
Definition BaseBluetooth.h:220

Bluetooth event callback function type.

Enumeration Type Documentation

◆ hf_bluetooth_connection_state_t

Bluetooth connection states.

Enumerator
HF_BLUETOOTH_CONNECTION_STATE_DISCONNECTED 

Disconnected

HF_BLUETOOTH_CONNECTION_STATE_CONNECTING 

Connecting

HF_BLUETOOTH_CONNECTION_STATE_CONNECTED 

Connected

HF_BLUETOOTH_CONNECTION_STATE_ADVERTISING 

Advertising

HF_BLUETOOTH_CONNECTION_STATE_SCANNING 

Scanning

◆ hf_bluetooth_connection_type_t

Bluetooth connection types.

Enumerator
HF_BLUETOOTH_CONNECTION_TYPE_AUTO 

Auto-detect connection type

HF_BLUETOOTH_CONNECTION_TYPE_CLASSIC 

Classic Bluetooth only

HF_BLUETOOTH_CONNECTION_TYPE_BLE 

BLE only

◆ hf_bluetooth_device_type_t

enum class hf_bluetooth_device_type_t : hf_u8_t
strong

Bluetooth device types.

Enumerator
HF_BLUETOOTH_DEVICE_TYPE_UNKNOWN 

Unknown device type

HF_BLUETOOTH_DEVICE_TYPE_CLASSIC 

Bluetooth Classic device

HF_BLUETOOTH_DEVICE_TYPE_BLE 

Bluetooth Low Energy device

HF_BLUETOOTH_DEVICE_TYPE_DUAL 

Dual-mode device

◆ hf_bluetooth_event_t

enum class hf_bluetooth_event_t : hf_u8_t
strong

Bluetooth event types for callback functions.

Enumerator
HF_BLUETOOTH_EVENT_ENABLED 

Bluetooth enabled

HF_BLUETOOTH_EVENT_DISABLED 

Bluetooth disabled

HF_BLUETOOTH_EVENT_SCAN_START 

Scan started

HF_BLUETOOTH_EVENT_SCAN_STOP 

Scan stopped

HF_BLUETOOTH_EVENT_DEVICE_FOUND 

Device discovered

HF_BLUETOOTH_EVENT_PAIR_REQUEST 

Pairing request received

HF_BLUETOOTH_EVENT_PAIR_SUCCESS 

Pairing successful

HF_BLUETOOTH_EVENT_PAIR_FAILED 

Pairing failed

HF_BLUETOOTH_EVENT_UNPAIR_SUCCESS 

Unpairing successful

HF_BLUETOOTH_EVENT_CONNECT_SUCCESS 

Connection successful

HF_BLUETOOTH_EVENT_CONNECT_FAILED 

Connection failed

HF_BLUETOOTH_EVENT_DISCONNECT 

Device disconnected

HF_BLUETOOTH_EVENT_DATA_RECEIVED 

Data received

HF_BLUETOOTH_EVENT_DATA_SENT 

Data sent

HF_BLUETOOTH_EVENT_GATT_SERVICE_DISCOVERED 

GATT service discovered

HF_BLUETOOTH_EVENT_GATT_CHARACTERISTIC_READ 

GATT characteristic read

HF_BLUETOOTH_EVENT_GATT_CHARACTERISTIC_WRITE 

GATT characteristic written

HF_BLUETOOTH_EVENT_GATT_NOTIFICATION 

GATT notification received

◆ hf_bluetooth_mode_t

enum class hf_bluetooth_mode_t : hf_u8_t
strong

Bluetooth operating modes.

Enumerator
HF_BLUETOOTH_MODE_DISABLED 

Bluetooth disabled

HF_BLUETOOTH_MODE_CLASSIC 

Bluetooth Classic only

HF_BLUETOOTH_MODE_BLE 

Bluetooth Low Energy only

HF_BLUETOOTH_MODE_DUAL 

Both Classic and BLE

◆ hf_bluetooth_scan_mode_t

enum class hf_bluetooth_scan_mode_t : hf_u8_t
strong

Bluetooth scan modes.

Enumerator
HF_BLUETOOTH_SCAN_MODE_GENERAL_INQUIRY 

General inquiry scan

HF_BLUETOOTH_SCAN_MODE_LE_GENERAL 

BLE general discovery

HF_BLUETOOTH_SCAN_MODE_LE_LIMITED 

BLE limited discovery

◆ hf_bluetooth_scan_type_t

enum class hf_bluetooth_scan_type_t : hf_u8_t
strong

Bluetooth scan types.

Enumerator
HF_BLUETOOTH_SCAN_TYPE_PASSIVE 

Passive scanning

HF_BLUETOOTH_SCAN_TYPE_ACTIVE 

Active scanning

◆ hf_bluetooth_security_t

enum class hf_bluetooth_security_t : hf_u8_t
strong

Bluetooth security levels.

Enumerator
HF_BLUETOOTH_SECURITY_NONE 

No security

HF_BLUETOOTH_SECURITY_UNAUTHENTICATED 

Unauthenticated pairing

HF_BLUETOOTH_SECURITY_AUTHENTICATED 

Authenticated pairing

HF_BLUETOOTH_SECURITY_AUTHORIZED 

Authorized connection

HF_BLUETOOTH_SECURITY_ENCRYPTED 

Encrypted connection

HF_BLUETOOTH_SECURITY_AUTHENTICATED_SC 

Authenticated Secure Connections

◆ hf_bluetooth_state_t

enum class hf_bluetooth_state_t : hf_u8_t
strong

Bluetooth connection states.

Enumerator
HF_BLUETOOTH_STATE_DISABLED 

Bluetooth disabled

HF_BLUETOOTH_STATE_ENABLED 

Bluetooth enabled but not connected

HF_BLUETOOTH_STATE_SCANNING 

Scanning for devices

HF_BLUETOOTH_STATE_CONNECTING 

Attempting to connect

HF_BLUETOOTH_STATE_CONNECTED 

Connected to device

HF_BLUETOOTH_STATE_DISCONNECTING 

Disconnecting from device

HF_BLUETOOTH_STATE_PAIRING 

Pairing with device

HF_BLUETOOTH_STATE_PAIRED 

Paired with device

Function Documentation

◆ GetErrorString()

std::string_view BaseBluetooth::GetErrorString ( hf_bluetooth_err_t error)
inlinestatic

Get error description string.

Helper function to convert error enum to string.

Parameters
errorError code
Returns
Error description string

◆ HfBluetoothErrToString()

constexpr std::string_view HfBluetoothErrToString ( hf_bluetooth_err_t err)
constexprnoexcept

Convert hf_bluetooth_err_t to human-readable string.

Parameters
errThe error code to convert
Returns
Pointer to error description string

◆ ToString()

std::string hf_bluetooth_address_t::ToString ( ) const
inline

Convert address to string format.

Helper function implementations for hf_bluetooth_address_t.

Returns
Address string in format "XX:XX:XX:XX:XX:XX"