Raspberry pi 3 B+ as Access Point and Wifi client
Hello,
I'm trying to set up my raspberry pi to work as AP and wifi client at the same time.
I tried this tutorial https://pifi.imti.co/ but it's not really working for me. When I start the docker container I don't see the SSID. Also, I'm not using any Ethernet cables or anything like that as I don't want to use it. Do you have any suggestions on how I should do that?
Thanks in advance! : )
I'm trying to set up my raspberry pi to work as AP and wifi client at the same time.
I tried this tutorial https://pifi.imti.co/ but it's not really working for me. When I start the docker container I don't see the SSID. Also, I'm not using any Ethernet cables or anything like that as I don't want to use it. Do you have any suggestions on how I should do that?
Thanks in advance! : )
Re: Raspberry pi 3 B+ as Access Point and Wifi client
If you peek into IOT wifi's Github tree you can see the (golang) commands the container uses to instanciate the virtual AP.
These are the same commands you can use on the command-line in a non-containerized OS.
I would suggest you stop Docker and try creating the virtual AP from the native OS. There is a least one (long) thread about this in the forums here.
If you can manage to get uap0 and wlan0, then the problem is on the Docker or container side.
If creating the uap0 interface manually fails, make sure you are running the latest version of Raspbian (3B+ is recent and network hardware was upgraded) and try again.
Before all that however. In my experience it is not possible to create the uap interface if the wifi client interface is already active. You say you're not using ethernet, make sure the Pi has no networking active at all when you start the container from the console.
These are the same commands you can use on the command-line in a non-containerized OS.
I would suggest you stop Docker and try creating the virtual AP from the native OS. There is a least one (long) thread about this in the forums here.
If you can manage to get uap0 and wlan0, then the problem is on the Docker or container side.
If creating the uap0 interface manually fails, make sure you are running the latest version of Raspbian (3B+ is recent and network hardware was upgraded) and try again.
Before all that however. In my experience it is not possible to create the uap interface if the wifi client interface is already active. You say you're not using ethernet, make sure the Pi has no networking active at all when you start the container from the console.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel
Re: Raspberry pi 3 B+ as Access Point and Wifi client
So far my experience with trying to do this on Stretch and 3B has been less than stellar.
Sometimes it would work, more often than not it wouldn't. I have resolved by adding a second wifi dongal by CanaKIT. Seems to be working steadily.
I posted my setup files here: https://lb.raspberrypi.org/forums/viewt ... 3&start=75
Sometimes it would work, more often than not it wouldn't. I have resolved by adding a second wifi dongal by CanaKIT. Seems to be working steadily.
I posted my setup files here: https://lb.raspberrypi.org/forums/viewt ... 3&start=75
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Okay, here is the method I used that worked for me. It is based on IOT wifi's solution, but I wanted to use a language other than Go to manage my wifi connections, so all changes are within the standard Raspbian Stretch OS.
These steps are (as best as I can remember) in the order that I did them in:
1. Update system
Run apt-get update and upgrade to make sure you have the latest and greatest.
This took over an hour on my Pi 3B+ with my 20Mbps connection.
2. Install hostapd and dnsmasq
Install the hostapd access point daemon and the dnsmasq dhcp service.
3. Edit configuration files
Here we need to edit the config files for dhcpcd, hostapd, and dnsmasq so that they all play nice together. We do NOT, as in past implementations, make any edits to the /etc/network/interfaces file, since this can cause problems, per tutorial notes here: https://raspberrypi.stackexchange.com/q ... 7921#37921
Edit /etc/dhcpcd.conf
This sets up a static IP address on the uap0 interface that we will set up in the startup script. The nohook line prevents the 10-wpa-supplicant hook from running wpa-supplicant on this interface.
Replace /etc/dnsmasq.conf
Move the dnsmasq original file to save a copy of the quite useful example, you may even want to use some of the RPi-specific lines at the end. I did not test my solution with those.
Create a new /etc/dnsmasq.conf and add the following to it:
The IP address range here is totally arbitrary; use your own.
Create file /etc/hostapd/hostapd.conf and add the following:
(Feel free to delete the commented out lines)
Note: The channel written here MUST match the channel of the wifi that you connect to in client mode (via wpa-supplicant). If the channels for your AP and STA mode services do not match, then one or both of them will not run. This is because there is only one physical antenna. It cannot cover two channels at once.
Edit file /etc/default/hostapd and add the following over the #DAEMON_CONF line:
4. Create startup script
Add a new file /usr/local/bin/wifistart (or whatever name you like best), and add the following to it:
There are other and better ways of automating this startup process, which I adapted from IOT wifi's code here: https://github.com/cjimti/iotwifi This demonstrates the basic functionality in a simple script.
5. Edit rc.local system script
There are other ways of doing this, including creating a daemon that can be used by systemctl, which I would recommend doing if you want something that will restart if it fails. Adafruit has a simple write-up on that here: https://learn.adafruit.com/running-prog ... -a-service. I used rc.local for simplicity here.
Add the following to your /etc/rc.local script above the exit 0 line (note the spacing between "/bin/bash" and "/usr/local/bin/wifistart"):
6. Disable regular network services
The wifistart script handles starting up network services in a certain order and time frame. Disabling them here makes sure things are not run at system startup.
7. Reboot
If you want to test the code directly and view the output, just run from the terminal after commenting out the wifistart script line in rc.local.
Let me know if you have improvements or if this doesn't work for you. Cheers!
These steps are (as best as I can remember) in the order that I did them in:
1. Update system
Run apt-get update and upgrade to make sure you have the latest and greatest.
Code: Select all
sudo apt-get update
sudo apt-get upgrade
2. Install hostapd and dnsmasq
Install the hostapd access point daemon and the dnsmasq dhcp service.
Code: Select all
sudo apt-get install hostapd dnsmasq
Here we need to edit the config files for dhcpcd, hostapd, and dnsmasq so that they all play nice together. We do NOT, as in past implementations, make any edits to the /etc/network/interfaces file, since this can cause problems, per tutorial notes here: https://raspberrypi.stackexchange.com/q ... 7921#37921
Edit /etc/dhcpcd.conf
Code: Select all
interface uap0
static ip_address=192.168.50.1/24
nohook wpa_supplicant
Replace /etc/dnsmasq.conf
Move the dnsmasq original file to save a copy of the quite useful example, you may even want to use some of the RPi-specific lines at the end. I did not test my solution with those.
Code: Select all
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Code: Select all
interface=lo,uap0 #Use interfaces lo and uap0
bind-interfaces #Bind to the interfaces
server=8.8.8.8 #Forward DNS requests to Google DNS
domain-needed #Don't forward short names
bogus-priv #Never forward addresses in the non-routed address spaces
# Assign IP addresses between 192.168.70.50 and 192.168.70.150 with a 12-hour lease time
dhcp-range=192.168.70.50,192.168.70.150,12h
Create file /etc/hostapd/hostapd.conf and add the following:
(Feel free to delete the commented out lines)
Code: Select all
# Set the channel (frequency) of the host access point
channel=1
# Set the SSID broadcast by your access point (replace with your own, of course)
ssid=yourSSIDhere
# This sets the passphrase for your access point (again, use your own)
wpa_passphrase=passwordBetween8and64charactersLong
# This is the name of the WiFi interface we configured above
interface=uap0
# Use the 2.4GHz band (I think you can use in ag mode to get the 5GHz band as well, but I have not tested this yet)
hw_mode=g
# Accept all MAC addresses
macaddr_acl=0
# Use WPA authentication
auth_algs=1
# Require clients to know the network name
ignore_broadcast_ssid=0
# Use WPA2
wpa=2
# Use a pre-shared key
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
driver=nl80211
# I commented out the lines below in my implementation, but I kept them here for reference.
# Enable WMM
#wmm_enabled=1
# Enable 40MHz channels with 20ns guard interval
#ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
Edit file /etc/default/hostapd and add the following over the #DAEMON_CONF line:
Code: Select all
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Add a new file /usr/local/bin/wifistart (or whatever name you like best), and add the following to it:
Code: Select all
#!/bin/bash
# Redundant stops to make sure services are not running
echo "Stopping network services (if running)..."
systemctl stop hostapd.service
systemctl stop dnsmasq.service
systemctl stop dhcpcd.service
#Make sure no uap0 interface exists (this generates an error; we could probably use an if statement to check if it exists first)
echo "Removing uap0 interface..."
iw dev uap0 del
#Add uap0 interface (this is dependent on the wireless interface being called wlan0, which it may not be in Stretch)
echo "Adding uap0 interface..."
iw dev wlan0 interface add uap0 type __ap
#Modify iptables (these can probably be saved using iptables-persistent if desired)
echo "IPV4 forwarding: setting..."
sysctl net.ipv4.ip_forward=1
echo "Editing IP tables..."
iptables -t nat -A POSTROUTING -s 192.168.70.0/24 ! -d 192.168.70.0/24 -j MASQUERADE
# Bring up uap0 interface. Commented out line may be a possible alternative to using dhcpcd.conf to set up the IP address.
#ifconfig uap0 192.168.70.1 netmask 255.255.255.0 broadcast 192.168.70.255
ifconfig uap0 up
# Start hostapd. 10-second sleep avoids some race condition, apparently. It may not need to be that long. (?)
echo "Starting hostapd service..."
systemctl start hostapd.service
sleep 10
#Start dhcpcd. Again, a 5-second sleep
echo "Starting dhcpcd service..."
systemctl start dhcpcd.service
sleep 5
echo "Starting dnsmasq service..."
systemctl start dnsmasq.service
echo "wifistart DONE"
5. Edit rc.local system script
There are other ways of doing this, including creating a daemon that can be used by systemctl, which I would recommend doing if you want something that will restart if it fails. Adafruit has a simple write-up on that here: https://learn.adafruit.com/running-prog ... -a-service. I used rc.local for simplicity here.
Add the following to your /etc/rc.local script above the exit 0 line (note the spacing between "/bin/bash" and "/usr/local/bin/wifistart"):
Code: Select all
/bin/bash /usr/local/bin/wifistart
The wifistart script handles starting up network services in a certain order and time frame. Disabling them here makes sure things are not run at system startup.
Code: Select all
sudo systemctl stop hostapd
sudo systemctl stop dnsmasq
sudo systemctl stop dhcpcd
sudo systemctl disable hostapd
sudo systemctl disable dnsmasq
sudo systemctl disable dhcpcd
Code: Select all
sudo reboot
Code: Select all
sudo /usr/local/bin/wifistart
Let me know if you have improvements or if this doesn't work for you. Cheers!
Last edited by pugbot on Fri Feb 15, 2019 4:32 am, edited 1 time in total.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Like so many others I wanted use my pi 3B as both a wireless access point and wireless client using just the onboard wifi chip. I originally was following the IMTI Docker install https://imti.co/iot-wifi/#legacy-instru ... manual-way with limited success. I also tried the old manual way listed on the same blog with limited success. I eventually was able to get both the AP and WiFi working using a combination Pugbot's post and the original IMTI post.
As Pugbot mentioned in his post, the Interfaces file seems to be deprecated in Stretch. No changes are necessary to it. In it's place make the changes to the DHCPCD.conf as he described.
After that you can use either Pugbot's instructions or the IMTI Manual Setup instructions. I chose the later since they were a little cleaner without all of the service starts and stops in Pugbot's.
Now the key point using either Pugbot's instructions or the IMTI instructions. The DHCP range in dnsmasq.conf needs to include the static IP of the AP! In other words if the AP is 192.168.50.1 the DHCP range should be 192.168.50.1- 192.168.50.xxx. Without this the AP SSID broadcasts but the DHCP server would not hand out an IP address to the connecting client.
In Pugbot's instructions his static IP was 192.168.50.1 but his DHCP range was 192.168.70.50 through 70.150. In IMTI instructions the static IP was 192.168.50.1 but the DHCP range was 192.168.50.50 through 50.150. In both cases this was non-inclusive of the static IP of the AP.
Hope this helps.
As Pugbot mentioned in his post, the Interfaces file seems to be deprecated in Stretch. No changes are necessary to it. In it's place make the changes to the DHCPCD.conf as he described.
After that you can use either Pugbot's instructions or the IMTI Manual Setup instructions. I chose the later since they were a little cleaner without all of the service starts and stops in Pugbot's.
Now the key point using either Pugbot's instructions or the IMTI instructions. The DHCP range in dnsmasq.conf needs to include the static IP of the AP! In other words if the AP is 192.168.50.1 the DHCP range should be 192.168.50.1- 192.168.50.xxx. Without this the AP SSID broadcasts but the DHCP server would not hand out an IP address to the connecting client.
In Pugbot's instructions his static IP was 192.168.50.1 but his DHCP range was 192.168.70.50 through 70.150. In IMTI instructions the static IP was 192.168.50.1 but the DHCP range was 192.168.50.50 through 50.150. In both cases this was non-inclusive of the static IP of the AP.
Hope this helps.
-
- Posts: 137
- Joined: Tue Apr 29, 2014 6:18 pm
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Thanks for this info!
I followed pieyeguy's advice and expanded the dhcp address range to include 192.168.50.1.
I can wifi connect to the hotspot and then ssh and/or vnc connect to 192.168.50.1. The pi also connects as a client to my wifi router. Everything works!
But, it doesn't seem reliable. Eventually, I can not longer communicate over the hotspot. It stays connected, but the ssh session and/or vnc session become non-responsive.
Sometimes, just wifi disconnecting and reconnecting solves the problem. But right now, it doesn't
I noticed that while I have hostapd.conf set up for channel 10 (that's what I initially saw when I used
windows is reporting that I"m connected to channel 9. So, I checked again using iwlist and see that the client is actually using channel 9. It connected to another wifi router I have running. Maybe it worked for a while with the hotspot on 9 and the client on 10, but not reliably.
I'm thinking that might be the issue. I can remove all but one entry in my wpa_supplicant.conf file so that the pi will always connect to the same router. I'll try this and see if it resolves the issue.
But, that leaves me with a couple of questions...
If the pi can't connect to the specified SSID (say I'm at a different location), will the wifi hotspot sitll work and use the channel specified in hostapd.conf?
Would it be possible to implement a script that would first attempt to connect as a client using wpa_supplicant.conf (with several SSIDs). If a good connection is made, then use the channel found from iwlist as the channel to use for the hotspot? If a client connection isn't made, then use a specified channel.
I'd prefer the specified channel be used for the hotspot. If the client can't connect to an SSID on this channel, I could still connect reliably to the hotspot. Is this achievable? (always use channel in hostapd.conf for hotspot regardless of client connection).
Thanks!
I followed pieyeguy's advice and expanded the dhcp address range to include 192.168.50.1.
I can wifi connect to the hotspot and then ssh and/or vnc connect to 192.168.50.1. The pi also connects as a client to my wifi router. Everything works!
But, it doesn't seem reliable. Eventually, I can not longer communicate over the hotspot. It stays connected, but the ssh session and/or vnc session become non-responsive.
Sometimes, just wifi disconnecting and reconnecting solves the problem. But right now, it doesn't
I noticed that while I have hostapd.conf set up for channel 10 (that's what I initially saw when I used
Code: Select all
iwlist wlan0 channel
I'm thinking that might be the issue. I can remove all but one entry in my wpa_supplicant.conf file so that the pi will always connect to the same router. I'll try this and see if it resolves the issue.
But, that leaves me with a couple of questions...
If the pi can't connect to the specified SSID (say I'm at a different location), will the wifi hotspot sitll work and use the channel specified in hostapd.conf?
Would it be possible to implement a script that would first attempt to connect as a client using wpa_supplicant.conf (with several SSIDs). If a good connection is made, then use the channel found from iwlist as the channel to use for the hotspot? If a client connection isn't made, then use a specified channel.
I'd prefer the specified channel be used for the hotspot. If the client can't connect to an SSID on this channel, I could still connect reliably to the hotspot. Is this achievable? (always use channel in hostapd.conf for hotspot regardless of client connection).
Thanks!
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Following pugbot's post, I was able to share the WiFi as hotspot and connect to it. However, I was not able to access the Internet via it. Any suggestions? Thanks.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Following Pieyeguy's post I had some inexplicable problems.
After some try's with limited success I switched to following only pugbot's post and it works very well.
In the step 5. there is an char mistake, instead of"/bin/bash/ /usr/local/bin/wifistart" it should be "/bin/bash /usr/local/bin/wifistart".
I am able to share the WiFi as hotspot and connect to it too.
While RPI has Ethernet communication:
- possible to surf on RPI in the internet.
- possible to surf on the devices which are connected to RPI hotspot.
While RPI is connected through WiFi:
- it is possible to surf on RPI
- the devices could be connected to RPI hotspot
- not possible to surf on the devices which are connected to RPI hotspot.
I suspect it could be enough for my application. Maybe configuration of bridge=br0 could help to surf while RPI is connected through Wifi.
After some try's with limited success I switched to following only pugbot's post and it works very well.
In the step 5. there is an char mistake, instead of"/bin/bash/ /usr/local/bin/wifistart" it should be "/bin/bash /usr/local/bin/wifistart".
I am able to share the WiFi as hotspot and connect to it too.
While RPI has Ethernet communication:
- possible to surf on RPI in the internet.
- possible to surf on the devices which are connected to RPI hotspot.
While RPI is connected through WiFi:
- it is possible to surf on RPI
- the devices could be connected to RPI hotspot
- not possible to surf on the devices which are connected to RPI hotspot.
I suspect it could be enough for my application. Maybe configuration of bridge=br0 could help to surf while RPI is connected through Wifi.
-
- Posts: 246
- Joined: Tue May 01, 2012 8:47 am
- Location: Germany (old europe)
-
- Posts: 137
- Joined: Tue Apr 29, 2014 6:18 pm
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Will this support simultaneous use of hotspot and wifi client?
Some posts say you must choose a hotspot frequency that's the same as what the client uses. But, I think I read your script uses one based on the least congesting frequency band?
Does that impact the reliability of the client connection?
Some posts say you must choose a hotspot frequency that's the same as what the client uses. But, I think I read your script uses one based on the least congesting frequency band?
Does that impact the reliability of the client connection?
-
- Posts: 246
- Joined: Tue May 01, 2012 8:47 am
- Location: Germany (old europe)
Re: Raspberry pi 3 B+ as Access Point and Wifi client
my hotspot script supports ap (accesspoint) and client, if you have 2 wlan adapter. if you have only one (internal), it will use the adpater for ap.davethomaspilot wrote: ↑Thu Feb 14, 2019 4:26 pmWill this support simultaneous use of hotspot and wifi client?
Some posts say you must choose a hotspot frequency that's the same as what the client uses. But, I think I read your script uses one based on the least congesting frequency band?
Does that impact the reliability of the client connection?
If two adapters are available, the script will use 2 different channels. Running on the same channel (ap and client), I have problems with rpi 3Bs.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Yes, this is definitely achievable; I am doing it myself! As you can also see in rudrilatos' reply, you can even do it with a bash script. I am actually doing this in a .NET Core program as part of a larger application (long story), which I would not particularly recommend, so I did not include the details.davethomaspilot wrote: ↑Tue Feb 12, 2019 3:40 pmWould it be possible to implement a script that would first attempt to connect as a client using wpa_supplicant.conf (with several SSIDs). If a good connection is made, then use the channel found from iwlist as the channel to use for the hotspot? If a client connection isn't made, then use a specified channel.
I'd prefer the specified channel be used for the hotspot. If the client can't connect to an SSID on this channel, I could still connect reliably to the hotspot. Is this achievable? (always use channel in hostapd.conf for hotspot regardless of client connection).
Suffice it to say, I am parsing results from wpa_cli to figure out the client-side channel of any network prior to actually connecting to it (which I am doing manually). I use the following two commands to grab output containing SSID frequencies.
Code: Select all
wpa_cli -p /var/run/wpa_supplicant -i wlan0 scan #Scan local wifi
wpa_cli -p /var/run/wpa_supplicant -i wlan0 scan_results #Output scan results
The reboot is not very elegant, nor is parsing wpa_cli output, but it does the trick for me. There is most likely a much better way to gracefully bring down the hostapd and dnsmasq services and bring them up again matching the client-side channel without doing a full reboot, but I haven't had the time to fiddle with it yet, and what I have works for my purposes.
-
- Posts: 137
- Joined: Tue Apr 29, 2014 6:18 pm
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Thank you!
I put working on this on hold, pending a reply indicating "been there,done that".
I'll give it a try soon.
I put working on this on hold, pending a reply indicating "been there,done that".
I'll give it a try soon.
-
- Posts: 137
- Joined: Tue Apr 29, 2014 6:18 pm
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Has anyone successfully stayed connected to a hotspot (3a+ or 3b+) when configured per pugbot's great instructions?davethomaspilot wrote: ↑Tue Feb 12, 2019 3:40 pmThanks for this info!
I followed pieyeguy's advice and expanded the dhcp address range to include 192.168.50.1.
I can wifi connect to the hotspot and then ssh and/or vnc connect to 192.168.50.1. The pi also connects as a client to my wifi router. Everything works!
But, it doesn't seem reliable. Eventually, I can not longer communicate over the hotspot. It stays connected, but the ssh session and/or vnc session become non-responsive.
Sometimes, just wifi disconnecting and reconnecting solves the problem. But right now, it doesn't
I noticed that while I have hostapd.conf set up for channel 10 (that's what I initially saw when I used
windows is reporting that I"m connected to channel 9. So, I checked again using iwlist and see that the client is actually using channel 9. It connected to another wifi router I have running. Maybe it worked for a while with the hotspot on 9 and the client on 10, but not reliably.Code: Select all
iwlist wlan0 channel
I'm thinking that might be the issue. I can remove all but one entry in my wpa_supplicant.conf file so that the pi will always connect to the same router. I'll try this and see if it resolves the issue.
But, that leaves me with a couple of questions...
If the pi can't connect to the specified SSID (say I'm at a different location), will the wifi hotspot sitll work and use the channel specified in hostapd.conf?
Would it be possible to implement a script that would first attempt to connect as a client using wpa_supplicant.conf (with several SSIDs). If a good connection is made, then use the channel found from iwlist as the channel to use for the hotspot? If a client connection isn't made, then use a specified channel.
I'd prefer the specified channel be used for the hotspot. If the client can't connect to an SSID on this channel, I could still connect reliably to the hotspot. Is this achievable? (always use channel in hostapd.conf for hotspot regardless of client connection).
Thanks!
As a client, the connection is reliable, indefinitely. But, as a hotspot, the connection drops frequently.
It doesn't seem like a range or interference issue--I can be right at the hotspot and still have problems staying connected.
I'm about ready to give up on using the wifi as both a hotspot and client and try something like the script rudiratlos wrote.
But, on the 3A+, I have only one USB slot and it's already used. It would be nice to have the ability to connect directly to the pi as a hotspot and also have the ability to make it a client to a different wifi router.
Using a script to switch whether it's a client or hotspot isn't a good solution for me. Once configured to be a client, it would need to be connected to a router to reconfigure as a hotspot.
It's internal to a gadget, headless, and frequently moved to different venues. I need the ability to always connect directly to it without requiring a router.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Why not a hardware switch connected to a GPIO bit and monitored to determine AP or client status? So we need a script for AP or client depending on the switch position. You can use GPIO interrupt input to save having to poll.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
That would work, yes. I have a remote app controlling my Pi, so I needed software-based control. Additionally, with this solution, you can get both AP+STA modes working simultaneously, provided they are on the same channel. Depends on your project needs, I guess.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Although, the POST is very old but based on the recommendation of @pugbot, I have created full automated script.
The script is present in Github URL - https://github.com/idev1/rpihotspot/blo ... network.sh. Please evaluate and let me know about your observations.
The script is present in Github URL - https://github.com/idev1/rpihotspot/blo ... network.sh. Please evaluate and let me know about your observations.

-
- Posts: 1
- Joined: Sat Nov 23, 2019 6:21 am
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Thanks for the great script. It works great. As its works as repeater as well, wifi speed is reduced by half. That is the limitation of the device. To thank you I registered. There are two corrections to be done on the script.
On line numbers 640 & 641
systemctl systemctl enable netStop.service
systemctl systemctl start netStop.service
This spoils the working of the script. As two times systemctl gets repeated. If earlier there was some messing done with hostapd etc.,. then the directory of hostapd is not removed as there are left overs. These two are the small things which have to be corrected. Otherwise great.
On line numbers 640 & 641
systemctl systemctl enable netStop.service
systemctl systemctl start netStop.service
This spoils the working of the script. As two times systemctl gets repeated. If earlier there was some messing done with hostapd etc.,. then the directory of hostapd is not removed as there are left overs. These two are the small things which have to be corrected. Otherwise great.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Greate Scriptidev1_git wrote: ↑Sun Nov 03, 2019 12:20 pmAlthough, the POST is very old but based on the recommendation of @pugbot, I have created full automated script.
The script is present in Github URL - https://github.com/idev1/rpihotspot/blo ... network.sh. Please evaluate and let me know about your observations.![]()



I changed it a bit ... to be able to switch the repeater on and off.
Added to ur Script:
near Line 39
Code: Select all
startFile="$execDir/start
Code: Select all
if [ -f "$StartFile" ]; then
echo "[Remove]: $StartFile"
rm -f $netStartFile
fi
Code: Select all
# Create startup script without repeater mode
cat > $StartFile <<EOF
# booting rPi without repeater mode
# Output the standard errors and messages of rc.local executions to rc.local.log file.
exec 2> $rcLocalLogFile
exec 1>&2
#Start dhcpcd. Again, a 5-second sleep
echo "Starting dhcpcd service..."
systemctl start dhcpcd.service
sleep 20
echo "Starting dnsmasq service..."
systemctl restart dnsmasq.service
#systemctl start dnsmasq.service
echo "Enabling netStop service..."
systemctl enable netStop.service
systemctl start netStop.service
echo "Start DONE"
bash -c 'echo "\$(date +"%Y-%m-%d %T") - REPEATER MODE DEACTIVATED" >> $netLogFile'
EOF
chmod ug+x $StartFile
To the end replaced ur line in /etc/rc.local
Code: Select all
/bash/bin /home/pi/network-setup/bin/netStart
Code: Select all
# Repeater Mode Switch
_DATEI=repeater || true
if [ -f "/boot/$_DATEI" ]; then
/bin/bash /home/pi/network-setup/bin/netStart
else
/bin/bash /home/pi/network-setup/bin/start
fi
Maybe you like this idea .. I would be glad, if you would integrate it in your script.

Re: Raspberry pi 3 B+ as Access Point and Wifi client
Thanks @omkarpi3bplus for evaluating the script: https://github.com/idev1/rpihotspot/blo ... network.shomkarpi3bplus wrote: ↑Sat Nov 23, 2019 6:30 amThanks for the great script. It works great. As its works as repeater as well, wifi speed is reduced by half. That is the limitation of the device. To thank you I registered. There are two corrections to be done on the script.
On line numbers 640 & 641
systemctl systemctl enable netStop.service
systemctl systemctl start netStop.service
This spoils the working of the script. As two times systemctl gets repeated. If earlier there was some messing done with hostapd etc.,. then the directory of hostapd is not removed as there are left overs. These two are the small things which have to be corrected. Otherwise great.

Also, I am very thankful to you for identifying the problems in the script which, I have corrected now.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Thanks @Simon_420 for evaluating the script: https://github.com/idev1/rpihotspot/blo ... network.shSimon_420 wrote: ↑Wed Nov 27, 2019 7:11 pmGreate Scriptidev1_git wrote: ↑Sun Nov 03, 2019 12:20 pmAlthough, the POST is very old but based on the recommendation of @pugbot, I have created full automated script.
The script is present in Github URL - https://github.com/idev1/rpihotspot/blo ... network.sh. Please evaluate and let me know about your observations.![]()
![]()
![]()
!!! - Use it on rPi Zero W and raspbian Lite
I changed it a bit ... to be able to switch the repeater on and off.
Added to ur Script:
near Line 39near Line 334Code: Select all
startFile="$execDir/start
and near Line 585Code: Select all
if [ -f "$StartFile" ]; then echo "[Remove]: $StartFile" rm -f $netStartFile fi
I know, most of them is copy and paste, but i'm not a dev or Something and my english is also bad ^^Code: Select all
# Create startup script without repeater mode cat > $StartFile <<EOF # booting rPi without repeater mode # Output the standard errors and messages of rc.local executions to rc.local.log file. exec 2> $rcLocalLogFile exec 1>&2 #Start dhcpcd. Again, a 5-second sleep echo "Starting dhcpcd service..." systemctl start dhcpcd.service sleep 20 echo "Starting dnsmasq service..." systemctl restart dnsmasq.service #systemctl start dnsmasq.service echo "Enabling netStop service..." systemctl enable netStop.service systemctl start netStop.service echo "Start DONE" bash -c 'echo "\$(date +"%Y-%m-%d %T") - REPEATER MODE DEACTIVATED" >> $netLogFile' EOF chmod ug+x $StartFile
To the end replaced ur line in /etc/rc.localwithCode: Select all
/bash/bin /home/pi/network-setup/bin/netStart
Now i can easy switch on/off the repeater mode, with a flag in /boot...Code: Select all
# Repeater Mode Switch _DATEI=repeater || true if [ -f "/boot/$_DATEI" ]; then /bin/bash /home/pi/network-setup/bin/netStart else /bin/bash /home/pi/network-setup/bin/start fi
Maybe you like this idea .. I would be glad, if you would integrate it in your script.![]()

Also, it will be helpful for me to integrate your suggestions into the script but, please provide more info in the Github since, I am a bit confused with your suggestions.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
I have been working on this for a while. I am really trying to make this work in many ways but no matter what I try, regardless of the method, the connection doesn't get to the internet (I am hardwired).
I can connect to the AP but it always says no internet and drops the SSID from view.
Any help is greatly appreciated
I can connect to the AP but it always says no internet and drops the SSID from view.
Any help is greatly appreciated
Re: Raspberry pi 3 B+ as Access Point and Wifi client
Thank you very much for your script. I will test this as soon as I get back from my business tripidev1_git wrote: ↑Wed Dec 25, 2019 10:28 amThanks @Simon_420 for evaluating the script: https://github.com/idev1/rpihotspot/blo ... network.sh
Also, it will be helpful for me to integrate your suggestions into the script but, please provide more info in the Github since, I am a bit confused with your suggestions.

I do have a question or two and hope you or someone in the know can help me out.
1. One needs to specify the SSID of the AP one wants to create. However, what about the client side of things? Do you just need to connect the client via the normal interface or do you need to specify client information somewhere?
2. If the internet connection on the client side is dropped because of a weak signal and maybe the channel changes due to a different hotspot being closer, will I have to manually rerun the script or is this not an issue?
3. Does this still works as a repeater and therefor half the speed or is it an AP with full speed? Or was the above comment wrong?
Or is this based on it acting as a repeater rather and a client and AP at the same time? Reason I am asking is that I want to run a VPN client on this device that tunnels my external devices through the RasPi to my VPN server. I am not sure if this would work in repeater mode or only in true AP+STA mode.
Thank you very much for sharing your work and I apologize if some of my questions have obvious answers for someone sitting in front of their device. Unfortunately I am not and am sooo eager to give it a try that I am trying to learn as much about it as I can before I get back home.
Re: Raspberry pi 3 B+ as Access Point and Wifi client
@idev1_git:
I installed your script and it seemed to install okay. However, I do not see the AP I created. Can I somehow check what is wrong?
I installed your script and it seemed to install okay. However, I do not see the AP I created. Can I somehow check what is wrong?