v1.2.0 release

This commit is contained in:
Kyle Gabriel 2020-08-20 16:39:13 -04:00
parent 5b67743915
commit 08a9fe4ce0
8 changed files with 48 additions and 94 deletions

32
.vscode/launch.json vendored
View File

@ -1,32 +0,0 @@
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
// PIO Unified Debugger
//
// Documentation: https://docs.platformio.org/page/plus/debugging.html
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
{
"version": "0.2.0",
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "/home/kevinh/development/lora/ttgo-tbeam-ttn-tracker/.pio/build/esp32/firmware.elf",
"toolchainBinDir": "/home/kevinh/.platformio/packages/toolchain-xtensa32/bin",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
},
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "/home/kevinh/development/lora/ttgo-tbeam-ttn-tracker/.pio/build/esp32/firmware.elf",
"toolchainBinDir": "/home/kevinh/.platformio/packages/toolchain-xtensa32/bin",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

View File

@ -1,6 +1,6 @@
## TTGO T-Beam Tracker for The Things Network
Current version: 1.1.1
Current version: 1.2.0
Uploads GPS data from the TTGO T-Beam to [The Things Network](https://www.thethingsnetwork.org) (TTN) and [TTN Mapper](https://ttnmapper.org) for tracking and determining signal strength of LoRaWAN gateways and nodes.
@ -22,7 +22,7 @@ NOTE: There are now 2 versions of the TTGO T-BEAM, the first version (Rev0) and
* [ThingPulse/esp8266-oled-ssd1306](https://github.com/ThingPulse/esp8266-oled-ssd1306) (for Rev0 and Rev1)
* [lewisxhe/AXP202X_Library](https://github.com/lewisxhe/AXP202X_Library) (for Rev1 only)
3. Copy the contents of the project file ```main/lmic_project_config.h``` to the library file ```arduino-lmic/project_config/lmic_project_config.h``` and uncomment the proper frequency for your region.
3. Edit ```arduino-lmic/project_config/lmic_project_config.h``` and uncomment the proper frequency for your region.
4. Edit this project file ```main/configuration.h``` and select your correct board revision, either T_BEAM_V07 or T_BEAM_V10 (see [T-BEAM Board Versions](#t-beam-board-versions) to determine which board revision you have).

View File

@ -33,7 +33,7 @@ void ttn_register(void (*callback)(uint8_t message));
// -----------------------------------------------------------------------------
#define APP_NAME "TTN MAP-TRACK"
#define APP_VERSION "1.1.1"
#define APP_VERSION "1.2.0"
// -----------------------------------------------------------------------------
// Configuration
@ -56,8 +56,8 @@ void ttn_register(void (*callback)(uint8_t message));
#define DEBUG_PORT Serial // Serial debug port
#define SERIAL_BAUD 115200 // Serial debug baud rate
#define SLEEP_BETWEEN_MESSAGES true // Do sleep between messages
#define SEND_INTERVAL (5 * 60 * 1000) // Sleep for these many millis
#define SLEEP_BETWEEN_MESSAGES false // Do sleep between messages
#define SEND_INTERVAL (20 * 1000) // Sleep for these many millis
#define MESSAGE_TO_SLEEP_DELAY 5000 // Time after message before going to sleep
#define LOGO_DELAY 5000 // Time to show logo on first boot
#define LORAWAN_PORT 10 // Port the messages will be sent to

View File

@ -7,41 +7,39 @@ Credentials file
#pragma once
// Only one of these settings must be defined
//#define USE_ABP
#define USE_OTAA
#define USE_ABP
//#define USE_OTAA
#ifdef USE_ABP
// LoRaWAN NwkSKey, network session key
static const u1_t PROGMEM NWKSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const u1_t PROGMEM NWKSKEY[16] = { 0x59, 0xA5, 0xCC, 0xD8, 0xD0, 0x43, 0x20, 0x56, 0xCE, 0xB6, 0x93, 0x3C, 0x97, 0xFF, 0x21, 0xE1 };
// LoRaWAN AppSKey, application session key
static const u1_t PROGMEM APPSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const u1_t PROGMEM APPSKEY[16] = { 0x83, 0xF1, 0x0F, 0xE6, 0xFE, 0xB9, 0xBE, 0x37, 0xA2, 0x47, 0x96, 0xAA, 0xB4, 0x8D, 0xF6, 0x61 };
// LoRaWAN end-device address (DevAddr)
// This has to be unique for every node
static const u4_t DEVADDR = 0x00000000;
static const u4_t DEVADDR = 0x26021BCB;
#endif
#ifdef USE_OTAA
#if 0
// copy these variables to ../credentials-private.h and customize with your secret appkey.
// This EUI must be in little-endian format, so least-significant-byte
// first. When copying an EUI from ttnctl output, this means to reverse
// the bytes. For TTN issued EUIs the last bytes should be 0x00, 0x00,
// 0x00.
static const u1_t PROGMEM APPEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const u1_t PROGMEM APPEUI[8] = { 0x20, 0x77, 0x01, 0xD0, 0x7E, 0xD5, 0xB3, 0x70 };
// This should also be in little endian format, see above.
// Note: You do not need to set this field, if unset it will be generated automatically based on the device macaddr
static u1_t DEVEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static u1_t DEVEUI[8] = { 0xB7, 0x0F, 0x8E, 0x33, 0xF9, 0x37, 0x9E, 0x00 };
// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from ttnctl can be copied as-is.
// The key shown here is the semtech default key.
static const u1_t PROGMEM APPKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
#endif
static const u1_t PROGMEM APPKEY[16] = { 0xC4, 0xAB, 0xDA, 0xB6, 0xDC, 0xD6, 0xEC, 0x56, 0xDD, 0xAC, 0x90, 0x67, 0xCE, 0x17, 0x0D, 0x8A };
#endif

View File

@ -1,13 +0,0 @@
// This sketch supports EU868 and US915
// The Arduino-LMIC library by MCCI Catena is set to US915,
// these settings have to be copied over the ones in the
// lmic_project_config.h file in the library,
// inside the project_config folder.
// Make sure only one of the following is defined (CFG_us915 or CFG_eu868)
#define CFG_us915 1
//#define CFG_eu868 1
// DO NOT modify this
#define CFG_sx1276_radio 1

View File

@ -128,7 +128,7 @@ void sleep() {
#if SLEEP_BETWEEN_MESSAGES
// If the user has a screen, tell them we are about to sleep
if(ssd1306_found) {
if (ssd1306_found) {
// Show the going to sleep message on the screen
char buffer[20];
snprintf(buffer, sizeof(buffer), "Sleeping in %3.1fs\n", (MESSAGE_TO_SLEEP_DELAY / 1000.0));
@ -153,8 +153,6 @@ void sleep() {
}
void callback(uint8_t message) {
if (EV_JOINING == message) screen_print("Joining TTN...\n");
if (EV_JOINED == message) {
@ -193,7 +191,6 @@ void callback(uint8_t message) {
}
void scanI2Cdevice(void)
{
byte err, addr;
@ -241,6 +238,7 @@ void scanI2Cdevice(void)
LDO2 200mA -> LORA
LDO3 200mA -> GPS
*/
void axp192Init() {
if (axp192_found) {
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
@ -304,11 +302,12 @@ void initDeepSleep() {
Serial.printf("booted, wake cause %d (boot count %d)\n", wakeCause, bootCount);
}
void setup() {
// Debug
#ifdef DEBUG_PORT
#ifdef DEBUG_PORT
DEBUG_PORT.begin(SERIAL_BAUD);
#endif
#endif
initDeepSleep();
@ -319,6 +318,7 @@ void setup() {
// Buttons & LED
pinMode(BUTTON_PIN, INPUT_PULLUP);
#ifdef LED_PIN
pinMode(LED_PIN, OUTPUT);
#endif
@ -327,11 +327,10 @@ void setup() {
DEBUG_MSG(APP_NAME " " APP_VERSION "\n");
// Don't init display if we don't have one or we are waking headless due to a timer event
if(wakeCause == ESP_SLEEP_WAKEUP_TIMER)
if (wakeCause == ESP_SLEEP_WAKEUP_TIMER)
ssd1306_found = false; // forget we even have the hardware
if(ssd1306_found)
screen_setup();
if (ssd1306_found) screen_setup();
// Init GPS
gps_setup();
@ -348,7 +347,7 @@ void setup() {
if (!ttn_setup()) {
screen_print("[ERR] Radio module not found!\n");
if(REQUIRE_RADIO) {
if (REQUIRE_RADIO) {
delay(MESSAGE_TO_SLEEP_DELAY);
screen_off();
sleep_forever();
@ -366,7 +365,7 @@ void loop() {
ttn_loop();
screen_loop();
if(packetSent) {
if (packetSent) {
packetSent = false;
sleep();
}
@ -374,13 +373,13 @@ void loop() {
// if user presses button for more than 3 secs, discard our network prefs and reboot (FIXME, use a debounce lib instead of this boilerplate)
static bool wasPressed = false;
static uint32_t minPressMs; // what tick should we call this press long enough
if(!digitalRead(BUTTON_PIN)) {
if(!wasPressed) { // just started a new press
if (!digitalRead(BUTTON_PIN)) {
if (!wasPressed) { // just started a new press
Serial.println("pressing");
wasPressed = true;
minPressMs = millis() + 3000;
}
} else if(wasPressed) {
} else if (wasPressed) {
// we just did a release
wasPressed = false;
if(millis() > minPressMs) {
@ -405,6 +404,7 @@ void loop() {
screen_print("Waiting GPS lock\n");
first = false;
}
#ifdef GPS_WAIT_FOR_LOCK
if (millis() > GPS_WAIT_FOR_LOCK) {
sleep();

View File

@ -73,7 +73,7 @@ void screen_off() {
}
void screen_on() {
if(!display) return;
if (!display) return;
display->displayOn();
}
@ -110,8 +110,7 @@ void screen_print(const char * text) {
}
void screen_update() {
if(display)
display->display();
if (display) display->display();
}
void screen_setup() {
@ -126,7 +125,7 @@ void screen_setup() {
}
void screen_loop() {
if(!display) return;
if (!display) return;
#ifdef T_BEAM_V10
if (axp192_found && pmu_irq) {

View File

@ -31,9 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "configuration.h"
#include "credentials.h"
// This file should not be in any publig git repos, it contains your secret APPKEY
#include "../credentials-private.h"
// -----------------------------------------------------------------------------
// Globals
// -----------------------------------------------------------------------------
@ -119,6 +116,7 @@ static void printHex2(unsigned v) {
Serial.print(v, HEX);
}
#ifdef USE_OTAA
// generate DevEUI from macaddr if needed
void initDevEUI() {
bool needInit = true;
@ -136,6 +134,7 @@ void initDevEUI() {
}
Serial.println();
}
#endif
// LMIC library will call this method when an event is fired
void onEvent(ev_t event) {
@ -240,7 +239,10 @@ static void initCount() {
bool ttn_setup() {
initCount();
#if defined(USE_OTAA)
initDevEUI();
#endif
// SPI interface
SPI.begin(SCK_GPIO, MISO_GPIO, MOSI_GPIO, NSS_GPIO);