Software/Neuro Studio

Neuro Studio over WiFi

Connecting Neuro Studio to a Neuro N6 over WiFi on the network the board hosts, the network name and password Neuro Studio learns over USB, the link key prompt, and storing WPA2 or WPA3 WiFi settings on the board with the WiFi settings dialog.

intermediate7 min read

A sketch that streams over WiFi serves the same stream as USB on TCP port 5000, and Neuro Studio's panels and controls work over it as over USB. Neuro Studio connects as a TCP client; the board is the server. WiFi needs a carrier with the MAYA-W476 radio and a sketch that links the MayaW476 library; see WiFi. A board running the Arduino core streams over WiFi only on its own access point, with cfg.transport = TRANSPORT_WIFI_SOFTAP, and the computer joins that network. A board that joins another network streams over USB only.

Choosing WiFi

The transport menu in the status bar has one WiFi entry, WiFi (the board's network). Once it is chosen, the transport button in the status bar reads WiFi, and while no stream is arriving the connection card over the picture reads "Connection: WiFi, on the board's own network (address)". The entry's tooltip names the network to join and the board's address, in the form "Join network on this computer first; the board is at address".

A board that streams on the network it hosts announces its address and port over USB about once a second while the cable is connected. Neuro Studio reads the announcement over USB only and connects to that address when WiFi is chosen. Without an announcement it connects to 192.168.10.1:5000, the address of the board's access point. The address can be set at launch with --wifi-host and --wifi-port, which take the place of the announced one, and --network-only starts Neuro Studio on WiFi without using USB at all; see Getting Started.

A connect attempt is abandoned after 3 seconds and retried, and the connection card stays up between attempts. A link that has carried video and then delivers nothing for 10 seconds is treated as lost and reconnected, and a board that resets or disappears is detected through TCP keepalive. A lost link resets the window as a disconnection does: the overlays, the stream information and the panels that depend on the board's announcements, such as ISP Options, Camera Controls and Tuning, are cleared, and they return as the board announces them again once the link is re-established.

While a board moves its stream from USB to WiFi, its USB link goes quiet. For a board that sends nothing over its cable while it streams over WiFi, Auto USB recovery in the status bar is turned off, as recovery would otherwise reset the board.

The board's own network

In SoftAP mode the sketch sets the network's name and password, and the network uses WPA2 or WPA3. The WiFiVideoStream and WiFiAccessPoint examples host a network named NeuroN6-Cam, and other sketches can use other names. These examples use the board's own password, MayaW476.devicePassword(), and print the network name and password on the Serial Monitor each time a monitor connects.

The board's password is 16 characters in four groups of four, in the form xxxx-xxxx-xxxx-xxxx, made of lower-case letters and digits without l, o, 0 and 1, and drawn from the chip's hardware random number generator, so every board has a different password. The first call stores it on the board, which restarts once. Restarts, uploads and stored WiFi settings leave it unchanged.

Name and password from USB

While the board hosts its access point and no network host is attached, it sends the network's name and password over USB about once a second, in a META_BOARD_SOFTAP record, which never travels over the network. Neuro Studio learns them while the board is connected over USB, so the usual sequence is to connect the board over USB first and then choose WiFi. The connection card then shows the line "On this computer, join the board's WiFi network below, then press Connect." with the network's details:

ItemContent
NetworkThe network name
PasswordHidden behind a fixed mask of eight dots, which also hides its length. Show and Hide reveal and mask it. Copy copies it to the clipboard whether it is shown or hidden, and reads Copied for a moment afterwards

Neuro Studio accepts the name and password over USB only, keeps them in memory for the window, through the switch to WiFi, and never writes them to the Terminal, a log or a file. A new USB connection clears them, since it may be to another board.

Without them, for example after a launch with --network-only, the connection card reads "On this computer, join the WiFi network the board hosts, then press Connect.", "To see its name and password here, connect the board over USB first, then pick WiFi. The example sketches also print both on the Serial Monitor." and "A board that joins another network instead streams over USB only."

Windows

A network profile that Windows saved for one board fails to connect to another board that uses the same network name, because the password differs. The saved network is forgotten in Windows and joined again with the second board's password, as shown by Neuro Studio or printed on the Serial Monitor.

After the board's access point restarts, for example when the board is reset, Windows can be slow to rejoin the network by itself. Choosing the network again in the Windows network list rejoins it at once. Neuro Studio keeps retrying the connection and reconnects as soon as the computer is back on the board's network.

A board can require a link key, set by its sketch with WiFi.setLinkKey() or stored with its WiFi settings. Such a board sends a challenge when Neuro Studio connects and streams only after the correct answer, an HMAC-SHA256 of the challenge under the key, sent as a KEY0 command. Neuro Studio then shows the Link key dialog:

  • the key is typed into a hidden field, which Show and Hide reveal and mask;
  • Connect is enabled for a key of 8 to 64 bytes in UTF-8, which is one byte per ASCII character and more for other characters;
  • Cancel or Escape closes the dialog without a key.

Neuro Studio keeps each key, per board address, until the window closes, and answers later connections to the same board with it. If the board refuses a key, Neuro Studio forgets it and asks again with the message "The board refused the key it was given." After a cancelled prompt, Neuro Studio does not ask again about that board until a transport is chosen from the menu. The key keeps other hosts on the network off the board; it does not encrypt the stream.

WiFi settings dialog

The WiFi settings button in the status bar opens a dialog that stores one set of WiFi settings on the board over the USB cable. A sketch uses them when it calls WiFi.begin() with no arguments, and settings that host a network are also used when a sketch streams with TRANSPORT_WIFI_SOFTAP without starting an access point itself, so one build can take another network name, password or link key without an upload. The board accepts the settings over USB only, so nobody else on the network can change them; with the board connected over WiFi, or not connected, the dialog explains this and offers only Close.

The dialog stores WPA2 and WPA3 networks only, for joining and hosting alike.

FieldValues
BoardJoins a network, Hosts a network, or Has no stored settings
NetworkThe network name (SSID), 1 to 32 bytes
SecurityWPA2, WPA2 / WPA3 or WPA3. The default is WPA2 when joining and WPA2 / WPA3 when hosting
Password8 to 63 printable ASCII characters, or with WPA2 a key of 64 hexadecimal digits. Required when joining. Optional when hosting: left empty, the board keeps its own password. Show and Hide reveal and mask it, and the link key with it
ChannelWhen hosting: 1 to 11, default 6
HostnameOptional. The board's own name, letters, digits and hyphens, up to 32 characters
Link keyOptional. 8 to 64 bytes in UTF-8; only hosts that know it receive the stream

Under the form, the dialog notes that a board joining a network streams over USB only, or, when hosting, that with no password the board uses its own, which Neuro Studio shows when WiFi is chosen with the board on USB. A problem with the entries is shown under the form, for example "Joining a network needs its password." or "A 64-digit hex key works with WPA2 only.", and the store button stays disabled until it is fixed. The board itself checks only a password's length and reports a refusal on its serial port alone, so Neuro Studio checks the rest before sending.

Store on board sends the settings; with Has no stored settings selected the button reads Remove from board and erases them. The settings travel as an asset-store record, one USB command every 20 ms, and the board restarts to write the record, so the stream returns a few seconds later. The board keeps the settings only if its sketch links the MayaW476 WiFi library, which brings the asset store; a board running any other sketch does not restart and keeps nothing. Storing or removing the settings leaves the board's own password unchanged.

Settings that host a network are the ones for streaming to Neuro Studio over WiFi. A board that joins a network with the stored settings keeps its video stream on USB, as it streams over WiFi only on its own access point.

Getting Started, WiFi, Live Tuning and Assets and Wire Protocol.