The default initialization code installs the WILCS02 driver when
the kernel detects the WILCS02-SD board, and sets it to
SoftAP mode upon booting up. An NGINX web server is running to host the web server which
allows the users to provide the target AP credentials. Users can connect a STA device
(PC or mobile phone) to the WILCS02 SoftAP and input the
target AP’s SSID and Pass phrase through a webpage to configure the WILCS02 to run in STA mode to connect to the target
network.
The following figure illustrates the kernel detecting the WILCS02 SDIO card and installing the WILCS02
driver.Figure 6-4. Kernel Showing Detection of the WILCS02 and
Driver Installation
The following is the sequence of the establishing the Wi-Fi®
connection :
During the initialization, /etc/init.d/S85start-wlan
automatically runs and executes /root/Start_AP.sh, which runs
the hostapd application in the background to configure the
Wi-Fi device to set as SoftAP.
script /root/Start_AP.sh: This script initiates the
Wi-Fi interface and use hostapd to set the device to
softAP mode.
/etc/init.d/S80dhcp-server: Runs as a DHCP server to
distribute IP addresses to the connected clients (STA).
/root/websocket: Use this to create web socket
connection to receive the network credential information from the web
server.
The script /root/Start_AP.sh initializes the Wi-Fi interface,
configures the device to SoftAP mode, starts necessary services like
hostapd and DHCP, and sets up a WebSocket daemon for
network credential
communication.
#!/bin/shif lsmod | grep -q "wilc_sdio" ; thenecho"1.############## WILCS02-SDIO module is available ##############"elseecho"1. Inserting the wilcs02-sdio module"
modprobe wilc-sdio
if lsmod | grep -q "wilc_sdio"; thenecho"WILCS02-SDIO module insterted successfully"elseecho"WILCS02-SDIO module insert failed"exit0fifiecho"2.############## Bringing up the wlan0 interface ##############"while true
doif ifconfig wlan0 &> /dev/nulL
thenecho"wlan0 interface exists"breakelseecho"wlan0 interface does not exist"fi
sleep 5# Adjust the sleep duration as neededdone
ifconfig wlan0 up
if ifconfig | grep -q "wlan0" ; thenecho"Wireless LAN interface is UP!"elseecho"Wireless LAN interface has FAILED"exit0fiecho"3.############## Starting the Host AP deamon ##############"
hostapd /etc/wilc_hostapd_open.conf -B &
if ps | grep -q "hostapd" ;
thenecho"hostapd process has started successfully"elseecho"hostapd has failed to start"exit0fiecho"4.############## Configuring the AP IP Address to 192.168.0.1 ##############"
ifconfig wlan0 192.168.0.1echo"5.############## Starting the DHCP server ##############"
/etc/init.d/S80dhcp-server restart
echo"6.############## Starting the WEB scoket deamon ##############"cd /root
./websocket &
echo"Now, The device comes up as an Access Point(AP) mode"
After the platform boot up, the
users can use PC or mobile phone and perform the following:
Scan Wi-Fi and discover
SSID microchip -SoftAP.
Connect PC or mobile
phone to the WILCS02 SoftAP
SSID:
microchip-SoftAP
Security:
Open
Figure 6-5. Discover SoftAP by Phone
Use a browser to access 192.168.1.1. The user can see a network provisioning webpage.
Input the SSID and the “Pass
phrase” of the target AP. Click Connect.Figure 6-6. Network Provisioning Webpage (new)
The websocket
process receive the target AP’s credentials. It reboots the platform to run in
Station mode to connect the target AP. The websocket process
adds the /etc/run_sta file to the system so that the platform
can run in Station mode when it boots up.
Note:
The user can remove the file /etc/run_sta and
reboot to set the platform to the SoftAP mode again (if
necessary).
There is a known issue where a hard reboot may require
re-initializing the WILC-SDIO operation at this step.
Figure 6-7. Console Log Showing
WebSocket Receive AP CredentialsFigure 6-8. Console Log Showing
Device is Rebooted
The script /root/Start_STA.sh is executed when the platform
boots up to run the platform in Station mode and connect to the target AP. This
script initiates the Wi-Fi interface and use wpa_supplicant to
connect the device to the target AP. udhcpc runs as a DHCP
client to obtain IP
address.
#!/bin/bash
sh /root/check_linkstat.sh &
ifconfig wlan0 up
wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf &
udhcpc -i wlan0 &
The LED (D5) on the SAMA5D27-SOM1-EK1
evaluation board indicates the Wi-Fi connection status. When the platform
successfully to connects to the target AP, the LED (D5) on the board turns
ON in blue color.
Blinking Blue: The device is attempting to connect to the target
AP.
Solid Blue: The device has successfully connected to the target
AP.
Figure 6-9. Console Log Showing the Device Connect AP
Checking Network Connectivity –
The user can check the network connectivity using the following commands:
iwconfig
ifconfig
Figure 6-10. Console Log of Command iwconfig and
ifconfig