Rpi-jukebox-rfid: feature request: Hotspot Mode per GPIO aktivieren

Created on 25 Sep 2018  ·  13Comments  ·  Source: MiczFlor/RPi-Jukebox-RFID

Hallo Zusammen,

ich hatte gerade eine Idee.
Ist es möglich den RaspberryPI per GPIO Tastenkombination in den HotSpot mode zu setzten?

Somit könnte man zum beispiel auch im Urlaub die Box per WLAN steuern,
dazu könnte man auch die Box für einen freund aufsetzt und er kann dann später einfach die BOX ohne Konsolen Kenntnisse in sein WLAN hängen.

Alternativ wenn man per Tastenkombination auf der Box eigene Scripte ausführen könnte.
Damit könnte man solche Feature relative einfach selbst aufsetzten.

Gruß Robert

All 13 comments

I think it's a great idea, I guess with hotspot mode you mean PI as access point for direct connect?
https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

This way you could access the Pi to directly control OR setup the local WIFI connect in your hotel or at a friend and this way also get Internet connection to add youtube streams... on the go. I already asked myself if I can configure different wifi-access credentials for different wifi-SSIDs (but still did not search for it).

Perhaps not only GPIO but also RFID command to set "Access Point"-mode would be nice.

I think it is an excellent idea, too. And started working on this:
https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/master/scripts/installscripts/stretch-install-default-HotspotAddOn.sh
This was during the time of the "one line install script" and I dropped it, because it got too complicated to add this to the mix.
My idea was - an that is the script I started with: if the Phoniebox does not find a known Wifi to connect to, it will go into Hotspot Mode.
With a switch, that might be even easier.
The main problem - and the switch idea (GPIO and/or RFID) solves that: not all wifi cards can do hotspot mode.
So if you want to get a headstart, be my guest :) I join you guys later when reviewing the pull request :)

I also like the idea of connecting the box with different devices.

Instead of putting the phonipox into a AP a solution could also be to add additional wifis to the wifi list.
See: https://medium.com/@mikestreety/use-a-raspberry-pi-with-multiple-wifi-networks-2eda2d39fdd6

So you can put in for example your mobile hotspot.

I also like the idea of connecting the box with different devices.

Instead of putting the phonipox into a AP a solution could also be to add additional wifis to the wifi list.
See: https://medium.com/@mikestreety/use-a-raspberry-pi-with-multiple-wifi-networks-2eda2d39fdd6

So you can put in for example your mobile hotspot.

That's neat and would be the other way round and no hotspot mode on Pi wifi needed as your mobilephone is the "hotspot". Then phoniebox just tests through all perconfigured wifis on start in given order an last one is always your mobile hotspot on the phone.
This way you could also directly use the internet connection via SIM at least for one or two youtube videos.

Sorry for threadjacking - this post is not on "Pi as hotspot" but "Pi connecting to multiple hotspots":

@Franzformator
It works, but not as described in the link as it is for older raspberian versions. Here is the config for our version including mixed static/dhcp and priorities of ssids:

Warning: have a eth-cable near and test if the eth0 conf works, so if you config something wrong on wifi, you have a backup solution to connect.

_sudo nano /etc/dhcpcd.conf_

...
interface eth0
static ip_address=192.168.0.222/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 46.182.19.48 fd51:42f8:caae:d92e::1
static domain_search=

#wlan Bereich:  Standard -interface wlan0- aber da static und dhcp noetig nach SSID filtern
#interface wlan0

ssid fritzhome
static ip_address=192.168.0.223/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 46.182.19.48 fd51:42f8:caae:d92e::1
static domain_search=

ssid androidhotspot
# wenn nichts weiter angegeben dann reicht das wohl fuer dhcp

# weitere ssid nachfolgend eintragen - passworte dann in etc dhcpcd.conf
# ssid hotel

# ssid friend

Followed by entering the passwords for the SSIDs and priorising if more than one SSID is present. That way I could get the PI to take the androidhotspot on boot and after shutting down hotspot it automagically connected to fritzhome. id_string is not needed I think.

_sudo nano /etc/wpa_supplicant/wpa_supplicant.conf_

country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="fritzhome"
        psk="passwordhere"
        id_str="home"
        priority=3
}

network={
        ssid="androidhotspot"
        psk="passwordhere"
        id_str="mobile"
        priority=5
}

[Update]Be sure to change hostname to a unique name like phoniebox, so can connect to your box no matter which IP-Adress the box gets on other wifis:
sudo nano /etc/hostname
phoniebox

_sudo reboot_

connect to your box

  • via browser http://phoniebox (be sure to use the http:// - if it didn't work, it could be you land on phoniebox.de ;) )
  • via ssh using phoniebox:22

Mobile Hotspot use:
Be aware your PI is using your perhaps expensive 3G data plan (e.g. foreign country) so perhaps deactivate mobile data prior to letting PI connect.

not needed, hostname section above
One thing has to be know using a mobile hotspot (at least on andorid without rooting). The PI needs to be set to DHCP and it seems it always gets an IP in DNS range 192.168.42.1-254 or 192.168.43.1-254 (https://android.stackexchange.com/a/60408). To see which IP ur PI (pun intended) has, see your mobile hotspot device list on android. after that "Mobile SSH" on Andorid or browser interface works as usual.

Hotel Use:
not needed, hostname section above
If you don't know the hotels subnet it will be hard to guess I guess, so perhaps a latest_wifi_ips.log of recently used IPs should be written out somewhere so you can:
let PI access the hotel wifi once
* then use mobile hotspot an check the latest_wifi_ips.log and write down hotel dhcp-IP
* reconnect to hotel wifi and enter found IP in browser / ssh (be aware that other hotel guests / friends could also control your PI.

AddOn: script addhotspot.sh writes correct config to both files (as DHCP-config without prio):


#!/bin/bash

# addhotspot.sh newssid newpassword
wpa_passphrase "$1" $2 >> /etc/wpa_supplicant/wpa_supplicant.conf

# /etc/dhcpcd.conf
echo ssid $1 >> /etc/dhcpcd.conf

usage:
_sudo ./addhotspot.sh hotelssid hotelpassword_

Sounds perfect!

I think that you don't get your IP inside some WiFis should not be a problem. Also, that your IP is changing trough DHCP should be ok.

My suggestion would be to use hostname to address the Phonibox on the network. In the moment this name is "raspberrypi".
Maybe we should change it to "phoniebox" or something else to prevent collisions.

See: https://blog.jongallant.com/2017/11/raspberrypi-change-hostname/

Hi @Franzformator @gizmo21
if this works and two people tried it, could you add this as a document to the docs section - which I would then merge and link from the manual? Then
a) we have some working hack in the docs
b) your contribution will be in the contributors hall of fame :)

My phoniebox is not finished jet and I can't run it in the next weeks. But I will test this as soon as possible.

If this works.
Would it be possible to manage the WiFi list over the Web-App?

Should be possible. Parsing config files to extract data is just very annoying at times :)

Typed with thumbs and good intentions.

Am 27.09.2018 um 07:25 schrieb Franzformator notifications@github.com:

If this works.
Would it be possible to manage the WiFi list over the Web-App?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Well perhaps a first simple approach would be to just enter new Hotspots via web-app by just taking the two values and fire&forget them into my addhotspot.sh

A later correction of password or SSID had to be done on cmdline though.

Perhaps I'll try that. That said, I already thought of a userconfigurable separate /htdocs/userform.php (gitignored) but linked from navbar or settings menu.
There you could configure some own form-fields to take arguments for your own .sh scripts you would like to run from the webapp.
I already did that with my CD-autorip2audiofolder-feature via abcde, but after a git pull I have to remerge that again.
Well I guess the userbase to use this userform.php feature is too small.

I think the first step would be to integrate the scripts and create a pull request, so others can test it on the develop branch - including me :)
Also, I am curious to see that custom form fields beast you created. Why not share it and then we can see what to do with it.
If the script set for the hot spot works, we can work on the UI step by step. I think there is a good bunch of Phoniebox users who would know how to navigate their way around the scripts.
All the best, micz

Added manual update #229 for https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/225#issuecomment-424531924

Added the userScript.php part as well https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/229/commits/998d4f935782fa181a8ca2e1c812512ebc02424d
^this one is just a proof-of-concept and the php-code is mainly taken from an older version of fileUpload.php so don't expect pretty code or fitting variablenames - hope it integrates into the newer versions at least for testing (I'm still on 1.0). For a real integration it needs to be recoded.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

laclaro picture laclaro  ·  10Comments

fred-h20 picture fred-h20  ·  7Comments

toxidle picture toxidle  ·  7Comments

MontyMcMutton picture MontyMcMutton  ·  8Comments

topas-rec picture topas-rec  ·  9Comments