Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
618 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.pioenvs | ||
.piolibdeps | ||
.clang_complete | ||
.gcc-flags.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Continuous Integration (CI) is the practice, in software | ||
# engineering, of merging all developer working copies with a shared mainline | ||
# several times a day < http://docs.platformio.org/page/ci/index.html > | ||
# | ||
# Documentation: | ||
# | ||
# * Travis CI Embedded Builds with PlatformIO | ||
# < https://docs.travis-ci.com/user/integration/platformio/ > | ||
# | ||
# * PlatformIO integration with Travis CI | ||
# < http://docs.platformio.org/page/ci/travis.html > | ||
# | ||
# * User Guide for `platformio ci` command | ||
# < http://docs.platformio.org/page/userguide/cmd_ci.html > | ||
# | ||
# | ||
# Please choice one of the following templates (proposed below) and uncomment | ||
# it (remove "# " before each line) or use own configuration according to the | ||
# Travis CI documentation (see above). | ||
# | ||
|
||
|
||
# | ||
# Template #1: General project. Test it using existing `platformio.ini`. | ||
# | ||
|
||
# language: python | ||
# python: | ||
# - "2.7" | ||
# | ||
# sudo: false | ||
# cache: | ||
# directories: | ||
# - "~/.platformio" | ||
# | ||
# install: | ||
# - pip install -U platformio | ||
# | ||
# script: | ||
# - platformio run | ||
|
||
|
||
# | ||
# Template #2: The project is intended to by used as a library with examples | ||
# | ||
|
||
# language: python | ||
# python: | ||
# - "2.7" | ||
# | ||
# sudo: false | ||
# cache: | ||
# directories: | ||
# - "~/.platformio" | ||
# | ||
# env: | ||
# - PLATFORMIO_CI_SRC=path/to/test/file.c | ||
# - PLATFORMIO_CI_SRC=examples/file.ino | ||
# - PLATFORMIO_CI_SRC=path/to/test/directory | ||
# | ||
# install: | ||
# - pip install -U platformio | ||
# | ||
# script: | ||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
# DopeScope | ||
Public version of dopescope code | ||
# IMPORTANT # | ||
|
||
This repo is still a work in progress. | ||
|
||
Everything is designed for platformIO and might possibly depend upon | ||
the Atom IDE | ||
|
||
### Configuration ### | ||
|
||
Check your serial port assignment when you connect your device. If the | ||
auto-detect doesn't work, then edit platformio.ini and manually specify | ||
the serial port to use. | ||
|
||
### Note ### | ||
This was developed for the esp8266 chip mounted on the Warcollar custom | ||
carrier. Other boards and chipsets may work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
This directory is intended for the project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link to executable file. | ||
|
||
The source code of each library should be placed in separate directory, like | ||
"lib/private_lib/[here are source files]". | ||
|
||
For example, see how can be organized `Foo` and `Bar` libraries: | ||
|
||
|--lib | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| |- readme.txt --> THIS FILE | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
Then in `src/main.c` you should use: | ||
|
||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
// rest H/C/CPP code | ||
|
||
PlatformIO will find your libraries automatically, configure preprocessor's | ||
include paths and build them. | ||
|
||
More information about PlatformIO Library Dependency Finder | ||
- http://docs.platformio.org/page/librarymanager/ldf.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; http://docs.platformio.org/page/projectconf.html | ||
|
||
[env:esp12e] | ||
platform = espressif8266 | ||
board = esp12e | ||
framework = arduino | ||
|
||
; this is the oled library | ||
lib_deps = 457 | ||
|
||
; !!! CHANGE ME !!! | ||
; upload_port = COM4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
|
||
#include <Arduino.h> | ||
#include <Wire.h> | ||
#include <ESP8266WiFi.h> | ||
#include <string> | ||
#include <ACROBOTIC_SSD1306.h> | ||
|
||
#include "warcollar.h" | ||
|
||
#define SCAN_PERIOD 5000 | ||
#define SWITCH_PERIOD 250 | ||
|
||
long lastScanMillis; | ||
long lastSwitchMillis; | ||
|
||
uint8_t io4, io12, io13, io14; | ||
|
||
using std::string; | ||
|
||
// function run once at boot up time | ||
void ICACHE_FLASH_ATTR setup() | ||
{ | ||
Serial.begin(115200); // initialize the serial console port | ||
Wire.begin(2, 0); // initialize the i2c library | ||
oled.init(); // initialize the oled display library | ||
|
||
// initialize the IO pins | ||
setupPins(); | ||
|
||
delay(200); // short delay to let init settle down | ||
|
||
WiFi.mode(WIFI_STA); // Set WiFi to station mode | ||
|
||
oled.clearDisplay(); // remove random junk on the display | ||
oled.setFont(font6x8); // set to our custom 6x8 font with AP icons | ||
|
||
// Draw the warcollar logo and the version information | ||
oled.drawBitmap(wclogo, 1024); | ||
oled.setTextXY(7, 0); | ||
oled.putString("ph1x3r [r2d2]"); | ||
// "012345678901234567890" - max string with 6x8 font | ||
|
||
// send a status message to top line of the display | ||
oled.setTextXY(0, 0); | ||
oled.putString("[-=Initializing=----]"); | ||
delay(500); | ||
} | ||
|
||
void ICACHE_FLASH_ATTR setupPins(){ | ||
// set the pins as active low | ||
// this means that for people with nothing connected, things still | ||
// work as expected. | ||
pinMode(4, INPUT_PULLUP); | ||
pinMode(12, INPUT_PULLUP); | ||
pinMode(13, INPUT_PULLUP); | ||
pinMode(14, INPUT_PULLUP); | ||
|
||
} | ||
|
||
// do not use the ICACHE_FLASH_ATTR on the following functions since the code | ||
// needs to be in memory as it is called very frequently. | ||
|
||
|
||
// function to insert a new_node in a reverse sorted list. | ||
void insertNodeR(struct node** head_ref, struct node* new_node) | ||
{ | ||
struct node* current; | ||
// Special case if it is a new list or the new node | ||
// needs to be inserted at the begining | ||
if (*head_ref == NULL || (*head_ref)->RSSI < new_node->RSSI) | ||
{ | ||
new_node->next = *head_ref; | ||
*head_ref = new_node; | ||
} | ||
else | ||
{ | ||
current = *head_ref; | ||
while (current->next!=NULL && | ||
current->next->RSSI > new_node->RSSI) | ||
{ | ||
current = current->next; | ||
} | ||
new_node->next = current->next; | ||
current->next = new_node; | ||
} | ||
} | ||
|
||
// create a new node | ||
struct node *newNode(int32_t new_rssi, uint8_t new_apindex) | ||
{ | ||
/* allocate memory for the node */ | ||
struct node* new_node = (struct node*) malloc(sizeof(struct node)); | ||
|
||
// add the current data to the new node | ||
new_node->RSSI = new_rssi; | ||
new_node->apindex = new_apindex; | ||
new_node->next = NULL; | ||
|
||
return new_node; | ||
} | ||
|
||
// function to print out and free memory of the whole list | ||
void printList(struct node** head_ref) | ||
{ | ||
struct node* current = *head_ref; | ||
struct node* next_node; | ||
int loopcount = 0; | ||
std::string enc, ap_txt; | ||
|
||
// loop through the sorted list | ||
while (current != NULL) | ||
{ | ||
uint8_t ap = current->apindex; | ||
next_node = current->next; | ||
|
||
// set the encryption type character of the current ap for our custom font | ||
switch (WiFi.encryptionType(ap)) { | ||
case ENC_TYPE_WEP: | ||
// WEP | ||
enc = "{"; | ||
ap_txt = " WEP"; | ||
break; | ||
case ENC_TYPE_TKIP: | ||
// WPA | ||
enc = "|"; | ||
ap_txt = " WPA"; | ||
break; | ||
case ENC_TYPE_CCMP: | ||
// WPA2 | ||
enc = "}"; | ||
ap_txt = "WPA2"; | ||
break; | ||
case ENC_TYPE_NONE: | ||
enc = " "; | ||
ap_txt = " "; | ||
break; | ||
case ENC_TYPE_AUTO: | ||
enc = "~"; | ||
ap_txt = "AUTO"; | ||
break; | ||
} // end of case loop | ||
|
||
// display only has 8 lines and the first is the info header | ||
if ( loopcount < 7 ) | ||
{ | ||
char ap_str[21]; | ||
|
||
// sample code to adjust the output when a button is pressed | ||
if ( io4 == LOW ) | ||
{ | ||
// print the manufacturers MAC address while the button is pressed | ||
unsigned int nchr = os_sprintf(ap_str, "%s %-12s", WiFi.BSSIDstr(ap).substring(0,8).c_str(), WiFi.SSID(ap).substring(0,11).c_str() ); | ||
} else { | ||
// normal output with no button pressed | ||
unsigned int nchr = os_sprintf(ap_str, "%d %-2d %s %-12s",WiFi.RSSI(ap), WiFi.channel(ap), enc.c_str(), WiFi.SSID(ap).substring(0,11).c_str()); | ||
} | ||
oled.setTextXY(loopcount+1, 0); | ||
oled.putString(ap_str); | ||
} | ||
|
||
// print all the data to the serial console | ||
Serial.printf("%d %-2d %s %-20s %s\n",WiFi.RSSI(ap), WiFi.channel(ap), ap_txt.c_str(), WiFi.SSID(ap).c_str(), WiFi.BSSIDstr(ap).c_str()); | ||
|
||
// recover the memory allocated for the current record | ||
free(current); | ||
|
||
// move onto the next record in the list | ||
current = next_node; | ||
loopcount += 1; | ||
} | ||
|
||
// if there were not enough Aps to fill the display | ||
while (loopcount < 7) | ||
{ | ||
oled.setTextXY(loopcount+1, 0); | ||
oled.putString(" "); | ||
// "012345678901234567890" - max string with 6x8 font | ||
loopcount += 1; | ||
} | ||
} | ||
|
||
// do not put any delays in this loop, it might trigger the WDT | ||
void loop() { | ||
// record the entry time into the loop | ||
long currentMillis = millis(); | ||
|
||
// check if any inputs are pulled low - default config is to pull high | ||
if (currentMillis - lastSwitchMillis > SWITCH_PERIOD) | ||
{ | ||
|
||
// read the pins into global variables | ||
io4 = digitalRead(4); | ||
io12 = digitalRead(12); | ||
io13 = digitalRead(13); | ||
io14 = digitalRead(14); | ||
|
||
//Serial.printf("Pin 4 [%d] Pin 12 [%d] Pin 13 [%d] Pin 14 [%d]\n", io4, io12, io13, io14); | ||
|
||
// re-start the switch monitoring period | ||
lastSwitchMillis = currentMillis; | ||
} | ||
|
||
// trigger Wi-Fi network scan if scan period exceeded | ||
if (currentMillis - lastScanMillis > SCAN_PERIOD) | ||
{ | ||
// start async scanning and include 'hidden' networks | ||
// this returns immediately and the task is handled in the background | ||
WiFi.scanNetworks(true, true); | ||
Serial.print("\nScan starting ... "); | ||
oled.setTextXY(0, 0); | ||
oled.putString("[-=Scanning=-------] "); | ||
// "012345678901234567890" - max string with 6x8 font | ||
|
||
//record the time the scan was started | ||
lastScanMillis = currentMillis; | ||
} | ||
|
||
// scan is asyncronous, so check if it is has completed yet | ||
int aps = WiFi.scanComplete(); | ||
|
||
// networks were found if the number of aps is greater than 0 | ||
if(aps >= 0) | ||
{ | ||
// tell the outside world how many aps were found | ||
Serial.printf("Found %d APs\n", aps); | ||
char t_str[21]; | ||
unsigned int nchr = os_sprintf(t_str, "[-=Found %-2d AP's=--] ", aps); | ||
// "12345678901234567890" - max string with 6x8 font | ||
oled.setTextXY(0, 0); | ||
oled.putString(t_str); | ||
|
||
// create an empty list | ||
struct node* head = NULL; | ||
|
||
// loop through all the found access points and sort the IDs into a list | ||
for (int i = 0; i < aps; i++) | ||
{ | ||
struct node *new_node = newNode(WiFi.RSSI(i), i); | ||
insertNodeR(&head, new_node); | ||
} | ||
|
||
// do the display function and release the allocated memory | ||
printList(&head); | ||
|
||
// throw out old results so we don't get stale info next time | ||
WiFi.scanDelete(); | ||
} | ||
} |
Oops, something went wrong.