code sanitization

This commit is contained in:
Klaus K Wilting 2018-07-17 11:53:43 +02:00
parent 8f75fed9df
commit 7fdd4a72cd
11 changed files with 91 additions and 82 deletions

View File

@ -11,11 +11,11 @@
; ---> SELECT TARGET PLATFORM HERE! <--- ; ---> SELECT TARGET PLATFORM HERE! <---
[platformio] [platformio]
;env_default = generic env_default = generic
;env_default = heltec ;env_default = heltec
;env_default = ttgov1 ;env_default = ttgov1
;env_default = ttgov2 ;env_default = ttgov2
env_default = ttgov21 ;env_default = ttgov21
;env_default = ttgobeam ;env_default = ttgobeam
;env_default = lopy ;env_default = lopy
;env_default = lopy4 ;env_default = lopy4

View File

@ -1,6 +1,8 @@
#ifndef BLESCAN_H #ifndef BLESCAN_H
#define BLESCAN_H #define BLESCAN_H
#include "macsniff.h"
void start_BLEscan(void); void start_BLEscan(void);
void stop_BLEscan(void); void stop_BLEscan(void);

View File

@ -1,16 +1,37 @@
// The mother of all embedded development... // The mother of all embedded development...
#include <Arduino.h> #include <Arduino.h>
// needed for ESP_LOGx on arduino framework
#include <esp32-hal-log.h>
// attn: increment version after modifications to configData_t truct!
#define PROGVERSION "1.3.91" // use max 10 chars here!
#define PROGNAME "PAXCNT"
// std::set for unified array functions // std::set for unified array functions
#include <set> #include <set>
#include <array> #include <array>
#include <algorithm> #include <algorithm>
// basics // Struct holding devices's runtime configuration
#include "main.h" typedef struct {
#include "led.h" uint8_t lorasf; // 7-12, lora spreadfactor
#include "macsniff.h" uint8_t txpower; // 2-15, lora tx power
#include "payload.h" uint8_t adrmode; // 0=disabled, 1=enabled
uint8_t screensaver; // 0=disabled, 1=enabled
uint8_t screenon; // 0=disabled, 1=enabled
uint8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed
int16_t rssilimit; // threshold for rssilimiter, negative value!
uint8_t sendcycle; // payload send cycle [seconds/2]
uint8_t wifichancycle; // wifi channel switch cycle [seconds/100]
uint8_t blescantime; // BLE scan cycle duration [seconds]
uint8_t blescan; // 0=disabled, 1=enabled
uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
uint8_t vendorfilter; // 0=disabled, 1=enabled
uint8_t rgblum; // RGB Led luminosity (0..100%)
uint8_t gpsmode; // 0=disabled, 1=enabled
char version[10]; // Firmware version
} configData_t;
extern configData_t cfg; extern configData_t cfg;
extern char display_line6[], display_line7[]; extern char display_line6[], display_line7[];
@ -21,11 +42,41 @@ extern std::set<uint16_t> macs;
extern hw_timer_t *channelSwitch, *sendCycle; extern hw_timer_t *channelSwitch, *sendCycle;
extern portMUX_TYPE timerMux; extern portMUX_TYPE timerMux;
#ifdef HAS_GPS #ifdef HAS_LORA
extern gpsStatus_t gps_status; // struct for storing gps data #include "lorawan.h"
extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe
#endif #endif
#ifdef HAS_DISPLAY
#include "display.h"
#endif
#ifdef HAS_GPS
#include "gps.h"
typedef struct {
uint32_t latitude;
uint32_t longitude;
uint8_t satellites;
uint16_t hdop;
uint16_t altitude;
} gpsStatus_t;
extern gpsStatus_t gps_status; // struct for storing gps data
#endif
#ifdef BLECOUNTER
#include "blescan.h"
#endif
#ifdef HAS_BATTERY_PROBE
#include "battery.h"
#endif
#ifdef HAS_ANTENNA_SWITCH
#include "antenna.h"
#endif
// class for preparing payload data
#include "payload.h"
// payload encoder // payload encoder
#if PAYLOAD_ENCODER == 1 #if PAYLOAD_ENCODER == 1
extern TTNplain payload; extern TTNplain payload;
@ -36,3 +87,9 @@ extern CayenneLPP payload;
#else #else
#error "No valid payload converter defined" #error "No valid payload converter defined"
#endif #endif
void reset_counters(void);
void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
void led_loop(void);
uint64_t uptime();

View File

@ -1,7 +1,6 @@
#ifdef HAS_GPS #ifdef HAS_GPS
#include "globals.h" #include "globals.h"
#include <Wire.h>
// Local logging tag // Local logging tag
static const char TAG[] = "main"; static const char TAG[] = "main";

View File

@ -3,6 +3,8 @@
#include <TinyGPS++.h> #include <TinyGPS++.h>
extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe
void gps_read(void); void gps_read(void);
void gps_loop(void *pvParameters); void gps_loop(void *pvParameters);

View File

@ -1,5 +1,5 @@
#ifndef led_H
//#pragma once #define led_H
#ifdef HAS_RGB_LED #ifdef HAS_RGB_LED
#include <SmartLeds.h> #include <SmartLeds.h>
@ -35,3 +35,5 @@ enum led_states { LED_OFF, LED_ON };
void rgb_set_color(uint16_t hue); void rgb_set_color(uint16_t hue);
void blink_LED(uint16_t set_color, uint16_t set_blinkduration); void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
void led_loop(); void led_loop();
#endif

View File

@ -7,6 +7,8 @@
// Hash function for scrambling MAC addresses // Hash function for scrambling MAC addresses
#include "hash.h" #include "hash.h"
#include "led.h"
#define MAC_SNIFF_WIFI 0 #define MAC_SNIFF_WIFI 0
#define MAC_SNIFF_BLE 1 #define MAC_SNIFF_BLE 1

View File

@ -25,6 +25,7 @@ licenses. Refer to LICENSE.txt file in repository for more details.
// Basic Config // Basic Config
#include "globals.h" #include "globals.h"
#include "main.h"
// Initialize global variables // Initialize global variables
configData_t cfg; // struct holds current device configuration configData_t cfg; // struct holds current device configuration

View File

@ -1,77 +1,17 @@
#ifndef main_H
#define main_H
#include "led.h"
#include "macsniff.h"
#include "configmanager.h" #include "configmanager.h"
#include "senddata.h" #include "senddata.h"
// Does nothing and avoid any compilation error with I2C
#include <Wire.h>
// ESP32 lib Functions
#include <esp32-hal-log.h> // needed for ESP_LOGx on arduino framework
#include <esp_event_loop.h> // needed for Wifi event handler
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes #include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
#include <esp_event_loop.h> // needed for Wifi event handler
#ifdef HAS_LORA
#include "lorawan.h"
#endif
#ifdef HAS_DISPLAY
#include "display.h"
#endif
#ifdef HAS_GPS
#include "gps.h"
#endif
#ifdef BLECOUNTER
#include "blescan.h"
#endif
#ifdef HAS_BATTERY_PROBE
#include "battery.h"
#endif
#ifdef HAS_ANTENNA_SWITCH
#include "antenna.h"
#endif
// program version - note: increment version after modifications to configData_t
// struct!!
#define PROGVERSION "1.3.91" // use max 10 chars here!
#define PROGNAME "PAXCNT"
// Struct holding devices's runtime configuration
typedef struct {
uint8_t lorasf; // 7-12, lora spreadfactor
uint8_t txpower; // 2-15, lora tx power
uint8_t adrmode; // 0=disabled, 1=enabled
uint8_t screensaver; // 0=disabled, 1=enabled
uint8_t screenon; // 0=disabled, 1=enabled
uint8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed
int16_t rssilimit; // threshold for rssilimiter, negative value!
uint8_t sendcycle; // payload send cycle [seconds/2]
uint8_t wifichancycle; // wifi channel switch cycle [seconds/100]
uint8_t blescantime; // BLE scan cycle duration [seconds]
uint8_t blescan; // 0=disabled, 1=enabled
uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
uint8_t vendorfilter; // 0=disabled, 1=enabled
uint8_t rgblum; // RGB Led luminosity (0..100%)
uint8_t gpsmode; // 0=disabled, 1=enabled
char version[10]; // Firmware version
} configData_t;
#ifdef HAS_GPS
typedef struct {
uint32_t latitude;
uint32_t longitude;
uint8_t satellites;
uint16_t hdop;
uint16_t altitude;
} gpsStatus_t;
extern gpsStatus_t gps_status; // struct for storing gps data
extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe
#endif
void reset_counters(void); void reset_counters(void);
void blink_LED(uint16_t set_color, uint16_t set_blinkduration); void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
void led_loop(void); void led_loop(void);
uint64_t uptime(); uint64_t uptime();
#endif

View File

@ -5,6 +5,7 @@
// Basic Config // Basic Config
#include "globals.h" #include "globals.h"
#include "rcommand.h"
// Local logging tag // Local logging tag
static const char TAG[] = "main"; static const char TAG[] = "main";

View File

@ -1,6 +1,9 @@
#ifndef rcommand_H #ifndef rcommand_H
#define rcommand_H #define rcommand_H
#include "senddata.h"
#include "configmanager.h"
void rcommand(uint8_t cmd, uint8_t arg); void rcommand(uint8_t cmd, uint8_t arg);
void switch_lora(uint8_t sf, uint8_t tx); void switch_lora(uint8_t sf, uint8_t tx);