Difference between revisions of "WiFi"

From MOD Wiki
Jump to navigation Jump to search
 
(21 intermediate revisions by 3 users not shown)
Line 4: Line 4:
 
Please note this is an '''advanced''' and '''experimental''' feature, currently requiring knowledge of command-line.
 
Please note this is an '''advanced''' and '''experimental''' feature, currently requiring knowledge of command-line.
  
=== Step 0: Connect MOD unit via USB ===
+
=== Steps ===
  
We need to setup a few things on the unit, so it must be connected over USB first so we can SSH into it.
+
# Power on the unit
 +
# Connect it to a PC via USB cable
 +
# Plug the WiFi USB adapter/stick on the back of the unit
 +
# SSH into the device
 +
# Create and edit the file '''/data/wpa_supplicant.conf''' (this can be done with '''nano /data/wpa_supplicant.conf''' or '''vi /data/wpa_supplicant.conf''' as you prefer),
 +
Inside this file, write the following contents:
  
=== Step 1: Enabling custom firmware ===
+
<source>
 +
ctrl_interface=/run/wpa_supplicant
 +
update_config=1
 +
network={
 +
        ssid="MyWiFiSSID"
 +
        psk="password-goes-here"
 +
}
 +
</source>
 +
 
 +
# Modify "MyWiFiSSID" and "password" as needed for your network (NOTE: the quotes are necessary)
 +
# Run '''systemctl restart wpa-supplicant-wlan0 dhcpcd-wlan0 mod-hotspot''' to activate WiFi services (not needed on subsequent boots)<br><small>(mod-hotspot does not seem to be present everywhere, ignore error around it if reported)</small>
 +
# Reconnect the WiFi USB dongle and wait a few seconds
 +
# Run '''systemctl status wpa-supplicant-wlan0''' to verify that service is running correctly.<br>
 +
If you see "Active: active (running)" then all is fine, WiFi is working; otherwise continue to the custom firmware deploy steps.
 +
 
 +
=== Custom firmware deploy ===
  
Download any custom firmware that might be needed for your USB device.
+
In case custom firmware is needed (which MOD Devices does not ship), first we will find out which firmware to install.
The linux-firmware repo https://git.kernel.org/?p=linux/kernel/git/firmware/linux-firmware.git is a good starting point.
+
Here are the steps:
  
Then, create /data/firmware directory, and copy the firmware files inside.
+
# Run '''dmesg | tail''' and look for an error message like this;
Something like...
 
  
<source lang="bash">
+
<source>
ssh root@192.168.51.1 "mkdir /data/firmware"
+
[  293.903337] ieee80211 phy0: rt2x00lib_request_firmware: Error - Failed to request Firmware
scp rt2870.bin root@192.168.51.1:/data/firmware/
+
[  293.909338] ieee80211 phy0: rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin'
 
</source>
 
</source>
  
The SSH password is "mod"
+
# Note what is the firmware you need, in this example case it is '''rt2870.bin'''
 +
# Download the firmware (for example, from the linux-firmware project using https://cdn.kernel.org/pub/linux/kernel/firmware/linux-firmware-20221109.tar.gz or similar)
 +
# Create the firmware folder inside the SSH session, by running '''ssh root@192.168.51.1 mkdir /data/firmware'''
 +
# Copy the firmware file over SSH to this new folder, using something like '''scp /path/to/firmware.bin root@192.168.51.1:/data/firmware/<em>name_of_the_kernel_driver</em>/firmware.bin'''
 +
# Unplug and replug the WiFi usb stick
 +
 
 +
=== Finalizing ===
  
=== Step 2: Create WPA config ===
+
We can verify that everything is working by running '''dmesg''' inside the SSH session and checking the latest messages.
 +
If all is ok, you should see something like this:
  
Create the file with the following contents: (adjust as needed for your network)
+
<source>
 +
[ 1321.759528] wlan0: authenticate with 00:06:91:64:12:a0
 +
[ 1321.801547] wlan0: send auth to 00:06:91:64:12:a0 (try 1/3)
 +
[ 1321.804295] wlan0: authenticated
 +
[ 1321.805147] wlan0: associate with 00:06:91:64:12:a0 (try 1/3)
 +
[ 1321.808800] wlan0: RX AssocResp from 00:06:91:64:12:a0 (capab=0x1411 status=0 aid=4)
 +
[ 1321.815169] wlan0: associated
 +
</source>
  
<source lang="bash">
+
==== Finding IP address ====
ctrl_interface=/run/wpa_supplicant
+
 
update_config=1
+
After the unit connects to the WiFi, you can know the IP address by running '''ifconfig'''.<br>
 +
On the '''wlan0''' section you see the IP, like this:
  
network={
+
<source>
        ssid="MyWiFiSSID"
+
wlan0    Link encap:Ethernet  HWaddr B8:A3:86:02:18:62 
        psk="password-goes-here"
+
          inet addr:192.168.1.126  Bcast:192.168.1.255  Mask:255.255.255.0
}
 
 
</source>
 
</source>
 +
 +
If you can't connect to the device with USB or bluetooth (typically when you're on stage...) you can :
 +
* connect to the wifi network with your smartphone/tablet (on the same network your MODdevice is connected to)
 +
* scan the local network your with an android app like [https://f-droid.org/en/packages/de.csicar.ning/ '''Ning''' (f-droid)] or [https://play.google.com/store/apps/details?id=com.wwnd.netmapper '''Net Scan''' (google play without ad)]
 +
 +
 +
Bonus: if your OS and WiFi network supports zeroconf/mDNS, you can now at this point remove the USB cable and connect to the unit via http://modduo.local/, http://modduox.local/ or http://moddwarf.local/ depending on your unit model.<br>
 +
This allows to keep using the plugin store and software updates. (which is blocked when using the WiFi IP directly)
 +
 +
==== Useful resources ====
 +
 +
# https://wiki.archlinux.org/index.php/Wpa_supplicant
 +
# https://wiki.archlinux.org/index.php/Network_configuration/Wireless#iw

Latest revision as of 13:06, 25 April 2024

Starting from v1.10, it is possible to connect a MOD unit to a wireless network. We can achieve this by using a WiFi USB dongle, connected on the back of the unit.

Please note this is an advanced and experimental feature, currently requiring knowledge of command-line.

Steps

  1. Power on the unit
  2. Connect it to a PC via USB cable
  3. Plug the WiFi USB adapter/stick on the back of the unit
  4. SSH into the device
  5. Create and edit the file /data/wpa_supplicant.conf (this can be done with nano /data/wpa_supplicant.conf or vi /data/wpa_supplicant.conf as you prefer),

Inside this file, write the following contents:

ctrl_interface=/run/wpa_supplicant
update_config=1
network={
        ssid="MyWiFiSSID"
        psk="password-goes-here"
}
  1. Modify "MyWiFiSSID" and "password" as needed for your network (NOTE: the quotes are necessary)
  2. Run systemctl restart wpa-supplicant-wlan0 dhcpcd-wlan0 mod-hotspot to activate WiFi services (not needed on subsequent boots)
    (mod-hotspot does not seem to be present everywhere, ignore error around it if reported)
  3. Reconnect the WiFi USB dongle and wait a few seconds
  4. Run systemctl status wpa-supplicant-wlan0 to verify that service is running correctly.

If you see "Active: active (running)" then all is fine, WiFi is working; otherwise continue to the custom firmware deploy steps.

Custom firmware deploy

In case custom firmware is needed (which MOD Devices does not ship), first we will find out which firmware to install. Here are the steps:

  1. Run dmesg | tail and look for an error message like this;
[  293.903337] ieee80211 phy0: rt2x00lib_request_firmware: Error - Failed to request Firmware
[  293.909338] ieee80211 phy0: rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin'
  1. Note what is the firmware you need, in this example case it is rt2870.bin
  2. Download the firmware (for example, from the linux-firmware project using https://cdn.kernel.org/pub/linux/kernel/firmware/linux-firmware-20221109.tar.gz or similar)
  3. Create the firmware folder inside the SSH session, by running ssh root@192.168.51.1 mkdir /data/firmware
  4. Copy the firmware file over SSH to this new folder, using something like scp /path/to/firmware.bin root@192.168.51.1:/data/firmware/name_of_the_kernel_driver/firmware.bin
  5. Unplug and replug the WiFi usb stick

Finalizing

We can verify that everything is working by running dmesg inside the SSH session and checking the latest messages. If all is ok, you should see something like this:

[ 1321.759528] wlan0: authenticate with 00:06:91:64:12:a0
[ 1321.801547] wlan0: send auth to 00:06:91:64:12:a0 (try 1/3)
[ 1321.804295] wlan0: authenticated
[ 1321.805147] wlan0: associate with 00:06:91:64:12:a0 (try 1/3)
[ 1321.808800] wlan0: RX AssocResp from 00:06:91:64:12:a0 (capab=0x1411 status=0 aid=4)
[ 1321.815169] wlan0: associated

Finding IP address

After the unit connects to the WiFi, you can know the IP address by running ifconfig.
On the wlan0 section you see the IP, like this:

wlan0     Link encap:Ethernet  HWaddr B8:A3:86:02:18:62  
          inet addr:192.168.1.126  Bcast:192.168.1.255  Mask:255.255.255.0

If you can't connect to the device with USB or bluetooth (typically when you're on stage...) you can :


Bonus: if your OS and WiFi network supports zeroconf/mDNS, you can now at this point remove the USB cable and connect to the unit via http://modduo.local/, http://modduox.local/ or http://moddwarf.local/ depending on your unit model.
This allows to keep using the plugin store and software updates. (which is blocked when using the WiFi IP directly)

Useful resources

  1. https://wiki.archlinux.org/index.php/Wpa_supplicant
  2. https://wiki.archlinux.org/index.php/Network_configuration/Wireless#iw