11 ms·
Simultaneous AP and Client Mode Wi-Fi on Raspberry Pi Zero W
- dcminter 6y agoThe pithier article (linked to from the above) is at https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/ https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simul...
- lukicdarkoo 6y agoThe 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.
- djsumdog 6y agoI noticed the script was using the same MAC address for the ap0 adapter. From that blog post... > A number of tutorials I found claimed that the address for the virtual AP must be different from the primary MAC address. I found there to be no difference in behavior, but you should be able to change the last byte, for example, to give your client and AP different MACs. huh ... You'd think this could cause interference, but I guess not if they have different SSIDs and passwords.
- brendawalsh 6y agoAny 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 6y agoI 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.
- brendawalsh 6y agoI saw the apt install cron, and wondered what the solution w/out cron entailed.
- lukicdarkoo 6y agoI 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 6y agoSystemd 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.
- lukicdarkoo 6y agoNo idea! I spent some time debugging it, but it just does't make sense it works with cron and not with systemd. Let me know if you have any idea where to look!
- nottorp 6y agoBecause systemd does many things badly instead of one thing well :)
- shubhamjain0594 6y agoThanks for this. I had built [similar repository](https://github.com/computationalprivacy/unveil-pi-data-collector https://github.com/computationalprivacy/unveil-pi-data-colle...) 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 6y agoHere's the article which the posted GitHub project is based on. https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/ https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simul... > 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.
- messe 6y agoWhatever happened to ad-hoc mode?
- capableweb 6y agoNot 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 6y agoI thought ad-hoc is N devices, optionally decentralized. This could emulate that.
- ausjke 6y agoad-hoc in general runs a different path inside kernel module, which is normally not supported as well as AP/client mode, so, while many chips can do ah-hoc in theory, in software side it is a difference story
- mschuster91 6y agoIt's extremely rare that one gets to a working ad-hoc setup... it's a chicken-egg problem. Drivers, firmware, software and UI support are bad, so no one uses it, so development is an afterthought, rinse and repeat.
- cordite 6y agoI haven't considered this since the days of Nintendo DS picto chat.
- ngcc_hk 6y agoWhy 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 6y agoPartially 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.
- Raed667 6y agoA 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 6y agoStarting point: https://github.com/balena-io/wifi-connect https://github.com/balena-io/wifi-connect
- numpad0 6y agoI’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
- flak48 6y agoYep. I didn't do it with a RasPi but with a Chinese chip I found off AliExpress Managed to strip down OpenWRT so it would fit in the meager 16MB RAM/8MB flash. In the init script (a bash script) just checked if a wifi network was configured previously (creds stored in a file). If configured, try to connect to the network for 10 seconds. If it couldn't connect, then switch to AP mode and start a lightHTTPd server listening on 192.168.0.1:80. The only files it served was a simple index.html with some JS that called a bash script via CGI that used a openwrt bash library to scan and list the available wifi networks. Then a HTML form to choose an SSID and enter the password, upon submit call another bash file to connect to the network (switch to client mode) with a timeout. If it fails, the bash would switch back to AP mode. Polling in JS to check if the connection was successful (by checking if AP mode becomes active again)
- jiggunjer 6y agoThis is basically what a chromecast does?
- Raed667 6y ago
- sorenjan 6y agoCan 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 6y agoI think it would need to spoof the same MAC as the original AP too.
- est31 6y agoNo, 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_ 6y agoHow 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)
- not_exactly__ 6y agoI’d like to know this too please :)
- deleted 6y ago[deleted]
- reactchain 6y agoHas anyone noticed a shortage of Pi Zeros recently? It seems everywhere has run out of stock.
- capableweb 6y agoRecently? I've seen a shortage (in EU shops (Pi Zero W specifically)) since it was launched and seems it's not getting better either.
- kingosticks 6y agoComes and goes. As it happens they are back in at https://shop.pimoroni.com/products/raspberry-pi-zero-w https://shop.pimoroni.com/products/raspberry-pi-zero-w (limited to 1 per order).
- capableweb 6y agoWhen it's in stock, it's always limited to X per order, so I'd still stay it's in shortage currently
- kingosticks 6y agoYes, I entirely agree. I often add one with my orders when I can because they are useful and the equivalent clone versions work out very expensive in the UK. They are in short supply because the margin on them must be tiny and it's not worth wasting much manufacturing capacity on them. I wish they would update the specs but I think that's very unlikely to happen as they'll lose the original $5 computer claim. I don't care if it got a little more expensive (again), I like the form-factor.
- mleo 6y agoMore 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.
- sdfhbdf 6y agoI've looked at the links posted here and the repo but I fail to find what is the use case for this?
- opencl 6y agoIt could be used as a range extender, though not a very good one. Probably a better use case would be connecting older devices like the Nintendo DS that don't support WPA2 to your network without forcing all of your other devices onto WEP.
- sleavey 6y agoWhy not a very good one? In terms of range (with the PCB antenna)? Or does the Pi firmware not support some modern 802.11 standards or what?
- flaviu2 6y agoI'd guess the hardware is the problem. Most antennas I've seen on access points are larger than the entire Pi Zero W. While I'm no radio expert, I'd expect APs to use the smaller antennas if they were capable of being as good as bigger antennas.
- sleavey 6y agoAh, that reminds me of an article someone here linked to a few years ago: [1]. That claims the efficiency is -3.5 dB compared to a typical -1.25 dB dipole in dedicated wireless equipment. Not bad; the difference is only a factor of ~2 in power for x8 reduction in size. [1] https://www.embedded-computing.com/articles/a-lesson-in-wireless-engineering-from-the-raspberry-pi https://www.embedded-computing.com/articles/a-lesson-in-wire...
- zamadatix 6y agoWell 2 things really. Yeah the hardware is a bit garbage as it only goes up to 802.11n only on 2.4 GHz and it's also a 1x1 with a poor antenna. The big thing though is it requires you use the same channel which is disastrous for repeater performance. Ideally you'd have 802.11ac/ax with 2 separate PHYs each with 4x4 (even if the clients are 1x1 or 2x2 the additional beamforming helps) set to two separate channels. That's not to say it won't function well enough in a pinch but I wouldn't seek this out as a permanent answer if I were buying new.
- Dahoon 6y agoSo in short a poor range extender or a way to do MitM.
- op03 6y agoThe 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/
- 7ewis 6y agoWould 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.
- gzu 6y agoI was interested in setting up something similar (as a novelty) to cheaply bypass an untrusted network. Untrusted Wifi > RasPi Client > OpenVPN > AP How would you go about routing the VPN device between client and AP?
- derefr 6y agoMaybe 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 6y agoDuring 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).
- yeswecatan 6y agoSounds like it would work. I may give that a try. Now to find a VPN for Canada... edit: Now that I think about it, what's the difference between using the Pi as an AP and using it as a DNS server?
- basilfx 6y agoI'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 6y agoWhat 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.
- cptskippy 6y agoThis 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 6y agoI 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 6y agoCan you explain more?
- jjeaff 6y agoYou 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.
- 0134340 6y agoOr you can buy an older used router for ~$10 that supports FreshTomato or DDWRT, I know those support simultaneous AP and client mode. I spent a year using one for such needs and worked well on an E2500. Or buy a dedicated like OP said as it's probably less trouble and more reliable, depending on model.
- DrAwdeOccarim 6y agohttps://en.wikipedia.org/wiki/Captive_portal#Circumvention_of_captive_portals https://en.wikipedia.org/wiki/Captive_portal#Circumvention_o... In case anyone wants to know more.
- non-entity 6y agoJust 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 6y agoIt'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
- punnerud 6y agoHow 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.
- woleium 6y agoor just route over icmp or dns
- jacobwilliamroy 6y agoYou 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.
- BossingAround 6y agoI 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.
- noncoml 6y agoVPN access point
- cmxch 6y agoInitial configuration/management for the device in question.
- TaylorAlexander 6y agoWould be good for a robot you can ssh in to at home and still connect when out in the field.
- EricE 6y agoOr provide a gateway for wireless devices that don’t support WPA2 Enterprise? Interesting....