logo elektroda
logo elektroda
X
logo elektroda

OpenBeken HTTP WiFi Setup: Connect to Router & Disable AP Mode via REST Commands

User question

How to use HTTP to configure OpenBK to connect to a WiFi network AND shut down AP mode

Artificial Intelligence Response

Direct answer to the question

  • Send one single, URL-encoded HTTP request (or a small batch of requests) to the OpenBeken (OpenBK) REST interface while the device is still in its temporary AP network.
  • The minimum sequence is:
  1. Set SSID and password (Wifi_SSID, Wifi_Pass).
  2. Force client/STA mode on (Wifi_EnableSta 1).
  3. Explicitly turn the AP off (Wifi_EnableAp 0).
  4. Save to flash and reboot (Save, Restart).

Typical one-liner (replace <SSID> and <PWD> and URL-encode all non-alphanumerics):

http://192.168.4.1/cm?cmnd=backlog%20Wifi_SSID%20<SSID>%3B%20Wifi_Pass%20<PWD>%3B%20Wifi_EnableSta%201%3B%20Wifi_EnableAp%200%3B%20Save%3B%20Restart

After reboot the AP disappears, the module joins your router, obtains a DHCP address, and is reachable at that new IP.

Key points
• Use /cm?cmnd= (OpenBK/Tasmota compatible) or /cfg?cmd= (older builds) – whichever your firmware exposes.
• The backlog meta-command executes all sub-commands atomically, so you cannot lock yourself out halfway through.
• AP is automatically re-enabled by the watchdog only if the STA connection fails; that is your recovery path.


Detailed problem analysis

  1. Firmware behaviour
    • Freshly flashed OpenBeken boots in AP + STA-off to let you configure Wi-Fi.
    • As soon as valid STA credentials are stored and the association succeeds, the internal state machine turns off the AP unless it is forced to stay on (Wifi_EnableAp 1).
    • If STA fails for a configurable time-out (default 30–60 s) the code falls back to AP mode – this prevents bricking the device.

  2. Command interface variants
    OpenBeken keeps Tasmota compatibility but also ships a lighter “CFG” parser:

    /cm?cmnd=<COMMAND> – Tasmota syntax (most common in nightlies, 1.17.x+)
    /cfg?cmd=<COMMAND> – legacy/size-optimised builds before 1.15 or when WEBAPP_TINY is enabled.

    Detect the variant: point your browser to http://192.168.4.1/cm?cmnd=Help – if you get JSON back, /cm is active; otherwise try /cfg?cmd=Help.

  3. Minimal command set

    Wifi_SSID <string> ; target AP name (case sensitive)
    Wifi_Pass <string> ; WPA/WPA2 password
    Wifi_EnableSta 1 ; turn STA client on
    Wifi_EnableAp 0 ; disable internal AP
    Save ; write to flash (idempotent)
    Restart ; soft-reboot
  4. Why a single backlog is safer
    • If you first change the SSID and the module reboots before you disable its AP, you will lose access until STA comes up.
    • If credentials are wrong you still get a safety net because the watchdog later re-enables AP.

  5. URL-encoding pitfalls
    • Space ⇒ %20, semicolon ⇒ %3B, @%40, &%26, etc.
    • ALWAYS encode the password, because WPA keys often contain “problem” characters.
    • CURL example with automatic encoding:

curl -G --data-urlencode "cmnd=backlog Wifi_SSID MyHome; Wifi_Pass p@ss&word!; Wifi_EnableSta 1; Wifi_EnableAp 0; Save; Restart" http://192.168.4.1/cm
  1. JSON alternative (firmware 1.18+):
POST http://192.168.4.1/cfg_set
{
"Wifi_SSID":"MyHome",
"Wifi_Pass":"p@ss&word!",
"Wifi_EnableSta":1,
"Wifi_EnableAp":0
}

Current information and trends

• Build 1.18 (April-2024) added a RESTful /api/* tier and token-based auth; the older /cm endpoint remains for compatibility.
• Newer OpenBeken images detect captive portal probes and pop up a configuration page automatically on Android/iOS.
• Work is in progress to add Wi-Fi Easy-Pair (WPS-like) – expect this in Q3-2024, which may eliminate the AP step entirely.

Supporting explanations and details

• Think of Wifi_EnableAp as the equivalent of Tasmota SetOption1.
• The command interpreter is non-blocking; it queues directives and flashes config only when Save is issued, hence the need for it.
• A quick-blinking LED during boot means the module is waiting for STA DHCP; slow consistent blink means AP fallback.

Ethical and legal aspects

• Disabling the AP removes an unsecured SSID from the air, reducing the attack surface and preventing accidental connections.
• If you enable basic HTTP auth, note that credentials are sent in clear text unless you proxy the device through TLS.
• When used in consumer products, comply with radio regulations (2.4 GHz output power limits, DFS where applicable).

Practical guidelines

Implementation script snippet (bash):

#!/bin/bash
IP=192.168.4.1
SSID="MySSID"
PASS="MyPassword!"
CMD="backlog Wifi_SSID $SSID; Wifi_Pass $PASS; Wifi_EnableSta 1; Wifi_EnableAp 0; Save; Restart"
curl -G --data-urlencode "cmnd=$CMD" "http://$IP/cm"

Potential challenges & fixes
• Wrong credentials → AP reappears; just reconnect and retry.
• Corporate network with WPA-Enterprise (EAP) not supported yet (only WPA-PSK).
• Dual-band routers: ensure the 2.4 GHz SSID is enabled; BK7231 chips are 2.4 GHz-only.

Possible disclaimers or additional notes

• Some Tuya devices wire the reset pin to a tactile button – five quick presses trigger a factory reset if you get locked out.
• Very old OBK snapshots (pre-2022) used WifiSSID/WifiKey instead of Wifi_SSID/Wifi_Pass. Upgrade is strongly advised.

Suggestions for further research

• Monitor the “rework branch” on GitHub for ESP-Now bridging, which will offer offline provisioning without an AP.
• Evaluate OTA encryption (AES-CTR) that landed in June-2024 nightlies.
• For fleet roll-outs look at the Python obktool (CLI mass-flasher + provisioning utility).

Brief summary

Configure OpenBeken over HTTP by sending a single backlog containing: set SSID, set password, enable STA, disable AP, save, reboot. Use /cm?cmnd= or /cfg?cmd= depending on firmware. After restart the module joins your router and its temporary AP vanishes; if the connection fails, the AP re-enables itself for recovery. Proper URL-encoding and a single atomic backlog keep the procedure reliable and scriptable.

Ask additional question

Wait...(2min)
Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.