code sanitizations
This commit is contained in:
parent
cf7c908883
commit
861115913a
@ -8,9 +8,10 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
; ---> SELECT TARGET PLATFORM HERE! <---
|
||||
[platformio]
|
||||
;env_default = heltec_wifi_lora_32
|
||||
env_default = ttgov2
|
||||
env_default = heltec_wifi_lora_32
|
||||
;env_default = ttgov2
|
||||
;env_default = ttgov1
|
||||
;env_default = lopy
|
||||
;env_default = lopy4
|
||||
@ -23,8 +24,8 @@ monitor_baud = 115200
|
||||
lib_deps = U8g2
|
||||
build_flags =
|
||||
;set log level, we need build_flag for this, otherwise we can't use ESP_LOGx in arduino framework
|
||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
||||
;needed for ESP32 BLE Ardunio v0.4.9
|
||||
-fexceptions
|
||||
-std=c++11
|
||||
@ -43,8 +44,8 @@ monitor_baud = 115200
|
||||
lib_deps = U8g2
|
||||
build_flags =
|
||||
;set log level, we need build_flag for this, otherwise we can't use ESP_LOGx in arduino framework
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
||||
;needed for ESP32 BLE Ardunio v0.4.9
|
||||
-fexceptions
|
||||
-std=c++11
|
||||
@ -64,8 +65,8 @@ monitor_baud = 115200
|
||||
lib_deps = U8g2
|
||||
build_flags =
|
||||
;set log level, we need build_flag for this, otherwise we can't use ESP_LOGx in arduino framework
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
||||
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
|
||||
;needed for ESP32 BLE Ardunio v0.4.9
|
||||
-fexceptions
|
||||
-std=c++11
|
||||
@ -92,7 +93,6 @@ build_flags =
|
||||
;override lora settings from LMiC library in lmic/config.h and use main.h instead
|
||||
-D_lmic_config_h_
|
||||
-include "src/main.h"
|
||||
-include "src/hal/antenna.h"
|
||||
-include "src/hal/lopy.h"
|
||||
;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp)
|
||||
; -DCONFIG_FREERTOS_UNICORE
|
||||
@ -113,7 +113,6 @@ build_flags =
|
||||
;override lora settings from LMiC library in lmic/config.h and use main.h instead
|
||||
-D_lmic_config_h_
|
||||
-include "src/main.h"
|
||||
-include "src/hal/antenna.h"
|
||||
-include "src/hal/lopy4.h"
|
||||
;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp)
|
||||
; -DCONFIG_FREERTOS_UNICORE
|
@ -1,16 +0,0 @@
|
||||
/* struct holding devices's runtime configuration */
|
||||
|
||||
typedef struct {
|
||||
int8_t lorasf; // 7-12, lora spreadfactor
|
||||
int8_t txpower; // 2-15, lora tx power
|
||||
int8_t adrmode; // 0=disabled, 1=enabled
|
||||
int8_t screensaver; // 0=disabled, 1=enabled
|
||||
int8_t screenon; // 0=disabled, 1=enabled
|
||||
int8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed
|
||||
int16_t rssilimit; // threshold for rssilimiter, negative value!
|
||||
int8_t wifiscancycle; // wifi scan cycle [seconds/2]
|
||||
int8_t wifichancycle; // wifi channel switch cycle [seconds/100]
|
||||
int8_t blescancycle; // BLE scan cycle [seconds]
|
||||
int8_t blescan; // 0=disabled, 1=enabled
|
||||
char version[10]; // Firmware version
|
||||
} configData_t;
|
@ -1,14 +1,6 @@
|
||||
// First things first
|
||||
#include "main.h"
|
||||
|
||||
// The mother of all embedded development...
|
||||
#include <Arduino.h>
|
||||
|
||||
// we neededthis to ESP_LOGx on arduino framework
|
||||
#include "esp32-hal-log.h"
|
||||
|
||||
#include <String.h>
|
||||
|
||||
// std::set for unified array functions
|
||||
#include <set>
|
||||
|
||||
@ -19,21 +11,36 @@
|
||||
#include <lmic.h>
|
||||
#include <hal/hal.h>
|
||||
|
||||
// configData_t
|
||||
#include "configmanager.h"
|
||||
// Struct holding devices's runtime configuration
|
||||
|
||||
extern uint8_t mydata[];
|
||||
extern uint64_t uptimecounter;
|
||||
extern int macnum, blenum, countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
||||
extern bool joinstate;
|
||||
|
||||
extern osjob_t sendjob;
|
||||
|
||||
extern std::set<uint64_t, std::greater <uint64_t> > macs;
|
||||
|
||||
extern U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8;
|
||||
typedef struct {
|
||||
int8_t lorasf; // 7-12, lora spreadfactor
|
||||
int8_t txpower; // 2-15, lora tx power
|
||||
int8_t adrmode; // 0=disabled, 1=enabled
|
||||
int8_t screensaver; // 0=disabled, 1=enabled
|
||||
int8_t screenon; // 0=disabled, 1=enabled
|
||||
int8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed
|
||||
int16_t rssilimit; // threshold for rssilimiter, negative value!
|
||||
int8_t wifiscancycle; // wifi scan cycle [seconds/2]
|
||||
int8_t wifichancycle; // wifi channel switch cycle [seconds/100]
|
||||
int8_t blescancycle; // BLE scan cycle [seconds]
|
||||
int8_t blescan; // 0=disabled, 1=enabled
|
||||
char version[10]; // Firmware version
|
||||
} configData_t;
|
||||
|
||||
extern configData_t cfg;
|
||||
extern uint8_t mydata[];
|
||||
extern uint64_t uptimecounter;
|
||||
extern osjob_t sendjob;
|
||||
extern int macnum, blenum, countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
||||
extern bool joinstate;
|
||||
extern std::set<uint64_t, std::greater <uint64_t> > macs;
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
extern HAS_DISPLAY u8x8;
|
||||
#else
|
||||
extern U8X8_NULL u8x8;
|
||||
#endif
|
||||
|
||||
#ifdef BLECOUNTER
|
||||
extern int scanTime;
|
||||
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Pycom Limited.
|
||||
*
|
||||
* This software is licensed under the GNU GPL version 3 or any
|
||||
* later version, with permitted additional terms. For more information
|
||||
* see the Pycom Licence v1.0 document supplied with this file, or
|
||||
* available at https://www.pycom.io/opensource/licensing
|
||||
*/
|
||||
|
||||
#ifndef _ANTENNA_H_
|
||||
#define _ANTENNA_H_
|
||||
|
||||
typedef enum {
|
||||
ANTENNA_TYPE_INTERNAL = 0,
|
||||
ANTENNA_TYPE_EXTERNAL
|
||||
} antenna_type_t;
|
||||
|
||||
extern void antenna_init (void);
|
||||
extern void antenna_select (antenna_type_t antenna_type);
|
||||
|
||||
#endif /* _ANTENNA_H_ */
|
@ -1,9 +1,8 @@
|
||||
// Hardware related definitions for Heltec LoRa-32 Board
|
||||
|
||||
#define HELTEC
|
||||
#define HAS_DISPLAY // has OLED-Display
|
||||
#define HAS_LED // has usable on board LED
|
||||
#define HAS_BUTTON // has usable on board button
|
||||
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C // OLED-Display on board
|
||||
#define HAS_LED GPIO_NUM_25 // white LED on board
|
||||
#define HAS_BUTTON GPIO_NUM_0 // button "PROG" on board
|
||||
#define CFG_sx1276_radio 1
|
||||
|
||||
// re-define pin definitions of pins_arduino.h
|
||||
@ -19,6 +18,6 @@
|
||||
#define DIO2 32 // ESP32 GPIO32 (Pin12) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only)
|
||||
|
||||
// Hardware pin definitions for Heltec LoRa-32 Board with OLED SSD1306 I2C Display
|
||||
#define OLED_RST 16 // ESP32 GPIO16 (Pin16) -- SD1306 Reset
|
||||
#define OLED_SDA 4 // ESP32 GPIO4 (Pin4) -- SD1306 Data
|
||||
#define OLED_SCL 15 // ESP32 GPIO15 (Pin15) -- SD1306 Clock
|
||||
#define OLED_RST 16 // ESP32 GPIO16 (Pin16) -- SD1306 RST
|
||||
#define OLED_SDA 4 // ESP32 GPIO4 (Pin4) -- SD1306 D1+D2
|
||||
#define OLED_SCL 15 // ESP32 GPIO15 (Pin15) -- SD1306 D0
|
||||
|
@ -15,4 +15,12 @@
|
||||
|
||||
// select WIFI antenna (internal = onboard / external = u.fl socket)
|
||||
#define PIN_ANTENNA_SWITCH 16
|
||||
#define WIFI_LOPY_ANTENNA ANTENNA_TYPE_INTERNAL
|
||||
#define WIFI_LOPY_ANTENNA ANTENNA_TYPE_INTERNAL
|
||||
|
||||
typedef enum {
|
||||
ANTENNA_TYPE_INTERNAL = 0,
|
||||
ANTENNA_TYPE_EXTERNAL
|
||||
} antenna_type_t;
|
||||
|
||||
extern void antenna_init (void);
|
||||
extern void antenna_select (antenna_type_t antenna_type);
|
||||
|
@ -15,4 +15,12 @@
|
||||
|
||||
// select WIFI antenna (internal = onboard / external = u.fl socket)
|
||||
#define PIN_ANTENNA_SWITCH 21
|
||||
#define WIFI_LOPY_ANTENNA ANTENNA_TYPE_INTERNAL
|
||||
#define WIFI_LOPY_ANTENNA ANTENNA_TYPE_INTERNAL
|
||||
|
||||
typedef enum {
|
||||
ANTENNA_TYPE_INTERNAL = 0,
|
||||
ANTENNA_TYPE_EXTERNAL
|
||||
} antenna_type_t;
|
||||
|
||||
extern void antenna_init (void);
|
||||
extern void antenna_select (antenna_type_t antenna_type);
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Hardware related definitions for Heltec TTGOv1 board
|
||||
|
||||
#define TTGO
|
||||
#define HAS_DISPLAY // has OLED-Display
|
||||
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
||||
#define CFG_sx1276_radio 1
|
||||
|
||||
// re-define pin definitions of pins_arduino.h
|
||||
@ -16,7 +15,7 @@
|
||||
#define DIO1 33 // ESP32 GPIO33 (Pin13) -- SX1276 DIO1 (Pin9) used by LMIC for detecting LoRa RX_Timeout
|
||||
#define DIO2 32 // ESP32 GPIO32 (Pin12) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only)
|
||||
|
||||
// Hardware pin definitions for Heltec LoRa-32 Board with OLED SSD1306 I2C Display
|
||||
// Hardware pin definitions for TTGOv1 Board with OLED SSD1306 I2C Display
|
||||
#define OLED_RST 16 // ESP32 GPIO16 (Pin16) -- SD1306 Reset
|
||||
#define OLED_SDA 4 // ESP32 GPIO4 (Pin4) -- SD1306 Data
|
||||
#define OLED_SCL 15 // ESP32 GPIO15 (Pin15) -- SD1306 Clock
|
@ -1,7 +1,6 @@
|
||||
// Hardware related definitions for TTGO V2 Board
|
||||
|
||||
#define TTGO
|
||||
#define HAS_DISPLAY // has OLED-Display
|
||||
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
||||
#define CFG_sx1276_radio 1
|
||||
|
||||
// re-define pin definitions of pins_arduino.h
|
||||
|
43
src/main.cpp
43
src/main.cpp
@ -29,19 +29,13 @@
|
||||
// OLED driver
|
||||
#include <U8x8lib.h>
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(OLED_RST, OLED_SCL, OLED_SDA);
|
||||
#else
|
||||
U8X8_NULL u8x8;
|
||||
#endif
|
||||
|
||||
// LMIC-Arduino LoRaWAN Stack
|
||||
#include <lmic.h>
|
||||
#include <hal/hal.h>
|
||||
|
||||
// Basic Config
|
||||
#include "loraconf.h"
|
||||
#include "configmanager.h"
|
||||
#include "globals.h"
|
||||
|
||||
// WiFi Functions
|
||||
#include <esp_wifi.h>
|
||||
@ -50,15 +44,15 @@
|
||||
#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
|
||||
osjob_t sendjob, initjob; // LMIC
|
||||
|
||||
// Initialize global variables
|
||||
int macnum = 0, blenum = 0;
|
||||
uint32_t uptimecounter = 0;
|
||||
uint64_t uptimecounter = 0;
|
||||
bool joinstate = false;
|
||||
extern uint8_t mydata[];
|
||||
|
||||
std::set<uint64_t, std::greater <uint64_t> > macs; // storage holds MAC frames
|
||||
|
||||
@ -67,8 +61,8 @@ static volatile bool ButtonTriggered = false;
|
||||
|
||||
// local Tag for logging
|
||||
static const char *TAG = "paxcnt";
|
||||
// Note: Log level control seems working during runtime, so we need to switch loglevel
|
||||
// by compiler build option in platformio.ini
|
||||
// Note: Log level control seems not working during runtime,
|
||||
// so we need to switch loglevel by compiler build option in platformio.ini
|
||||
#ifndef VERBOSE
|
||||
int redirect_log(const char * fmt, va_list args) {
|
||||
//do nothing
|
||||
@ -140,6 +134,12 @@ void lorawan_loop(void * pvParameters) {
|
||||
|
||||
/* beginn hardware specific parts -------------------------------------------------------- */
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
HAS_DISPLAY u8x8(OLED_RST, OLED_SCL, OLED_SDA);
|
||||
#else
|
||||
U8X8_NULL u8x8;
|
||||
#endif
|
||||
|
||||
#ifdef LOPY
|
||||
// defined in antenna.cpp
|
||||
void antenna_init (void);
|
||||
@ -155,8 +155,8 @@ void lorawan_loop(void * pvParameters) {
|
||||
void set_onboard_led(int st){
|
||||
#ifdef HAS_LED
|
||||
switch (st) {
|
||||
case 1: digitalWrite(LED_BUILTIN, HIGH); break;
|
||||
case 0: digitalWrite(LED_BUILTIN, LOW); break;
|
||||
case 1: digitalWrite(HAS_LED, HIGH); break;
|
||||
case 0: digitalWrite(HAS_LED, LOW); break;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
@ -326,11 +326,8 @@ void setup() {
|
||||
|
||||
ESP_LOGI(TAG, "Starting %s %s", PROGNAME, PROGVERSION);
|
||||
|
||||
/*
|
||||
tcpip_adapter_init(); // not sure if necessary, but seems needed for TTGOv1
|
||||
// ESP Event Loop
|
||||
esp_event_loop_init(NULL, NULL); // not sure if necessary -> to be checked
|
||||
*/
|
||||
// system event handler for wifi task, needed for wifi_sniffer_init()
|
||||
esp_event_loop_init(NULL, NULL);
|
||||
|
||||
// Print chip information on startup
|
||||
#ifdef VERBOSE
|
||||
@ -348,17 +345,17 @@ void setup() {
|
||||
// Read settings from NVRAM
|
||||
loadConfig(); // includes initialize if necessary
|
||||
|
||||
// initialize hardware -> perhaps to be moved to new hal.cpp
|
||||
// initialize hardware
|
||||
#ifdef HAS_LED
|
||||
// initialize LED
|
||||
pinMode(LED_BUILTIN, OUTPUT); // white LED on Heltec board
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
pinMode(HAS_LED, OUTPUT);
|
||||
digitalWrite(HAS_LED, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_BUTTON
|
||||
// install button interrupt
|
||||
pinMode(GPIO_NUM_0, INPUT_PULLDOWN); // button "PROG" on Heltec board
|
||||
attachInterrupt(digitalPinToInterrupt(GPIO_NUM_0), isr_button_pressed, FALLING);
|
||||
pinMode(HAS_BUTTON, INPUT_PULLDOWN);
|
||||
attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), isr_button_pressed, FALLING);
|
||||
#endif
|
||||
|
||||
// initialize wifi antenna
|
||||
|
@ -1,5 +1,5 @@
|
||||
// program version
|
||||
#define PROGVERSION "1.2.22" // use max 10 chars here!
|
||||
#define PROGVERSION "1.3.0" // use max 10 chars here!
|
||||
#define PROGNAME "PAXCNT"
|
||||
|
||||
// Verbose enables serial output
|
||||
|
@ -49,7 +49,7 @@ void wifi_sniffer_init(void) {
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
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_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_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
|
||||
|
Loading…
Reference in New Issue
Block a user