Wi-Fi Access Point (AP)
Instead of being a Wi-Fi® client, ARTIK can be set up as a Wi-Fi Access Point (SoftAP mode). Using its external Ethernet connection, the ARTIK module provides wireless Internet services to other Wi-Fi clients.
Prerequisites
-
Connect to the ARTIK board with your usual terminal emulator program.
-
For ARTIK images using Fedora 22 but released prior to April 2016, run the following command at the Linux® prompt to install utility programs for running SoftAP mode.
dnf install hostapd bridge-utils
SoftAP Mode
If you want to run as an independent access point, you will need to set up Network Address Translation (NAT) as described in the procedures below. Refer to a site like RedHat for detailed information on the topic.
This procedure assumes that you are starting from a known-working state, where you have previously been able to use both the Ethernet and Wi-Fi interfaces as a client. Refer to Ethernet and Wi-Fi Networks for details.
Preparation
You'll need to make some one-time configuration file changes to prepare for AP mode operation.
-
Configure Host Access Point Daemon (hostapd), a user space program used to turn the ARTIK wireless network interface circuit into a Wi-Fi access point.
-
Open the 'hostapd' configuration file for editing.
vi /etc/hostapd/hostapd.conf
-
Copy and paste each of these assignments, replacing any existing ones and modifying as needed.
interface=wlan0
driver=nl80211
ssid=ARTIK_AP
(choose the name here)
hw_mode=g
channel=6
auth_algs=1
wpa=2
wpa_passphrase=artik@iot
(choose the passphrase here)
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
-
If you are providing an unsecured Wi-Fi connection, comment out entries for the last five assigments shown (the
auth_algs
torsn...
lines). -
Save and close.
-
-
Configure dnsmasq, a lightweight DHCP and caching DNS server that resolves local hostnames internally by using the
/etc/hosts
file along with any binding address ranges you specify here.-
Open the 'dnamasq' configuration file for editing.
vi /etc/dnsmasq.conf
-
Search for the
bind-interfaces
section. -
Select and copy this category and assignment.
bind-interfaces
dhcp-range=192.168.1.2,192.168.1.100
-
Paste in the selection, replacing the existing
#bind-interfaces
line, to specify the range of IP addresses for DHCP "leases". -
Modify the range if necessary so that it does not overlap other ranges in use. For example, if the Ethernet address from your router is 192.168.1.x, choose something else for your wlan, like 192.168.31.x.
-
Save and close.
-
-
Using the
iptables
command set, configure the access point to route through IP masquerade rules to provide the network address translation needed.-
Open a new file for editing as a shell script file. We'll call ours 'aproute.sh'.
vi aproute.sh
-
Select and copy these commands.
sysctl net.ipv4.ip_forward=1
iptables --flush
iptables -t nat --flush
iptables --delete-chain
iptables -t nat --delete-chain
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i wlan0 -j ACCEPT
- Paste them into the file, save, and exit.
- Remember to make the file executable.
chmod 777 aproute.sh
-
Enabling Access Point
Before beginning, disable Connection Manager to prevent it from stealing connections.
systemctl disable connman
reboot
With the file changes in place, run the following commands to activate Access Point operation.
-
Bring up Ethernet operation.
ifconfig eth0 up
dhclient eth0
You can typeifconfig eth0
to verify that you have a valid IP address. -
For all module types except ARTIK 530, reset the network driver for the mode change.
modprobe -r dhd
modprobe dhd op_mode=2
-
Bring up Wi-Fi operation, specifying its gateway IP address. For example:
ifconfig wlan0 192.168.1.1 up
Make sure this matches the starting point of thedhcp-range
you chose earlier in thednsmasq.conf
file. -
Start
dnsmasq
to enable hostname service within the IP address range configured.
dnsmasq -C /etc/dnsmasq.conf
-
Execute the script file to start network address translation.
./aproute.sh
-
Start the host access point daemon in the background.
hostapd /etc/hostapd/hostapd.conf -B
Access Point operation should now be fully functional.
Turning off Access Point
You can use the script like the one below to disable the access point. Omit the modprobe
lines for ARTIK 530.
systemctl stop hostapd
systemctl stop dnsmasq
modprobe -r dhd
modprobe dhd op_mode=0
ifconfig wlan0 up
if [ -f "/usr/lib/systemd/system/wpa_supplicant.service" ]; then
systemctl restart wpa_supplicant
fi
You could then return to client mode with the usual dhclient wlan0
command after you have either restarted Connection Manager or run wpa_supplicant
manually as noted here.
AP-STA Mode (ARTIK 530)
The Wi-Fi chipset used on the ARTIK 530 module is capable of running in a half-duplex repeater mode to emulate concurrent AP (access point) and STA (client) mode Wi-Fi operation. The Ethernet connection is not used in this environment. Other module types are not configurable to operate in this mode.
This mode has limitations, including:
– Single Tx and Rx (not intended for heavy Wi-Fi traffic)
– Cannot reliably meet beacon frame timing (will drop connections)
There are no guarantees that this mode will be reliable in your application.
This emulated AP-STA mode is intended for controlled environments only, where these limitations are understood and can be mitigated. When set for AP-STA mode, the subsystem will likely spend some time operating in STA mode, and during this time cannot meet AP beacon frame interval requirements. Any client device depending on accurate interval lengths will therefore detect a problem and disconnect.
Preparation
You'll first need to follow the SoftAP mode Preparation section to set up the configuration files. Then, you'll need to change access point (AP) references from wlan0
to uap0
, since the wlan0
interface will be used instead as the "client" (STA) side.
-
Edit
/etc/hostapd/hostapd.conf
to add or update the interface name.
interface=uap0
-
Do the same in
/etc/dnsmasq.conf
, also changing the bind address range.
interface=uap0
bind-interfaces
dhcp-range=192.168.173.2,192.168.173.100
Enabling AP+STA Operation
The steps here are similar to those for simple SoftAP mode, except for the addition of Step 2 and changed references to uap0
and wlan0
where needed. If your Ethernet interface is powered on, you'll want to disable it as noted here.
-
Disable Connection Manager to prevent it from stealing connections.
systemctl disable connman
reboot
-
Power-down, reconfigure, and power-up the Wi-Fi chipset.
-
Power down the Wi-Fi chipset and unload the driver.
echo 0 > /sys/devices/platform/sd8x-rfkill/pwr_ctrl
rmmod sd8xxx mlan
-
Power up the Wi-Fi chipset and reload the driver configured for operation in the new mode.
modprobe mlan
modprobe sd8xxx drv_mode=5
echo 3 > /sys/module/sd8xxx/parameters/drv_mode
echo 1 > /sys/devices/platform/sd8x-rfkill/pwr_ctrl
-
-
Restart STA (client) operation.
dhclient -r # (kill it if already running)
systemctl restart wpa_supplicant
dhclient wlan0
-
Bring up Wi-Fi operation on the access point, specifying its gateway IP address.
ifconfig uap0 192.168.173.1 up
-
Start
dnsmasq
to enable hostname service within the IP address range configured.dnsmasq -C /etc/dnsmasq.conf
-
Start network address translation. Note that the output no longer goes to
eth0
.
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
-
Start the host access point daemon.
hostapd /etc/hostapd/hostapd.conf -B
Repeater operation should now be fully functional.
Access Point with ARTIK SDK
Load and build the Wi-Fi_ap
example in the ARTIK IDE.
Before running the program, you'll need to make these minimal configuration changes for Ubuntu.
-
In the
/etc/hostapd/hostapd.conf
file, make sure these settings are present.
ctrl_interface=/var/run/hostapd
ctrl_interface_group=netdev
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
driver=nl80211
interface=wlan0
hw_mode=g
channel=1
ssid=test
(choose the name here) -
Add the following line to
/etc/default/hostapd
in order to make the daemon use the config file.
DAEMON_CONF="/etc/hostapd/hostapd.conf"
-
Start the hostapd service. hostapd has conflicts with daemons connman and wpa_supplicant. Disable the conflicting services and run hostapd as follows.
systemctl stop connman
systemctl stop wpa_supplicant
systemctl start hostapd
If everything was properly set up, the service should start with no error. -
Run the
Wi-Fi_ap
program. Remember to start the DHCP server as well.
Kura Management Portal
Once you have your ARTIK 530 or 710 board set up as an access point, you may consider installing Kura as the administrative portal to your gateway. You can also use it with an ARTIK 520 by following the steps noted here. It has great features like:
- Built-in MQTT broker
- Automatic clock setting service that sets the system clock from the Internet
- "Wires" canvas (similar to Node-RED) that connects clouds, SQL databases, etc.
- Reading of GPS coordinates from an attached USB GPS dongle
It's worth checking out. It's very quick to set up and learn about.
-
Connect an Ethernet cable to your ARTIK board.
Running the automated setup procedure without a working Ethernet link could cause your Wi-Fi connection to be reconfigured in a way that blocks you from accessing your board.
-
Download the Kura Installer for your ARTIK module OS type to your development PC.
Kura Installer (64-bit Ubuntu) Kura Installer (Fedora) -
Copy it to your ARTIK root using
scp
or other means. -
Install it.
chmod 777 kura...installer.sh
./kura...intaller.sh
You should see a message that the Kura service will be running on the next boot. -
Reboot your ARTIK board now, and start Wi-Fi using
dhclient wlan0
(installing Kura may undo any auto-start script you had set up previously). -
Run
systemctl status kura
to verify that the service is running. -
Run
ifconfig eth0
to determine the IP address assigned to your Ethernet port. -
Back on your development PC, enter this IP address into your browser.
You should see the Kura management screen (username and password are both 'admin' by default). Now you have a gateway administrator page to configure your ARTIK board.