Wi-Fi Station

Configuration of RS9113 driver on the Device

If you are using the rs9113 as a Wi-Fi Access Point, /etc/default/rs9113, on the device, you must have the COEX_MODE variable set to 1, 3, 5, or 9. Also, you can set the country code and other parameters as documented in /etc/default/rs9113.

1. If hostapd produces errors, the COEX_MODE is incorrect. To prevent the driver from loading during boot set the value of RS9113_LOAD in /etc/default/rs9113 to zero:

RS9113_LOAD=0

2. Reboot.

3. Correct the COEX_MODE value.

4. Change the RS9113_LOAD value back to one in the file, /etc/default/rs9113.

5. From the shell, now reboot again and load the driver by entering the following command:

mtcdt: /etc/init.d/rs9113 restart

NOTE: Whenever you change the band of the rs9113 module you must reload the driver. The rs9113 module only supports 5GHz or 2.4GHz, but not both at the same time.

Bring up the VAP (Virtual Access Point) Node for Wi-Fi

1. Start the new VAP (device driver node) entering the command:

mtcdt: /opt/rs9113/onebox_util rpine0 create_vap wifi0 sta sw_bmiss
Driver initialization is done
Creating VAP in station mode
Software Beacon miss handling enabled
VAP created Successfully

2. Create network entry for wifi0 and add to /etc/network/interfaces using the following commands: 

mtcdt: auto wifi0
mtcdt: iface wifi0 inet dhcp

3. To bring up the interface for scanning (possibly DHCP), enter the command. 

mtcdt: ifup wifi0

4. If this fails and wifi had been up on wifi0 previously, it may be necessary to first bring down wifi0 then bring it up again with the following commands: 

mtcdt: ifdown wifi0
mtcdt: ifup wifi0

5. Save the file. Then scan by entering this command: 

mtcdt: iw dev wifi0 scan | tee /tmp/scan.txt

6. Determine which Wi-Fi signal is strongest. To get a list of Wi-Fi signals and their strengths, enter this command: 

mtcdt: iwlist wifi0 scanning >/tmp/scan.txt

Configuring Wi-Fi Station/wpa_supplicant

1. You need to create a Wi-Fi configuration. You may already have the necessary information such as the passphrase (psk). But if you do not have this information, the scan command can provide it:

mtcdt: iw dev wifi0 scan | tee /tmp/scan.txt

Example output from a scan: 

BSS 9c:4e:20:c8:ee:9e(on wifi0)
                TSF: 0 usec (0d, 00:00:00)
                freq: 5785
                beacon interval: 102 TUs
                capability: ESS Privacy RadioMeasure (0x1011)
                signal: -72.00 dBm
                last seen: 2720 ms ago
                Information elements from Probe Response frame:
                SSID: Mtech_guest
                Supported rates: 6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0
                TIM: DTIM Count 0 DTIM Period 1 Bitmap Control 0x0 Bitmap[0] 0x0 (+ 3 octets)
                Country: US            Environment: Indoor/Outdoor
                                Channels [36 - 48] @ 17 dBm
                                Channels [52 - 64] @ 24 dBm
                                Channels [100 - 116] @ 24 dBm
                                Channels [132 - 140] @ 24 dBm
                                Channels [149 - 165] @ 30 dBm
                BSS Load:
                                 * station count: 14
                                 * channel utilisation: 7/255
                                 * available admission capacity: 23437 [*32us]
                HT capabilities:
                                Capabilities: 0x182c
                                                HT20
                                                SM Power Save disabled
                                                RX HT20 SGI
                                                No RX STBC
                                                Max AMSDU length: 7935 bytes
                                                DSSS/CCK HT40
                                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                                Minimum RX AMPDU time spacing: 8 usec (0x06)
                                HT RX MCS rate indexes supported: 0-15
                                HT TX MCS rate indexes are undefined
                RSN:       * Version: 1
                                 * Group cipher: CCMP
                                 * Pairwise ciphers: CCMP
                                 * Authentication suites: PSK
                                 * Capabilities: PreAuth 4-PTKSA-RC 4-GTKSA-RC (0x0029)
                HT operation:
                                 * primary channel: 157
                                 * secondary channel offset: no secondary
                                 * STA channel width: 20 MHz
                                 * RIFS: 1
                                 * HT protection: no
                                 * non-GF present: 1
                                 * OBSS non-GF present: 0
                                 * dual beacon: 0
                                 * dual CTS protection: 0
                                 * STBC beacon: 0
                                 * L-SIG TXOP Prot: 0
                                 * PCO active: 0
                                 * PCO phase: 0
                Extended capabilities: Proxy ARP Service, WNM-Notification
                WMM:    * Parameter version 1
                                 * u-APSD
                                 * BE: CW 15-1023, AIFSN 3
                                 * BK: CW 15-1023, AIFSN 7
                                 * VI: CW 7-15, AIFSN 2, TXOP 3008 usec
                                 * VO: CW 3-7, AIFSN 2, TXOP 1504 usec

2. Then, optionally, hash the password. Use the wpa_passphrase to hash the password: 

mtcdt: wpa_passphrase Mtech_guest 'Mtech_guest_password' >/tmp/m.conf

The output of wpa_passphrase includes the unhashed password as a comment.  Remove this comment before putting the psk into the wpa_supplicant configuration.

3. Now enter the generated psk, SSID and BSSID of the router in /etc/wpa_supplicant/psk5g.conf:

ctrl_interface=/run/wpa_supplicant
               update_config=1
               fast_reauth=1
               ap_scan=1
network={
               bssid=9c:4e:20:c8:ee:9e
               ssid="Mtech_guest"
               psk=babc4085713f121c819d0da8694184b25f035f860246b195a2d99d5c2b383725>
                scan_ssid=1
                key_mgmt=WPA-PSK
                priority=1
                proto=WPA RSN
                pairwise=CCMP TKIP
                group=CCMP TKIP
                }

Start the wpa_supplicant Daemon

1. Start wpa_supplicant and bring up the interface (choose the appropriate file) using the following commands: 

mtcdt: wpa_supplicant -i wifi0 -D nl80211 -B -c /etc/wpa_supplicant/psk.conf
Successfully initialized wpa_supplicant
mtcdt: ifup wifi0
dhcpc (v1.22.1) started
Sending discover...
Sending select for 192.168.1.5...
Lease of 192.168.1.5 obtained, lease time 86400
etc/udhcpc.d/50default: Adding DNS 192.168.1.1

2. Now verify the connection either from another screen, or use <ctrl>+z followed by bg %1 to put wpa_supplicant in the background: 

mtcdt: iw dev wifi0  link
Connected to 9c:4e:20:c8:ee:9e (on wifi0)
SSID: Mtech_guest
freq: 5785

3. Enter the ifup from another screen (using ethernet or ssh): 

mtcdt: ifdown wifi0
mtcdt: ifup wifi0
dhcpc (v1.22.1) started
Sending discover...
Sending select for 192.168.1.5...
Lease of 192.168.1.5 obtained, lease time 86400
/etc/udhcpc.d/50default: Adding DNS 192.168.1.1

4. Start DHCP if the previous setup did not acquire an address: 

mtcdt: udhcpc -R -n -p /var/run/udhcpc.wifi0.pid -i wifi0
udhcpc (v1.22.1) started
Sending discover...
Sending select for 192.168.1.7...
Lease of 192.168.1.7 obtained, lease time 86400
/etc/udhcpc.d/50default: Adding DNS 192.168.1.1

Integration of boot, ifup, and ifdown with Wi-Fi station

To allow ifup and ifdown commands to work with wpa_supplicant, and to connect at boot, the file /etc/network/interfaces must be configured.

This configuration creates the wifi0 VAP at boot:

auto wifi0
iface wifi0 inet dhcp
wpa-conf /etc/wpa_supplicant.conf
wpa-driver nl80211
pre-up bash -c '([[ -d /sys/class/net/wifi0 ]] || /opt/rs9113/onebox_util rpine0 create_vap wifi0 sta sw_bmiss)'
udhcpc_opts -t 10 -b

The wifi0 VAP  does not exist before the pre-up section is run. The wpa_supplicant.conf file should contain an SSID, and other configurations as shown in the prior section Configuring Wi-Fi Station/wpa_supplicant.

The udhcpc program has the following options applied at boot and by ifup:

udhcpc -R -n -p /var/run/udhcpc.wifi0.pid -i wifi0

These options specified by udhcpc_opts are added to the end:

udhcpc -R -n -p /var/run/udhcpc.wifi0.pid -i wifi0 -t 10 -b

This means that the boot or ifup command is held up for up to ten attempts to reach the DHCP server. The -b option means that udhcpc is placed in the background after the 10 attempts are complete.  Then the boot proceeds or if -b option is not specified, ifup command terminates.

The interface is available after the udhcpc daemon receives a response from the DHCP server. Without the -b option, udhcpc holds up the boot or ifup command until the DHCP server responds.

When -t is set to 0, the -b option is ignored.  In this case, udhcp blocks until the DHCP has responded, and tries indefinitely.

Without any options, udhcpc  will wait approximately nine seconds for a response, and abort if none is received.  At this point, you will need to try running ifup again, or reboot the device.

For more information refer to: https://busybox.net/downloads/BusyBox.html