commit
c84600022f
@ -8,10 +8,11 @@
|
|||||||
; 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 = ttgov1
|
;env_default = ttgov1
|
||||||
|
;env_default = ttgov2
|
||||||
;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,15 +1,10 @@
|
|||||||
// Log Level magic
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
// not using this seems to break U8X8LIB
|
// not using this seems to break U8X8LIB
|
||||||
#include <Arduino.h>
|
//#include <Arduino.h>
|
||||||
|
|
||||||
// Local logging tag
|
|
||||||
static const char *TAG = "blecount";
|
|
||||||
|
|
||||||
// Basic Config
|
// Basic Config
|
||||||
|
#include "main.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "loraconf.h"
|
//#include "loraconf.h"
|
||||||
|
|
||||||
#ifdef BLECOUNTER
|
#ifdef BLECOUNTER
|
||||||
#include <BLEDevice.h>
|
#include <BLEDevice.h>
|
||||||
@ -17,6 +12,9 @@ static const char *TAG = "blecount";
|
|||||||
#include <BLEScan.h>
|
#include <BLEScan.h>
|
||||||
#include <BLEAdvertisedDevice.h>
|
#include <BLEAdvertisedDevice.h>
|
||||||
|
|
||||||
|
// Local logging tag
|
||||||
|
static const char *TAG = "blecount";
|
||||||
|
|
||||||
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
||||||
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* configmanager persists runtime configuration using NVRAM of ESP32*/
|
/* configmanager persists runtime configuration using NVRAM of ESP32*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include <nvs.h>
|
#include <nvs.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
|
@ -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
|
||||||
|
@ -16,3 +16,11 @@
|
|||||||
// 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);
|
||||||
|
@ -16,3 +16,11 @@
|
|||||||
// 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
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
|
|
||||||
// Basic Config
|
// Basic Config
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
// #include <Arduino.h>
|
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "loraconf.h"
|
|
||||||
|
|
||||||
// LMIC-Arduino LoRaWAN Stack
|
// LMIC-Arduino LoRaWAN Stack
|
||||||
|
#include "loraconf.h"
|
||||||
#include <lmic.h>
|
#include <lmic.h>
|
||||||
#include <hal/hal.h>
|
#include <hal/hal.h>
|
||||||
|
|
||||||
|
88
src/main.cpp
88
src/main.cpp
@ -1,27 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Oliver Brandmueller <ob@sysadm.in> 2017/2018
|
Copyright 2018 Oliver Brandmueller <ob@sysadm.in>
|
||||||
* Klaus Wilting <verkehrsrot@arcor.de> 2018
|
Copyright 2018 Klaus Wilting <verkehrsrot@arcor.de>
|
||||||
*
|
|
||||||
* some lines of code taken from:
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
*
|
you may not use this file except in compliance with the License.
|
||||||
* Copyright (c) 2017, Łukasz Marcin Podkalicki <lpodkalicki@gmail.com>
|
You may obtain a copy of the License at
|
||||||
* ESP32/016 WiFi Sniffer.
|
|
||||||
* https://github.com/lpodkalicki/blog/tree/master/esp32/016_wifi_sniffer
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
|
||||||
* Arduino-LMIC Library
|
Unless required by applicable law or agreed to in writing, software
|
||||||
* TTN OTAA Example
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* https://github.com/matthijskooijman/arduino-lmic/blob/master/examples/ttn-otaa/
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
*
|
See the License for the specific language governing permissions and
|
||||||
* nkolban esp32 snippets
|
limitations under the License.
|
||||||
* BLE Scan
|
|
||||||
* https://github.com/nkolban/esp32-snippets/tree/master/cpp_utils/tests/BLETests/Arduino/BLE_scan
|
NOTICE:
|
||||||
*
|
Parts of the source files in this repository are made available under different licenses.
|
||||||
* parts of code in lorawan.cpp has been grabbed from RadioHead Library
|
Refer to LICENSE.txt file in repository for more details.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// First things first
|
// Basic Config
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
// std::set for unified array functions
|
// std::set for unified array functions
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -29,20 +31,11 @@
|
|||||||
// 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 "loraconf.h"
|
||||||
#include <lmic.h>
|
#include <lmic.h>
|
||||||
#include <hal/hal.h>
|
#include <hal/hal.h>
|
||||||
|
|
||||||
// Basic Config
|
|
||||||
#include "loraconf.h"
|
|
||||||
#include "configmanager.h"
|
|
||||||
|
|
||||||
// WiFi Functions
|
// WiFi Functions
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
#include <esp_wifi_types.h>
|
#include <esp_wifi_types.h>
|
||||||
@ -50,15 +43,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 +60,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 +133,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 +154,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 +325,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 +344,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.2.3" // use max 10 chars here!
|
||||||
#define PROGNAME "PAXCNT"
|
#define PROGNAME "PAXCNT"
|
||||||
|
|
||||||
// Verbose enables serial output
|
// Verbose enables serial output
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// parses multiple number of command / value pairs from LoRaWAN remote command port (RCMDPORT)
|
// parses multiple number of command / value pairs from LoRaWAN remote command port (RCMDPORT)
|
||||||
// checks commands and executes each command with 1 argument per command
|
// checks commands and executes each command with 1 argument per command
|
||||||
|
|
||||||
|
// Basic Config
|
||||||
|
#include "main.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
// Local logging tag
|
// Local logging tag
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
#include "main.h"
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
// Basic Config
|
// Basic Config
|
||||||
|
#include "main.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "loraconf.h"
|
|
||||||
|
|
||||||
// WiFi Functions
|
// WiFi Functions
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
@ -49,7 +45,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