|
Lamp-Da 0.1
A compact lantern project
|
Namespaces | |
| namespace | lampda::hal::ble::services::battery |
| OTA battery level service. | |
| namespace | lampda::hal::ble::services::uart |
| OTA UART connection. | |
Classes | |
| struct | lampda::hal::ble::gap_addr_t |
| struct | lampda::hal::ble::hal_ble_characteristic_t |
| GATT Characteristic Definition. More... | |
| struct | lampda::hal::ble::hal_ble_service_t |
| GATT Service Definition. More... | |
| struct | lampda::hal::ble::hal_ble_sec_config_t |
| Security Configuration. More... | |
| struct | lampda::hal::ble::hal_ble_adv_params_t |
| Advertising Parameters. More... | |
| struct | lampda::hal::ble::hal_ble_conn_params_t |
| Connection Parameters. More... | |
| struct | lampda::hal::ble::hal_ble_event_callbacks_t |
| BLE Event Callback Collection. More... | |
| struct | lampda::hal::ble::services::system_infos::Infos |
Typedefs | |
| using | lampda::hal::ble::hal_ble_conn_handle_t = uint16_t |
| Characteristic Read/Write Callback Context. | |
| using | lampda::hal::ble::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 | lampda::hal::ble::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 | lampda::hal::ble::hal_ble_char_handle_t = uint16_t |
| Characteristic Descriptor Handle Storage. | |
| using | lampda::hal::ble::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 | lampda::hal::ble::hal_ble_secure_cb_t = void(*)(hal_ble_conn_handle_t conn_handle) |
| Connection secured Callback. | |
| using | lampda::hal::ble::hal_ble_advertising_stops_cb_t = void(*)() |
| Advertising stopped callback. | |
| using | lampda::hal::ble::hal_ble_conn_state_cb_t = void(*)(hal_ble_conn_handle_t conn_handle) |
| Connection State Change Callback. | |
| using | lampda::hal::ble::hal_ble_disconn_state_cb_t = void(*)(hal_ble_conn_handle_t conn_handle, uint8_t reason) |
| Disconnection State Change Callback. | |
Enumerations | |
| enum class | lampda::hal::ble::hal_ble_adress_type : uint8_t { lampda::hal::ble::hal_ble_adress_type::INVALID , lampda::hal::ble::hal_ble_adress_type::PUBLIC , lampda::hal::ble::hal_ble_adress_type::RANDOM_STATIC , lampda::hal::ble::hal_ble_adress_type::RANDOM_PRIVATE_RESOLVABLE , lampda::hal::ble::hal_ble_adress_type::RANDOM_PRIVATE_NON_RESOLVABLE , lampda::hal::ble::hal_ble_adress_type::ANONYMOUS } |
| enum class | lampda::hal::ble::hal_ble_feature_t { HAL_BLE_FEATURE_BONDING , HAL_BLE_FEATURE_LE_SECURE_CONNECTIONS , lampda::hal::ble::hal_ble_feature_t::HAL_BLE_FEATURE_DLE , lampda::hal::ble::hal_ble_feature_t::HAL_BLE_FEATURE_MULTI_ROLE } |
| Query BLE Feature Support. More... | |
Functions | |
| int32_t | lampda::hal::ble::hal_ble_init (const char *device_name, const hal_ble_event_callbacks_t *callbacks) |
| Initialize BLE Stack. | |
| int32_t | lampda::hal::ble::hal_ble_deinit (void) |
| Deinitialize BLE Stack. | |
| bool | lampda::hal::ble::hal_ble_is_initialized (void) |
| Check if BLE Stack is Initialized. | |
| int32_t | lampda::hal::ble::hal_ble_add_service (hal_ble_service_t *service, const bool addToAdvertised) |
| Add a Service to GATT Database. | |
| int32_t | lampda::hal::ble::hal_ble_add_characteristic (hal_ble_characteristic_t *characteristic) |
| Add a Characteristic to the Current Service. | |
| int32_t | lampda::hal::ble::hal_ble_set_characteristic_value (hal_ble_char_handle_t char_handle, const uint8_t *data, uint16_t length) |
| Update Characteristic Value. | |
| int32_t | lampda::hal::ble::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 | lampda::hal::ble::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 | lampda::hal::ble::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 | lampda::hal::ble::hal_ble_start_advertising (const hal_ble_adv_params_t *adv_params) |
| Start Advertising (Peripheral Becomes Discoverable) | |
| int32_t | lampda::hal::ble::hal_ble_stop_advertising (void) |
| Stop Advertising. | |
| bool | lampda::hal::ble::hal_ble_is_advertising (void) |
| Check if Currently Advertising. | |
| int32_t | lampda::hal::ble::hal_ble_disconnect (hal_ble_conn_handle_t conn_handle) |
| Disconnect a Connected Central. | |
| hal_ble_conn_handle_t | lampda::hal::ble::hal_ble_get_connection_handle () |
| Return the current connection handle. | |
| int32_t | lampda::hal::ble::hal_ble_get_mtu (hal_ble_conn_handle_t conn_handle) |
| Get Current MTU (Maximum Transmission Unit) Size. | |
| int32_t | lampda::hal::ble::hal_ble_set_security_config (const hal_ble_sec_config_t *sec_config) |
| Configure Security Parameters. | |
| int32_t | lampda::hal::ble::hal_ble_start_pairing (hal_ble_conn_handle_t conn_handle) |
| Initiate Pairing from Peripheral Side. | |
| int32_t | lampda::hal::ble::hal_ble_clear_bonds (void) |
| Clear All Stored Bonds (Forget Paired Centrals) | |
| int32_t | lampda::hal::ble::hal_ble_set_device_name (const char *name) |
| Set Device Name. | |
| int32_t | lampda::hal::ble::hal_ble_get_device_name (char *name, uint16_t max_length) |
| Get Device Name. | |
| int32_t | lampda::hal::ble::hal_ble_set_tx_power (int8_t tx_power_dbm) |
| Set TX Power (Transmit Power) | |
| int8_t | lampda::hal::ble::hal_ble_get_tx_power (void) |
| Get TX Power. | |
| uint8_t | lampda::hal::ble::hal_ble_get_connection_count (void) |
| Get Number of Active Connections. | |
| bool | lampda::hal::ble::hal_ble_is_connected (hal_ble_conn_handle_t conn_handle) |
| Get Connection State. | |
| int8_t | lampda::hal::ble::hal_ble_get_rssi (hal_ble_conn_handle_t conn_handle) |
| Get Connection Signal Strength (RSSI) | |
| gap_addr_t | lampda::hal::ble::hal_ble_get_address (hal_ble_conn_handle_t conn_handle) |
| Return the adress of the connected device. | |
| bool | lampda::hal::ble::hal_ble_can_load_bound_key (hal_ble_conn_handle_t conn_handle) |
| bool | lampda::hal::ble::hal_ble_has_feature (hal_ble_feature_t feature) |
| Check if Feature is Supported. | |
| void | lampda::hal::ble::services::battery::init (const uint8_t batteryLevel, const bool addToAdvertised) |
| Init the service, with an initial value (0-100) | |
| void | lampda::hal::ble::services::battery::write_battery_level (const uint8_t batteryLevel) |
| update battery level (0-100) | |
| void | lampda::hal::ble::services::battery::notify_battery_level (const uint8_t batteryLevel) |
| notify the connected device of a battery level (0-100) | |
| void | lampda::hal::ble::services::uart::init (const bool addToAdvertised) |
| Start the uart service. | |
| bool | lampda::hal::ble::services::uart::is_notified_enabled () |
| Return true uart notify is activated. | |
| bool | lampda::hal::ble::services::uart::is_available () |
| Return true if a char is available to read. | |
| char | lampda::hal::ble::services::uart::read () |
| Read a character (blocking) | |
| void | lampda::hal::ble::services::uart::flush () |
| Flush the rx queue. | |
| size_t | lampda::hal::ble::services::uart::write (const char *const buffer, size_t bufferSize) |
| Write a buffer to connected device. | |
| void | lampda::hal::ble::services::system_infos::init (const Infos &sysInfos, const bool addToAdvertised) |
| using lampda::hal::ble::hal_ble_advertising_stops_cb_t = typedef void (*)() |
Advertising stopped callback.
Fired when a the advertising stops for any reason.
| [in] | conn_handle | Connection that paired |
| using lampda::hal::ble::hal_ble_char_handle_t = typedef uint16_t |
Characteristic Descriptor Handle Storage.
Internal (opaque) for platform use.
| using lampda::hal::ble::hal_ble_conn_handle_t = typedef uint16_t |
Characteristic Read/Write Callback Context.
Opaque handle to connection context for callbacks.
| using lampda::hal::ble::hal_ble_conn_state_cb_t = typedef void (*)(hal_ble_conn_handle_t conn_handle) |
Connection State Change Callback.
Fired when Central connects or disconnects.
| [in] | conn_handle | Connection handle (invalid after disconnect) |
| using lampda::hal::ble::hal_ble_disconn_state_cb_t = typedef void (*)(hal_ble_conn_handle_t conn_handle, uint8_t reason) |
Disconnection State Change Callback.
Fired when Central connects or disconnects.
| [in] | conn_handle | Connection handle (invalid after disconnect) |
| [in] | reason | Disconnect reason code (0 = normal, varies by platform) |
| using lampda::hal::ble::hal_ble_pairing_complete_cb_t = typedef void (*)(hal_ble_conn_handle_t conn_handle, hal::ble::hal_ble_pairing_result code) |
Pairing Completed Callback.
Fired when pairing finishes (success or failure).
| [in] | conn_handle | Connection that paired |
| [in] | code | pairing code |
| using lampda::hal::ble::hal_ble_read_callback_t = typedef 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.
Allows dynamic value generation at read time.
| [in] | conn_handle | Connection handle |
| [in] | char_handle | Characteristic being read |
| [out] | data | Buffer to fill with characteristic value |
| [in] | max_length | Maximum bytes to write |
data, or negative error code | using lampda::hal::ble::hal_ble_secure_cb_t = typedef void (*)(hal_ble_conn_handle_t conn_handle) |
Connection secured Callback.
Fired when a secure connection is established.
| [in] | conn_handle | Connection that paired |
| using lampda::hal::ble::hal_ble_write_callback_t = typedef void (*)(hal_ble_conn_handle_t conn_handle, const uint8_t* data, uint16_t length) |
Callback fired when Central writes to a characteristic.
| [in] | conn_handle | Connection handle (identifies which Central) |
| [in] | data | Pointer to received data |
| [in] | length | Number of bytes received |
|
strong |
|
strong |
| int32_t lampda::hal::ble::hal_ble_add_characteristic | ( | hal_ble_characteristic_t * | characteristic | ) |
Add a Characteristic to the Current Service.
Characteristics hold data values and define client interaction methods.
| [in,out] | characteristic | Characteristic definition (handle will be filled) |
| int32_t lampda::hal::ble::hal_ble_add_service | ( | hal_ble_service_t * | service, |
| const bool | addToAdvertised | ||
| ) |
Add a Service to GATT Database.
Services group related characteristics. Typically called before adding characteristics.
| [in,out] | service | Service definition (handle will be filled) |
| bool lampda::hal::ble::hal_ble_can_load_bound_key | ( | hal_ble_conn_handle_t | conn_handle | ) |
Fill a bound key if it exists
| int32_t lampda::hal::ble::hal_ble_clear_bonds | ( | void | ) |
Clear All Stored Bonds (Forget Paired Centrals)
Erases bonding information; next connection requires re-pairing. Useful for factory reset scenarios.
| int32_t lampda::hal::ble::hal_ble_deinit | ( | void | ) |
Deinitialize BLE Stack.
Stops advertising, closes connections, releases resources.
| int32_t lampda::hal::ble::hal_ble_disconnect | ( | hal_ble_conn_handle_t | conn_handle | ) |
Disconnect a Connected Central.
Forcefully closes the link to a specific Central.
| [in] | conn_handle | Connection handle |
| int32_t lampda::hal::ble::hal_ble_get_characteristic_value | ( | hal_ble_char_handle_t | char_handle, |
| uint8_t * | data, | ||
| uint16_t | max_length | ||
| ) |
Read Current Characteristic Value.
Retrieves value from GATT database (useful for non-callback characteristics).
| [in] | char_handle | Characteristic handle |
| [out] | data | Buffer to receive value |
| [in] | max_length | Buffer size |
| uint8_t lampda::hal::ble::hal_ble_get_connection_count | ( | void | ) |
Get Number of Active Connections.
| int32_t lampda::hal::ble::hal_ble_get_device_name | ( | char * | name, |
| uint16_t | max_length | ||
| ) |
Get Device Name.
| [out] | name | Buffer to receive device name |
| [in] | max_length | Buffer size |
| int32_t lampda::hal::ble::hal_ble_get_mtu | ( | hal_ble_conn_handle_t | conn_handle | ) |
Get Current MTU (Maximum Transmission Unit) Size.
Default is 23 bytes; may increase after negotiation with Central.
| [in] | conn_handle | Connection handle |
| int8_t lampda::hal::ble::hal_ble_get_rssi | ( | hal_ble_conn_handle_t | conn_handle | ) |
Get Connection Signal Strength (RSSI)
RSSI (Received Signal Strength Indicator) indicates link quality.
| [in] | conn_handle | Connection handle |
| int8_t lampda::hal::ble::hal_ble_get_tx_power | ( | void | ) |
Get TX Power.
| bool lampda::hal::ble::hal_ble_has_feature | ( | hal_ble_feature_t | feature | ) |
Check if Feature is Supported.
| [in] | feature | Feature to query |
| int32_t lampda::hal::ble::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.
Indication: Server sends value; Central must send acknowledgment. Slower but reliable (guaranteed delivery).
| [in] | conn_handle | Connection handle (target Central) |
| [in] | char_handle | Characteristic handle |
| [in] | data | Updated value |
| [in] | length | Number of bytes |
| int32_t lampda::hal::ble::hal_ble_init | ( | const char * | device_name, |
| const hal_ble_event_callbacks_t * | callbacks | ||
| ) |
Initialize BLE Stack.
Must be called before any other hal_ble_* function.
| [in] | device_name | Peripheral device name (max 31 characters for advertising) |
| [in] | callbacks | Event handler callbacks |
| bool lampda::hal::ble::hal_ble_is_advertising | ( | void | ) |
Check if Currently Advertising.
| bool lampda::hal::ble::hal_ble_is_connected | ( | hal_ble_conn_handle_t | conn_handle | ) |
Get Connection State.
| [in] | conn_handle | Connection handle |
| bool lampda::hal::ble::hal_ble_is_initialized | ( | void | ) |
Check if BLE Stack is Initialized.
| int32_t lampda::hal::ble::hal_ble_notify | ( | hal_ble_char_handle_t | char_handle, |
| const uint8_t * | data, | ||
| uint16_t | length | ||
| ) |
Send Notification to All Connected Centrals.
Notification: Server sends value change without waiting for acknowledgment. Faster but unreliable (client may miss it).
| [in] | char_handle | Characteristic handle |
| [in] | data | Updated value |
| [in] | length | Number of bytes |
| int32_t lampda::hal::ble::hal_ble_set_characteristic_value | ( | hal_ble_char_handle_t | char_handle, |
| const uint8_t * | data, | ||
| uint16_t | length | ||
| ) |
Update Characteristic Value.
Changes the current value stored in GATT database. Use for non-callback characteristics or when value changes internally.
| [in] | char_handle | Characteristic handle (from hal_ble_add_characteristic) |
| [in] | data | New value |
| [in] | length | Number of bytes |
| int32_t lampda::hal::ble::hal_ble_set_device_name | ( | const char * | name | ) |
Set Device Name.
Public name shown in advertisements and GATT Device Information Service.
| [in] | name | Device name (max 31 characters recommended) |
| int32_t lampda::hal::ble::hal_ble_set_security_config | ( | const hal_ble_sec_config_t * | sec_config | ) |
Configure Security Parameters.
Set encryption level, bonding mode, MITM protection, etc. Must be called before starting advertising.
| [in] | sec_config | Security configuration |
| int32_t lampda::hal::ble::hal_ble_set_tx_power | ( | int8_t | tx_power_dbm | ) |
Set TX Power (Transmit Power)
Controls radio transmission strength (affects range and power consumption).
| [in] | tx_power_dbm | Transmit power in dBm (typical: -40 to +4 dBm) |
| int32_t lampda::hal::ble::hal_ble_start_advertising | ( | const hal_ble_adv_params_t * | adv_params | ) |
Start Advertising (Peripheral Becomes Discoverable)
Begins broadcasting BLE advertisements periodically. Centrals can discover and connect to this device.
| [in] | adv_params | Advertising interval and mode |
| int32_t lampda::hal::ble::hal_ble_start_pairing | ( | hal_ble_conn_handle_t | conn_handle | ) |
Initiate Pairing from Peripheral Side.
Requests the connected Central to start pairing (security exchange).
| [in] | conn_handle | Connection handle |
| int32_t lampda::hal::ble::hal_ble_stop_advertising | ( | void | ) |
Stop Advertising.
Stops broadcasting; existing connections remain active.
| uint16_t lampda::hal::ble::hal_ble_conn_params_t::conn_latency |
Slave latency (skip N connection events, 0-499)
| const char* lampda::hal::ble::hal_ble_characteristic_t::descriptor |
User descriptor
| hal_ble_char_handle_t lampda::hal::ble::hal_ble_characteristic_t::handle |
Output: Set by hal_ble_add_characteristic()
| bool lampda::hal::ble::hal_ble_adv_params_t::include_tx_power |
Include TX power in advertising packet
| uint16_t lampda::hal::ble::hal_ble_characteristic_t::initial_length |
Length of initial value
| uint8_t* lampda::hal::ble::hal_ble_characteristic_t::initial_value |
Optional initial value (NULL = empty)
| uint16_t lampda::hal::ble::hal_ble_adv_params_t::interval_max_ms |
Max advertising interval (milliseconds)
| uint16_t lampda::hal::ble::hal_ble_adv_params_t::interval_min_ms |
Min advertising interval (milliseconds, typical 20-10240)
| uint16_t lampda::hal::ble::hal_ble_conn_params_t::max_conn_interval_ms |
Maximum connection interval
| uint16_t lampda::hal::ble::hal_ble_characteristic_t::max_length |
Max value size in bytes
| uint16_t lampda::hal::ble::hal_ble_conn_params_t::min_conn_interval_ms |
Minimum connection interval (7.5 to 4000 ms)
| bool lampda::hal::ble::hal_ble_sec_config_t::mitm_required |
Require MITM (Man-In-The-Middle) protection
| hal_ble_advertising_stops_cb_t lampda::hal::ble::hal_ble_event_callbacks_t::on_advertising_stops |
Called on advertising stopped
| hal_ble_conn_state_cb_t lampda::hal::ble::hal_ble_event_callbacks_t::on_connect |
Called on connection established
| hal_ble_disconn_state_cb_t lampda::hal::ble::hal_ble_event_callbacks_t::on_disconnect |
Called on connection lost
| hal_ble_pairing_complete_cb_t lampda::hal::ble::hal_ble_sec_config_t::on_pairing_done |
Called when pairing finishes
| hal_ble_secure_cb_t lampda::hal::ble::hal_ble_sec_config_t::on_secured |
Called when connection is secured
| hal_ble_gatt_prop_t lampda::hal::ble::hal_ble_characteristic_t::properties |
Read/Write/Notify/Indicate flags
| hal_ble_read_callback_t lampda::hal::ble::hal_ble_characteristic_t::read_cb |
Optional callback on read
| bool lampda::hal::ble::hal_ble_adv_params_t::restartOnDisconnect |
Restart Advertising on disconnection
| hal_ble_gatt_perm_t lampda::hal::ble::hal_ble_characteristic_t::rPermissions |
Read Access control (encrypted, etc.)
| uint16_t lampda::hal::ble::hal_ble_conn_params_t::supervision_timeout_ms |
Timeout before link is dropped (100-32000 ms)
| uint16_t lampda::hal::ble::hal_ble_adv_params_t::timeout_s |
Advertizing timeout
| hal_ble_uuid_t lampda::hal::ble::hal_ble_characteristic_t::uuid |
Characteristic UUID
| hal_ble_uuid_t lampda::hal::ble::hal_ble_service_t::uuid |
Service UUID (e.g., 0x180A for Device Info)
| uint8_t { ... } ::uuid128[16] |
128-bit UUID (little-endian, LSB first)
| uint8_t lampda::hal::ble::hal_ble_uuid_t::uuid128[16] |
128-bit UUID (little-endian, LSB first)
| uint16_t { ... } ::uuid16 |
16-bit UUID (little-endian)
| uint16_t lampda::hal::ble::hal_ble_uuid_t::uuid16 |
16-bit UUID (little-endian)
| hal_ble_gatt_perm_t lampda::hal::ble::hal_ble_characteristic_t::wPermissions |
Write Access control (encrypted, etc.)
| hal_ble_write_callback_t lampda::hal::ble::hal_ble_characteristic_t::write_cb |
Optional callback on write