Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
lampda::hal::ble Namespace Reference

Handle the platform specific bluetooth operations. More...

Classes

struct  gap_addr_t
 
struct  hal_ble_adv_params_t
 Advertising Parameters. More...
 
struct  hal_ble_characteristic_t
 GATT Characteristic Definition. More...
 
struct  hal_ble_conn_params_t
 Connection Parameters. More...
 
struct  hal_ble_event_callbacks_t
 BLE Event Callback Collection. More...
 
struct  hal_ble_sec_config_t
 Security Configuration. More...
 
struct  hal_ble_service_t
 GATT Service Definition. More...
 
struct  hal_ble_uuid_t
 UUID structure (supports both 16-bit and 128-bit) More...
 

Typedefs

using hal_ble_conn_handle_t = uint16_t
 Characteristic Read/Write Callback Context.
 
using hal_ble_write_callback_t = void(*)(hal_ble_conn_handle_t conn_handle, const uint8_t *data, uint16_t length)
 Callback fired when Central writes to a characteristic.
 
using hal_ble_read_callback_t = int32_t(*)(hal_ble_conn_handle_t conn_handle, uint16_t char_handle, uint8_t *data, uint16_t max_length)
 Callback fired when Central reads a characteristic.
 
using hal_ble_char_handle_t = uint16_t
 Characteristic Descriptor Handle Storage.
 
using hal_ble_pairing_complete_cb_t = void(*)(hal_ble_conn_handle_t conn_handle, hal::ble::hal_ble_pairing_result code)
 Pairing Completed Callback.
 
using hal_ble_secure_cb_t = void(*)(hal_ble_conn_handle_t conn_handle)
 Connection secured Callback.
 
using hal_ble_advertising_stops_cb_t = void(*)()
 Advertising stopped callback.
 
using hal_ble_conn_state_cb_t = void(*)(hal_ble_conn_handle_t conn_handle)
 Connection State Change Callback.
 
using hal_ble_disconn_state_cb_t = void(*)(hal_ble_conn_handle_t conn_handle, uint8_t reason)
 Disconnection State Change Callback.
 

Enumerations

enum class  hal_ble_uuid_type_t { TYPE_16BIT , TYPE_128BIT }
 UUID (Universally Unique Identifier) type. More...
 
enum class  hal_ble_gatt_perm_t : uint8_t { READ = 0x01 , READ_ENCRYPTED = 0x02 , WRITE = 0x04 , WRITE_ENCRYPTED = 0x08 }
 GATT (Generic Attribute Profile) Attribute Permissions. More...
 
enum class  hal_ble_gatt_prop_t : uint8_t {
  READ = 0x01 , WRITE_NO_RSP = 0x02 , WRITE = 0x04 , NOTIFY = 0x08 ,
  INDICATE = 0x10 , BROADCAST = 0x20
}
 GATT Characteristic Properties. More...
 
enum class  hal_ble_pairing_result : uint8_t {
  SUCCESS = 0 , UNSPECIFIED , TIMEOUT , AUTH_REQ ,
  PAIRING_NOT_SUPP , REPEATED_ATTEMPTS , INVALID_PARAMS
}
 pairing result code More...
 
enum class  hal_ble_adress_type : uint8_t {
  hal_ble_adress_type::INVALID , hal_ble_adress_type::PUBLIC , hal_ble_adress_type::RANDOM_STATIC , hal_ble_adress_type::RANDOM_PRIVATE_RESOLVABLE ,
  hal_ble_adress_type::RANDOM_PRIVATE_NON_RESOLVABLE , hal_ble_adress_type::ANONYMOUS
}
 
enum class  hal_ble_feature_t { HAL_BLE_FEATURE_BONDING , HAL_BLE_FEATURE_LE_SECURE_CONNECTIONS , hal_ble_feature_t::HAL_BLE_FEATURE_DLE , hal_ble_feature_t::HAL_BLE_FEATURE_MULTI_ROLE }
 Query BLE Feature Support. More...
 

Functions

int32_t hal_ble_init (const char *device_name, const hal_ble_event_callbacks_t *callbacks)
 Initialize BLE Stack.
 
int32_t hal_ble_deinit (void)
 Deinitialize BLE Stack.
 
bool hal_ble_is_initialized (void)
 Check if BLE Stack is Initialized.
 
int32_t hal_ble_add_service (hal_ble_service_t *service, const bool addToAdvertised)
 Add a Service to GATT Database.
 
int32_t hal_ble_add_characteristic (hal_ble_characteristic_t *characteristic)
 Add a Characteristic to the Current Service.
 
int32_t hal_ble_set_characteristic_value (hal_ble_char_handle_t char_handle, const uint8_t *data, uint16_t length)
 Update Characteristic Value.
 
int32_t hal_ble_get_characteristic_value (hal_ble_char_handle_t char_handle, uint8_t *data, uint16_t max_length)
 Read Current Characteristic Value.
 
int32_t hal_ble_notify (hal_ble_char_handle_t char_handle, const uint8_t *data, uint16_t length)
 Send Notification to All Connected Centrals.
 
int32_t hal_ble_indicate (hal_ble_conn_handle_t conn_handle, hal_ble_char_handle_t char_handle, const uint8_t *data, uint16_t length)
 Send Indication to a Specific Connected Central.
 
int32_t hal_ble_start_advertising (const hal_ble_adv_params_t *adv_params)
 Start Advertising (Peripheral Becomes Discoverable)
 
int32_t hal_ble_stop_advertising (void)
 Stop Advertising.
 
bool hal_ble_is_advertising (void)
 Check if Currently Advertising.
 
int32_t hal_ble_disconnect (hal_ble_conn_handle_t conn_handle)
 Disconnect a Connected Central.
 
hal_ble_conn_handle_t hal_ble_get_connection_handle ()
 Return the current connection handle.
 
int32_t hal_ble_get_mtu (hal_ble_conn_handle_t conn_handle)
 Get Current MTU (Maximum Transmission Unit) Size.
 
int32_t hal_ble_set_security_config (const hal_ble_sec_config_t *sec_config)
 Configure Security Parameters.
 
int32_t hal_ble_start_pairing (hal_ble_conn_handle_t conn_handle)
 Initiate Pairing from Peripheral Side.
 
int32_t hal_ble_clear_bonds (void)
 Clear All Stored Bonds (Forget Paired Centrals)
 
int32_t hal_ble_set_device_name (const char *name)
 Set Device Name.
 
int32_t hal_ble_get_device_name (char *name, uint16_t max_length)
 Get Device Name.
 
int32_t hal_ble_set_tx_power (int8_t tx_power_dbm)
 Set TX Power (Transmit Power)
 
int8_t hal_ble_get_tx_power (void)
 Get TX Power.
 
uint8_t hal_ble_get_connection_count (void)
 Get Number of Active Connections.
 
bool hal_ble_is_connected (hal_ble_conn_handle_t conn_handle)
 Get Connection State.
 
int8_t hal_ble_get_rssi (hal_ble_conn_handle_t conn_handle)
 Get Connection Signal Strength (RSSI)
 
gap_addr_t hal_ble_get_address (hal_ble_conn_handle_t conn_handle)
 Return the adress of the connected device.
 
bool hal_ble_can_load_bound_key (hal_ble_conn_handle_t conn_handle)
 
bool hal_ble_has_feature (hal_ble_feature_t feature)
 Check if Feature is Supported.
 

Detailed Description

Handle the platform specific bluetooth operations.

Enumeration Type Documentation

◆ hal_ble_gatt_perm_t

enum class lampda::hal::ble::hal_ble_gatt_perm_t : uint8_t
strong

GATT (Generic Attribute Profile) Attribute Permissions.

Controls who can read/write characteristic values.

Enumerator
READ 

Client can read

READ_ENCRYPTED 

Read only over encrypted link

WRITE 

Client can write

WRITE_ENCRYPTED 

Write only over encrypted link

◆ hal_ble_gatt_prop_t

enum class lampda::hal::ble::hal_ble_gatt_prop_t : uint8_t
strong

GATT Characteristic Properties.

Defines how clients interact with a characteristic.

Enumerator
READ 

Client can read value

WRITE_NO_RSP 

Write without response

WRITE 

Write with response (acknowledgment)

NOTIFY 

Server sends notifications (no ack)

INDICATE 

Server sends indications (requires ack)

BROADCAST 

Can be broadcast (advertising data)

◆ hal_ble_pairing_result

enum class lampda::hal::ble::hal_ble_pairing_result : uint8_t
strong

pairing result code

Enumerator
UNSPECIFIED 

Unspecified reason.

TIMEOUT 

Procedure timed out.

AUTH_REQ 

Authentication requirements not met.

PAIRING_NOT_SUPP 

Pairing not supported.

REPEATED_ATTEMPTS 

Too little time elapsed since last attempt.

INVALID_PARAMS 

Invalid parameters.

◆ hal_ble_uuid_type_t

UUID (Universally Unique Identifier) type.

Supports both:

  • 16-bit UUIDs (BLE standard shortcuts, e.g., 0x180A for Device Information)
  • 128-bit UUIDs (vendor-specific custom services)
Enumerator
TYPE_16BIT 

Standard BLE 16-bit UUID

TYPE_128BIT 

Vendor-specific 128-bit UUID