Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
ble.h
Go to the documentation of this file.
1
5#ifndef BSP_BLE_H
6#define BSP_BLE_H
7
8#include <cstddef>
9#include <stdint.h>
10#include <array>
11
12namespace lampda {
13namespace bsp {
15namespace ble {
16
17static constexpr size_t MaxBleNameLenght = 32;
18
19// Load bounded devices
20void load_bound_file();
21
23bool is_activated();
25bool is_advertising();
27bool is_open_to_all();
29bool is_connected();
31bool is_bounded();
32bool is_bounded(std::array<uint8_t, 8>& buffer);
33
34void disconnect();
35
37bool is_connection_allowed(uint16_t connectionHandle);
38
41
43bool set_bluetooth_name(const std::array<char, MaxBleNameLenght>& name);
45std::array<char, MaxBleNameLenght> get_ble_name();
46
52void start_advertising(bool allowUnknownConnections);
53
59
62
64void write_battery_level(const uint8_t batteryLevel);
66void notify_battery_level(const uint8_t batteryLevel);
67
69bool was_used();
70
72void init();
73
75void shutdown();
76
77namespace serial {
79bool is_activated();
80
82bool is_available();
83
85char read();
86
88size_t write(const char* const buffer, size_t bufferSize);
89
91uint16_t mtu_size();
92
93} // namespace serial
94
95} // namespace ble
96} // namespace bsp
97} // namespace lampda
98
99#endif
bool is_connected()
Return true if a bluetooth user is connected.
Definition: ble.cpp:427
void force_pairing_mode()
Start the pairing mode (open to all devices), even if a device is connected. The connected device is ...
Definition: ble.cpp:538
void init()
Optional bypass to start the BLE device early, without advertising.
Definition: ble.cpp:573
bool is_activated()
Return true if the bluetooth is activated.
Definition: ble.cpp:421
bool is_advertising()
Return true is the bluetooth is visible by other devices.
Definition: ble.cpp:423
void stop_bluetooth_advertising()
disable the bluetooth advertising, but not the bluetooth
Definition: ble.cpp:555
std::array< char, MaxBleNameLenght > get_ble_name()
Return the current bluetooth name.
Definition: ble.cpp:485
void write_battery_level(const uint8_t batteryLevel)
update battery level
Definition: ble.cpp:564
bool is_connection_allowed(uint16_t connectionHandle)
If this returns false, do not accept any actions from bluetooth.
Definition: ble.cpp:449
void shutdown()
shutdown the bluetooth and services
Definition: ble.cpp:616
bool is_open_to_all()
Return true if the device is advertising, and all can connect.
Definition: ble.cpp:425
bool is_bounded()
Return true if the bluetooth connection is bounded to a pair.
Definition: ble.cpp:429
void start_advertising(bool allowUnknownConnections)
start the advertising sequence (with a timeout)
Definition: ble.cpp:492
bool was_used()
Return tue if the bluetooth was used during lifetime.
Definition: ble.cpp:571
void notify_battery_level(const uint8_t batteryLevel)
notify the connected device of a battery level
Definition: ble.cpp:566
void clear_bounded_devices()
Clear the bounded bluetooth devices.
Definition: ble.cpp:456
bool set_bluetooth_name(const std::array< char, MaxBleNameLenght > &name)
Set a new name for the bluetooth.
Definition: ble.cpp:467
Program scope.
Definition: control_fixed_modes.hpp:14