
Simultaneous AP and Client Mode Wi-Fi on Raspberry Pi Zero W - lukicdarkoo
https://github.com/lukicdarkoo/rpi-wifi
======
basilfx
I've been using a similar solution, but I had quite some problems using AP and
client mode at the same time. The WiFi chip inside the RPi Zero W (BCM43430)
only supports AP and client mode on the same channel. If you setup an AP
first, then connect to a client network, hostapd will update the channel of
the AP, but clients will notice a disconnect. There are also issues with the
firmware blob (see
[https://github.com/raspberrypi/firmware/issues/1403](https://github.com/raspberrypi/firmware/issues/1403))
in AP mode that haven't been solved yet.

~~~
watchdogtimer
What I did on a similar project using a different board was scan all the APs
in the area first, get the band of the AP with the strongest signal, then
bring up the device AP using that band. I figured the AP with the strongest
signal is the closest AP and the one you most likely want to connect to.

------
dcminter
The pithier article (linked to from the above) is at

[https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-
simul...](https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simultaneous-
ap-and-managed-mode-wifi/)

~~~
lukicdarkoo
The script is heavily based on the article. Full credit to the article!

For everybody interested in details, the article gives useful insights on
configuration automated by the script.

------
shubhamjain0594
Thanks for this.

I had built [similar
repository]([https://github.com/computationalprivacy/unveil-pi-data-
colle...](https://github.com/computationalprivacy/unveil-pi-data-collector))
as a part of wifi data capture and visualisation experiment ([Project
UNVEIL]([https://github.com/computationalprivacy/unveil-
deployment)](https://github.com/computationalprivacy/unveil-deployment\))) but
it used external antenna.

Any links on how does underlying hardware work to enable simultaneous
connections?

~~~
lioeters
Here's the article which the posted GitHub project is based on.

[https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-
simul...](https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simultaneous-
ap-and-managed-mode-wifi/)

> At this point, we should be able to connect a device to our Raspberry Pi
> Zero W’s AP SSID, while we also have our RPi connect to another access point
> for internet access, and we should be able to access the internet from that
> device through our RPi.

The "simultaneous" aspect seems to be achieved by having two devices: wlan0
and ap0, the latter created by udev.

------
cptskippy
This is perfect for hotels whose TV sucks and their wifi has those captive
portals so you can't use a Chromecast, Firestick, or Roku.

It just needs a captive portal of its own when the client side is
disconnected.

~~~
jjeaff
I travel with a little $12 wireless access point for this purpose. Which is
actually cheaper than you can get a pi zero w setup with PSU anyway.

~~~
DrAwdeOccarim
Can you explain more?

~~~
jjeaff
You can search for "travel router". These things are built exactly for this.
[https://www.amazon.com/s?k=travel+router](https://www.amazon.com/s?k=travel+router)

They usually have an interface so that when you get to a hotel, you can either
plug them into the hardline or they will let you connect and then select the
hotel's wifi and enter the password.

The great thing is that all your devices will already have your travel router
wifi info saved. So when I go to a hotel and fire it up and connect, all our
phones, ipads, Roku, even an Amazon echo we sometimes take will will all
connect right up.

Sometimes I even luck out and the lan cable going into the TV will be
unmetered. One hotel I was getting 100mbps up/down all week for free.

------
sdfhbdf
I've looked at the links posted here and the repo but I fail to find what is
the use case for this?

~~~
gumby
Ever stay at a hotel that charges for wifi access on a per device basis?

~~~
dboreham
No, but it's not uncommon to find hotel internet that has a fairly low device
count limit. The place I use WiFi repeaters is on airplanes, to avoid the
hassle of re-authenticating every time I switch between phone and tablet and
laptop.

------
7ewis
Would this be good for something like connecting the Pi to a VPN for say
Canada, then broadcasting an SSID for it.

Then connecting a Fire TV Stick or Chromecast to this AP, and tricking it into
letting you stream Canadian Netflix or DAZN etc.

~~~
derefr
Maybe it was just an arbitrary example, but really, there's no reason to want
Canadian Netflix. We only get about half the stuff the US does.

Also, we have the same "content can't be offered here by Netflix because the
local IP license has been bought out by a different owner" problem that the US
and many other places does; but in Canada's case, most of those local IP
owners are conservative dinosaur media companies, who either haven't managed,
or haven't bothered, to set up their own alternative streaming services yet.
They just... hold the licenses, doing nothing with them. Hoarding them, like a
dragon. So there are many shows you just can't stream in Canada at all, no
matter who you're willing to pay.

~~~
zxcvbn4038
During the pandemic I can blaze through new additions to the Netflix US
catalog with speed, then its time to go find something new to watch for the
next few weeks. All of the regional Netflix get movies and shows that the US
does not - I was able to watch Star Trek Discovery in its entirety on Netflix
Germany for example. Netflix Hong Kong has an amazing catalogue but I could
not get that one to work with my VPN. Netflix UK is the most disappointing
because it is more or less devoid of UK movies and shows aside from Monty
Python and Peppa Pig (both already available in the US anyway).

------
brendawalsh
Any idea why systemd was not able to be reliably used, and had to use cron?

Is there a ‘fix’ for that ?

edit: This was not meant to be offensive. I was simply hoping somebody could
offer how it could be used with systemd and remove the reliance on cron.

~~~
Nextgrid
I think it’s just a shortcut because of lack of experience with systemd (this
is not intended to be offensive btw - if cron is already installed and you
save time by just using what you know, why not?). I would be very surprised if
cron could do something that can’t be done with systemd timers.

~~~
lukicdarkoo
I suspected that the network wasn't ready, so I configured the service start
after network without much luck. I didn't go further than that.

~~~
Nextgrid
Systemd can be very powerful and you can even depend on individual devices
being added/removed. I’m pretty sure you can even replace the udev rules with
a systemd equivalent if you tried hard enough.

------
reactchain
Has anyone noticed a shortage of Pi Zeros recently? It seems everywhere has
run out of stock.

~~~
mleo
More time to tinker at home? Over the course of a couple weeks, I purchased
four a two months back. A project I worked on inspired at least another person
in my office to buy one.

~~~
wil421
My local microcenter has been jammed packed since the pandemic started. I also
purchased 2 a few months back and a bunch of accessories.

------
non-entity
Just curious, but I was trying to help someone with a Raspberry Pi Zero W wifi
issue the other day and had trouble finding sny info about the wireless
chipset used. I couldn't find it listen anywhere on the site, or several tech
review sites, only extremely useless information on the 802.11 versions
support. If it recall correctly, it didn't even show up in the schematica.
Luckily wikipedia had the name of the chipset used, but I don't get it. Why
does their official documentation seem to be so secretive?

~~~
dc_count
It's not secretive, it's just that most people are not very interested in the
exact type of Wi-Fi chipset used.

You can see the chipset name (BCM43430) on dmesg:

    
    
      $ dmesg | grep brcmfmac
      [   26.488164] brcmfmac: F1 signature read @0x18000000=0x1541a9a6
      [   26.512759] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
      [   26.513315] usbcore: registered new interface driver brcmfmac
      [   26.539406] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.raspberrypi,model-zero-w.txt

------
BossingAround
I wonder what's the use case other than a poor wifi extender, or niche cases
of sharing one connection between multiple devices where you pay per
connection.

Though I do wonder whether you can add a proper wifi antenna and make the RPI
an 'ok' wifi extender. That might be a viable option, provided the performance
is ok.

~~~
cmxch
Initial configuration/management for the device in question.

------
sorenjan
Can this be used as a range extender if you use the same SSID and password for
the access point as the net you're connecting to? Would other clients silently
roam between the two (or more) networks using the same name and password?

~~~
jiggunjer
I think it would need to spoof the same MAC as the original AP too.

~~~
est31
No, the identification method of an extended service set is the SSID, aka the
network name. Just set up the same SSID and password on both APs, and put them
onto the same ip layer network. Your device will roam the networks
automatically. Each AP should get its own MAC otherwise they will think
packets sent to the other AP was meant for them. WiFi is robust enough to deal
with noise like e.g. bluetooth, so it might survive it, but I doubt it'd
support two STAs with the same BSSID communicating with each other.

[https://en.wikipedia.org/wiki/Service_set_(802.11_network)](https://en.wikipedia.org/wiki/Service_set_\(802.11_network\))

~~~
voltagex_
How do you do this with most consumer devices? The only AP I've seen do it
successfully is the AsusWRT series - Media Extender mode seems to be
transparent. If I try it with anything else I'll end up with two seperate
networks, e.g. 192.168.8.0/24 connected to 10.1.1.0/24 (I actually have a
GL.inet AR750S in this configuration right now)

~~~
jonathonlui
If you can wire the 2 AP via a LAN, then this is how I've used cheap consumer
wifi APs which are usually combo AP+router devices:

The first AP is connecting to internet gateway through its WAN port. This AP
does the networking stuff like DHCP, NAT, etc.

The other wifi APs are configured to be AP-only, i.e. disable DHCP. Use same
wifi SSID and auth settings as the first AP. Then connect the APs using their
LAN ports.

Client devices should now connect to the AP with the best signal.

But if the client is already connected to an AP and a better-signal AP is
available, many clients won't automatically connect to the better AP. This is
because the client don't know that the other AP is the same network. So if you
move around you may need to trigger the client to disconnect and reconnect.

This can be solved with APs that have a "mesh" feature which can instruct
connected clients to reconnect to a better AP in the same network using
[https://en.wikipedia.org/wiki/IEEE_802.11k-2008](https://en.wikipedia.org/wiki/IEEE_802.11k-2008)
but AFAIK mesh systems from different manufacturers aren't interoperable.

------
ngcc_hk
Why is that not easy and widely used as nearly all devices we used like camera
(dslr to car camera) and remote controller all resolved to stop WiFi and
switch to another mode etc to connect.

~~~
caust1c
Partially because of chip capabilities, and partially because understanding
networking is hard.

I don't think most chips can do this fwiw, but it's definitely cheap enough
now that cameras and IoT devices will probably start doing it everywhere.

------
messe
Whatever happened to ad-hoc mode?

~~~
capableweb
Not sure exactly what you're referring to, did the author explain in the past
they rather want ad-hoc network setup or something?

Otherwise, ad-hoc is different from AP+Client, as ad-hoc is only between two
devices (at least from what I gather) while AP+Client would allow a
distributed network where clients are interconnected.

~~~
jiggunjer
I thought ad-hoc is N devices, optionally decentralized. This could emulate
that.

------
Dahoon
So in short a poor range extender or a way to do MitM.

~~~
op03
The Offline Wikipedia/Stackexchange project (Kiwix) has similar devices for
kids classrooms/libraries in rural areas with no internet -
[https://www.kiwix.org/en/downloads/kiwix-
hotspot/](https://www.kiwix.org/en/downloads/kiwix-hotspot/)

------
Raed667
A bit off topic:

I'm looking for a project that starts with an AP. Once someone connected to
it; it opens a web page to configure the client (choose which WIFI from a
list, and type the password).

It connects to the chosen WIFI and shuts down the AP.

Anyone here did something similar to that?

~~~
savrajsingh
Starting point: [https://github.com/balena-io/wifi-
connect](https://github.com/balena-io/wifi-connect)

~~~
numpad0
I’ve seen Raspberry Pi images from Ubiquity Robotics(not Ubiquiti Networks)
having similar daemon called “pifi” for command line operation, but this one
looks nicer

------
punnerud
How to get faster internet at a hotel: Have 4-5 of these connected and talking
with the hotels WiFi, and one who share Internet with you. All the traffic
goes to a server you have at home that “join+proxy” the traffic. Based on the
idea that every user have a limited bandwidth, combining multiple will give
you higher speed.

~~~
jacobwilliamroy
You can also plug multiple wifi dongles into a usb 3.0 hub and use magic to
load balance traffic across all the interfaces connected to different wifi
internet APs.

