Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
bluetooth.h
Go to the documentation of this file.
1
5#ifndef HAL_BLUETOOTH_HPP
6#define HAL_BLUETOOTH_HPP
7
8#include <stdint.h>
9#include <string>
10#include <array>
11
13
14namespace lampda {
15namespace hal {
17namespace bluetooth {
18
19static constexpr size_t MaxBleNameLenght = 32;
20
21// Load bounded devices
22void load_bound_file();
23
34bool is_bounded(std::array<uint8_t, 8>& buffer);
35
38
40bool is_connection_allowed(uint16_t connectionHandle);
41
44
46bool set_bluetooth_name(const std::array<char, MaxBleNameLenght>& name);
47
53void start_advertising(bool allowUnknownConnections);
54
57
59void write_battery_level(const uint8_t batteryLevel);
61void notify_battery_level(const uint8_t batteryLevel);
62
64bool was_used();
65
67void init();
68
70void shutdown();
71
72namespace serial {
75
78
80char read();
81
83size_t write(const char* const buffer, size_t bufferSize);
84
86uint16_t mtu_size();
87
88} // namespace serial
89
90} // namespace bluetooth
91} // namespace hal
92} // namespace lampda
93
94#endif
uint16_t mtu_size()
Return the usable MTU size.
bool is_available()
Return true if a char is available to read.
size_t write(const char *const buffer, size_t bufferSize)
Write a buffer to bluetooth serial.
char read()
Read a character (blocking)
void clear_bounded_devices()
Clear the bounded bluetooth devices.
void shutdown()
shutdown the bluetooth and services
void write_battery_level(const uint8_t batteryLevel)
update battery level
bool is_open_to_all()
Return true if the device is advertising, and all can connect.
void stop_bluetooth_advertising()
disable the bluetooth advertising, but not the bluetooth
bool is_advertising()
Return true is the bluetooth is visible by other devices.
void start_advertising(bool allowUnknownConnections)
start the advertising sequence (with a timeout)
bool set_bluetooth_name(const std::array< char, MaxBleNameLenght > &name)
Set a new name for the bluetooth.
bool was_used()
Return tue if the bluetooth was used during lifetime.
bool is_connection_allowed(uint16_t connectionHandle)
If this returns false, do not accept any actions from bluetooth.
bool is_connected()
Return true if a bluetooth user is connected.
bool is_bounded()
Return true if the bluetooth connection is bounded to a pair.
void disconnect()
Force disconnection.
void notify_battery_level(const uint8_t batteryLevel)
notify the connected device of a battery level
void init()
Optional bypass to start the BLE device early, without advertising.
bool is_activated()
Return true if the bluetooth is activated.
Program scope.
Definition: control_fixed_modes.hpp:12
Handle user text inputs.