Sharvin
Posts: 17
Joined: Tue Feb 19, 2019 1:19 pm

How to configure wireless client and AP on Raspberry Pi 3

Tue Jul 23, 2019 1:26 pm

Hello,

I am using Raspberry pi 3 B+ with Raspbian OS configured on it.

Problem =>

I want to configure Connman as a wireless client so that I can connect raspberry to the wifi networks and a standalone AP on the Raspberry Pi through which clients ( i.e. Mobile application, etc ) can connect to the Raspberry Pi.

To summarize the above line, I want a wireless client ( i.e.connman ) and AP both of them enabled on the Raspberry Pi.

I found many solutions with the reference of the wpa_supplicant but can't find any example or documentation with reference to connman for achieving this.

Solutions I tried =>

I have downloaded the Raspbian Stretch and after downloading the stretch I downloaded the hotspot script for enabling the AP from this link https://github.com/rudiratlos/hotspot

Configuration steps are as follows =>

1. Enabling the AP =>

Code: Select all

apt-get update && apt-get upgrade

apt-get install -y hostapd
apt-get install -y dnsmasq
wget https://raw.githubusercontent.com/rudiratlos/hotspot/master/hotspot
chmod +x hotspot
hotspot setup
hotspot modpar hostapd ssid myHotspotID 
hotspot modpar hostapd wpa_passphrase myHotspotPassword
hotspot modpar hostapd country_code SE
hotspot modpar crda REGDOMAIN SE
hotspot start
reboot
To confirm if the AP is enabled I first connected that AP from my local computer and then ssh the raspberry using that local computer and it worked properly.

Once this was working properly I installed the connman. For installing connman on the raspberry pi I am following this gist https://gist.github.com/mark2b/f90315aa ... 5152491192

2. Installing connman =>

Code: Select all

apt-get update && apt-get upgrade
apt-get install connman
sudo mv /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.orig
sudo reboot
Now when I try to connect another network I get the following issue =>

Code: Select all

[email protected]:/home/pi# connmanctl
connmanctl> services
*AO Wired                ethernet_b827eb118ee1_cable
connmanctl> scan wifi
Error /net/connman/technology/wifi: Not supported
connmanctl> enable wifi
Error wifi: Already enabled
This is the output of the ifconfig =>

Code: Select all

ap0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet <ip_address>  netmask <ip_address>  broadcast <ip_address>
        inet6 ce80::fa27:ebff:fg44:deb4  prefixlen 64  scopeid 0x20<link>
        ether f8:37:eb:34:tb:b4  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 4862 (4.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet <ip_address>  netmask <ip_address>  broadcast <ip_address>
        inet6 ef70::6ba4:2f68:cb41:c4ee  prefixlen 64  scopeid 0x20<link>
        inet6 fa47:8480:66bf:0:fb11:bb82:C9af:ge5b  prefixlen 64  scopeid 0x0<global>
        ether 8b:26:eb:12:8e:e1  txqueuelen 1000  (Ethernet)
        RX packets 7954  bytes 992598 (969.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 259  bytes 32208 (31.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet <ip_address>  netmask <ip_address>
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 160  bytes 12960 (12.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 160  bytes 12960 (12.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 8b:67:eb:34:dc:b4  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Now to confirm if the above procedure that I followed for connman is right I took another sd card with fresh Raspbian Stretch configured on it. This time I only did step 2 ( Installing connman => ).

Code: Select all

[email protected]:/home/pi# connmanctl
connmanctl> services
*AO Wired                ethernet_b827eb118ee1_cable
    wifi_1 wifi_gh1827eb44dcb4_5168796e61872720546563686e6f6c6f67696573_managed_psk
    wifi_2 wifi_lka827eb44dbb4_5068736e61727421746563686e6f4c6f676965735f455854_managed_psk
    wifi_3        wifi_sdsa827eb44dbb4_5068796e61627417722055464f_managed_psk
connmanctl> scan wifi
connmanctl> agent on
Agent registered
Scan completed for wifi
connmanctl> connect wifi_gh1827eb44dcb4_5168796e61872720546563686e6f6c6f67696573_managed_psk
Agent RequestInput wifi_gh1827eb44dcb4_5168796e61872720546563686e6f6c6f67696573_managed_psk
  Passphrase = [ Type=psk, Requirement=mandatory, Alternates=[ WPS ] ]
  WPS = [ Type=wpspin, Requirement=alternate ]
Passphrase? < wifi_password >
Connected wifi_gh1827eb44dcb4_5168796e61872720546563686e6f6c6f67696573_managed_psk

connmanctl> services
*AO Wired                ethernet_b827eb118ee1_cable
*AR wifi_1 wifi_gh1827eb44dcb4_5168796e61872720546563686e6f6c6f67696573_managed_psk
    wifi_2 wifi_lka827eb44dbb4_5068736e61727421746563686e6f4c6f676965735f455854_managed_psk
    wifi_3       wifi_sdsa827eb44dbb4_5068796e61627417722055464f_managed_psk
The output of ifconfig and iwconfig =>

Code: Select all

~ ifconfig =>
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet <ip-address>  netmask <ip-address>  broadcast <ip-address>
        inet6 fc47:8v90:66bf:0:905e:8d59:5501:dc07  prefixlen 64  scopeid 0x0<global>
        inet6 fe10::5493:2c41:98a3:fb89  prefixlen 64  scopeid 0x20<link>
        ether c8:37:eb:11:8e:e1  txqueuelen 1000  (Ethernet)
        RX packets 1631  bytes 180866 (176.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 241  bytes 29924 (29.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet <ip-address>  netmask <ip-address>
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 164  bytes 13304 (12.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 164  bytes 13304 (12.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet <ip-address>  netmask <ip-address>  broadcast <ip-address>
        inet6 fa47:8490:66cf:0:1654:3d5b:a9fg:4fe  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::1ee4:5f98:acda:d9af  prefixlen 64  scopeid 0x20<link>
        ether bn:26:eb:44:db:b4  txqueuelen 1000  (Ethernet)
        RX packets 724  bytes 90059 (87.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 92  bytes 14812 (14.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

~ iwconfig =>

eth0      no wireless extensions.

lo        no wireless extensions.

wlan0     IEEE 802.11  ESSID:"wifi_1"
          Mode:Managed  Frequency:2.412 GHz  Access Point: A4:76:0C:D5:83:00
          Bit Rate=65 Mb/s   Tx-Power=31 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=55/70  Signal level=-55 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

Question =>

How can I configure the AP and wireless client on the Raspberry pi?

Note: It would be great if connman can be used as a wireless client as it provides API which I am using. If not possible is there any other alternative which will help me in achieving this?
Last edited by Sharvin on Tue Jul 23, 2019 1:52 pm, edited 1 time in total.

epoch1970
Posts: 3548
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to configure wireless client and AP on Raspberry Pi 3

Tue Jul 23, 2019 1:46 pm

This is the official documentation for network configuration on Raspbian
https://www.raspberrypi.org/documentati ... /README.md

If you’re not using Raspbian this does not apply, see the instructions for your OS.

Is not possible to use the built in WiFi interface in Pi3 as a client and as an AP at the same time. You are wasting your time if this is what you are trying to achieve. Just get an additional WiFi adapter.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Beginners”