FastLED 3.10.8
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 either ESP32 + IDF 5+ + NimBLE headers, or an RP2350W build
27// that selected Arduino-Pico's BTstack menu.
28#if defined(FL_IS_ESP32) && defined(FL_IS_IDF_5_OR_HIGHER) \
29 && FL_HAS_INCLUDE(<nimble/nimble_port.h>)
30#define FL_BLE_AVAILABLE 1
31#elif defined(FL_IS_RP2350) && defined(ENABLE_BLE) && ENABLE_BLE \
32 && FL_HAS_INCLUDE(<BTstackLib.h>)
33#define FL_BLE_AVAILABLE 1
34#else
35#define FL_BLE_AVAILABLE 0
36#endif
37
38namespace fl {
39namespace net {
40namespace ble {
41
42// GATT UUIDs for FastLED BLE service (string form, used by validation/diagnostics)
43#define FL_BLE_SERVICE_UUID "12345678-1234-1234-1234-123456789abc"
44#define FL_BLE_CHAR_RX_UUID "12345678-1234-1234-1234-123456789ab0"
45#define FL_BLE_CHAR_TX_UUID "12345678-1234-1234-1234-123456789ab1"
46
47#if FL_BLE_AVAILABLE
48// NimBLE BLE_UUID128_INIT takes bytes in LITTLE-ENDIAN order.
49// UUID "12345678-1234-1234-1234-123456789abc" in BE byte order is:
50// 12 34 56 78 12 34 12 34 12 34 12 34 56 78 9a bc
51// Reversed (LE) for BLE_UUID128_INIT:
52// bc 9a 78 56 34 12 34 12 34 12 34 12 78 56 34 12
53#define FL_BLE_SERVICE_UUID_INIT \
54 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x34, 0x12, \
55 0x34, 0x12, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12
56
57#define FL_BLE_CHAR_RX_UUID_INIT \
58 0xb0, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x34, 0x12, \
59 0x34, 0x12, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12
60
61#define FL_BLE_CHAR_TX_UUID_INIT \
62 0xb1, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x34, 0x12, \
63 0x34, 0x12, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12
64#endif // FL_BLE_AVAILABLE
65
67struct StatusInfo {
68 bool connected = false;
70 bool txCharExists = false;
71 int txValueLen = 0;
72 int ringHead = 0;
73 int ringTail = 0;
74};
75
77struct TransportState;
78
83TransportState* createTransport(const char* deviceName) FL_NO_EXCEPT;
84
87void destroyTransport(TransportState* state) FL_NO_EXCEPT;
88
92StatusInfo queryStatus(const TransportState* state) FL_NO_EXCEPT;
93
99
100} // namespace ble
101} // namespace net
102} // namespace fl
TestState state
FastLED's Elegant JSON Library: fl::json
void destroyTransport(TransportState *) FL_NO_EXCEPT
Deinitialize BLE stack and free heap state.
Definition ble.cpp.hpp:26
StatusInfo queryStatus(const TransportState *) FL_NO_EXCEPT
Query BLE connection/subscription diagnostics.
Definition ble.cpp.hpp:30
fl::pair< fl::function< fl::optional< fl::json >()>, fl::function< void(const fl::json &)> > getTransportCallbacks(TransportState *) FL_NO_EXCEPT
Get RequestSource and ResponseSink lambdas for fl::Remote.
Definition ble.cpp.hpp:36
TransportState * createTransport(const char *) FL_NO_EXCEPT
Create BLE GATT server, heap-allocate transport state.
Definition ble.cpp.hpp:21
Platform-neutral BLE diagnostics (returned by queryStatus)
Definition ble.h:67
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
Base definition for an LED controller.
Definition crgb.hpp:179