jpiat
Posts: 10
Joined: Mon Sep 01, 2014 8:07 am

Switching between ap and host on pi3 wifi

Sun Oct 02, 2016 8:04 am

I'am trying to have my pi3 switch its WIFI between AP mode and host mode at the touch of a button. For this, i designed two script . The first script configures everything to AP mode :

Code: Select all

#!/bin/bash

cp /etc/network/interfaces_hotspot /etc/network/interfaces
systemctl stop wpa_supplicant.service
ifdown wlan0
ifup wlan0
systemctl start hostapd.service
systemctl start dnsmasq.service
while the second switch the interface to host mode :

Code: Select all

systemctl stop hostapd.service
systemctl stop dnsmasq.service
#systemctl disable hostapd.service
#systemctl disable dnsmasq.service
cp /etc/network/interfaces_local /etc/network/interfaces
ifdown wlan0
ip addr flush dev wlan0
pkill dhclient
pkill wpa_supplicant
ifup wlan0
The two script use preconfigured /et/network/interfaces configuration that works. The problem is that when i am in AP mode and switch to host mode, everything seems to work (wpa_supplicant is started), but it fails to connect to the AP. Sometime i just need to do a ifdown wlan0 and then ifup wlan0 but sometime i need to reboot the Pi.

Any idea on how to achieved the wanted behavior ?

ScheissSchiesser
Posts: 8
Joined: Wed Mar 23, 2016 2:48 pm

Re: Switching between ap and host on pi3 wifi

Wed Mar 15, 2017 5:23 am

Did you ever end up getting this to work? I am trying to set this up as well.

Thanks!

Return to “Troubleshooting”

Who is online

Users browsing this forum: Darksaber, Douglas6, pcmanbob and 4 guests