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

Improv Wi-Fi device: state, device information and Wi-Fi provisioning. More...

#include <JBImprov.h>

Public Member Functions

 JBImprov ()
 Use the built-in ESP32 / ESP8266 Wi-Fi support.
 JBImprov (JBImprovWiFi &wifi)
 Use a custom Wi-Fi implementation. wifi must outlive this object.
 JBImprov (const JBImprov &)=delete
JBImprov & operator= (const JBImprov &)=delete
void setFirmware (const char *name, const char *version)
 Firmware name and version reported in device info.
void setHardware (const char *hardware)
void setDeviceName (const char *name)
 User facing device name (copied). Defaults to the hostname.
bool setHostname (const char *hostname)
 Hostname used when connecting (copied). Defaults to the core's hostname.
void setRedirectUrl (const char *url)
 URL the client offers the user after provisioning, e.g. the device's web UI.
void setConnectTimeout (uint32_t milliseconds)
 Time to wait for a connection before reporting "unable to connect".
bool addTransport (JBImprovTransport &transport)
 Add a transport such as JBImprovSerial or JBImprovBLE.
void onProvisioned (JBImprovProvisionedCallback callback)
 Called after the device connected with credentials sent by a client.
void onStateChanged (JBImprovStateCallback callback)
 Called whenever the state changes.
void onIdentify (JBImprovIdentifyCallback callback)
void onHostnameChanged (JBImprovNameCallback callback)
 Called when a client sets a new hostname. Store it to keep it after a restart.
void onDeviceNameChanged (JBImprovNameCallback callback)
 Called when a client sets a new device name. Store it to keep it after a restart.
void begin ()
 Start all transports. Call after configuring.
void loop ()
 Process the transports and Wi-Fi. Call often from loop().
JBImprovState state () const
 Current state: Ready, Provisioning or Provisioned.
bool isProvisioned () const
 true when connected to Wi-Fi.
const char * deviceName () const
 The device name, including one set by a client.
const char * hostname () const
 The hostname, including one set by a client.
const char * firmwareName () const
 The firmware name set with setFirmware().
const char * firmwareVersion () const
 The firmware version set with setFirmware().
uint8_t capabilities () const
 Capability flags for BLE.
bool redirectUrl (char *buffer, size_t size)
 Write the redirect URL with placeholders replaced.

Friends

class JBImprovTransport
class JBImprovSerial
class JBImprovBLE

Detailed Description

Improv Wi-Fi device: state, device information and Wi-Fi provisioning.

Member Function Documentation

◆ addTransport()

bool JBImprov::addTransport ( JBImprovTransport & transport)

Add a transport such as JBImprovSerial or JBImprovBLE.

Returns
false if JBIMPROV_MAX_TRANSPORTS are already added.

◆ onIdentify()

void JBImprov::onIdentify ( JBImprovIdentifyCallback callback)

Called when a client asks the device to identify itself, e.g. blink a LED. Setting it adds the identify capability (BLE).

◆ redirectUrl()

bool JBImprov::redirectUrl ( char * buffer,
size_t size )

Write the redirect URL with placeholders replaced.

Returns
false if there is no URL or the device isn't connected.

◆ setFirmware()

void JBImprov::setFirmware ( const char * name,
const char * version )

Firmware name and version reported in device info.

The strings are not copied and must stay valid, string literals are fine.

◆ setHardware()

void JBImprov::setHardware ( const char * hardware)

Override the hardware string in device info (default: the chip, e.g. "ESP32-S3"). Not copied.

◆ setHostname()

bool JBImprov::setHostname ( const char * hostname)

Hostname used when connecting (copied). Defaults to the core's hostname.

Returns
false if it isn't a valid RFC 1123 hostname or the Wi-Fi layer rejects it.

◆ setRedirectUrl()

void JBImprov::setRedirectUrl ( const char * url)

URL the client offers the user after provisioning, e.g. the device's web UI.

Placeholders: {{ip_address}}, {{hostname}} and {{device_name}}. Not copied. Without a URL the result of a provisioning is empty.


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