X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=script%2Fboot_ap_mode.py;fp=script%2Fboot_ap_mode.py;h=f715aeb40278b6cf89b51fb9304f435cf3c31fce;hb=480bfdd3cbb50749f8f22eabb75c6cc2d6c467f6;hp=0000000000000000000000000000000000000000;hpb=a4fbe02cba620f5ddefae08975fd22dc8ea05212;p=networtool-web.git diff --git a/script/boot_ap_mode.py b/script/boot_ap_mode.py new file mode 100755 index 0000000..f715aeb --- /dev/null +++ b/script/boot_ap_mode.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python2 +from gpiozero import Button +import subprocess +import os + +# https://gpiozero.readthedocs.io/en/stable/recipes.html#pin-numbering +# https://www.raspberrypi.org/documentation/usage/gpio/ + +# Add this line in /etc/rc.local +# /usr/local/networktool-web/script/boot_ap_mode.py 2>&1 > /tmp/boot_ap_mode.txt + +# This script is used to boot with AP mode or WiFi mode. +# Run this in rc.local. When boot, it check the GPIO 21, if it is Low level (connected to Ground) +# Then it starts with AP mode + +DIR = os.path.dirname(os.path.realpath(__file__)) + +button = Button(21) +if button.is_pressed: + print 'button is pressed, switch to ap mode\n' + subprocess.check_call(DIR + '/startHostapd.sh', shell=True) + +