Skip to content

Commit f6b742c

Browse files
committedDec 14, 2013
wireless fixes
1 parent 0dee087 commit f6b742c

File tree

5 files changed

+55
-40
lines changed

5 files changed

+55
-40
lines changed
 

‎http/connect.php

+6-13
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,22 @@
1010
<div class="title">KegNet Client WiFi Configuration</div>
1111
<hr/>
1212
<br/>
13-
<textarea rows="15" cols="72" wrap="hard" disabled="disabled">
13+
<textarea wrap="hard" disabled="disabled" style="width:90%; height:120px;">
1414
<?php $ok = connect(); ?>
1515
</textarea>
1616
<br/>
1717
<br/>
1818
<div class="instructions">
1919
<?php if ($ok) { ?>
20-
Wifi Setup Success!<br/>
20+
Wifi Configuration OK!<br/>
2121
<br/>
22-
<span class="large">Step 1.</span>Disconnect the power and ethernet network cable from your
23-
KegNet device, and then reconnect the power cable only.<br/>
24-
<br/>
25-
<span class="large">Step 2.</span >In 2-3 minutes, the green "CON" indicator
26-
light should illuminate indicating a successfull connection to the
27-
KegNet servers over Wifi.<br/>
28-
<br/>
29-
<div class="center">
30-
<img alt="diagram" src="case_front_1.png" width="250" style="margin-left:auto;">
31-
</div>
22+
<span class="large">Click Next below to continue</span>
3223
<?php } else { ?>
3324
Wifi Configuration Failed!<br/>
3425
<br/>
35-
Click BACK try again. For addition help, please save and submit the
26+
<span class="large">Click BACK try again.</span><br/>
27+
<br/>
28+
For addition help, please save and submit the
3629
above output to KegNet support.
3730
<?php } ?>
3831
</div>

‎http/index.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<br/>
2929
Diagnostic report:<br/>
3030
<textarea rows="10" cols="70" wrap="hard">
31-
iwconfig results:
31+
ip link results:
3232
<?php echo var_dump($checkResult) ?>
3333
iwlist results:
3434
<?php echo var_dump($scanResult) ?>
@@ -76,17 +76,14 @@
7676
<?php } ?>
7777
<?php } ?>
7878
</div>
79-
<pre>
80-
<?php echo var_dump($scanResult) ?>
81-
</pre>
8279
</body>
8380
</html>
8481
<?php
8582
function checkWifi()
8683
{
8784
$lines = null;
8885
$ret = -1;
89-
exec('sudo iwconfig wlan0', $lines, $ret);
86+
exec('sudo ip link show wlan0', $lines, $ret);
9087
if ($ret != 0) {
9188
return array(false, $ret, $lines);
9289
} else {

‎http/style.css

+23-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ body {
22
background-color: white;
33
font-family: "Courier New", Courier, monospace;
44
font-size: 16px;
5-
color: #2e6e9e;
5+
color: #123464;
66
margin: 20px;
77
}
88

@@ -12,18 +12,31 @@ table {
1212
}
1313

1414
td {
15-
border: 1px solid #a6c9e2;
15+
border: 1px solid #123464;
1616
margin: 0;
1717
padding: 5px;
1818
}
1919

2020
hr {
21-
border: 1px solid #a6c9e2;
21+
border: 1px solid #123464;
2222
}
2323

24-
input {
24+
input[type="submit"] {
2525
font-family: "Courier New", Courier, monospace;
2626
font-size: 16px;
27+
}
28+
29+
input[type="submit"] {
30+
font-family: "Courier New", Courier, monospace;
31+
font-size: 18px;
32+
font-weight: bold;
33+
color: #123464;
34+
border: 1px solid #123464;
35+
border-radius: 5px;
36+
cursor: hand;
37+
}
38+
39+
input[type="submit"]:hover {
2740
color: #2e6e9e;
2841
}
2942

@@ -36,13 +49,13 @@ textarea {
3649
.instructions {
3750
font-family: "Courier New", Courier, monospace;
3851
font-size: 16px;
39-
color: #2e6e9e;
52+
color: #123464;
4053
}
4154

4255
.large {
4356
font-family: "Courier New", Courier, monospace;
4457
font-size: 16px;
45-
color: #2e6e9e;
58+
color: #123464;
4659
font-weight: bold;
4760
}
4861

@@ -57,8 +70,8 @@ textarea {
5770
}
5871

5972
.container {
60-
width: 600px;
61-
border: 1px solid #a6c9e2;
73+
width: 95%;
74+
border: none;
6275
display: block;
6376
margin: auto;
6477
padding: 10px;
@@ -67,7 +80,7 @@ textarea {
6780
.buttonBar {
6881
width: 100%;
6982
display: block;
70-
background-color: #a6c9e2;
83+
border-top: 2px solid #123464;
7184
}
7285

7386
.buttons {
@@ -79,4 +92,4 @@ textarea {
7992

8093
.passwordBox {
8194
font-weight: bold;
82-
}
95+
}

‎lib/client.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from ConfigParser import SafeConfigParser
1515
import M2Crypto
1616
from M2Crypto import EVP
17+
import subprocess
1718
from subprocess import call
1819
from kegnet import w1therm
1920

@@ -229,7 +230,7 @@ def process_IN_MOVED_TO(self, event):
229230
sys.exit(1)
230231

231232
def retryPours():
232-
log(syslog.LOG_DEBUG, "checking for pour retries...");
233+
#log(syslog.LOG_DEBUG, "checking for pour retries...");
233234

234235
fileList = os.listdir(SPOOL_DIR)
235236
if len(fileList) == 0:
@@ -316,7 +317,7 @@ def ping():
316317
log(syslog.LOG_DEBUG, "ping temp '{0}'".format(temp))
317318

318319
signData = "{0},{1},{2}".format(uuidString, temp, ts)
319-
log(syslog.LOG_DEBUG, "ping data {0}".format(signData))
320+
#log(syslog.LOG_DEBUG, "ping data {0}".format(signData))
320321

321322
try:
322323
key.reset_context(md='sha256')
@@ -366,22 +367,26 @@ def checkIP():
366367

367368
now = time.time()
368369
et = (now - lastIPCheck)
369-
log(syslog.LOG_DEBUG, "lastIPCheck={0}, et={1}".format(lastIPCheck, et));
370-
if (et < 600):
370+
if (et < 3600):
371371
return
372-
372+
373+
DEVNULL = open(os.devnull, 'w')
374+
if call(["ip", "link", "show", "wlan0"], stdout=DEVNULL, stderr=subprocess.STDOUT) != 0:
375+
log(syslog.LOG_DEBUG, "no wifi adapter found")
376+
return
377+
373378
ip = socket.gethostbyname(socket.gethostname())
374-
if (ip != lastIP):
375-
lastIP = ip
376-
sendIP(ip)
377-
379+
380+
lastIP = ip
378381
lastIPCheck = now
379382

383+
sendIP(ip)
384+
380385
def sendIP(ip):
381386
ts = currentTimeMillis()
382387

383388
signData = "{0},{1},{2}".format(uuidString, ip, ts)
384-
log(syslog.LOG_DEBUG, "ip data {0}".format(signData))
389+
#log(syslog.LOG_DEBUG, "ip data {0}".format(signData))
385390

386391
try:
387392
key.reset_context(md='sha256')

‎scripts/wificonfig

+9-2
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,19 @@ fi
7373

7474
echo "}" >> $temp
7575

76+
# wpa_supplicant appears to rewrite wpa_supplicant.conf upon startup, so
77+
# as a result if power is cycled during this, the file ends up zero length
78+
# so I am purposely stopping wpa_supplicant before writing the config file,
79+
# it will be started on boot
80+
#systemctl stop wpa_supplicant
81+
7682
mv $temp $conf
7783
chmod go-rwx $conf
7884

79-
echo "Wrote $conf, restarting wpa_supplicant"
85+
sync
86+
sync
8087

81-
systemctl restart wpa_supplicant
88+
echo "Wrote $conf, reboot to take effect"
8289

8390
exit 0
8491

0 commit comments

Comments
 (0)
Please sign in to comment.