Skip to content

Commit

Permalink
Merge pull request #805 from cyberman54/development
Browse files Browse the repository at this point in the history
v3.0.0
  • Loading branch information
cyberman54 authored May 29, 2021
2 parents 9e586ec + 67c0313 commit 83ff32b
Show file tree
Hide file tree
Showing 90 changed files with 1,067 additions and 4,047 deletions.
65 changes: 24 additions & 41 deletions README.md

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,43 @@
key, value = line.partition("=")[::2]
mykeys[key.strip()] = str(value).strip()

# usage of bintray: see https://github.com/r0oland/bintray-secure-ota
# usage of paxexpress: see https://github.com/paxexpress/docs

# get bintray user credentials from ota key file
user = mykeys["BINTRAY_USER"]
repository = mykeys["BINTRAY_REPO"]
apitoken = mykeys["BINTRAY_API_TOKEN"]
# get paxexpress credentials from ota key file
user = mykeys["PAXEXPRESS_USER"]
repository = mykeys["PAXEXPRESS_REPO"]
apitoken = mykeys["PAXEXPRESS_API_TOKEN"]

# get bintray upload parameters from platformio environment
# get paxexpress upload parameters from platformio environment
version = config.get("common", "release_version")
package, dummy = halconfig.partition(".")[::2]

# put bintray user credentials to platformio environment
env.Replace(BINTRAY_USER=user)
env.Replace(BINTRAY_REPO=repository)
env.Replace(BINTRAY_API_TOKEN=apitoken)
# put paxexpress user credentials to platformio environment
env.Replace(PAXEXPRESS_USER=user)
env.Replace(PAXEXPRESS_REPO=repository)
env.Replace(PAXEXPRESS_API_TOKEN=apitoken)

# get runtime credentials and put them to compiler directive
env.Append(BUILD_FLAGS=[
u'-DWIFI_SSID=\\"' + mykeys["OTA_WIFI_SSID"] + '\\"',
u'-DWIFI_PASS=\\"' + mykeys["OTA_WIFI_PASS"] + '\\"',
u'-DBINTRAY_USER=\\"' + mykeys["BINTRAY_USER"] + '\\"',
u'-DBINTRAY_REPO=\\"' + mykeys["BINTRAY_REPO"] + '\\"',
u'-DBINTRAY_PACKAGE=\\"' + package + '\\"',
u'-DPAXEXPRESS_USER=\\"' + mykeys["PAXEXPRESS_USER"] + '\\"',
u'-DPAXEXPRESS_REPO=\\"' + mykeys["PAXEXPRESS_REPO"] + '\\"',
u'-DPAXEXPRESS_PACKAGE=\\"' + package + '\\"',
u'-DARDUINO_LMIC_PROJECT_CONFIG_H=' + lmicconfig,
u'-I \"' + srcdir + '\"'
])

# function for pushing new firmware to bintray storage using API
def publish_bintray(source, target, env):
# function for pushing new firmware to paxexpress storage using API
def publish_paxexpress(source, target, env):
firmware_path = str(source[0])
firmware_name = basename(firmware_path)
url = "/".join([
"https://api.bintray.com", "content",
"https://pax.express", "content",
user, repository, package, version, firmware_name
])

print("Uploading {0} to Bintray. Version: {1}".format(
print("Uploading {0} to PAX.express. Version: {1}".format(
firmware_name, version))
print(url)

Expand All @@ -145,9 +145,9 @@ def publish_bintray(source, target, env):
("%s\n%s" % (r.status_code, r.text) if r else str(e)))
env.Exit(1)

print("The firmware has been successfuly published at Bintray.com!")
print("Firmware has been successfully published at PAX.express!")

# put build file name and upload command to platformio environment
env.Replace(
PROGNAME="firmware_" + package + "_v%s" % version,
UPLOADCMD=publish_bintray)
UPLOADCMD=publish_paxexpress)
9 changes: 0 additions & 9 deletions include/beacon_array.h

This file was deleted.

17 changes: 0 additions & 17 deletions include/blescan.h

This file was deleted.

4 changes: 3 additions & 1 deletion include/configmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "reset.h"
#include <Preferences.h>

void saveConfig(bool erase = false);
extern configData_t cfg;

void saveConfig(bool erase);
bool loadConfig(void);
void eraseConfig(void);
int version_compare(const String v1, const String v2);
Expand Down
4 changes: 2 additions & 2 deletions include/cyclic.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
#include "display.h"
#include "sds011read.h"
#include "sdcard.h"
#include "macsniff.h"
#include "reset.h"
#include "led.h"
#include "power.h"

extern Ticker cyclicTimer;

void setCyclicIRQ(void);
void doHousekeeping(void);
void reset_counters(void);
uint32_t getFreeRAM();

#endif
1 change: 1 addition & 0 deletions include/dcf77.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _DCF77_H

#include "globals.h"
#include "timekeeper.h"

#define DCF77_FRAME_SIZE (60)
#define DCF77_PULSE_LENGTH (100)
Expand Down
8 changes: 7 additions & 1 deletion include/display.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef _DISPLAY_H
#define _DISPLAY_H

#include <libpax_api.h>
#include "cyclic.h"
#include "qrcode.h"
#include "power.h"

#if (COUNT_ENS)
#include "corona.h"
Expand Down Expand Up @@ -76,13 +78,17 @@
#define QR_VERSION 3 // 29 x 29px

const uint8_t QR_SCALEFACTOR = (MY_DISPLAY_HEIGHT - 4) / 29; // 4px borderlines

extern uint8_t DisplayIsOn, displaybuf[];
extern hw_timer_t *displayIRQ;
extern uint8_t volatile channel; // wifi channel rotation counter

void dp_setup(int contrast = 0);
void dp_refresh(bool nextPage = false);
void dp_init(bool verbose = false);
void dp_shutdown(void);
void dp_drawPage(time_t t, bool nextpage);
void dp_message(const char *msg, int line, bool invers);
void dp_drawPage(bool nextpage);
void dp_println(int lines = 1);
void dp_printf(const char *format, ...);
void dp_setFont(int font, int inv = 0);
Expand Down
48 changes: 6 additions & 42 deletions include/globals.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
#ifndef _GLOBALS_H
#define _GLOBALS_H
#endif

// The mother of all embedded development...
#include <Arduino.h>

// Time functions
#include "microTime.h"
#include <Timezone.h>
#include <ezTime.h>
#include <RtcDateTime.h>
#include <Ticker.h>

// std::set for unified array functions
#include <set>
#include <array>
#include <algorithm>
#include "mallocator.h"
#include <bsec.h>

#define _bit(b) (1U << (b))
#define _bitl(b) (1UL << (b))

// bits in payloadmask for filtering payload data
#define COUNT_DATA _bit(0)
#define ALARM_DATA _bit(1)
#define RESERVED_DATA _bit(1)
#define MEMS_DATA _bit(2)
#define GPS_DATA _bit(3)
#define SENSOR1_DATA _bit(4)
Expand All @@ -48,19 +45,11 @@
for (;;) \
; \
}
#endif

#define _seconds() millis() / 1000.0

enum timesource_t { _gps, _rtc, _lora, _unsynced };
enum snifftype_t { MAC_SNIFF_WIFI, MAC_SNIFF_BLE, MAC_SNIFF_BLE_ENS };
enum runmode_t {
RUNMODE_POWERCYCLE,
RUNMODE_NORMAL,
RUNMODE_WAKEUP,
RUNMODE_UPDATE,
RUNMODE_SLEEP,
RUNMODE_MAINTENANCE
};

// Struct holding devices's runtime configuration
// using packed to avoid compiler padding, because struct will be memcpy'd to
Expand All @@ -75,15 +64,13 @@ typedef struct __attribute__((packed)) {
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 sleepcycle; // sleep cycle [seconds/2]
uint16_t sleepcycle; // sleep cycle [seconds/10]
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 wifiscan; // 0=disabled, 1=enabled
uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
uint8_t macfilter; // 0=disabled, 1=enabled
uint8_t rgblum; // RGB Led luminosity (0..100%)
uint8_t monitormode; // 0=disabled, 1=enabled
uint8_t payloadmask; // bitswitches for payload data
uint8_t enscount; // 0=disabled 1= enabled

Expand All @@ -100,13 +87,6 @@ typedef struct {
uint8_t Message[PAYLOAD_BUFFER_SIZE];
} MessageBuffer_t;

// Struct for MAC processing queue
typedef struct {
uint8_t mac[6];
int8_t rssi;
snifftype_t sniff_type;
} MacBuffer_t;

typedef struct {
int32_t latitude;
int32_t longitude;
Expand All @@ -131,22 +111,6 @@ typedef struct {
float pm25;
} sdsStatus_t;

extern std::set<uint16_t, std::less<uint16_t>, Mallocator<uint16_t>> macs;
extern std::array<uint64_t, 0xff>::iterator it;
extern std::array<uint64_t, 0xff> beacons;

extern configData_t cfg; // current device configuration
extern char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer
extern uint8_t volatile channel; // wifi channel rotation counter
extern uint8_t volatile rf_load; // RF traffic indicator
extern uint8_t batt_level; // display value
extern uint16_t volatile macs_wifi, macs_ble; // display values
extern bool volatile TimePulseTick; // 1sec pps flag set by GPS or RTC
extern timesource_t timeSource;
extern hw_timer_t *displayIRQ, *matrixDisplayIRQ, *ppsIRQ;
extern SemaphoreHandle_t I2Caccess;
extern TaskHandle_t irqHandlerTask, ClockTask, macProcessTask;
extern TimerHandle_t WifiChanTimer;
extern Timezone myTZ;
extern char clientId[20]; // unique clientID

#endif
#endif
2 changes: 2 additions & 0 deletions include/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define MY_DISPLAY_SCL SCL
#endif

extern SemaphoreHandle_t I2Caccess;

void i2c_init(void);
void i2c_deinit(void);
void i2c_scan(void);
Expand Down
3 changes: 2 additions & 1 deletion include/if482.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#define _IF482_H

#include "globals.h"
#include "timekeeper.h"

#define IF482_FRAME_SIZE (17)
#define IF482_SYNC_FIXUP (10) // calibration to fixup processing time [milliseconds]

String IRAM_ATTR IF482_Frame(time_t tt);
String IRAM_ATTR IF482_Frame(time_t t);

#endif
2 changes: 2 additions & 0 deletions include/irqhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ void mask_user_IRQ();
void unmask_user_IRQ();
void doIRQ(int irq);

extern TaskHandle_t irqHandlerTask;

#ifdef HAS_DISPLAY
void IRAM_ATTR DisplayIRQ();
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/ledmatrixdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "ledmatrixdisplay.h"

extern uint8_t MatrixDisplayIsOn;

extern LEDMatrix matrix;
extern hw_timer_t *matrixDisplayIRQ;

void init_matrix_display(bool reverse = false);
void refreshTheMatrixDisplay(bool nextPage = false);
Expand Down
13 changes: 13 additions & 0 deletions include/libpax_helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef _LIBPAX_HELPERS_H
#define _LIBPAX_HELPERS_H

#include <stdio.h>
#include <libpax_api.h>
#include "senddata.h"
#include "configmanager.h"

void init_libpax(void);

extern uint16_t volatile libpax_macs_ble, libpax_macs_wifi; // libpax values

#endif
1 change: 1 addition & 0 deletions include/lorawan.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#endif

extern TaskHandle_t lmicTask, lorasendTask;
extern char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer

esp_err_t lmic_init(void);
void lora_setupForNetwork(bool preJoin);
Expand Down
25 changes: 0 additions & 25 deletions include/macsniff.h

This file was deleted.

7 changes: 4 additions & 3 deletions include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
#include <esp_event_loop.h> // needed for Wifi event handler
#include <esp32-hal-timer.h> // needed for timers
#include <esp_coexist.h> // needed for coex version display
#include <esp_wifi.h> // needed for wifi init / deinit

#include "globals.h"
#include "reset.h"
#include "i2c.h"
#include "blescan.h"
#include "wifiscan.h"
#include "configmanager.h"
#include "cyclic.h"
#include "beacon_array.h"
#include "ota.h"
#include "irqhandler.h"
#include "spislave.h"
Expand All @@ -22,5 +20,8 @@
#include "timekeeper.h"
#include "corona.h"
#include "boot.h"
#include "libpax_helpers.h"
#include "power.h"
#include "antenna.h"

#endif
Loading

0 comments on commit 83ff32b

Please sign in to comment.