mix bb_nsk.add_wifi (bb_nsk v0.1.2)

Copy Markdown View Source

Makes the robot bring up its own network when it has none to join

A robot that has never been told about a network brings one up itself, named after the application and the last four of its serial number. Join it and the robot is reachable; tell it about a real network through that, and it joins. A mistyped passphrase costs a minute rather than a reflash, because a station configuration that never reaches a connection falls back to the access point.

One radio, so one mode at a time

The RTL8723DU advertises both station and access point, but not at once, so giving the robot a network of its own takes the access point away. That is what makes the fallback mandatory rather than a nicety, and it is what BB.NSK.Network.Monitor is for.

Nothing is stored

The SSID and passphrase are derived from the OTP application and the board's serial number. They survive a reboot without being written anywhere, they differ between two robots on the same bench — which matters in a room full of them — and they can be recovered from a robot that has forgotten everything else.

The passphrase is a hash rather than the serial's own digits, because the serial is printed on things, and it is drawn from an alphabet with no 0, 1, i, l or o in it, since somebody has to read it off a 400x300 e-paper panel and type it into a phone. Add the panel with mix bb_nsk.add_display and it will show it — that is the only place it can be read from.

wlan0 is configured at runtime

Not in config/target.exs, because the access point is named after the board's serial number and that isn't known until the robot is running.

What mix nerves.new leaves there — {"wlan0", %{type: VintageNetWiFi}} — is left alone. An interface declared with no networks is unconfigured by any sensible reading, and BB.NSK.Network.mode/1 reads it that way, so the robot brings its own network up immediately rather than waiting out a connection timeout for one it was never told about.

Example

mix bb_nsk.add_wifi
mix bb_nsk.add_wifi --regulatory-domain AU

Options

  • --robot - The robot module (defaults to {AppPrefix}.Robot).
  • --regulatory-domain - Two-letter country code for the radio (default NZ). Getting this wrong is a legal matter, not a performance one.