guess you are looking for a configuration mode on the Pi.
With a SPDT switch connected to GPIO pins you can trigger some scripts to change the PI's config and start in AP mode.
for both modes i would use different network interface config in /etc/network: interface.ap and interface.normal. the switching script just will set a symlink to the specific interface file
in normal mode the pi will connect its wlan0 to one of the WIFIs configured in the wpa_supplicant.conf. IP will be obtained automatically by DHCP.
The /etc/network/interfaces.ap to:
iface wlan0 inet dhcp
allow-hotplug wlan0
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
in AP mode, the wlan0 needs to be configured with a static IP, bring up hostapd and dhcp.
you will need a installation of hostapd and dhcp server (the following is from eLinux:
install software:
sudo apt-get install hostapd udhcpd
configure udhcpd: /etc/udhcpd.conf
start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices.
end 192.168.42.20
interface wlan0 # The device uDHCP listens on.
remaining yes
opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use.
opt subnet 255.255.255.0
opt router 192.168.42.1 # The Pi's IP address on wlan0 which we will set up shortly.
opt lease 864000 # 10 day DHCP lease time in seconds
infact all the dns settings will be irrelevant because the Pi has no internet connection during AP mode.
Then configure the /etc/network/interfaces.ap to:
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
and the last step for AP mode is the configuration of hostapd at /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=My_AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=My_Passphrase
wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP # You better do not use this weak encryption (only used by old client devices)
rsn_pairwise=CCMP
wiring the switch
here i can't bring up all details because i cant test the wiring at the moment. in general the configuration should be like this tutorial. the switch will be connected on two GPIO pins.
scripting
a phyton script will check the position of the switch and fire the changes if the mode changes. the status of the mode can be checked with a variable that will be set on status changes or just read where the symlink is pointing to...
it would be basically like this GPIO.input(21) is for AP mode and GPIO.input(17) is for normal mode:
while True:
if (GPIO.input(17) and my_state=='AP'):
my_state = 'normal'
os.system("rm /etc/network/interfaces")
os.system("ln -s /etc/network/interfaces.normal /etc/network/interfaces")
os.system("ifdown wlan0 && ifup wlan0")
os.system("systemctl stop hostapd")
os.system("systemctl stop udhcpd")
os.system("systemctl disbale hostapd")
os.system("systemctl disbale udhcpd")
if (GPIO.input(21) and my_state==normal):
my_state = 'ap'
os.system("rm /etc/network/interfaces")
os.system("ln -s /etc/network/interfaces.ap /etc/network/interfaces")
os.system("ifdown wlan0 && ifup wlan0")
os.system("systemctl enbale hostapd")
os.system("systemctl enbale udhcpd")
os.system("systemctl start hostapd")
os.system("systemctl start udhcpd")
okay this script snipplet is a quick example and very dirty. (I am not an expert in python and could not test it.) Maybe some others can help to improve it.
SSH does not reliably work via usb
- I'd be interested to know, reliability aside, how this is achieved at all ... I do have a kernel of a solution in mind, but nee to get to my raspberry pi to test it before I even propose a solution :p are you able to plug in a thumb drive with your enclosure?