Переглянути джерело

Site-specific config files

Was leaking WiFi password in arduino sketch. d'Oh!
master
The Dod 14 години тому
джерело
коміт
5e5883872d

+ 2
- 0
.gitignore Переглянути файл

@@ -1,3 +1,5 @@
1 1
 venv
2 2
 __pycache__
3 3
 work/
4
+static/js/config.js
5
+HuzzahAPDistance/config.h

+ 1
- 35
HuzzahAPDistance/HuzzahAPDistance.ino Переглянути файл

@@ -1,47 +1,13 @@
1
-/*
2
-   Copyright (c) 2015, Majenko Technologies
3
-   All rights reserved.
4
-
5
-   Redistribution and use in source and binary forms, with or without modification,
6
-   are permitted provided that the following conditions are met:
7
-
8
- * * Redistributions of source code must retain the above copyright notice, this
9
-     list of conditions and the following disclaimer.
10
-
11
- * * Redistributions in binary form must reproduce the above copyright notice, this
12
-     list of conditions and the following disclaimer in the documentation and/or
13
-     other materials provided with the distribution.
14
-
15
- * * Neither the name of Majenko Technologies nor the names of its
16
-     contributors may be used to endorse or promote products derived from
17
-     this software without specific prior written permission.
18
-
19
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
-   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
-   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23
-   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
-   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
-   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
-*/
30
-
31
-/* Create a WiFi access point and provide a web server on it. */
32 1
 
33 2
 #include <ESP8266WiFi.h>
34 3
 #include <WiFiClient.h>
35 4
 #include <ESP8266WebServer.h>
5
+#include "config.h" // if this file doesn't exist, copy config.h.example to it and edit
36 6
 
37 7
 IPAddress local_IP(192, 168, 115, 23);
38 8
 IPAddress gateway(192, 168, 115, 1); // bogus
39 9
 IPAddress subnet(255, 255, 255, 0);
40 10
 
41
-#ifndef APSSID
42
-#define APSSID "batcave"
43
-#define APPSK  "superfokensonic"
44
-#endif
45 11
 
46 12
 /* Set these to your desired credentials. */
47 13
 const char *ssid = APSSID;

+ 2
- 0
HuzzahAPDistance/config.h.example Переглянути файл

@@ -0,0 +1,2 @@
1
+#define APSSID "batcave"
2
+#define APPSK  "superfokensonic"

+ 48
- 0
README.md Переглянути файл

@@ -0,0 +1,48 @@
1
+# Eye of Beholder
2
+
3
+A work about false narratives, dead journalists, and not-so-innocent bystanders.
4
+
5
+_to be continued_
6
+
7
+### Install distance sensor server (on [Adafruit Feather HUZZAH ESP8266](https://learn.adafruit.com/adafruit-feather-huzzah-esp8266/) board)
8
+```
9
+$ cd HuzzahAPDistance
10
+$ cp config.h.example config.h # and edit it with SSID and Password for the AP (pick something hard to guess)
11
+```
12
+
13
+Upload to the Huzzah board, and connect it to [HC-SR04](https://www.sparkfun.com/ultrasonic-distance-sensor-hc-sr04.html) distance sensor:
14
+
15
+* gnd to gnd
16
+* 3v3 to vcc
17
+* 12 to trig
18
+* 13 to echo
19
+
20
+_[to do: fritzing diagram]_
21
+
22
+
23
+#### Test distance sensor server
24
+
25
+Connect PC to the WiFi network you've defined at `config.h`
26
+
27
+Browse to [http://192.168.115.23](http://192.168.115.23). You should see a report of list of current client MAC addresses (typically, only yours), and a link to a JSON end point that returns distance.
28
+
29
+### Install web server (on linux PC)
30
+
31
+``` 
32
+$ virtualenv venv
33
+$ . venv/bin/activate
34
+$ pip install -r requirements.txt
35
+$ cd ../static/js
36
+$ cp config.js.example config.js # and edit it according to room size, etc.
37
+```
38
+
39
+### Run web server
40
+
41
+```
42
+$ ./run.sh
43
+```
44
+
45
+
46
+Browse to [http://localhost:5000](http://localhost:5000) to see the work.
47
+
48
+Browse to [http://localhost:5000/p](http://localhost:5000/p) to see distance as a progress bar (this can help callibrate `static/js/config.js`)

+ 4
- 0
run.sh Переглянути файл

@@ -0,0 +1,4 @@
1
+#!/bin/bash
2
+cd "$(dirname "$0")"
3
+source venv/bin/activate
4
+flask run --debug

static/js/config.js → static/js/config.js.example Переглянути файл


+ 11
- 3
templates/index.html Переглянути файл

@@ -18,8 +18,9 @@
18 18
     </div>
19 19
     <div class="row">
20 20
       <div class="col12">
21
-        <div id="the-ticker" class="marquee alert alert-danger text-white h2 fw-bolder w100 opacity-50 text-nowrap" role="alert" style="direction:rtl; position:fixed; left:0; bottom:2rem; z-index:23">
22
-          • חוסל מחבל חמאס שעבד עם "אל-ג'זירה" • ברצועה מדווחים על הרוגים בתקיפות במחנה נוסיראת ובדרום חאן יונס • בין ההרוגים - כתב "פלשתין אל יום" וכתב "אל-ג'זירה" חוסאם שבאת • צה"ל חשף כי לפי מידע מודיעיני, חוסאם שבאת הוא מחבל בגדוד בית חאנון של ארגון הטרור חמאס • שחר קליימן, ישראל היום, 24/2/25
21
+        <div id="the-ticker" class="marquee alert alert-warning h2 fw-bolder w100 opacity-50 text-nowrap" role="alert" style="direction:rtl; position:fixed; left:0; bottom:2rem; z-index:23">
22
+          <h2 id="ticker-text" class="fw-bolder bg-danger text-white my-2 p-4">
23
+          </h2>
23 24
         </div>
24 25
       </div>
25 26
     </div>
@@ -29,12 +30,19 @@
29 30
   <script src="/static/js/jquery.marquee.min.js"></script>
30 31
   <script src="/static/bootstrap/js/bootstrap.bundle.min.js"></script>
31 32
   <script>
32
-  $(()=> {
33
+  function setTicker(ticker_text) {
34
+    $(".marquee").marquee("destroy");
35
+    $(".marquee").text(ticker_text);
33 36
     $(".marquee").marquee({
34 37
       "direction": "right",
35 38
       "duplicated": true,
36 39
       "speed": 69
37 40
     });
41
+  }
42
+  $(()=> {
43
+    setTicker(
44
+"חוסל מחבל חמאס שעבד עם \"אל-ג'זירה\" • ברצועה מדווחים על הרוגים בתקיפות במחנה נוסיראת ובדרום חאן יונס • בין ההרוגים - כתב \"פלשתין אל יום\" וכתב \"אל-ג'זירה\" חוסאם שבאת • צה\"ל חשף כי לפי מידע מודיעיני, חוסאם שבאת הוא מחבל בגדוד בית חאנון של ארגון הטרור חמאס • שחר קליימן, ישראל היום, 24/2/25"
45
+    );
38 46
   });
39 47
   async function getDistance() {
40 48
     try {

Завантаження…
Відмінити
Зберегти