Merge pull request #983 from cyberman54/master

sync dev to master
This commit is contained in:
Verkehrsrot 2023-07-02 21:08:33 +02:00 committed by GitHub
commit a3fa738fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 140 additions and 137 deletions

View File

@ -92,9 +92,9 @@ jobs:
- name: Copy of necessary files - name: Copy of necessary files
run: | run: |
cp platformio_orig.ini platformio.ini cp platformio_orig.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h cp shared/loraconf_sample.h shared/loraconf.h
cp src/ota_sample.conf src/ota.conf cp shared/ota_sample.conf shared/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf cp shared/paxcounter_orig.conf shared/paxcounter.conf
- name: Clean - name: Clean
run: pio run -t clean -e ci run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }} - name: Run PlatformIO CI for ${{ matrix.board }}
@ -143,9 +143,9 @@ jobs:
- name: Copy of necessary files - name: Copy of necessary files
run: | run: |
cp platformio_orig.ini platformio.ini cp platformio_orig.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h cp shared/loraconf_sample.h shared/loraconf.h
cp src/ota_sample.conf src/ota.conf cp shared/ota_sample.conf shared/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf cp shared/paxcounter_orig.conf shared/paxcounter.conf
- name: Clean - name: Clean
run: pio run -t clean -e ci run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }} - name: Run PlatformIO CI for ${{ matrix.board }}
@ -197,9 +197,9 @@ jobs:
- name: Copy of necessary files - name: Copy of necessary files
run: | run: |
cp platformio_orig_s3.ini platformio.ini cp platformio_orig_s3.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h cp shared/loraconf_sample.h shared/loraconf.h
cp src/ota_sample.conf src/ota.conf cp shared/ota_sample.conf shared/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf cp shared/paxcounter_orig.conf shared/paxcounter.conf
- name: Clean - name: Clean
run: pio run -t clean -e ci run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }} - name: Run PlatformIO CI for ${{ matrix.board }}
@ -235,22 +235,22 @@ jobs:
- name: Prepare config files for test - name: Prepare config files for test
run: | run: |
cp platformio_orig.ini platformio.ini cp platformio_orig.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h cp shared/loraconf_sample.h shared/loraconf.h
cp src/ota_sample.conf src/ota.conf cp shared/ota_sample.conf shared/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf cp shared/paxcounter_orig.conf shared/paxcounter.conf
# apply test credentials to loraconf.h # apply test credentials to loraconf.h
sed -i "s/APPEUI\[8\] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};/${{ secrets.APPEUI }}/" "src/loraconf.h" sed -i "s/APPEUI\[8\] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};/${{ secrets.APPEUI }}/" "shared/loraconf.h"
sed -i "s/APPKEY\[16\] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};/${{ secrets.APPKEY }}/" "src/loraconf.h" sed -i "s/APPKEY\[16\] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};/${{ secrets.APPKEY }}/" "shared/loraconf.h"
# apply test credentials to ota.conf # apply test credentials to ota.conf
sed -i "/OTA_WIFI_SSID/c OTA_WIFI_SSID = ${{ secrets.OTA_WIFI_SSID }}" "src/ota.conf" sed -i "/OTA_WIFI_SSID/c OTA_WIFI_SSID = ${{ secrets.OTA_WIFI_SSID }}" "shared/ota.conf"
sed -i "/OTA_WIFI_PASS/c OTA_WIFI_PASS = ${{ secrets.OTA_WIFI_PASS }}" "src/ota.conf" sed -i "/OTA_WIFI_PASS/c OTA_WIFI_PASS = ${{ secrets.OTA_WIFI_PASS }}" "shared/ota.conf"
sed -i "/PAXEXPRESS_USER/c PAXEXPRESS_USER = ${{ secrets.PAXEXPRESS_USER }}" "src/ota.conf" sed -i "/PAXEXPRESS_USER/c PAXEXPRESS_USER = ${{ secrets.PAXEXPRESS_USER }}" "shared/ota.conf"
sed -i "/PAXEXPRESS_REPO/c PAXEXPRESS_REPO = ${{ secrets.PAXEXPRESS_REPO }}" "src/ota.conf" sed -i "/PAXEXPRESS_REPO/c PAXEXPRESS_REPO = ${{ secrets.PAXEXPRESS_REPO }}" "shared/ota.conf"
sed -i "/PAXEXPRESS_API_TOKEN/c PAXEXPRESS_API_TOKEN = ${{ secrets.PAXEXPRESS_API_TOKEN }}" "src/ota.conf" sed -i "/PAXEXPRESS_API_TOKEN/c PAXEXPRESS_API_TOKEN = ${{ secrets.PAXEXPRESS_API_TOKEN }}" "shared/ota.conf"
- name: Build and deploy for testboard - name: Build and deploy for testboard
env: env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }}
run: pio remote -a prenzlpi run -t upload -r run: pio remote -a prenzlpi run -t upload
- name: Wait 120 seconds - name: Wait 120 seconds
run: sleep 120s run: sleep 120s
shell: bash shell: bash

6
.gitignore vendored
View File

@ -10,7 +10,7 @@
.vscode/.browse.c_cpp.db* .vscode/.browse.c_cpp.db*
.clang_complete .clang_complete
.gcc-flags.json .gcc-flags.json
src/loraconf.h shared/loraconf.h
src/ota.conf shared/ota.conf
platformio.ini platformio.ini
src/paxcounter.conf shared/paxcounter.conf

View File

@ -14,23 +14,23 @@ The following exampls show how to add a custom temperature and humidty sensor.
To use a custom sensor you first have to enable the Sensor which you want to use. For this you have to edit or add `HAS_SENSOR_1` in either the `paxcounter.conf` or the `hal` file of your board. To use a custom sensor you first have to enable the Sensor which you want to use. For this you have to edit or add `HAS_SENSOR_1` in either the `paxcounter.conf` or the `hal` file of your board.
=== "Activate Sensor 1" === "Activate Sensor 1"
```c linenums="132" title="src/paxcounter_orig.conf" ```c linenums="132" title="shared/paxcounter_orig.conf"
#define HAS_SENSOR_1 1 #define HAS_SENSOR_1 1
``` ```
=== "Activate Sensor 2" === "Activate Sensor 2"
```c linenums="132" title="src/paxcounter_orig.conf" ```c linenums="132" title="shared/paxcounter_orig.conf"
#define HAS_SENSOR_2 1 #define HAS_SENSOR_2 1
``` ```
=== "Activate Sensor 3" === "Activate Sensor 3"
```c linenums="132" title="src/paxcounter_orig.conf" ```c linenums="132" title="shared/paxcounter_orig.conf"
#define HAS_SENSOR_3 1 #define HAS_SENSOR_3 1
``` ```
You might also add a constant for your custom sensor in the `paxcounter.conf` file. This is optional but can be used to identify the sensor type. You might also add a constant for your custom sensor in the `paxcounter.conf` file. This is optional but can be used to identify the sensor type.
```c linenums="133" title="src/paxcounter_orig.conf" ```c linenums="133" title="shared/paxcounter_orig.conf"
#define HAS_GY21 1 // (1) #define HAS_GY21 1 // (1)
``` ```

View File

@ -14,24 +14,24 @@ You can add up to 3 user defined sensors. Insert your sensor's payload scheme in
For these peripherals no additional code is needed. To activate configure them in the board's hal file before building the code. For these peripherals no additional code is needed. To activate configure them in the board's hal file before building the code.
See [`generic.h`](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/src/hal/generic.h) for all options and for proper configuration of BME280/BME680. See [`generic.h`](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/shared/hal/generic.h) for all options and for proper configuration of BME280/BME680.
=== "BME/ BMP Configuration" === "BME/ BMP Configuration"
```c linenums="37" title="src/hal/generic.h" ```c linenums="37" title="shared/hal/generic.h"
--8<-- "src/hal/generic.h:37:49" --8<-- "shared/hal/generic.h:37:49"
``` ```
=== "SDS011 Configuration" === "SDS011 Configuration"
```c linenums="51" title="src/hal/generic.h" ```c linenums="51" title="shared/hal/generic.h"
--8<-- "src/hal/generic.h:51:56" --8<-- "shared/hal/generic.h:51:56"
``` ```
=== "Custom Sensors Configuration" === "Custom Sensors Configuration"
```c linenums="57" title="src/hal/generic.h" ```c linenums="57" title="shared/hal/generic.h"
--8<-- "src/hal/generic.h:57:60" --8<-- "shared/hal/generic.h:57:60"
``` ```
=== "Complete `generic.h`" === "Complete `generic.h`"
```c linenums="1" title="src/hal/generic.h" ```c linenums="1" title="shared/hal/generic.h"
--8<-- "src/hal/generic.h" --8<-- "shared/hal/generic.h"
``` ```
Output of user sensor data can be switched by user remote control command `0x14` sent to Port 2. Output of user sensor data can be switched by user remote control command `0x14` sent to Port 2.
@ -51,8 +51,8 @@ Output of sensor and peripheral data is internally switched by a bitmask registe
\*) GPS data can also be combined with paxcounter payload on port 1, `#define GPSPORT 1` in paxcounter.conf to enable \*) GPS data can also be combined with paxcounter payload on port 1, `#define GPSPORT 1` in paxcounter.conf to enable
```c linenums="102" title="src/paxcounter_orig.conf" ```c linenums="102" title="shared/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:102:102" --8<-- "shared/paxcounter_orig.conf:102:102"
``` ```
@ -60,8 +60,8 @@ Output of sensor and peripheral data is internally switched by a bitmask registe
Paxcounter supports a battery friendly power saving mode. In this mode the device enters deep sleep, after all data is polled from all sensors and the dataset is completeley sent through all user configured channels (LORAWAN / SPI / MQTT / SD-Card). Set `#define SLEEPCYCLE` in paxcounter.conf to enable power saving mode and to specify the duration of a sleep cycle. Paxcounter supports a battery friendly power saving mode. In this mode the device enters deep sleep, after all data is polled from all sensors and the dataset is completeley sent through all user configured channels (LORAWAN / SPI / MQTT / SD-Card). Set `#define SLEEPCYCLE` in paxcounter.conf to enable power saving mode and to specify the duration of a sleep cycle.
```c linenums="20" title="src/paxcounter_orig.conf" ```c linenums="20" title="shared/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:20:20" --8<-- "shared/paxcounter_orig.conf:20:20"
``` ```
@ -73,14 +73,14 @@ Paxcounter supports a battery friendly power saving mode. In this mode the devic
Paxcounter can keep a time-of-day synced with external or on board time sources. Set `#define TIME_SYNC_INTERVAL` in `paxcounter.conf` to enable time sync. Paxcounter can keep a time-of-day synced with external or on board time sources. Set `#define TIME_SYNC_INTERVAL` in `paxcounter.conf` to enable time sync.
```c linenums="88" title="src/paxcounter_orig.conf" ```c linenums="88" title="shared/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:88:88" --8<-- "shared/paxcounter_orig.conf:88:88"
``` ```
Supported external time sources are GPS, LORAWAN network time and LORAWAN application timeserver time. Supported on board time sources are the RTC of ESP32 and a DS3231 RTC chip, both are kept sycned as fallback time sources. Time accuracy depends on board's time base which generates the pulse per second. Supported are GPS PPS, SQW output of RTC, and internal ESP32 hardware timer. Time base is selected by #defines in the board's hal file, see example in [`generic.h`](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/src/hal/generic.h). Supported external time sources are GPS, LORAWAN network time and LORAWAN application timeserver time. Supported on board time sources are the RTC of ESP32 and a DS3231 RTC chip, both are kept sycned as fallback time sources. Time accuracy depends on board's time base which generates the pulse per second. Supported are GPS PPS, SQW output of RTC, and internal ESP32 hardware timer. Time base is selected by #defines in the board's hal file, see example in [`generic.h`](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/shared/hal/generic.h).
```c linenums="87" title="src/hal/generic.h" ```c linenums="87" title="shared/hal/generic.h"
--8<-- "src/hal/generic.h:87:96" --8<-- "shared/hal/generic.h:87:96"
``` ```
@ -100,8 +100,8 @@ Paxcounter can be used to sync a wall clock which has a DCF77 or IF482 time tele
This describes how to set up a mobile PaxCounter:<br> Follow all steps so far for preparing the device, selecting the packed payload format. In `paxcounter.conf` set `PAYLOAD_OPENSENSEBOX` to `1`. This describes how to set up a mobile PaxCounter:<br> Follow all steps so far for preparing the device, selecting the packed payload format. In `paxcounter.conf` set `PAYLOAD_OPENSENSEBOX` to `1`.
```c linenums="60" title="src/paxcounter_orig.conf" ```c linenums="60" title="shared/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:60:60" --8<-- "shared/paxcounter_orig.conf:60:60"
``` ```
Register a new sensebox on [https://opensensemap.org/](https://opensensemap.org). In the sensor configuration select "TheThingsNetwork" and set decoding profile to "LoRa serialization". Enter your TTN Application and Device ID. Setup decoding option using: Register a new sensebox on [https://opensensemap.org/](https://opensensemap.org). In the sensor configuration select "TheThingsNetwork" and set decoding profile to "LoRa serialization". Enter your TTN Application and Device ID. Setup decoding option using:
@ -112,7 +112,7 @@ This describes how to set up a mobile PaxCounter:<br> Follow all steps so far fo
## SD-card ## SD-card
Data can be stored on SD-card if the board provides an SD card interface, either with SPI or MMC mode. To enable this feature, specify interface mode and hardware pins in board's hal file (`src/hal/<board.h\>`): Data can be stored on a FAT32 (pre-)formatted SD-card if the board provides an SD card interface, either with SPI or MMC mode. To enable this feature, specify interface mode and hardware pins in board's hal file (`shared/hal/<board.h\>`):
```c ```c
#define HAS_SDCARD 1 // SD-card interface, using SPI mode #define HAS_SDCARD 1 // SD-card interface, using SPI mode
@ -126,10 +126,10 @@ Data can be stored on SD-card if the board provides an SD card interface, either
#define SDCARD_SCLK (14) #define SDCARD_SCLK (14)
``` ```
This is an example of a board with MMC SD-card interface: [https://www.aliexpress.com/item/32915894264.html](https://www.aliexpress.com/item/32915894264.html). For this board use file [`src/hal/ttgov21new.h`](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/src/hal/ttgov21new.h) and add the lines given above. This is an example of a board with MMC SD-card interface: [https://www.aliexpress.com/item/32915894264.html](https://www.aliexpress.com/item/32915894264.html). For this board use file [`shared/hal/ttgov21new.h`](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/shared/hal/ttgov21new.h) and add the lines given above.
Another approach would be this tiny board: [https://www.aliexpress.com/item/32424558182.html](https://www.aliexpress.com/item/32424558182.html) (needs 5V). Another approach would be this tiny board: [https://www.aliexpress.com/item/32424558182.html](https://www.aliexpress.com/item/32424558182.html) (needs 5V).
In this case you choose the correct file for your ESP32-board in the src/hal-directory and add the lines given above. Edit the pin numbers given in the example, according to your wiring. In this case you choose the correct file for your ESP32-board in the shared/hal-directory and add the lines given above. Edit the pin numbers given in the example, according to your wiring.
Data is written on SD-card to a single file. After 3 write operations the data is flushed to the disk to minimize flash write cycles. Thus, up to the last 3 records of data will get lost when the Paxcounter looses power during operation. Data is written on SD-card to a single file. After 3 write operations the data is flushed to the disk to minimize flash write cycles. Thus, up to the last 3 records of data will get lost when the Paxcounter looses power during operation.
@ -147,6 +147,6 @@ If you want to change this, modify `src/sdcard.cpp` and `include/sdcard.h`.
Additionally, it's possible to redirect system console output to a plain text file on SD card. This can be useful for debugging headless devices in the field. In `paxcounter.conf` set `SDLOGGING` to `1`. Additionally, it's possible to redirect system console output to a plain text file on SD card. This can be useful for debugging headless devices in the field. In `paxcounter.conf` set `SDLOGGING` to `1`.
```c linenums="16" title="src/paxcounter_orig.conf" ```c linenums="16" title="shared/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:16:16" --8<-- "shared/paxcounter_orig.conf:16:16"
``` ```

View File

@ -41,15 +41,15 @@ Edit `platformio_orig.ini` (for ESP32 CPU based boards) *or* `platformio_orig_s3
## paxcounter.conf ## paxcounter.conf
Edit `src/paxcounter_orig.conf` and tailor settings in this file according to your needs and use case. Please take care of the duty cycle regulations of the LoRaWAN network you're going to use. Copy or rename to `src/paxcounter.conf`. Edit `shared/paxcounter_orig.conf` and tailor settings in this file according to your needs and use case. Please take care of the duty cycle regulations of the LoRaWAN network you're going to use. Copy or rename to `shared/paxcounter.conf`.
=== "Copy" === "Copy"
``` bash ``` bash
cp src/paxcounter_orig.conf src/paxcounter.conf cp shared/paxcounter_orig.conf shared/paxcounter.conf
``` ```
=== "Rename" === "Rename"
``` bash ``` bash
mv src/paxcounter_orig.conf src/paxcounter.conf mv shared/paxcounter_orig.conf shared/paxcounter.conf
``` ```
@ -58,52 +58,52 @@ Edit `src/paxcounter_orig.conf` and tailor settings in this file according to yo
If your device has a **real time clock** it can be updated by either LoRaWAN network or GPS time, according to settings *TIME_SYNC_INTERVAL* and *TIME_SYNC_LORAWAN* in `paxcounter.conf`. If your device has a **real time clock** it can be updated by either LoRaWAN network or GPS time, according to settings *TIME_SYNC_INTERVAL* and *TIME_SYNC_LORAWAN* in `paxcounter.conf`.
```c linenums="85" title="paxcounter.conf" ```c linenums="85" title="paxcounter.conf"
--8<-- "src/paxcounter_orig.conf:85:85" --8<-- "shared/paxcounter_orig.conf:85:85"
``` ```
## src/lmic_config.h ## shared/lmic_config.h
Edit `src/lmic_config.h` and tailor settings in this file according to your country and device hardware. Please take care of national regulations when selecting the frequency band for LoRaWAN. Edit `shared/lmic_config.h` and tailor settings in this file according to your country and device hardware. Please take care of national regulations when selecting the frequency band for LoRaWAN.
```c linenums="9" title="national regulations in src/lmic_config.h " ```c linenums="9" title="national regulations in shared/lmic_config.h "
--8<-- "src/lmic_config.h:9:18" --8<-- "shared/lmic_config.h:9:18"
``` ```
## src/loraconf.h ## shared/loraconf.h
Create file `src/loraconf.h` using the template [src/loraconf_sample.h](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/src/loraconf_sample.h) and adjust settings to use your personal values. To join the network and activate your paxcounter, you must configure either OTAA or ABP join method. You should use OTAA, whenever possible. To understand the differences of the two methods, [this article](https://www.thethingsnetwork.org/docs/devices/registration.html) may be useful. Create file `shared/loraconf.h` using the template [shared/loraconf_sample.h](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/shared/loraconf_sample.h) and adjust settings to use your personal values. To join the network and activate your paxcounter, you must configure either OTAA or ABP join method. You should use OTAA, whenever possible. To understand the differences of the two methods, [this article](https://www.thethingsnetwork.org/docs/devices/registration.html) may be useful.
=== "Copy" === "Copy"
``` bash ``` bash
cp src/loraconf_sample.h src/loraconf.h cp shared/loraconf_sample.h shared/loraconf.h
``` ```
=== "Rename" === "Rename"
``` bash ``` bash
mv src/loraconf_sample.h src/loraconf.h mv shared/loraconf_sample.h shared/loraconf.h
``` ```
To configure OTAA, leave `#define LORA_ABP` deactivated (commented). To use ABP, activate (uncomment) `#define LORA_ABP` in the file `src/loraconf.h`. To configure OTAA, leave `#define LORA_ABP` deactivated (commented). To use ABP, activate (uncomment) `#define LORA_ABP` in the file `shared/loraconf.h`.
The file `src/loraconf_sample.h` contains more information about the values to provide. The file `shared/loraconf_sample.h` contains more information about the values to provide.
=== "Activate OTAA (Default), Deactivate ABP" === "Activate OTAA (Default), Deactivate ABP"
``` c linenums="18" title="src/loraconf.h" ``` c linenums="18" title="shared/loraconf.h"
--8<-- "src/loraconf_sample.h:18:18" --8<-- "shared/loraconf_sample.h:18:18"
``` ```
=== "Deactivate OTAA, Activate ABP" === "Deactivate OTAA, Activate ABP"
``` c linenums="18" title="src/loraconf.h" ``` c linenums="18" title="shared/loraconf.h"
#define LORA_ABP #define LORA_ABP
``` ```
## src/ota.conf ## shared/ota.conf
Create file `src/ota.conf` using the template [src/ota_sample.conf](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/src/ota_sample.conf) and enter your WIFI network & key. These settings are used for downloading updates via WiFi, either from a remote https server, or locally via WebUI. If you want to use a remote server, you need a <A HREF="https://github.com/paxexpress/docs">PAX.express repository</A>. Enter your PAX.express credentials in ota.conf. If you don't need wireless firmware updates just rename ota.sample.conf to ota.conf. Create file `shared/ota.conf` using the template [shared/ota_sample.conf](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/shared/ota_sample.conf) and enter your WIFI network & key. These settings are used for downloading updates via WiFi, either from a remote https server, or locally via WebUI. If you want to use a remote server, you need a <A HREF="https://github.com/paxexpress/docs">PAX.express repository</A>. Enter your PAX.express credentials in ota.conf. If you don't need wireless firmware updates just rename ota.sample.conf to ota.conf.
=== "Copy" === "Copy"
``` bash ``` bash
cp src/ota_sample.conf src/ota.conf cp shared/ota_sample.conf shared/ota.conf
``` ```
=== "Rename" === "Rename"
``` bash ``` bash
mv src/ota_sample.conf src/ota.conf mv shared/ota_sample.conf shared/ota.conf
``` ```
# Building # Building

View File

@ -24,7 +24,7 @@ LoLin32lite + [LoraNode32-Lite shield](https://github.com/hallard/LoLin32-Lite-L
- TTGO: [T-Wristband](https://www.aliexpress.com/item/4000527495064.html) - TTGO: [T-Wristband](https://www.aliexpress.com/item/4000527495064.html)
- Generic ESP32 - Generic ESP32
*) supports microSD/TF-card for local logging of paxcounter data *) supports microSD/TF-card for local logging of paxcounter data. SD/TF-card must be FAT32 formatted.
Depending on board hardware following features are supported: Depending on board hardware following features are supported:
@ -45,7 +45,7 @@ Depending on board hardware following features are supported:
- SD-card (see section SD-card here) for logging pax data - SD-card (see section SD-card here) for logging pax data
Target platform must be selected in `platformio.ini`.<br> Target platform must be selected in `platformio.ini`.<br>
Hardware dependent settings (pinout etc.) are stored in board files in [/hal](https://github.com/cyberman54/ESP32-Paxcounter/tree/master/src/hal) directory. If you want to use a ESP32 board which is not yet supported, use hal file generic.h and tailor pin mappings to your needs. Pull requests for new boards welcome.<br> Hardware dependent settings (pinout etc.) are stored in board files in [/shared/hal](https://github.com/cyberman54/ESP32-Paxcounter/tree/master/shared/hal) directory. If you want to use a ESP32 board which is not yet supported, use hal file generic.h and tailor pin mappings to your needs. Pull requests for new boards welcome.<br>
### 3D printed cases ### 3D printed cases
Some 3D printable cases can be found (and, if wanted so, ordered) on Thingiverse, see Some 3D printable cases can be found (and, if wanted so, ordered) on Thingiverse, see
@ -73,4 +73,4 @@ By default, bluetooth sniffing is not started. If you enable bluetooth be aware
``` c linenums="29" title="paxcounter.conf" ``` c linenums="29" title="paxcounter.conf"
#define BLECOUNTER 1 #define BLECOUNTER 1
``` ```

View File

@ -1,7 +1,7 @@
# Payload format # Payload format
You can select different payload formats in [`paxcounter.conf`](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/src/paxcounter_orig.conf): You can select different payload formats in [`paxcounter.conf`](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/shared/paxcounter_orig.conf):
- ***Plain*** uses big endian format and generates json fields, e.g. useful for TTN console - ***Plain*** uses big endian format and generates json fields, e.g. useful for TTN console
@ -10,8 +10,8 @@ You can select different payload formats in [`paxcounter.conf`](https://github.c
- [***CayenneLPP***](https://developers.mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload) generates MyDevices Cayenne readable fields - [***CayenneLPP***](https://developers.mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload) generates MyDevices Cayenne readable fields
```c linenums="20" title="src/paxcounter_orig.conf" ```c linenums="20" title="shared/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:20:20" --8<-- "shared/paxcounter_orig.conf:20:20"
``` ```

View File

@ -6,6 +6,7 @@
// Time functions // Time functions
#ifdef HAS_RTC #ifdef HAS_RTC
#include <RtcUtility.h>
#include <RtcDateTime.h> #include <RtcDateTime.h>
#endif #endif
#include <Ticker.h> #include <Ticker.h>

View File

@ -4,7 +4,6 @@
#if (HAS_GPS) #if (HAS_GPS)
#include <TinyGPS++.h> // library for parsing NMEA data #include <TinyGPS++.h> // library for parsing NMEA data
#include <RtcDateTime.h>
#include "timekeeper.h" #include "timekeeper.h"
#ifndef GPS_BAUDRATE #ifndef GPS_BAUDRATE

View File

@ -51,11 +51,11 @@ release_version = 3.6.0
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 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 ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 3 debug_level = 3
extra_scripts = pre:src/build.py extra_scripts = pre:shared/build.py
otakeyfile = ota.conf otakeyfile = ota.conf
lorakeyfile = loraconf.h lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@6.3.1 platform_espressif32 = espressif32@6.3.2
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 115200 ; set by build.py and taken from hal file upload_speed = 115200 ; set by build.py and taken from hal file
lib_deps_lora = lib_deps_lora =
@ -93,7 +93,7 @@ lib_deps_all =
${common.lib_deps_sensors} ${common.lib_deps_sensors}
${common.lib_deps_ledmatrix} ${common.lib_deps_ledmatrix}
build_flags_all = build_flags_all =
-include "src/paxcounter.conf" -include "shared/paxcounter.conf"
'-D CORE_DEBUG_LEVEL=${common.debug_level}' '-D CORE_DEBUG_LEVEL=${common.debug_level}'
'-D LOG_LOCAL_LEVEL=${common.debug_level}' '-D LOG_LOCAL_LEVEL=${common.debug_level}'
'-D PROGVERSION="${common.release_version}"' '-D PROGVERSION="${common.release_version}"'
@ -114,7 +114,7 @@ upload_speed = ${common.upload_speed}
platform = ${common.platform_espressif32} platform = ${common.platform_espressif32}
lib_deps = ${common.lib_deps_all} lib_deps = ${common.lib_deps_all}
build_flags = build_flags =
-include "src/hal/${board.halfile}" -include "shared/hal/${board.halfile}"
${common.build_flags_all} ${common.build_flags_all}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
@ -138,6 +138,6 @@ platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/
[env:ci] [env:ci]
build_flags = build_flags =
-include "src/hal/${sysenv.CI_HALFILE}" ; set by CI -include "shared/hal/${sysenv.CI_HALFILE}" ; set by CI
${common.build_flags_all} ${common.build_flags_all}
upload_protocol = esptool upload_protocol = esptool

View File

@ -14,11 +14,11 @@ release_version = 3.6.0
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 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 ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 3 debug_level = 3
extra_scripts = pre:src/build.py extra_scripts = pre:shared/build.py
otakeyfile = ota.conf otakeyfile = ota.conf
lorakeyfile = loraconf.h lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@6.3.1 platform_espressif32 = espressif32@6.3.2
monitor_speed = 115200 monitor_speed = 115200
upload_speed = 115200 ; set by build.py and taken from hal file upload_speed = 115200 ; set by build.py and taken from hal file
lib_deps_all = lib_deps_all =
@ -32,7 +32,7 @@ lib_deps_all =
256dpi/MQTT @ ^2.5.1 256dpi/MQTT @ ^2.5.1
ricmoo/QRCode @ ^0.0.1 ricmoo/QRCode @ ^0.0.1
build_flags_all = build_flags_all =
-include "src/paxcounter.conf" -include "shared/paxcounter.conf"
'-D CORE_DEBUG_LEVEL=${common.debug_level}' '-D CORE_DEBUG_LEVEL=${common.debug_level}'
'-D LOG_LOCAL_LEVEL=${common.debug_level}' '-D LOG_LOCAL_LEVEL=${common.debug_level}'
'-D PROGVERSION="${common.release_version}"' '-D PROGVERSION="${common.release_version}"'
@ -53,7 +53,7 @@ upload_speed = ${common.upload_speed}
platform = ${common.platform_espressif32} platform = ${common.platform_espressif32}
lib_deps = ${common.lib_deps_all} lib_deps = ${common.lib_deps_all}
build_flags = build_flags =
-include "src/hal/${board.halfile}" -include "shared/hal/${board.halfile}"
${common.build_flags_all} ${common.build_flags_all}
extra_scripts = ${common.extra_scripts} extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
@ -64,6 +64,6 @@ upload_protocol = esptool
[env:ci] [env:ci]
build_flags = build_flags =
-include "src/hal/${sysenv.CI_HALFILE}" ; set by CI -include "shared/hal/${sysenv.CI_HALFILE}" ; set by CI
${common.build_flags_all} ${common.build_flags_all}
upload_protocol = esptool upload_protocol = esptool

View File

@ -19,11 +19,14 @@ env = DefaultEnvironment()
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read("platformio.ini") config.read("platformio.ini")
# get platformio source path # get platformio project directory
srcdir = env.get("PROJECT_SRC_DIR") prjdir = env.get("PROJECT_DIR")
# get platformio shared path
shareddir = os.path.join (prjdir, "shared")
# get hal path # get hal path
haldir = os.path.join (srcdir, "hal") haldir = os.path.join (shareddir, "hal")
# check if hal file is present in source directory # check if hal file is present in source directory
halconfig = config.get("board", "halfile") halconfig = config.get("board", "halfile")
@ -42,23 +45,23 @@ if os.path.isfile(halconfigfile) and os.access(halconfigfile, os.R_OK):
else: else:
sys.exit("Missing file " + halconfigfile + ", please create it! Aborting.") sys.exit("Missing file " + halconfigfile + ", please create it! Aborting.")
# check if lmic config file is present in source directory # check if lmic config file is present in shared directory
lmicconfig = config.get("common", "lmicconfigfile") lmicconfig = config.get("common", "lmicconfigfile")
lmicconfigfile = os.path.join (srcdir, lmicconfig) lmicconfigfile = os.path.join (shareddir, lmicconfig)
if os.path.isfile(lmicconfigfile) and os.access(lmicconfigfile, os.R_OK): if os.path.isfile(lmicconfigfile) and os.access(lmicconfigfile, os.R_OK):
print("Parsing LMIC configuration from " + lmicconfigfile) print("Parsing LMIC configuration from " + lmicconfigfile)
else: else:
sys.exit("Missing file " + lmicconfigfile + ", please create it! Aborting.") sys.exit("Missing file " + lmicconfigfile + ", please create it! Aborting.")
# check if lora key file is present in source directory # check if lora key file is present in shared directory
lorakeyfile = os.path.join (srcdir, config.get("common", "lorakeyfile")) lorakeyfile = os.path.join (shareddir, config.get("common", "lorakeyfile"))
if os.path.isfile(lorakeyfile) and os.access(lorakeyfile, os.R_OK): if os.path.isfile(lorakeyfile) and os.access(lorakeyfile, os.R_OK):
print("Parsing LORAWAN keys from " + lorakeyfile) print("Parsing LORAWAN keys from " + lorakeyfile)
else: else:
sys.exit("Missing file " + lorakeyfile + ", please create it! Aborting.") sys.exit("Missing file " + lorakeyfile + ", please create it! Aborting.")
# check if ota key file is present in source directory # check if ota key file is present in shared directory
otakeyfile = os.path.join (srcdir, config.get("common", "otakeyfile")) otakeyfile = os.path.join (shareddir, config.get("common", "otakeyfile"))
if os.path.isfile(otakeyfile) and os.access(otakeyfile, os.R_OK): if os.path.isfile(otakeyfile) and os.access(otakeyfile, os.R_OK):
print("Parsing OTA keys from " + otakeyfile) print("Parsing OTA keys from " + otakeyfile)
else: else:
@ -113,7 +116,7 @@ env.Append(BUILD_FLAGS=[
u'-DPAXEXPRESS_REPO=\\"' + mykeys["PAXEXPRESS_REPO"] + '\\"', u'-DPAXEXPRESS_REPO=\\"' + mykeys["PAXEXPRESS_REPO"] + '\\"',
u'-DPAXEXPRESS_PACKAGE=\\"' + package + '\\"', u'-DPAXEXPRESS_PACKAGE=\\"' + package + '\\"',
u'-DARDUINO_LMIC_PROJECT_CONFIG_H=' + lmicconfig, u'-DARDUINO_LMIC_PROJECT_CONFIG_H=' + lmicconfig,
u'-I \"' + srcdir + '\"' u'-I \"' + shareddir + '\"'
]) ])
# function for pushing new firmware to paxexpress storage using API # function for pushing new firmware to paxexpress storage using API

View File

@ -1,34 +1,34 @@
// clang-format off // clang-format off
// upload_speed 921600 // upload_speed 921600
// board esp32dev // board esp32dev
#ifndef _FIPY_H #ifndef _FIPY_H
#define _FIPY_H #define _FIPY_H
#include <stdint.h> #include <stdint.h>
// Hardware related definitions for Pycom FiPy Board // Hardware related definitions for Pycom FiPy Board
#define HAS_LORA 1 // comment out if device shall not send data via LoRa #define HAS_LORA 1 // comment out if device shall not send data via LoRa
#define CFG_sx1272_radio 1 #define CFG_sx1272_radio 1
#define HAS_LED NOT_A_PIN // FiPy has no on board LED, so we use RGB LED #define HAS_LED NOT_A_PIN // FiPy has no on board LED, so we use RGB LED
#define RGB_LED_COUNT 1 // we have 1 LED #define RGB_LED_COUNT 1 // we have 1 LED
#define HAS_RGB_LED FastLED.addLeds<WS2812, GPIO_NUM_0, GRB>(leds, RGB_LED_COUNT); #define HAS_RGB_LED FastLED.addLeds<WS2812, GPIO_NUM_0, GRB>(leds, RGB_LED_COUNT);
#define BOARD_HAS_PSRAM // use extra 4MB extern RAM #define BOARD_HAS_PSRAM // use extra 4MB extern RAM
// Pins for LORA chip SPI interface, reset line and interrupt lines // Pins for LORA chip SPI interface, reset line and interrupt lines
#define LORA_SCK (5) #define LORA_SCK (5)
#define LORA_CS (18) #define LORA_CS (18)
#define LORA_MISO (19) #define LORA_MISO (19)
#define LORA_MOSI (27) #define LORA_MOSI (27)
#define LORA_RST LMIC_UNUSED_PIN #define LORA_RST LMIC_UNUSED_PIN
#define LORA_IRQ (23) // LoRa IRQ #define LORA_IRQ (23) // LoRa IRQ
#define LORA_IO1 (23) // Pin tied via diode to DIO0 #define LORA_IO1 (23) // Pin tied via diode to DIO0
#define LORA_IO2 LMIC_UNUSED_PIN #define LORA_IO2 LMIC_UNUSED_PIN
// select WIFI antenna (internal = onboard / external = u.fl socket) // select WIFI antenna (internal = onboard / external = u.fl socket)
#define HAS_ANTENNA_SWITCH GPIO_NUM_21 // pin for switching wifi antenna #define HAS_ANTENNA_SWITCH GPIO_NUM_21 // pin for switching wifi antenna
#define WIFI_ANTENNA 0 // 0 = internal, 1 = external #define WIFI_ANTENNA 0 // 0 = internal, 1 = external
#endif #endif

View File

@ -7,7 +7,7 @@
* LMIC LoRaWAN configuration * LMIC LoRaWAN configuration
* *
* Read the values from TTN console (or whatever applies), insert them here, * Read the values from TTN console (or whatever applies), insert them here,
* and rename this file to src/loraconf.h * and rename this file to shared/loraconf.h
* *
* You can configure OTAA or ABP Activation. In order to use ABP, uncomment * You can configure OTAA or ABP Activation. In order to use ABP, uncomment
* (enable) the following line, but you should only do so, if you have good * (enable) the following line, but you should only do so, if you have good

View File

@ -266,7 +266,7 @@ esp_err_t lmic_init(void) {
// This tells LMIC to make the receive windows bigger, in case your clock is // This tells LMIC to make the receive windows bigger, in case your clock is
// faster or slower. This causes the transceiver to be earlier switched on, // faster or slower. This causes the transceiver to be earlier switched on,
// so consuming more power. You may sharpen (reduce) CLOCK_ERROR_PERCENTAGE // so consuming more power. You may sharpen (reduce) CLOCK_ERROR_PERCENTAGE
// in src/lmic_config.h if you are limited on battery. // in shared/lmic_config.h if you are limited on battery.
#ifdef CLOCK_ERROR_PROCENTAGE #ifdef CLOCK_ERROR_PROCENTAGE
LMIC_setClockError(CLOCK_ERROR_PROCENTAGE * MAX_CLOCK_ERROR / 1000); LMIC_setClockError(CLOCK_ERROR_PROCENTAGE * MAX_CLOCK_ERROR / 1000);
#endif #endif