Skip navigation
Home > All Places > Software Forums > Wi-Fi/Bluetooth for Linux > Blog > 2019 > September
2019
VinayakS_26

Concurrent AP and STA

Posted by VinayakS_26 Moderator Sep 30, 2019

Introduction

 

This blog is to demonstrate the setup of Concurrent AP and STA in a linux host(i.MX6 was used for this purpose).

Pre-requisites

 

The host should have the following utilities/daemons running:

1. iw (en:users:documentation:iw [Linux Wireless] )

2. wpa_supplicant and wpa_cli (check out this link for more details:Supplicant in Linux )

3. hostapd ( HostApd setup in Linux  )

 

The wpa_supplicant is used to setup the STA and hostapd is used for setting up the AP.

 

Procedure

 

Steps/ Description
Command /FormatExample /Outputs

To configure the STA:

Configure the wpa_supplicant daemon with the credentials/details of the AP to which your  STA has to connect. For this modify the wpa_suplicant.conf config file.

>>>vi  /etc/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

update_config=1

 

network={

ssid=<YourSSID>  #ssid of your AP to which the device has to connect.

psk=<YourPassphrase>  #Password

  }

 

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

update_config=1

 

network={

ssid="yyyyyyyy" #ssid of your AP to which the device has to connect.

psk="xxxxxxxx">  #Password

  }

To configure the AP:

Configure the hostapd daemon with credential/detail of the AP that you want to setup.

>>> vi /etc/hostapd.conf

interface=wlan1

channel=11 

ssid=<Router-Name>

wpa=1

wpa_passphrase=<Passphrase>

 

#above are the major changes to made in the hostapd.conf

#following is a sample hostapd.conf

interface=wlan0

driver=nl80211

ssid=test_ssid

hw_mode=g

channel=1

macaddr_acl=0

auth_algs=1

wpa=2

wpa_key_mgmt=WPA-PSK

wpa_passphrase=test_ssid

rsn_pairwise=CCMP

wpa_pairwise=CCMP

ctrl_interface=/tmp/hostapd

Kill the wpa_supplicant daemon that is already runnnig

>>>grep -aux | grep wpa_supplicant

>>>killall wpa_supplicant

3092  1.0  0.0   1872   364 pts/2    S+   07:49   0:00 grep wpa_supplicant
Remove the existing interface of supplicant>>>rm -rf /var/run/wpa_supplicant/wlan0
Add a virtual interface to setup the AP>>>iw dev wlan0 interface add wlan1 type __ap
Setup the IP address of the AP>>>ifconfig wlan0 192.168.1.3

#Sample output

IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready

Start the wpa_supplicant with the nl80211 driver>>>wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B &

#Sample output

root@imx6ulevk:/usr/sbin# Successfully initialized wpa_supplicant

rfkill: Cannot open RFKILL control device

rfkill: Cannot get wiphy information

[1]+  Done                 

root@imx6ulevk:/usr/sbin# IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Enable network and check the status of the connection

>>>wpa_cli -p /var/run/wpa_supplicant -i wlan0 enable_network 0

>>>wpa_cli -p /var/run/wpa_supplicant -i wlan0 status

bssid=f0:5c:19:8a:95:63

freq=2462

ssid=CY-IOT-HOTSPOT

id=0

mode=station

pairwise_cipher=CCMP

group_cipher=CCMP

key_mgmt=WPA2-PSK

wpa_state=COMPLETED

p2p_device_address=62:f1:89:3e:ed:f9

address=xx:xx:xx:xx:xx:xx

uuid=xxxxxxxxxxxxx

Start dhcp client to leased out an IP from your dhcp server. If your AP/router supports static, you could setup a static IP as well using ifconfig.>>>udhcpc -i wlan0 up

#Sample  output

root@imx6ulevk:/usr/sbin# udhcpc -i wlan0 up

udhcpc (v1.24.1) started

Sending discover...

Sending select for 192.168.1.107...

Lease of 192.168.1.107 obtained, lease time 86400

/etc/udhcpc.d/50default: Adding DNS 192.168.1.1

Setup the host AP by calling the hostapd daemon.>>>./hostapd /etc/hostapd.conf -B &

#Sample  output

wlan1: interface state UNINITIALIZED->ENABLED

wlan1: AP-ENABLED

Filter Blog

By date:
By tag: