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