|
phyphox BLE
Plot your Arduino's data in the phyphox app and control the board from the phone
|
#include <Server.h>

Classes | |
| class | SerializerSource |
| The serializer's byte view, so the transfer can read it. More... | |
Public Member Functions | |
| Server (Transport &transport) | |
| ~Server () | |
| void | setClock (uint32_t(*nowMs)()) |
| Millisecond clock for the transfer's retry timing (the façade passes millis). | |
| void | setDeviceName (const char *name) |
| void | setMtu (uint16_t payload) |
| void | setConnectionParameters (uint16_t minInterval, uint16_t maxInterval, uint16_t latency, uint16_t timeout) |
| void | addExperiment (const PhyphoxBleExperiment &exp) |
| Serve the description (copies it; builds the part table). | |
| void | setCustomXml (const uint8_t *xml, uint32_t len) |
| Serve user-supplied XML instead; the 1.x GATT layout (cddf1002 data, cddf1003 config with five floats, events) is created so hand-written documents keep working. | |
| bool | start () |
| Request the start. | |
| bool | ensureStarted () |
| Bring the transport up now if start() was requested and it is not up yet. | |
| void | poll () |
| drives the transfer; calls transport_.poll() | |
| bool | started () const |
| bool | startFailed () const |
| The transport refused to come up (no module answered, a service could not be created). | |
| bool | writeFloats (const float *values, uint8_t count) |
| 1…5 floats → data characteristic | |
| bool | writeBytes (const uint8_t *bytes, uint16_t len) |
| raw array (≤ MTU payload) | |
| ChannelStore & | channels () |
| void | setChannelCallbacks (uint8_t channel, ChangeCallback onChange, PressCallback onPress) |
| Attach callbacks to a channel at any time, before or after the experiment was added. | |
| const ExperimentEvent & | lastEvent () const |
| void | setConfigHandler (void(*h)()) |
| void | setEventHandler (void(*h)()) |
| const uint8_t * | legacyConfig () const |
| User-XML mode: the raw last value of the 1.x config characteristic. | |
| const TransferSession & | transfer () const |
| bool | customXml () const |
| uint16_t | mtu () const |
| void | printXml (Sink &sink) |
| The document as served: the user's own bytes in user-XML mode, else the generated one. | |
| void | ensureDocument () |
| const ExperimentStore & | store () const |
| const ServerStats & | stats () const |
| uint16_t | connections () const |
| bool | subscribed () const |
| void | onConnect () override |
| void | onDisconnect () override |
| void | onSubscribe (CharId id, bool enabled) override |
The central enabled/disabled notifications on id (only CH_EXPERIMENT and CH_DATA are notifiable). | |
| void | onWrite (CharId id, const uint8_t *data, uint16_t len) override |
The central wrote len bytes to id. | |
| void | onNotifyStatus (CharId id, bool accepted) override |
| Asynchronous verdict on the last notify() for stacks that report it later. | |
| void | pump () override |
| Drive the transfer: send what is due. | |
Public Member Functions inherited from phyphox::TransportListener | |
| virtual | ~TransportListener () |
|
inline |
| phyphox::Server::~Server | ( | ) |
| void phyphox::Server::addExperiment | ( | const PhyphoxBleExperiment & | exp | ) |
Serve the description (copies it; builds the part table).
May be called after start(): the new document is served from the next transfer on.
|
inline |
|
inline |
|
inline |
| void phyphox::Server::ensureDocument | ( | ) |
| bool phyphox::Server::ensureStarted | ( | ) |
Bring the transport up now if start() was requested and it is not up yet.
|
inline |
|
inline |
User-XML mode: the raw last value of the 1.x config characteristic.
|
inline |
|
overridevirtual |
Implements phyphox::TransportListener.
|
overridevirtual |
Implements phyphox::TransportListener.
|
overridevirtual |
Asynchronous verdict on the last notify() for stacks that report it later.
Transports whose notify() is synchronous never call this.
Implements phyphox::TransportListener.
|
overridevirtual |
The central enabled/disabled notifications on id (only CH_EXPERIMENT and CH_DATA are notifiable).
Implements phyphox::TransportListener.
|
overridevirtual |
The central wrote len bytes to id.
Implements phyphox::TransportListener.
| void phyphox::Server::poll | ( | ) |
drives the transfer; calls transport_.poll()
| void phyphox::Server::printXml | ( | Sink & | sink | ) |
The document as served: the user's own bytes in user-XML mode, else the generated one.
|
inlineoverridevirtual |
Drive the transfer: send what is due.
Called by the core from poll(), or by a transport that runs the transfer in its own task (ESP32, see drivesTransfer()). Never called from inside a stack callback.
Implements phyphox::TransportListener.
| void phyphox::Server::setChannelCallbacks | ( | uint8_t | channel, |
| ChangeCallback | onChange, | ||
| PressCallback | onPress | ||
| ) |
Attach callbacks to a channel at any time, before or after the experiment was added.
|
inline |
Millisecond clock for the transfer's retry timing (the façade passes millis).
|
inline |
| void phyphox::Server::setConnectionParameters | ( | uint16_t | minInterval, |
| uint16_t | maxInterval, | ||
| uint16_t | latency, | ||
| uint16_t | timeout | ||
| ) |
| void phyphox::Server::setCustomXml | ( | const uint8_t * | xml, |
| uint32_t | len | ||
| ) |
Serve user-supplied XML instead; the 1.x GATT layout (cddf1002 data, cddf1003 config with five floats, events) is created so hand-written documents keep working.
|
inline |
|
inline |
| void phyphox::Server::setMtu | ( | uint16_t | payload | ) |
| bool phyphox::Server::start | ( | ) |
Request the start.
The transport is brought up LAZILY, at the first poll() or write(): the 1.x examples call start() before addExperiment(), and the characteristic layout depends on the experiment, so the stack must not be configured before setup() is done.
|
inline |
|
inline |
The transport refused to come up (no module answered, a service could not be created).
Tried once; poll() and write() do nothing afterwards. PhyphoxBLE::printErrors() reports it.
|
inline |
|
inline |
|
inline |
|
inline |
| bool phyphox::Server::writeBytes | ( | const uint8_t * | bytes, |
| uint16_t | len | ||
| ) |
raw array (≤ MTU payload)
| bool phyphox::Server::writeFloats | ( | const float * | values, |
| uint8_t | count | ||
| ) |
1…5 floats → data characteristic