Skip to content

Transports

RadioKit supports multiple transport layers that can run simultaneously. The library broadcasts widget state changes across all active transports automatically.

Bluetooth Low Energy via NimBLE-Arduino (ESP32).

RadioKit.startBLE("MyDevice");

Compile-time guard:

#define ENABLE_RK_BLE

When ENABLE_RK_BLE is defined, the generated setup() calls RadioKit.startBLE(). Comment out the define to disable BLE at compile time.

Configuration:

SettingDefaultDescription
Service UUID0000FFE0-0000-1000-8000-00805F9B34FBBLE service identifier
Characteristic UUID0000FFE1-0000-1000-8000-00805F9B34FBBLE characteristic identifier
MTUAuto-negotiatedMaximum transmission unit
Advertising nameRK_<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.

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 default

Configuration:

SettingDefaultDescription
Baud Rate1000000Recommended for best performance
Data Bits8Standard serial configuration
Stop Bits1Standard serial configuration
ParityNoneStandard 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.

WebSocket server on port 5555. Supports both AP and STA modes.

RadioKit.startWiFi();

Compile-time guard:

#define ENABLE_RK_WIFI

When ENABLE_RK_WIFI is defined, the generated setup() calls RadioKit.startWiFi(). Comment out the define to disable WiFi at compile time.

Configuration:

SettingDefaultDescription
Port5555WebSocket server port
AP SSIDRK_<device_name>Open network (no password)
STA SSIDConfigured via config.sta_ssid or NVSWiFi network name
STA PasswordConfigured via config.sta_password or NVSWiFi network password

AP vs STA Mode:

  • If sta_ssid is empty (default), the device starts in AP mode — creates an open WiFi network named RK_<device_name> that the phone connects to directly.
  • If sta_ssid is configured (via config.sta_ssid or 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.

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() first

Compile-time guard:

#define ENABLE_RK_CLOUD

When ENABLE_RK_CLOUD is defined, the generated setup() calls RadioKit.startCloud(). Comment out the define to disable Cloud at compile time.

Configuration:

SettingDefaultDescription
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.

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 // disabled

The 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.

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
}
}

On first boot, the library writes default enable flags to NVS:

NVS KeyDefaultDescription
rk_ble_on1BLE transport enabled
rk_wifi_on1WiFi transport enabled
rk_cloud_on0Cloud transport disabled

The app can toggle these via the Settings protocol. Changes take effect on the next startBLE() / startWiFi() / startCloud() call (after reboot).