6.5.2 Establishing the Wi-Fi Connection
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.
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 thehostapd
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 usehostapd
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 likehostapd
and DHCP, and sets up a WebSocket daemon for network credential communication.#!/bin/sh if lsmod | grep -q "wilc_sdio" ; then echo "1.############## WILCS02-SDIO module is available ##############" else echo "1. Inserting the wilcs02-sdio module" modprobe wilc-sdio if lsmod | grep -q "wilc_sdio"; then echo "WILCS02-SDIO module insterted successfully" else echo "WILCS02-SDIO module insert failed" exit 0 fi fi echo "2.############## Bringing up the wlan0 interface ##############" while true do if ifconfig wlan0 &> /dev/nulL then echo "wlan0 interface exists" break else echo "wlan0 interface does not exist" fi sleep 5 # Adjust the sleep duration as needed done ifconfig wlan0 up if ifconfig | grep -q "wlan0" ; then echo "Wireless LAN interface is UP!" else echo "Wireless LAN interface has FAILED" exit 0 fi echo "3.############## Starting the Host AP deamon ##############" hostapd /etc/wilc_hostapd_open.conf -B & if ps | grep -q "hostapd" ; then echo "hostapd process has started successfully" else echo "hostapd has failed to start" exit 0 fi echo "4.############## Configuring the AP IP Address to 192.168.0.1 ##############" ifconfig wlan0 192.168.0.1 echo "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
- 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.
- The
websocket
process receive the target AP’s credentials. It reboots the platform to run in Station mode to connect the target AP. Thewebsocket
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.
- The user can remove the file
- 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 usewpa_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.
- Checking Network Connectivity –
The user can check the network connectivity using the following commands:
iwconfig
ifconfig