move all user configurable files to shared dir

This commit is contained in:
cyberman54 2023-07-01 19:11:35 +02:00
parent 2deaec1aed
commit b09934e76e
14 changed files with 77 additions and 75 deletions

View File

@ -92,9 +92,9 @@ jobs:
- name: Copy of necessary files
run: |
cp platformio_orig.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h
cp src/ota_sample.conf src/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf
cp shared/loraconf_sample.h shared/loraconf.h
cp shared/ota_sample.conf shared/ota.conf
cp shared/paxcounter_orig.conf shared/paxcounter.conf
- name: Clean
run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }}
@ -143,9 +143,9 @@ jobs:
- name: Copy of necessary files
run: |
cp platformio_orig.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h
cp src/ota_sample.conf src/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf
cp shared/loraconf_sample.h shared/loraconf.h
cp shared/ota_sample.conf shared/ota.conf
cp shared/paxcounter_orig.conf shared/paxcounter.conf
- name: Clean
run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }}
@ -197,9 +197,9 @@ jobs:
- name: Copy of necessary files
run: |
cp platformio_orig_s3.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h
cp src/ota_sample.conf src/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf
cp shared/loraconf_sample.h shared/loraconf.h
cp shared/ota_sample.conf shared/ota.conf
cp shared/paxcounter_orig.conf shared/paxcounter.conf
- name: Clean
run: pio run -t clean -e ci
- name: Run PlatformIO CI for ${{ matrix.board }}
@ -235,18 +235,18 @@ jobs:
- name: Prepare config files for test
run: |
cp platformio_orig.ini platformio.ini
cp src/loraconf_sample.h src/loraconf.h
cp src/ota_sample.conf src/ota.conf
cp src/paxcounter_orig.conf src/paxcounter.conf
cp shared/loraconf_sample.h shared/loraconf.h
cp shared/ota_sample.conf shared/ota.conf
cp shared/paxcounter_orig.conf shared/paxcounter.conf
# 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/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/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 }}/" "shared/loraconf.h"
# 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_PASS/c OTA_WIFI_PASS = ${{ secrets.OTA_WIFI_PASS }}" "src/ota.conf"
sed -i "/PAXEXPRESS_USER/c PAXEXPRESS_USER = ${{ secrets.PAXEXPRESS_USER }}" "src/ota.conf"
sed -i "/PAXEXPRESS_REPO/c PAXEXPRESS_REPO = ${{ secrets.PAXEXPRESS_REPO }}" "src/ota.conf"
sed -i "/PAXEXPRESS_API_TOKEN/c PAXEXPRESS_API_TOKEN = ${{ secrets.PAXEXPRESS_API_TOKEN }}" "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 }}" "shared/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 }}" "shared/ota.conf"
sed -i "/PAXEXPRESS_API_TOKEN/c PAXEXPRESS_API_TOKEN = ${{ secrets.PAXEXPRESS_API_TOKEN }}" "shared/ota.conf"
- name: Build and deploy for testboard
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }}

6
.gitignore vendored
View File

@ -10,7 +10,7 @@
.vscode/.browse.c_cpp.db*
.clang_complete
.gcc-flags.json
src/loraconf.h
src/ota.conf
shared/loraconf.h
shared/ota.conf
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.
=== "Activate Sensor 1"
```c linenums="132" title="src/paxcounter_orig.conf"
```c linenums="132" title="shared/paxcounter_orig.conf"
#define HAS_SENSOR_1 1
```
=== "Activate Sensor 2"
```c linenums="132" title="src/paxcounter_orig.conf"
```c linenums="132" title="shared/paxcounter_orig.conf"
#define HAS_SENSOR_2 1
```
=== "Activate Sensor 3"
```c linenums="132" title="src/paxcounter_orig.conf"
```c linenums="132" title="shared/paxcounter_orig.conf"
#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.
```c linenums="133" title="src/paxcounter_orig.conf"
```c linenums="133" title="shared/paxcounter_orig.conf"
#define HAS_GY21 1 // (1)
```

View File

@ -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
```c linenums="102" title="src/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:102:102"
```c linenums="102" title="shared/paxcounter_orig.conf"
--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.
```c linenums="20" title="src/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:20:20"
```c linenums="20" title="shared/paxcounter_orig.conf"
--8<-- "shared/paxcounter_orig.conf:20:20"
```
@ -73,8 +73,8 @@ 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.
```c linenums="88" title="src/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:88:88"
```c linenums="88" title="shared/paxcounter_orig.conf"
--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/shared/hal/generic.h).
@ -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`.
```c linenums="60" title="src/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:60:60"
```c linenums="60" title="shared/paxcounter_orig.conf"
--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:
@ -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`.
```c linenums="16" title="src/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:16:16"
```c linenums="16" title="shared/paxcounter_orig.conf"
--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
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"
``` bash
cp src/paxcounter_orig.conf src/paxcounter.conf
cp shared/paxcounter_orig.conf shared/paxcounter.conf
```
=== "Rename"
``` 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`.
```c linenums="85" title="paxcounter.conf"
--8<-- "src/paxcounter_orig.conf:85:85"
--8<-- "shared/paxcounter_orig.conf:85:85"
```
## src/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.
## shared/lmic_config.h
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 "
--8<-- "src/lmic_config.h:9:18"
```c linenums="9" title="national regulations in shared/lmic_config.h "
--8<-- "shared/lmic_config.h:9:18"
```
## src/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.
## shared/loraconf.h
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"
``` bash
cp src/loraconf_sample.h src/loraconf.h
cp shared/loraconf_sample.h shared/loraconf.h
```
=== "Rename"
``` 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`.
The file `src/loraconf_sample.h` contains more information about the values to provide.
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 `shared/loraconf_sample.h` contains more information about the values to provide.
=== "Activate OTAA (Default), Deactivate ABP"
``` c linenums="18" title="src/loraconf.h"
--8<-- "src/loraconf_sample.h:18:18"
``` c linenums="18" title="shared/loraconf.h"
--8<-- "shared/loraconf_sample.h:18:18"
```
=== "Deactivate OTAA, Activate ABP"
``` c linenums="18" title="src/loraconf.h"
``` c linenums="18" title="shared/loraconf.h"
#define LORA_ABP
```
## src/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.
## shared/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"
``` bash
cp src/ota_sample.conf src/ota.conf
cp shared/ota_sample.conf shared/ota.conf
```
=== "Rename"
``` bash
mv src/ota_sample.conf src/ota.conf
mv shared/ota_sample.conf shared/ota.conf
```
# Building

View File

@ -1,7 +1,7 @@
# 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
@ -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
```c linenums="20" title="src/paxcounter_orig.conf"
--8<-- "src/paxcounter_orig.conf:20:20"
```c linenums="20" title="shared/paxcounter_orig.conf"
--8<-- "shared/paxcounter_orig.conf:20:20"
```

View File

@ -93,7 +93,7 @@ lib_deps_all =
${common.lib_deps_sensors}
${common.lib_deps_ledmatrix}
build_flags_all =
-include "src/paxcounter.conf"
-include "shared/paxcounter.conf"
'-D CORE_DEBUG_LEVEL=${common.debug_level}'
'-D LOG_LOCAL_LEVEL=${common.debug_level}'
'-D PROGVERSION="${common.release_version}"'

View File

@ -32,7 +32,7 @@ lib_deps_all =
256dpi/MQTT @ ^2.5.1
ricmoo/QRCode @ ^0.0.1
build_flags_all =
-include "src/paxcounter.conf"
-include "shared/paxcounter.conf"
'-D CORE_DEBUG_LEVEL=${common.debug_level}'
'-D LOG_LOCAL_LEVEL=${common.debug_level}'
'-D PROGVERSION="${common.release_version}"'

View File

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

View File

@ -7,7 +7,7 @@
* LMIC LoRaWAN configuration
*
* 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
* (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
// faster or slower. This causes the transceiver to be earlier switched on,
// 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
LMIC_setClockError(CLOCK_ERROR_PROCENTAGE * MAX_CLOCK_ERROR / 1000);
#endif