From 4b27aad02605bac949a104976e55f9961650008d Mon Sep 17 00:00:00 2001 From: sessionm21 Date: Sat, 16 May 2020 02:27:51 +0100 Subject: [PATCH] lmic debugging --- .gitmodules | 2 +- Makefile | 9 ++++++++- collar.cpp | 37 +++++++++++++++++++++++++++---------- fenceless_lmic_config.h | 6 ++++++ 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/.gitmodules b/.gitmodules index 045915f..296f541 100644 --- a/.gitmodules +++ b/.gitmodules @@ -21,4 +21,4 @@ url = https://github.com/adafruit/TinyLoRa [submodule "libraries/arduino-lmic"] path = libraries/arduino-lmic - url = https://github.com/mcci-catena/arduino-lmic.git + url = ssh://sessionm@access.engr.oregonstate.edu:/nfs/stak/users/sessionm/git/arduino-lmic.git diff --git a/Makefile b/Makefile index e6fa039..5583865 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,11 @@ CFLAGS?=-Datmega328p\ -flto\ -fno-fat-lto-objects\ -fuse-linker-plugin\ - -Wall + -Wall\ + # -finline-functions\ + # -fipa-sra\ + + CXXFLAGS?=-Datmega328p\ -std=c++11\ @@ -45,6 +49,9 @@ CXXFLAGS?=-Datmega328p\ -fno-fat-lto-objects\ -fuse-linker-plugin\ -Wall\ + # -finline-functions\ + # -fipa-sra\ + INC_DIRS?=-I./\ -I./$(ARDUINO_DIR)/libraries/SPI/src\ diff --git a/collar.cpp b/collar.cpp index 1012e83..362a7d1 100644 --- a/collar.cpp +++ b/collar.cpp @@ -10,6 +10,11 @@ static const PROGMEM u1_t NWKSKEY[16] = { 0x52, 0x92, 0xC0, 0x72, 0x2D, 0x3C, 0x // LoRaWAN AppSKey, application session key static const u1_t PROGMEM APPSKEY[16] = { 0xC4, 0x30, 0xEF, 0x56, 0x4F, 0x6D, 0xA2, 0x56, 0x1F, 0x15, 0x2F, 0xB8, 0x62, 0xC7, 0xCA, 0xC2 }; +// Chirpstack keys +// static const u1_t PROGMEM NWKSKEY[16] = {0x5b,0xe6,0x8b,0xb7,0xaa,0x4f,0x01,0x85,0x54,0x72,0xd9,0x6f,0xd8,0xba,0xbc,0x99}; +// static const u1_t PROGMEM APPSKEY[16] = {0xee,0x9a,0x94,0x96,0x9d,0x59,0xfb,0xc2,0x7a,0xe6,0x07,0xe1,0x6e,0x04,0x37,0x5b}; +// static const u4_t DEVADDR = 0x005d96f5; + // LoRaWAN end-device address (DevAddr) // See http://thethingsnetwork.org/wiki/AddressSpace // The library converts the address to network byte order as needed. @@ -19,7 +24,15 @@ static const u4_t DEVADDR = 0x260212B6; static const u4_t DEVADDR = 0; #endif +// void printf(char *str) { +// Serial.println(str); +// } + static osjob_t sendjob; +void debug_function(char *str) { + Serial.println(str); +} + // Schedule TX every this many seconds (might become longer due to duty // cycle limitations). @@ -42,9 +55,9 @@ TinyGPSPlus gps; uint8_t general_int; +volatile uint8_t n_poly; #define isr general_int #define timeout general_int -#define n_poly general_int /**************************************************** * Track each pair of X and Y coordinates * - arrays are used by the pnpoly function @@ -100,12 +113,12 @@ void import_protobuf(const uint8_t *protobuffer, const uint32_t size) { for(uint8_t i=0;i0) { - const uint8_t oob = !check_bounds(latitude, longitude); - if(oob) { + uint8_t out_of_bounds = !check_bounds(latitude, longitude); + if(out_of_bounds) { Serial.println(oob); } else { Serial.println(inb); } - - memcpy(buffer+13, (void*)&oob, 1); + digitalWrite(LED_BUILTIN, out_of_bounds); + buffer[13] = out_of_bounds; } else { - const uint8_t oob = 0; - memcpy(buffer+13, (void*)&oob, 1); + uint8_t out_of_bounds = 0; + buffer[13] = out_of_bounds; } memcpy(buffer+3, (void*)&latitude, 4); memcpy(buffer+8, (void*)&longitude, 4); @@ -196,6 +209,8 @@ void setup() { delay(100); Serial.println(F("Starting")); + pinMode(LED_BUILTIN, OUTPUT); + // LMIC init os_init(); // Reset the MAC state. Session and pending data transfers will be discarded. @@ -222,6 +237,8 @@ void setup() { // Set data rate and transmit power for uplink LMIC_setDrTxpow(DR_SF7,14); + + delay(1000); } void loop() { diff --git a/fenceless_lmic_config.h b/fenceless_lmic_config.h index b69ece1..52fbc14 100644 --- a/fenceless_lmic_config.h +++ b/fenceless_lmic_config.h @@ -13,3 +13,9 @@ #define DISABLE_BEACONS // #define DISABLE_LMIC_FAILURE_TO #define USE_IDEETRON_AES + + +#ifndef LORA_DEBUG_F +#define LORA_DEBUG_F +extern void debug_function(char*); +#endif