diff --git a/README.md b/README.md index 12e7d59b..c5684f42 100644 --- a/README.md +++ b/README.md @@ -82,25 +82,28 @@ By default bluetooth sniffing is disabled (#define *BLECOUNTER* 0 in paxcounter. # Preparing -Before compiling the code, +Compile time configuration is spread across several files. Before compiling the code, edit or create the following files: -- **edit platformio.ini** and select desired hardware target in section boards. To add a new board, create an appropriate hardware abstraction layer file in hal subdirectory, and add a pointer to this file in sections boards. +## platformio.ini +Edit `platformio.ini` and select desired hardware target in section boards. To add a new board, create an appropriate hardware abstraction layer file in hal subdirectory, and add a pointer to this file in sections boards. -- **edit src/paxcounter.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. +## src/paxcounter.conf +Edit `src/paxcounter.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. -- **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. +If your device has a **real time clock** it can be updated bei either LoRaWAN network or GPS time, according to settings *TIME_SYNC_INTERVAL* and *TIME_SYNC_LORAWAN* in `paxcounter.conf`. -- **create file loraconf.h in your local /src directory** using the template [loraconf.sample.h](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/src/loraconf.sample.h) and populate it with your personal APPEUI und APPKEY for the LoRaWAN network. If you're using popular TheThingsNetwork you can copy&paste the keys from TTN console or output of ttnctl. +## 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. -- **create file ota.conf in your local /src directory** using the template [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. If you want to push own OTA updates you need a Bintray account. Enter your Bintray user account data in ota.conf. If you don't need wireless firmware updates just rename ota.sample.conf to ota.conf. +## 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 modify it, to use your personal values. +To join the network and activate your paxcounter, you have to configure either the preferred OTAA method or the ABP 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. -To join the network you have to configure either the preferred OTAA method or the ABP method. The DEVEUI for OTAA will be derived from the device's MAC adress during device startup and is shown on the device's display (if it has one). It is also printed on the serial console for copying it, if you set *verbose 1* in paxcounter.conf and *debug_level 3* in platformio.ini. +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.h.sample` contains more information about the values to provide. -If your device has a fixed DEVEUI enter this in your local loraconf.h file. During compile time this DEVEUI will be grabbed from loraconf.h and inserted in the code. - -If your device has silicon **Unique ID** which is stored in serial EEPROM Microchip 24AA02E64 you don't need to change anything. The Unique ID will be read during startup and DEVEUI will be generated from it, overriding settings in loraconf.h. - -If your device has a **real time clock** it can be updated bei either LoRaWAN network or GPS time, according to settings *TIME_SYNC_INTERVAL* and *TIME_SYNC_LORAWAN* in paxcounter.conf. +## 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. If you want to push own OTA updates you need a Bintray account. Enter your Bintray user account data in ota.conf. If you don't need wireless firmware updates just rename ota.sample.conf to ota.conf. # Building diff --git a/src/loraconf.sample.h b/src/loraconf.sample.h index bfd513ad..826a39f9 100644 --- a/src/loraconf.sample.h +++ b/src/loraconf.sample.h @@ -9,34 +9,32 @@ * Read the values from TTN console (or whatever applies), insert them here, * and rename this file to src/loraconf.h * - * You can configure you PaxCounter to activate via OTAA (recommended) or ABP. - * In order to use ABP, uncomment (enable) the following line, - * otherwise, leave the line commented (disabled). - * + * 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 + * reasons for not using OTAA. + * *************************************************************/ //#define LORA_ABP +#ifndef LORA_ABP /************************************************************ * OTAA configuration - * - * Note that DEVEUI, APPEUI and APPKEY should all be specified in MSB format. - * (This is different from standard LMIC-Arduino which expects DEVEUI and APPEUI - * in LSB format.) + * + * DEVEUI, APPEUI and APPKEY should all be specified in MSB format as + * displayed in TTN console, so you can cut & paste from there. This is different + * from standard LMIC-Arduino which expects DEVEUI and APPEUI in LSB format. + * For TTN, APPEUI in MSB format always starts with 0x70, 0xB3, 0xD5. - * Set your DEVEUI here, if you have one. You can leave this untouched, - * then the DEVEUI will be generated during runtime from device's MAC adress - * and will be displayed on device's screen as well as on serial console. - * - * NOTE: Use MSB format (as displayed in TTN console, so you can cut & paste - * from there) - * For TTN, APPEUI in MSB format always starts with 0x70, 0xB3, 0xD5 - * - * Note: If using a board with Microchip 24AA02E64 Uinique ID for deveui, - * the DEVEUI will be overwriten by the one contained in the Microchip module + * Set your DEVEUI here, if your device has have a fixed one. + * If you leave this untouched, then the DEVEUI will be derived from device's + * MAC adress during startup and will be displayed on device's screen as well as + * on serial console, if you set 'verbose 1' in paxcounter.conf and + * 'debug_level 3' in platformio.ini. + * If using a board with Microchip 24AA02E64 Uinique ID for deveui, the DEVEUI + * will be overwritten by the one contained in the Microchip module. * ************************************************************/ -#ifndef LORA_ABP static const u1_t DEVEUI[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -47,6 +45,7 @@ static const u1_t APPKEY[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, #endif +#ifdef LORA_ABP /************************************************************ * ABP configuration (for development) * @@ -54,13 +53,16 @@ static const u1_t APPKEY[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, * - Network Session Key (NWKSKEY) * - App Session Key and your (APPSKEY) * - Device Address (DEVADDR) - * from TTN console and replace the example values below. - * + * from e.g. TTN console and replace the example values below. + * * NOTE: Use MSB format (as displayed in TTN console, so you can cut & paste * from there) * + * NOTE: You may also need to adjust lorawan_abp.cpp in order to configure + * different channels and data rate channels to match your country's regulations + * and your network's settings. + * ************************************************************/ -#ifdef LORA_ABP // ID of LoRaAlliance assigned Network (for a list, see e.g. here // https://www.thethingsnetwork.org/docs/lorawan/prefix-assignments.html)