Transports
RadioKit supports multiple transport layers that can run simultaneously. The library broadcasts widget state changes across all active transports automatically.
BLE Transport
Section titled “BLE Transport”Bluetooth Low Energy via NimBLE-Arduino (ESP32).
RadioKit.startBLE("MyDevice");Compile-time guard:
#define ENABLE_RK_BLEWhen ENABLE_RK_BLE is defined, the generated setup() calls RadioKit.startBLE(). Comment out the define to disable BLE at compile time.
Configuration:
| Setting | Default | Description |
|---|---|---|
| Service UUID | 0000FFE0-0000-1000-8000-00805F9B34FB | BLE service identifier |
| Characteristic UUID | 0000FFE1-0000-1000-8000-00805F9B34FB | BLE characteristic identifier |
| MTU | Auto-negotiated | Maximum transmission unit |
| Advertising name | RK_<device_name> | Auto-prefixed with RK_ for app filtering |
Requirements:
- NimBLE-Arduino library (^1.4.1)
- ESP32 board (ESP32, ESP32-S3, ESP32-C3)
NVS Control:
BLE can be enabled/disabled via NVS. On first boot, BLE is enabled by default (rk_ble_on=1). The app can toggle this via the Settings protocol.
Serial Transport
Section titled “Serial Transport”USB/UART serial communication. Serial is always enabled by default — the generated code includes #define ENABLE_RK_SERIAL unconditionally. Comment out the define to disable serial.
RadioKit.startSerial(Serial);Compile-time guard:
#define ENABLE_RK_SERIAL // always defined by defaultConfiguration:
| Setting | Default | Description |
|---|---|---|
| Baud Rate | 1000000 | Recommended for best performance |
| Data Bits | 8 | Standard serial configuration |
| Stop Bits | 1 | Standard serial configuration |
| Parity | None | Standard serial configuration |
Supported Interfaces:
- USB CDC (native USB)
- FTDI FT232R
- CP2102/CP2104
- CH340/CH341
- Hardware UART
Auth Bypass: Physical serial access implies full device-level authentication. No password prompt is required.
WiFi Transport
Section titled “WiFi Transport”WebSocket server on port 5555. Supports both AP and STA modes.
RadioKit.startWiFi();Compile-time guard:
#define ENABLE_RK_WIFIWhen ENABLE_RK_WIFI is defined, the generated setup() calls RadioKit.startWiFi(). Comment out the define to disable WiFi at compile time.
Configuration:
| Setting | Default | Description |
|---|---|---|
| Port | 5555 | WebSocket server port |
| AP SSID | RK_<device_name> | Open network (no password) |
| STA SSID | Configured via config.sta_ssid or NVS | WiFi network name |
| STA Password | Configured via config.sta_password or NVS | WiFi network password |
AP vs STA Mode:
- If
sta_ssidis empty (default), the device starts in AP mode — creates an open WiFi network namedRK_<device_name>that the phone connects to directly. - If
sta_ssidis configured (viaconfig.sta_ssidor NVS), the device starts in STA mode — connects to the configured WiFi network. The phone must be on the same network.
NVS Persistence:
WiFi credentials are stored in NVS and survive power cycles. The app can update them via the SET_WIFI settings command (which triggers an automatic reboot to apply).
NVS Control:
WiFi can be enabled/disabled via NVS (rk_wifi_on). On first boot, WiFi is enabled by default.
Cloud Transport
Section titled “Cloud Transport”WebSocket client connecting to a relay server. Requires WiFi to be active first.
RadioKit.config.cloud_url = "wss://relay.example.com:443";RadioKit.config.cloud_account = "<public-key-hex>";RadioKit.startCloud(); // Must call startWiFi() firstCompile-time guard:
#define ENABLE_RK_CLOUDWhen ENABLE_RK_CLOUD is defined, the generated setup() calls RadioKit.startCloud(). Comment out the define to disable Cloud at compile time.
Configuration:
| Setting | Default | Description |
|---|---|---|
| cloud_url | "" | Relay server WebSocket URL |
| cloud_account | "" | Ed25519 public key hex for authentication |
Authentication:
Cloud relay uses Ed25519 challenge-response authentication. The cloud_account is the hex-encoded Ed25519 public key. The device signs a nonce from the relay server to prove identity.
NVS Persistence:
Cloud URL and account are stored in NVS. The app can update them via the SET_CLOUD_INFO settings command.
NVS Control:
Cloud can be enabled/disabled via NVS (rk_cloud_on). On first boot, Cloud is disabled by default. Cloud requires WiFi to be active — if WiFi is disabled, Cloud is suppressed even if rk_cloud_on=1.
Multiple Transports
Section titled “Multiple Transports”You can activate multiple transports simultaneously. The designer generates #define directives at the top of the header file to enable/disable each transport at compile time:
#define ENABLE_RK_SERIAL#define ENABLE_RK_BLE#define ENABLE_RK_WIFI// #define ENABLE_RK_CLOUD // disabledThe generated setup() uses #ifdef guards around each start call:
void setup() { RadioKit.begin();#ifdef ENABLE_RK_SERIAL RadioKit.startSerial(Serial);#endif#ifdef ENABLE_RK_BLE RadioKit.startBLE(RadioKit.config.name);#endif#ifdef ENABLE_RK_WIFI RadioKit.startWiFi();#endif#ifdef ENABLE_RK_CLOUD RadioKit.startCloud(); // Requires startWiFi() first#endif}Serial is always defined by default. Comment out #define ENABLE_RK_SERIAL manually to disable serial.
The library will automatically broadcast widget state changes to all active transports.
Transport Status
Section titled “Transport Status”Check transport status in your loop:
void loop() { RadioKit.update();
if (RadioKit.isConnected()) { // At least one transport is connected }
if (RadioKit.getRssi() != 0) { // BLE signal strength available }}Transport Enable/Disable via NVS
Section titled “Transport Enable/Disable via NVS”On first boot, the library writes default enable flags to NVS:
| NVS Key | Default | Description |
|---|---|---|
rk_ble_on | 1 | BLE transport enabled |
rk_wifi_on | 1 | WiFi transport enabled |
rk_cloud_on | 0 | Cloud transport disabled |
The app can toggle these via the Settings protocol. Changes take effect on the next startBLE() / startWiFi() / startCloud() call (after reboot).