FastLED 3.9.15
Loading...
Searching...
No Matches
ble.h
Go to the documentation of this file.
1
16
17#pragma once
18
19#include "fl/stl/json.h"
20#include "fl/stl/has_include.h"
21#include "fl/stl/function.h"
22#include "fl/stl/optional.h"
23#include "fl/stl/noexcept.h"
24#include "fl/stl/pair.h"
25
26// BLE requires: ESP32 + IDF 5+ + NimBLE headers present
27#if defined(FL_IS_ESP32) && defined(FL_IS_IDF_5_OR_HIGHER) \
28 && FL_HAS_INCLUDE(<nimble/nimble_port.h>)
29#define FL_BLE_AVAILABLE 1
30#else
31#define FL_BLE_AVAILABLE 0
32#endif
33
34namespace fl {
35namespace net {
36namespace ble {
37
38// GATT UUIDs for FastLED BLE service (string form, used by validation/diagnostics)
39#define FL_BLE_SERVICE_UUID "12345678-1234-1234-1234-123456789abc"
40#define FL_BLE_CHAR_RX_UUID "12345678-1234-1234-1234-123456789ab0"
41#define FL_BLE_CHAR_TX_UUID "12345678-1234-1234-1234-123456789ab1"
42
43#if FL_BLE_AVAILABLE
44// NimBLE BLE_UUID128_INIT takes bytes in LITTLE-ENDIAN order.
45// UUID "12345678-1234-1234-1234-123456789abc" in BE byte order is:
46// 12 34 56 78 12 34 12 34 12 34 12 34 56 78 9a bc
47// Reversed (LE) for BLE_UUID128_INIT:
48// bc 9a 78 56 34 12 34 12 34 12 34 12 78 56 34 12
49#define FL_BLE_SERVICE_UUID_INIT \
50 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x34, 0x12, \
51 0x34, 0x12, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12
52
53#define FL_BLE_CHAR_RX_UUID_INIT \
54 0xb0, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x34, 0x12, \
55 0x34, 0x12, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12
56
57#define FL_BLE_CHAR_TX_UUID_INIT \
58 0xb1, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x34, 0x12, \
59 0x34, 0x12, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12
60#endif // FL_BLE_AVAILABLE
61
63struct StatusInfo {
64 bool connected = false;
66 bool txCharExists = false;
67 int txValueLen = 0;
68 int ringHead = 0;
69 int ringTail = 0;
70};
71
73struct TransportState;
74
79TransportState* createTransport(const char* deviceName) FL_NOEXCEPT;
80
83void destroyTransport(TransportState* state) FL_NOEXCEPT;
84
88StatusInfo queryStatus(const TransportState* state) FL_NOEXCEPT;
89
95
96} // namespace ble
97} // namespace net
98} // namespace fl
TestState state
FastLED's Elegant JSON Library: fl::json
TransportState * createTransport(const char *) FL_NOEXCEPT
Create BLE GATT server, heap-allocate transport state.
Definition ble.cpp.hpp:21
StatusInfo queryStatus(const TransportState *) FL_NOEXCEPT
Query BLE connection/subscription diagnostics.
Definition ble.cpp.hpp:30
void destroyTransport(TransportState *) FL_NOEXCEPT
Deinitialize BLE stack and free heap state.
Definition ble.cpp.hpp:26
fl::pair< fl::function< fl::optional< fl::json >()>, fl::function< void(const fl::json &)> > getTransportCallbacks(TransportState *) FL_NOEXCEPT
Get RequestSource and ResponseSink lambdas for fl::Remote.
Definition ble.cpp.hpp:36
Platform-neutral BLE diagnostics (returned by queryStatus)
Definition ble.h:63
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT