code sanitization; button on TTGOv1
This commit is contained in:
parent
c84600022f
commit
ce5dadeffe
@ -1,10 +1,6 @@
|
|||||||
// not using this seems to break U8X8LIB
|
|
||||||
//#include <Arduino.h>
|
|
||||||
|
|
||||||
// Basic Config
|
// Basic Config
|
||||||
#include "main.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
//#include "loraconf.h"
|
|
||||||
|
|
||||||
#ifdef BLECOUNTER
|
#ifdef BLECOUNTER
|
||||||
#include <BLEDevice.h>
|
#include <BLEDevice.h>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Hardware related definitions for Heltec TTGOv1 board
|
// Hardware related definitions for TTGOv1 board
|
||||||
|
|
||||||
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C // OLED-Display on board
|
||||||
|
#define HAS_LED GPIO_NUM_2 // white LED on board
|
||||||
|
#define HAS_BUTTON GPIO_NUM_0 // button "PRG" on board
|
||||||
#define CFG_sx1276_radio 1
|
#define CFG_sx1276_radio 1
|
||||||
|
|
||||||
// re-define pin definitions of pins_arduino.h
|
// re-define pin definitions of pins_arduino.h
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
// Hardware related definitions for TTGO V2 Board
|
// Hardware related definitions for TTGO V2 Board
|
||||||
|
|
||||||
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
||||||
#define CFG_sx1276_radio 1
|
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
||||||
|
|
||||||
// re-define pin definitions of pins_arduino.h
|
// re-define pin definitions of pins_arduino.h
|
||||||
#define PIN_SPI_SS 18 // ESP32 GPIO18 (Pin18) -- SX1276 NSS (Pin19) SPI Chip Select Input
|
#define PIN_SPI_SS 18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input
|
||||||
#define PIN_SPI_MOSI 27 // ESP32 GPIO27 (Pin27) -- SX1276 MOSI (Pin18) SPI Data Input
|
#define PIN_SPI_MOSI 27 // ESP32 GPIO27 (Pin27) -- HPD13A MOSI/DSI (Pin6) SPI Data Input
|
||||||
#define PIN_SPI_MISO 19 // ESP32 GPIO19 (Pin19) -- SX1276 MISO (Pin17) SPI Data Output
|
#define PIN_SPI_MISO 19 // ESP32 GPIO19 (Pin19) -- HPD13A MISO/DSO (Pin7) SPI Data Output
|
||||||
#define PIN_SPI_SCK 5 // ESP32 GPIO5 (Pin5) -- SX1276 SCK (Pin16) SPI Clock Input
|
#define PIN_SPI_SCK 5 // ESP32 GPIO5 (Pin5) -- HPD13A SCK (Pin5) SPI Clock Input
|
||||||
|
|
||||||
// non arduino pin definitions
|
// non arduino pin definitions
|
||||||
#define RST LMIC_UNUSED_PIN // not sure
|
#define RST LMIC_UNUSED_PIN // connected to ESP32 RST/EN
|
||||||
#define DIO0 26 // wired on PCB
|
#define DIO0 26 // ESP32 GPIO26 wired on PCB to HPD13A
|
||||||
#define DIO1 33 // needs to be wired external
|
#define DIO1 33 // HPDIO1 on pcb, needs to be wired external to GPIO33
|
||||||
#define DIO2 32 // needs to be wired external (but not necessary for LoRa)
|
#define DIO2 32 // HPDIO2 on pcb, needs to be wired external to GPIO32 (not necessary for LoRa, only FSK)
|
||||||
|
|
||||||
// Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display
|
// Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display
|
||||||
#define OLED_RST U8X8_PIN_NONE // to be checked if really not connected
|
#define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN
|
||||||
#define OLED_SDA 21 // ESP32 GPIO4 (Pin4) -- SD1306 Data
|
#define OLED_SDA 21 // ESP32 GPIO4 (Pin4) -- SD1306 D1+D2
|
||||||
#define OLED_SCL 22 // ESP32 GPIO15 (Pin15) -- SD1306 Clock
|
#define OLED_SCL 22 // ESP32 GPIO15 (Pin15) -- SD1306 D0
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <lmic.h>
|
#include <lmic.h>
|
||||||
#include <hal/hal.h>
|
#include <hal/hal.h>
|
||||||
|
|
||||||
// needs to be defined here
|
|
||||||
uint8_t mydata[] = "0000";
|
uint8_t mydata[] = "0000";
|
||||||
|
|
||||||
// Local logging Tag
|
// Local logging Tag
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -36,14 +36,10 @@ Refer to LICENSE.txt file in repository for more details.
|
|||||||
#include <lmic.h>
|
#include <lmic.h>
|
||||||
#include <hal/hal.h>
|
#include <hal/hal.h>
|
||||||
|
|
||||||
// WiFi Functions
|
// ESP32 Functions
|
||||||
#include <esp_wifi.h>
|
#include <esp_event_loop.h> // needed for Wifi event handler
|
||||||
#include <esp_wifi_types.h>
|
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
|
||||||
#include <esp_system.h>
|
#include <esp32-hal-log.h> // needed for ESP_LOGx on arduino framework
|
||||||
#include <esp_event.h>
|
|
||||||
#include <esp_event_loop.h>
|
|
||||||
#include <esp_spi_flash.h>
|
|
||||||
#include <esp32-hal-log.h> // we need this for ESP_LOGx on arduino framework
|
|
||||||
|
|
||||||
configData_t cfg; // struct holds current device configuration
|
configData_t cfg; // struct holds current device configuration
|
||||||
osjob_t sendjob, initjob; // LMIC
|
osjob_t sendjob, initjob; // LMIC
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// program version
|
// program version
|
||||||
#define PROGVERSION "1.2.3" // use max 10 chars here!
|
#define PROGVERSION "1.2.31" // use max 10 chars here!
|
||||||
#define PROGNAME "PAXCNT"
|
#define PROGNAME "PAXCNT"
|
||||||
|
|
||||||
// Verbose enables serial output
|
// Verbose enables serial output
|
||||||
|
@ -2,28 +2,20 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
// WiFi Functions
|
// ESP32 Functions
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
#include <esp_wifi_types.h>
|
|
||||||
#include <esp_system.h>
|
#ifdef VENDORFILTER
|
||||||
#include <esp_event.h>
|
#include <array>
|
||||||
#include <esp_event_loop.h>
|
#include <algorithm>
|
||||||
|
#include "vendor_array.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Local logging tag
|
// Local logging tag
|
||||||
static const char *TAG = "wifisniffer";
|
static const char *TAG = "wifisniffer";
|
||||||
|
|
||||||
static wifi_country_t wifi_country = {.cc="EU", .schan=1, .nchan=13, .policy=WIFI_COUNTRY_POLICY_AUTO};
|
static wifi_country_t wifi_country = {.cc="EU", .schan=1, .nchan=13, .policy=WIFI_COUNTRY_POLICY_AUTO};
|
||||||
|
|
||||||
#ifdef VENDORFILTER
|
|
||||||
#include <array>
|
|
||||||
#include <algorithm>
|
|
||||||
#include "vendor_array.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void wifi_sniffer_init(void);
|
|
||||||
extern void wifi_sniffer_set_channel(uint8_t channel);
|
|
||||||
extern void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned frame_ctrl:16;
|
unsigned frame_ctrl:16;
|
||||||
unsigned duration_id:16;
|
unsigned duration_id:16;
|
||||||
@ -39,6 +31,10 @@ typedef struct {
|
|||||||
uint8_t payload[0]; /* network data ended with 4 bytes csum (CRC32) */
|
uint8_t payload[0]; /* network data ended with 4 bytes csum (CRC32) */
|
||||||
} wifi_ieee80211_packet_t;
|
} wifi_ieee80211_packet_t;
|
||||||
|
|
||||||
|
extern void wifi_sniffer_init(void);
|
||||||
|
extern void wifi_sniffer_set_channel(uint8_t channel);
|
||||||
|
extern void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
|
||||||
|
|
||||||
void wifi_sniffer_init(void) {
|
void wifi_sniffer_init(void) {
|
||||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
cfg.nvs_enable = 0; // we don't want wifi settings from NVRAM
|
cfg.nvs_enable = 0; // we don't want wifi settings from NVRAM
|
||||||
@ -46,8 +42,8 @@ void wifi_sniffer_init(void) {
|
|||||||
ESP_ERROR_CHECK(esp_wifi_set_country(&wifi_country));
|
ESP_ERROR_CHECK(esp_wifi_set_country(&wifi_country));
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM) );
|
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM) );
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL) );
|
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL) );
|
||||||
//ESP_ERROR_CHECK( esp_wifi_start() );
|
//ESP_ERROR_CHECK(esp_wifi_start()); // not sure if we need this in this application?
|
||||||
//ESP_ERROR_CHECK( esp_wifi_set_max_tx_power(-128) ); // we don't need to TX, so we use lowest power level to save energy
|
//ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(-128)); // we don't need to TX, so we use lowest power level to save energy
|
||||||
wifi_promiscuous_filter_t filter = {.filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // we need only MGMT frames
|
wifi_promiscuous_filter_t filter = {.filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // we need only MGMT frames
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter)); // set MAC frame filter
|
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter)); // set MAC frame filter
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler));
|
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler));
|
||||||
|
Loading…
Reference in New Issue
Block a user