diff --git a/.gitignore b/.gitignore index 259148f..fe935e1 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,29 @@ *.exe *.out *.app + +# Vim backups +*.swp + +# travis +.travis.yml + +# PlatformIO work files +.pio +.pioenvs +.piolibdeps +*tags* + +# IDE +.travis.yml +extensions.json +settings.json +*tags* +.clang_complete +.gcc-flags.json +.vscode +.vscode/.browse.c_cpp.db* +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json + diff --git a/README.md b/README.md index 8b8054f..7e9b40f 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ It shows you the traffic of all nearby devices on the selected WiFi channel. - SD card support to capture traffic - better performance due to the powerful ESP32 - shows average RSSI +- [PlatformIO](http://platformio.org/) support ## Now Available on **Tindie**: https://goo.gl/kZmVug @@ -39,7 +40,7 @@ Sometimes the device can get into a restart loop, because it crashes everytime w Also please be aware that not every packet can be saved all the time! If more packets come in that can be saved, they will be dropped. -## Compiling Source +## Compiling Source on Arduino (**0.** Download and install [Arduino](https://www.arduino.cc/en/Main/Software)) **1.** Install the Arduino core for the ESP32: https://github.com/espressif/arduino-esp32#installation-instructions **2.** Install this ESP8266/ESP32 OLED library: https://github.com/squix78/esp8266-oled-ssd1306 @@ -51,6 +52,18 @@ Also please be aware that not every packet can be saved all the time! If more pa If you ran into upload problems, try setting the flash frequency to 40MHz and the upload speed 115200. If you want to use your own hardware, you may want to edit the settings in lines 22 - 32. +## Compiling Source on Platformio + +**0.** Please install first [PlatformIO](http://platformio.org/) open source ecosystem for IoT compatible with **Arduino** +**1.** [Download](https://github.com/spacehuhn/PacketMonitor32/archive/master.zip) and unzip the repository +**2.** Compiling and Uploading the firmware: + +``` bash +pio run --target upload +``` + +**NOTE**: If you want use TTGO board, please select it on `platformio.ini` + ## License This project is licensed under the MIT License - see the [license file](LICENSE) for details. diff --git a/include/README b/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..c39a17c --- /dev/null +++ b/platformio.ini @@ -0,0 +1,48 @@ +; 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 +; https://docs.platformio.org/page/projectconf.html +; + +[platformio] +default_envs = lolin32 ; select here your default environment + +[common_env_data] +platform = espressif32 +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +build_flags = + -D CORE_DEBUG_LEVEL=0 + ; -D DSTIKE + -D TTGO + +lib_deps = + 2978 ; ESP8266 and ESP32 Oled Driver for SSD1306 display + +[env:lolin32] +platform = espressif32 +board = lolin32 +framework = ${common_env_data.framework} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} +build_flags = + ${common_env_data.build_flags} + -D LOLIN32=1 + +[env:WEMOSOLED] +platform = espressif32 +board = lolin32 +framework = ${common_env_data.framework} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} +build_flags = + ${common_env_data.build_flags} + -D WEMOSOLED=1 + + diff --git a/Buffer.cpp b/src/Buffer.cpp similarity index 100% rename from Buffer.cpp rename to src/Buffer.cpp diff --git a/Buffer.h b/src/Buffer.h similarity index 100% rename from Buffer.h rename to src/Buffer.h diff --git a/PacketMonitor32.ino b/src/PacketMonitor32.ino similarity index 95% rename from PacketMonitor32.ino rename to src/PacketMonitor32.ino index e7ccc92..b221b22 100644 --- a/PacketMonitor32.ino +++ b/src/PacketMonitor32.ino @@ -21,13 +21,19 @@ using namespace std; #define MAX_CH 14 // 1 - 14 channels (1-11 for US, 1-13 for EU and 1-14 for Japan) #define SNAP_LEN 2324 // max len of each recieved packet -#define BUTTON_PIN 5 // button to change the channel #define USE_DISPLAY // comment out if you don't want to use the OLED display -#define FLIP_DISPLAY // comment out if you don't like to flip it +//#define FLIP_DISPLAY // comment out if you don't like to flip it +#ifdef DSTIKE +#define BUTTON_PIN 5 // button to change the channel #define SDA_PIN 26 #define SCL_PIN 27 -#define MAX_X 128 +#elif TTGO +#define BUTTON_PIN 0 // button to change the channel +#define SDA_PIN 5 +#define SCL_PIN 4 +#endif +#define MAX_X 126 #define MAX_Y 51 #if CONFIG_FREERTOS_UNICORE @@ -66,6 +72,9 @@ uint32_t deauths = 0; // deauth frames per second unsigned int ch = 1; // current 802.11 channel int rssiSum; +void wifi_promiscuous(void* buf, wifi_promiscuous_pkt_type_t type); +void coreTask( void * p ); + /* ===== functions ===== */ double getMultiplicator() { uint32_t maxVal = 1; @@ -164,7 +173,7 @@ void draw() { display.setTextAlignment(TEXT_ALIGN_LEFT); display.drawString( 36, 0, ("Pkts:")); - display.drawLine(0, 63 - MAX_Y, MAX_X, 63 - MAX_Y); + display.drawLine(0, 63 - MAX_Y, MAX_X-1, 63 - MAX_Y); for (int i = 0; i < MAX_X; i++) { len = pkts[i] * multiplicator; display.drawLine(i, 63, i, 63 - (len > MAX_Y ? MAX_Y : len)); diff --git a/test/README b/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html