JBImprov
Improv Wi-Fi provisioning over serial and Bluetooth LE
Loading...
Searching...
No Matches
JBImprovSerial Class Reference

Improv Serial transport on any Arduino Stream (Serial, Serial1, USB CDC...). More...

#include <JBImprovSerial.h>

Inheritance diagram for JBImprovSerial:
JBImprovTransport

Public Member Functions

 JBImprovSerial (Stream &stream)
 Use stream, which must outlive this object.
void setAutoRead (bool autoRead)
 Read the stream from JBImprov::loop() (default true).
bool handleByte (uint8_t byte)
 Process one byte received from the client.

Protected Member Functions

void loop () override
 Called from JBImprov::loop().
void sendState (JBImprovState state) override
 Report the provisioning state. Called on every change and when asked.
void sendError (JBImprovError error) override
 Write an error state to the client. Use setError() instead, it skips repeats.
void sendResult (uint8_t command, const uint8_t *data, uint8_t length) override
 Send an RPC result. data holds length prefixed strings.
bool handleTransportCommand (uint8_t command, const uint8_t *data, uint8_t length) override
 Handle a command whose meaning depends on the transport (0x02).
bool scanResultsPerNetwork () override
Protected Member Functions inherited from JBImprovTransport
virtual void begin ()
 Called from JBImprov::begin().
virtual bool isAuthorized ()
 true if commands that change the device are allowed now.
virtual void authorizationUsed ()
 Called after an authorized command was used, to restart an authorization timeout.
void handleCommand (uint8_t command, const uint8_t *data, uint8_t length)
 Pass a received RPC command to JBImprov.
void setError (JBImprovError error)
 Report an error state if it differs from the last one sent.

Additional Inherited Members

Protected Attributes inherited from JBImprovTransport
JBImprov * _improv = nullptr
 The JBImprov instance this transport was added to.
JBImprovError _lastError = JBImprovError::None
 The last error state sent, used by setError().

Detailed Description

Improv Serial transport on any Arduino Stream (Serial, Serial1, USB CDC...).

The stream must be started (e.g. Serial.begin(115200)) by the application.

Member Function Documentation

◆ handleByte()

bool JBImprovSerial::handleByte ( uint8_t byte)

Process one byte received from the client.

Returns
true if the byte is part of an Improv frame, false if it is other data the application can use.

◆ handleTransportCommand()

bool JBImprovSerial::handleTransportCommand ( uint8_t command,
const uint8_t * data,
uint8_t length )
overrideprotectedvirtual

Handle a command whose meaning depends on the transport (0x02).

Returns
true if handled.

Reimplemented from JBImprovTransport.

◆ loop()

void JBImprovSerial::loop ( )
overrideprotectedvirtual

Called from JBImprov::loop().

Reimplemented from JBImprovTransport.

◆ scanResultsPerNetwork()

bool JBImprovSerial::scanResultsPerNetwork ( )
inlineoverrideprotectedvirtual

true to send one RPC result per scanned network (serial), false for one combined result (BLE).

Reimplemented from JBImprovTransport.

◆ sendError()

void JBImprovSerial::sendError ( JBImprovError error)
overrideprotectedvirtual

Write an error state to the client. Use setError() instead, it skips repeats.

Implements JBImprovTransport.

◆ sendResult()

void JBImprovSerial::sendResult ( uint8_t command,
const uint8_t * data,
uint8_t length )
overrideprotectedvirtual

Send an RPC result. data holds length prefixed strings.

Implements JBImprovTransport.

◆ sendState()

void JBImprovSerial::sendState ( JBImprovState state)
overrideprotectedvirtual

Report the provisioning state. Called on every change and when asked.

Implements JBImprovTransport.

◆ setAutoRead()

void JBImprovSerial::setAutoRead ( bool autoRead)
inline

Read the stream from JBImprov::loop() (default true).

Turn it off if the application reads the stream itself and passes every byte to handleByte().


The documentation for this class was generated from the following files: