--- /dev/null
+#!/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)
+
+
</textarea>
<form action="/main" method="post">
<br>
-Current Mode {{mode}}
-<input type="checkbox" name=
- Scan and Select the WiFI to connect to:<br>
+Current Mode {{mode}} <br>
+Scan and Select the WiFI to connect to:<br>
<select name='select'>
% for ssid in ssids:
+ % if mode == 'AP':
+ <option value="----" selected>{{ssid}}</option>
+ % end
% if ssid == usedSsid:
<option value={{ssid}} selected>{{ssid}}</option>
% else:
+++ /dev/null
-%if name == 'World':
- <h1>Hello {{name}}!</h1>
- <p>This is a test.</p>
-%else:
- <h1>Hello {{name.title()}}!</h1>
- <p>How are you?</p>
-%end
+++ /dev/null
-<html>
-<body>
-<div id='Network Config' style="text-align:center;">
-<p>Login<p>
- <form action='/mm' method='post'>
- Username: <input name="username" type="password" /><br>
- Password: <input name="password" type="password" />
- </form>
-</div>
-
-<div id='Tracker++ Config'>
- <form action='/mm' method='post'>
- Username: <input name="username" type="password" />
- Password: <input name="password" type="password" />
- </form>
-</div>
-<p>This is atest </p>
-</body>
-</html>
DIR = os.path.dirname(os.path.realpath(__file__))
CONF = '/usr/local/trackerpp/config/trackerpp.conf'
SERVICE = 'trackerpp.service'
+USERNAME = 'admin'
+PASSWORD = 'admin123'
TEMPLATE_PATH.insert(0, DIR + '/views/')
# return AP or
def getCurrentMode():
- return subprocess.check_output("iw dev | grep type | awk '{print $2}'", shell=True).strip()
+ return subprocess.check_output("iw dev wlan0 info | grep type | awk '{print $2}'", shell=True).strip()
def isAPmode():
return getCurrentMode() == 'AP'
return template('login.tpl', username="username", password="password")
def check_login(username, password):
- return True
- #return username == 'admin' and password == 'admin123'
+ return username == USERNAME and password == PASSWORD
form_dict = {'ipaddr': getIpAddr(),
'ssids': getSSIDs(),