Filter results by

Wi-Fi Access Point (AP)

Instead of being a Wi-Fi client, ARTIK can be set up for Wi-Fi Access Point (SoftAP) communication.

The main part of this article describes systems running Fedora 22, including Rev 0.5 developer systems. Refer to the Older Installations section for ARTIK systems running Fedora 20 (Rev 2.0 – Rev 3.3 boards whose firmware image has not been updated to Fedora 22).

Prerequisites

  • Connect to the ARTIK board with your usual terminal emulator program. If using two boards, you should connect with separate terminal instances over separate ports to each board.

  • 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 the boards already have WPA supplicant services configured and running successfully as a client. Refer to Configuring Wi-Fi on ARTIK for details.

Steps:

  1. Configure and start dnsmasq
  2. Configure iptables for IP masquerade routing
  3. Configure and start hostapd for host access point operation.

Step 1: Configure dnsmasq

dnsmasq is a lightweight DHCP and caching DNS server that resolves local hostnames internally by using the /etc/hosts file.

  1. Add the following lines in /etc/dnsmasq.conf to specify the range of IP addresses for DHCP leases.

    bind-interfaces
    dhcp-range=192.168.1.2,192.168.1.100

  2. Stop connection manager to prevent it from stealing connections.

    # systemctl stop connman

  3. Configure Wi-Fi module operation mode.

    #ifconfig eth0 up
    #dhclient eth0

  4. Reset network driver for the mode change.
    #modprobe -r dhd
    #modprobe dhd op_mode=2

  5. Set up wlan0 with gateway IP address.

    #ifconfig wlan0 192.168.1.1 up

  6. Start dnsmasq

    #dnsmasq -C /etc/dnsmasq.conf

Step 2: Configure iptables

The configuration commands below use the iptables command to set up the access point to route through IP masquerade rules, providing the network address translation needed. You can copy and paste these as a group to run them, or you can save them to a file and run them using a shell script.

1
2
3
4
5
6
7
8
9
# set up the ip forwarding using MASQUERADE
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

Step 3: Configure Host Access Point Daemon (hostapd)

hostapd is a user space program used to turn the ARTIK network interface circuit into an access point. More information can be found here.

  1. Update /etc/hostapd/hostapd.conf with vi to include the text shown below.
1
2
3
4
5
6
7
8
9
10
11
interface=wlan0
driver=nl80211
ssid=ARTIK_AP
auth_algs=1
hw_mode=g
channel=6
wpa=2
wpa_passphrase=artik@iot
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
  1. Start hostapd
    # hostapd /etc/hostapd/hostapd.conf -B

Access Point operation is now fully functional.

Turning Off Access Point

You can use the script below to disable the access point. You could then return to client mode with the usual dhclient wlan0 command.

1
2
3
4
5
6
7
killall hostapd
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

Older Installations

These instructions apply only to ARTIK Rev 2.0 – Rev 3.3 boards whose firmware image has not been updated to Fedora 22.

This article shows how to set up an ARTIK 5 or 10 using Fedora 20 as an Access Point.

Initial setup

  1. To start with, if you are using Fedora 20, you will need to manually install the following packages:

    1
    2
    3
     #yum install hostapd
     #yum install bridge-utils
     #yum install libnl
  2. Add the following settings to the hostapd.conf file, located in /etc/hostapd.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     interface=wlan0
     driver=nl80211
     channel=1 
     hw_mode=g
     preamble=1
     dtim_period=2
     beacon_int=100
     logger_syslog=-1
     logger_syslog_level=2
     logger_stdout=-1
     logger_stdout_level=2
     ctrl_interface=/var/run/hostapd
     ctrl_interface_group=0
     ssid=SEC_WPA2_CCMP_AP
     max_num_sta=1 (only one STA available)
     macaddr_acl=0
     auth_algs=1
     wme_enabled=0
     eapol_key_index_workaround=0
     eap_server=0
     wpa=2
     wpa_passphrase=12345678
     wpa_key_mgmt=WPA-PSK
     wpa_pairwise=CCMP 
  3. Configure dnsmasq by adding the following lines to /etc/dnsmasq.conf. (This allows the use of DHCP, DNS, etc.)

    1
    2
     bind-interfaces
     dhcp-range=192.168.1.2, 192.168.1.100 
  4. Stop NetworkManager to prevent NetworkManager from getting connections and configuring Wi-Fi module operation mode.

    1
    2
    3
    4
     #service NetworkManager stop
     #modprobe -r dhd
     #modprobe dhd op_mode=2
     #dnsmasq -C /etc/dnsmasq.conf 

Start the Access Point

  1. Configure driver and firmware files.

    1
    2
    3
    4
    5
    6
     # ifconfig wlan0 down
     # echo "/etc/wifi/4354a1_apsta.bin" > /sys/module/dhd/parameters/firmware_path
     # ifconfig wlan0 up
     # ifconfig wlan0 down
     # echo 2 > /sys/module/dhd/parameters/op_mode
     # ifconfig wlan0 up
  2. Start hostapd.

    1
     # hostapd /etc/hostapd.conf -B 
Last updated on: