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! <---
[platformio]
;env_default = generic
env_default = generic
;env_default = heltec
;env_default = ttgov1
;env_default = ttgov2
env_default = ttgov21
;env_default = ttgov21
;env_default = ttgobeam
;env_default = lopy
;env_default = lopy4

View File

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

View File

@ -1,16 +1,37 @@
// The mother of all embedded development...
#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
#include <set>
#include <array>
#include <algorithm>
// basics
#include "main.h"
#include "led.h"
#include "macsniff.h"
#include "payload.h"
// 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;
extern configData_t cfg;
extern char display_line6[], display_line7[];
@ -21,11 +42,41 @@ extern std::set<uint16_t> macs;
extern hw_timer_t *channelSwitch, *sendCycle;
extern portMUX_TYPE timerMux;
#ifdef HAS_GPS
extern gpsStatus_t gps_status; // struct for storing gps data
extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe
#ifdef HAS_LORA
#include "lorawan.h"
#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
#if PAYLOAD_ENCODER == 1
extern TTNplain payload;
@ -35,4 +86,10 @@ extern TTNpacked payload;
extern CayenneLPP payload;
#else
#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
#include "globals.h"
#include <Wire.h>
// Local logging tag
static const char TAG[] = "main";

View File

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

View File

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

View File

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

View File

@ -25,6 +25,7 @@ licenses. Refer to LICENSE.txt file in repository for more details.
// Basic Config
#include "globals.h"
#include "main.h"
// Initialize global variables
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 "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
#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
#include <esp_event_loop.h> // needed for Wifi event handler
void reset_counters(void);
void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
void led_loop(void);
uint64_t uptime();
uint64_t uptime();
#endif

View File

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

View File

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