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

Improv BLE transport using the ESP32 BLE library. More...

#include <JBImprovBLE.h>

Inheritance diagram for JBImprovBLE:
JBImprovTransport

Public Member Functions

void setAuthorizationRequired (bool required)
 Require physical authorization before credentials are accepted.
void setAuthorizationTimeout (uint32_t milliseconds)
 How long an authorization lasts.
void authorize ()
 Authorize the client, e.g. when a button is pressed. Lasts the authorization timeout.
bool isAuthorized () override
 true if credentials are accepted right now.
void setAdvertiseWhenProvisioned (bool advertise)
 Keep advertising after the device is provisioned (default false).
bool isClientConnected () const
 true while a client is connected.

Protected Member Functions

void begin () override
 Called from JBImprov::begin().
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).
void authorizationUsed () override
 Called after an authorized command was used, to restart an authorization timeout.
Protected Member Functions inherited from JBImprovTransport
virtual bool scanResultsPerNetwork ()
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 BLE transport using the ESP32 BLE library.

Owns the BLE stack (BLEDevice::init()), so don't use it together with other BLE server code. The advertised name is the device name.

Member Function Documentation

◆ authorizationUsed()

void JBImprovBLE::authorizationUsed ( )
inlineoverrideprotectedvirtual

Called after an authorized command was used, to restart an authorization timeout.

Reimplemented from JBImprovTransport.

◆ begin()

void JBImprovBLE::begin ( )
inlineoverrideprotectedvirtual

Called from JBImprov::begin().

Reimplemented from JBImprovTransport.

◆ handleTransportCommand()

bool JBImprovBLE::handleTransportCommand ( uint8_t command,
const uint8_t * data,
uint8_t length )
inlineoverrideprotectedvirtual

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

Returns
true if handled.

Reimplemented from JBImprovTransport.

◆ isAuthorized()

bool JBImprovBLE::isAuthorized ( )
inlineoverridevirtual

true if credentials are accepted right now.

Reimplemented from JBImprovTransport.

◆ loop()

void JBImprovBLE::loop ( )
inlineoverrideprotectedvirtual

Called from JBImprov::loop().

Reimplemented from JBImprovTransport.

◆ sendError()

void JBImprovBLE::sendError ( JBImprovError error)
inlineoverrideprotectedvirtual

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

Implements JBImprovTransport.

◆ sendResult()

void JBImprovBLE::sendResult ( uint8_t command,
const uint8_t * data,
uint8_t length )
inlineoverrideprotectedvirtual

Send an RPC result. data holds length prefixed strings.

Implements JBImprovTransport.

◆ sendState()

void JBImprovBLE::sendState ( JBImprovState state)
inlineoverrideprotectedvirtual

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

Implements JBImprovTransport.

◆ setAdvertiseWhenProvisioned()

void JBImprovBLE::setAdvertiseWhenProvisioned ( bool advertise)
inline

Keep advertising after the device is provisioned (default false).

The specification stops the Improv service once provisioned. Turn this on to allow changing the network over BLE later.

◆ setAuthorizationRequired()

void JBImprovBLE::setAuthorizationRequired ( bool required)
inline

Require physical authorization before credentials are accepted.

When on, the device reports "authorization required" until authorize() is called, for example from a button press. Off by default, which lets anyone in range provision the device while it isn't connected.


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