commit
293895055f
@ -3,6 +3,8 @@
|
||||
|
||||
Tutorial (in german language): https://www.heise.de/select/make/2019/1/1551099236518668
|
||||
|
||||
**IMPORTANT: MUST USE PLATFORMIO V4 (not v3.x)**
|
||||
|
||||
<img src="img/Paxcounter-title.jpg">
|
||||
<img src="img/Paxcounter-ttgo.jpg">
|
||||
<img src="img/Paxcounter-lolin.gif">
|
||||
@ -410,8 +412,8 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
||||
|
||||
bits 4..7 time status
|
||||
0x00 = timeNotSet (never synched)
|
||||
0x10 = timeNeedsSync (last sync failed)
|
||||
0x20 = timeSet (synched)
|
||||
0x01 = timeNeedsSync (last sync failed)
|
||||
0x02 = timeSet (synched)
|
||||
|
||||
0x87 set time/date
|
||||
|
||||
|
16
build.py
16
build.py
@ -1,5 +1,5 @@
|
||||
# build.py
|
||||
# pre-build script, setting up build environment
|
||||
# pre-build script, setting up build environment and fetch hal file for user's board
|
||||
|
||||
import sys
|
||||
import os
|
||||
@ -55,8 +55,20 @@ if os.path.isfile(otakeyfile) and os.access(otakeyfile, os.R_OK):
|
||||
else:
|
||||
sys.exit("Missing file " + otakeyfile + ", please create it! Aborting.")
|
||||
|
||||
# parse ota key file
|
||||
# parse hal file
|
||||
mykeys = {}
|
||||
with open(halconfigfile) as myfile:
|
||||
for line in myfile:
|
||||
line2 = line.strip("// ")
|
||||
key, value = line2.partition(" ")[::2]
|
||||
mykeys[key.strip()] = str(value).strip()
|
||||
myboard = mykeys["board"]
|
||||
myuploadspeed = mykeys["upload_speed"]
|
||||
env.Replace(BOARD=myboard)
|
||||
env.Replace(UPLOAD_SPEED=myuploadspeed)
|
||||
print '\033[94m' + "TARGET BOARD: " + myboard + " @ " + myuploadspeed + "bps" + '\033[0m'
|
||||
|
||||
# parse ota key file
|
||||
with open(otakeyfile) as myfile:
|
||||
for line in myfile:
|
||||
key, value = line.partition("=")[::2]
|
||||
|
@ -5,103 +5,43 @@
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
|
||||
; ---> SELECT TARGET PLATFORM HERE! <---
|
||||
; ---> SELECT THE TARGET PLATFORM HERE! <---
|
||||
[board]
|
||||
halfile = generic.h
|
||||
;halfile = ebox.h
|
||||
;board = esp32dev
|
||||
;upload_speed = 115200
|
||||
|
||||
;halfile = eboxtube.h
|
||||
;board = esp32dev
|
||||
;upload_speed = 115200
|
||||
|
||||
;halfile = ecopower.h
|
||||
;board = esp32dev
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = heltec.h
|
||||
;board = heltec_wifi_lora_32
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = heltecv2.h
|
||||
;board = heltec_wifi_lora_32_V2
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = ttgov1.h
|
||||
;board = ttgo-lora32-v1
|
||||
;upload_speed = 115200
|
||||
|
||||
;halfile = ttgov2.h
|
||||
;board = ttgo-lora32-v1
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = ttgov21old.h
|
||||
;board = esp32dev
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = ttgov21new.h
|
||||
;board = esp32dev
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = ttgofox.h
|
||||
;board = esp32dev
|
||||
;upload_speed = 921600
|
||||
|
||||
halfile = ttgobeam.h
|
||||
board = ttgo-t-beam
|
||||
upload_speed = 921600
|
||||
|
||||
;halfile = ttgobeam.h
|
||||
;halfile = fipy.h
|
||||
;board = esp32dev
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = lopy.h
|
||||
;board = lopy
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = lopy4.h
|
||||
;board = lopy4
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = lolin32litelora.h
|
||||
;board = lolin32
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = lolin32lora.h
|
||||
;board = lolin32
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = lolin32lite.h
|
||||
;board = lolin32
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = wemos32oled.h
|
||||
;board = lolin32
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = octopus32.h
|
||||
;board = featheresp32
|
||||
;upload_speed = 921600
|
||||
|
||||
;halfile = generic.h
|
||||
;board = esp32dev
|
||||
;upload_speed = 115200
|
||||
|
||||
|
||||
[platformio]
|
||||
; upload firmware to board with usb cable
|
||||
;default_envs = usb
|
||||
default_envs = usb
|
||||
|
||||
; upload firmware to a jfrog bintray repository
|
||||
;default_envs = ota
|
||||
|
||||
default_envs = dev
|
||||
;default_envs = dev
|
||||
build_cache_dir = /tmp/platformio-shared-cache
|
||||
description = Paxcounter is a proof-of-concept ESP32 device for metering passenger flows in realtime. It counts how many mobile devices are around.
|
||||
description = Paxcounter is a device for metering passenger flows in realtime. It counts how many mobile devices are around.
|
||||
|
||||
[common]
|
||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||
release_version = 1.7.71
|
||||
release_version = 1.7.8
|
||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
||||
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
||||
debug_level = 3
|
||||
@ -111,7 +51,9 @@ lorakeyfile = loraconf.h
|
||||
lmicconfigfile = lmic_config.h
|
||||
platform_espressif32 = espressif32@1.9.0
|
||||
board_build.partitions = min_spiffs.csv
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
upload_speed = 115200
|
||||
lib_deps_lora =
|
||||
;MCCI LoRaWAN LMIC library@2.3.2
|
||||
https://github.com/mcci-catena/arduino-lmic.git
|
||||
@ -124,12 +66,12 @@ lib_deps_rgbled =
|
||||
lib_deps_gps =
|
||||
1655@>=1.0.2 ;TinyGPSPlus by Mikal Hart
|
||||
lib_deps_sensors =
|
||||
Adafruit Unified Sensor@^1.0.3
|
||||
Adafruit BME280 Library@1.0.8
|
||||
Adafruit Unified Sensor@>=1.0.3
|
||||
Adafruit BME280 Library@>=1.0.9
|
||||
lib_deps_basic =
|
||||
ArduinoJson@^5.13.1
|
||||
76@^1.2.2 ;Timezone by Jack Christensen
|
||||
274@^2.3.3 ;RTC by Michael Miller
|
||||
76@>=1.2.2 ;Timezone by Jack Christensen
|
||||
274@>=2.3.3 ;RTC by Michael Miller
|
||||
SimpleButton
|
||||
lib_deps_all =
|
||||
${common.lib_deps_basic}
|
||||
@ -137,6 +79,7 @@ lib_deps_all =
|
||||
${common.lib_deps_display}
|
||||
${common.lib_deps_rgbled}
|
||||
${common.lib_deps_gps}
|
||||
${common.lib_deps_sensors}
|
||||
${common.lib_deps_matrix_display}
|
||||
build_flags_basic =
|
||||
-include "src/hal/${board.halfile}"
|
||||
@ -154,8 +97,8 @@ build_flags_all =
|
||||
-mfix-esp32-psram-cache-issue
|
||||
|
||||
[env]
|
||||
board = ${board.board}
|
||||
upload_speed = ${board.upload_speed}
|
||||
board = ${common.board}
|
||||
upload_speed = ${common.upload_speed}
|
||||
platform = ${common.platform_espressif32}
|
||||
framework = arduino
|
||||
board_build.partitions = ${common.board_build.partitions}
|
||||
@ -173,6 +116,7 @@ upload_protocol = esptool
|
||||
|
||||
[env:dev]
|
||||
upload_protocol = esptool
|
||||
build_type = debug
|
||||
platform = https://github.com/platformio/platform-espressif32.git#develop
|
||||
platform_packages =
|
||||
; use upstream Git version
|
||||
|
@ -77,16 +77,24 @@ void gps_storelocation(gpsStatus_t &gps_store) {
|
||||
// store current GPS timedate in struct
|
||||
void IRAM_ATTR gps_storetime(gpsStatus_t &gps_store) {
|
||||
|
||||
gps_store.time_age = gps.time.age();
|
||||
if (gps.time.isUpdated() && gps.date.isValid() && (gps.time.age() < 1000)) {
|
||||
|
||||
if (gps.time.isValid() && gps.date.isValid() && (gps_store.time_age < 1000)) {
|
||||
/* nmea telegram serial delay compensation; not sure if we need this?
|
||||
|
||||
if (gps.time.age() > nmea_txDelay_ms)
|
||||
gps_store.timedate.Second = gps.time.second() + 1;
|
||||
else
|
||||
gps_store.timedate.Second = gps.time.second();
|
||||
*/
|
||||
|
||||
gps_store.timedate.Second = gps.time.second();
|
||||
gps_store.timedate.Minute = gps.time.minute();
|
||||
gps_store.timedate.Hour = gps.time.hour();
|
||||
gps_store.timedate.Day = gps.date.day();
|
||||
gps_store.timedate.Month = gps.date.month();
|
||||
gps_store.timedate.Year =
|
||||
CalendarYrToTm(gps.date.year()); // year offset from 1970 in microTime.h
|
||||
gps_store.timedate.Month = gps.date.month();
|
||||
gps_store.timedate.Day = gps.date.day();
|
||||
gps_store.timedate.Hour = gps.time.hour();
|
||||
gps_store.timedate.Minute = gps.time.minute();
|
||||
gps_store.timedate.Second = gps.time.second();
|
||||
|
||||
} else
|
||||
gps_store.timedate = {0};
|
||||
}
|
||||
@ -96,11 +104,8 @@ time_t get_gpstime(gpsStatus_t value) {
|
||||
|
||||
time_t t = timeIsValid(makeTime(value.timedate));
|
||||
|
||||
// if (t)
|
||||
// t = value.time_age > nmea_txDelay_ms ? t : t - 1;
|
||||
|
||||
// show NMEA data in verbose mode, useful for debugging GPS
|
||||
ESP_LOGV(
|
||||
ESP_LOGD(
|
||||
TAG,
|
||||
"GPS time: %d | GPS NMEA data: passed %d / failed: %d / with fix: %d", t,
|
||||
gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix());
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 115200
|
||||
// board esp32dev
|
||||
|
||||
#ifndef _EBOX_H
|
||||
#define _EBOX_H
|
||||
|
@ -1,4 +1,7 @@
|
||||
// clang-format off
|
||||
// upload_speed 115200
|
||||
// board esp32dev
|
||||
|
||||
|
||||
#ifndef _EBOXTUBE_H
|
||||
#define _EBOXTUBE_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board esp32dev
|
||||
|
||||
#ifndef _GENERIC_H
|
||||
#define _GENERIC_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board esp32dev
|
||||
|
||||
#ifndef _FIPY_H
|
||||
#define _FIPY_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 115200
|
||||
// board esp32dev
|
||||
|
||||
#ifndef _GENERIC_H
|
||||
#define _GENERIC_H
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board heltec_wifi_lora_32
|
||||
|
||||
#ifndef _HELTEC_H
|
||||
#define _HELTEC_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board heltec_wifi_lora_32_V2
|
||||
|
||||
#ifndef _HELTECV2_H
|
||||
#define _HELTECV2_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board lolin32
|
||||
|
||||
#ifndef _LOLINLITE_H
|
||||
#define _LOLINLITE_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board lolin32
|
||||
|
||||
#ifndef _LOLINLITELORA_H
|
||||
#define _LOLINLITELORA_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board lolin32
|
||||
|
||||
#ifndef _LOLINLORA_H
|
||||
#define _LOLINLORA_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board lopy
|
||||
|
||||
#ifndef _LOPY_H
|
||||
#define _LOPY_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board lopy4
|
||||
|
||||
#ifndef _LOPY4_H
|
||||
#define _LOPY4_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board featheresp32
|
||||
|
||||
#ifndef _OCTOPUS_H
|
||||
#define _OCTOPUS_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board ttgo-t-beam
|
||||
|
||||
#ifndef _TTGOBEAM_H
|
||||
#define _TTGOBEAM_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board esp32dev
|
||||
|
||||
#ifndef _TTGOFOX_H
|
||||
#define _TTGOFOX_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 115200
|
||||
// board ttgo-lora32-v1
|
||||
|
||||
#ifndef _TTGOV1_H
|
||||
#define _TTGOV1_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board ttgo-lora32-v1
|
||||
|
||||
#ifndef _TTGOV2_H
|
||||
#define _TTGOV2_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board esp32dev
|
||||
|
||||
#ifndef _TTGOV21NEW_H
|
||||
#define _TTGOV21NEW_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board esp32dev
|
||||
|
||||
#ifndef _TTGOV21OLD_H
|
||||
#define _TTGOV21OLD_H
|
||||
|
@ -1,4 +1,6 @@
|
||||
// clang-format off
|
||||
// upload_speed 921600
|
||||
// board lolin32
|
||||
|
||||
#ifndef _WEMOS32OLED_H
|
||||
#define _WEMOS32OLED_H
|
||||
|
@ -31,7 +31,7 @@ time_t timeProvider(void) {
|
||||
time_t t = 0;
|
||||
|
||||
#if (HAS_GPS)
|
||||
// fetch recent time from last NEMA record
|
||||
// fetch recent time from last NMEA record
|
||||
t = get_gpstime(gps_pps_status);
|
||||
if (t) {
|
||||
#ifdef HAS_RTC
|
||||
@ -140,9 +140,11 @@ void IRAM_ATTR CLOCKIRQ(void) {
|
||||
|
||||
SyncToPPS(); // advance systime, see microTime.h
|
||||
|
||||
// store recent gps time, if we have gps
|
||||
// store recent gps time, and try to get gps time if time is not synced
|
||||
#if (HAS_GPS)
|
||||
gps_storetime(gps_pps_status);
|
||||
if (timeSource == _unsynced)
|
||||
timeSync();
|
||||
#endif
|
||||
|
||||
// advance wall clock, if we have
|
||||
|
Loading…
Reference in New Issue
Block a user