phyphox BLE
Plot your Arduino's data in the phyphox app and control the board from the phone
Loading...
Searching...
No Matches
Esp32Ble4Transport.h
Go to the documentation of this file.
1// Transport for the BLE library of arduino-esp32 4.x (`#include <BLE.h>`, the global `BLE`
2// object, value handles and per-event lambdas). Core 4.0 replaced the 3.x BLEDevice library
3// without a compatibility layer, so 3.x keeps Esp32CoreBleTransport and Select.h picks one of
4// the two by ESP_ARDUINO_VERSION_MAJOR. Written against 4.0.0-RC1 (2026-09-23).
5//
6// The 4.x library is stack-agnostic (Bluedroid on the classic ESP32, NimBLE elsewhere, also on
7// the ESP32-P4 through esp-hosted), and keeps subscriptions per connection on both stacks —
8// the 3.x CCCD workarounds are gone. What it does not do is report a refused notification:
9// the broadcast notify() returns OK whatever the stack said, and onStatus() is declared but
10// never called (RC1). The per-connection notify(connHandle, …) does return Fail when the stack
11// refuses a packet up front, so this transport notifies each subscribed connection itself.
12// Bluedroid can still drop an accepted packet inside its own task; as on 3.x, the experiment
13// characteristic waits for ESP_GATTS_CONF_EVT through the custom GATTS handler (see the .cpp).
14// Build with -DPHYPHOX_BLE_ESP32_TRACE to see refused confirmations on Serial. poll() is a
15// no-op: the stack runs in its own tasks.
16#ifndef PHYPHOX_BLE_TRANSPORT_ESP32BLE4_H
17#define PHYPHOX_BLE_TRANSPORT_ESP32BLE4_H
18
19#include "Transport.h"
20
21namespace phyphox {
22
24public:
25 bool begin(const GattLayout& layout, TransportListener& listener) override;
26 bool notify(CharId id, const uint8_t* data, uint16_t len) override;
27 void setValue(CharId id, const uint8_t* data, uint16_t len) override;
28 bool connected() const override;
29 uint16_t mtuPayload() const override;
30 void requestMtu(uint16_t payload) override;
31 void requestConnectionParameters(uint16_t, uint16_t, uint16_t, uint16_t) override;
32 void poll() override {}
33 bool drivesTransfer() const override { return true; }
34 void restartAdvertising() override;
35 const char* name() const override { return "ESP32"; }
37private:
39};
40
41} // namespace phyphox
42
43#endif
Definition Esp32Ble4Transport.h:23
const char * name() const override
"ArduinoBLE", "ESP32", "NINA-B31" — for printXML/debug
Definition Esp32Ble4Transport.h:35
void poll() override
Give the stack CPU time.
Definition Esp32Ble4Transport.h:32
uint16_t mtuPayload() const override
The negotiated MTU payload (ATT_MTU − 3), or PHYPHOX_BLE_DEFAULT_MTU.
bool notify(CharId id, const uint8_t *data, uint16_t len) override
Send a notification.
void setValue(CharId id, const uint8_t *data, uint16_t len) override
Set a characteristic's value without notifying (initial values, the legacy config).
bool connected() const override
void requestMtu(uint16_t payload) override
Ask the stack for an MTU before connecting (ESP32 only today; others ignore).
void restartAdvertising() override
bool drivesTransfer() const override
True if the transport calls listener.pump() from a task of its own, so the core must not also pump fr...
Definition Esp32Ble4Transport.h:33
void requestConnectionParameters(uint16_t, uint16_t, uint16_t, uint16_t) override
Ask the central for connection parameters (units of 1.25 ms / 10 ms).
bool begin(const GattLayout &layout, TransportListener &listener) override
Create services and characteristics, start advertising the experiment service.
static Esp32Ble4Transport & instance()
Callbacks from the transport into the core (implemented by Server).
Definition Transport.h:40
Definition Transport.h:59
Definition ChannelStore.h:11
Definition Transport.h:23
What the core asks the transport to create at begin().
Definition Transport.h:29