lmic debugging
This commit is contained in:
parent
5c8bf78f72
commit
4b27aad026
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -21,4 +21,4 @@
|
||||||
url = https://github.com/adafruit/TinyLoRa
|
url = https://github.com/adafruit/TinyLoRa
|
||||||
[submodule "libraries/arduino-lmic"]
|
[submodule "libraries/arduino-lmic"]
|
||||||
path = 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
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -25,7 +25,11 @@ CFLAGS?=-Datmega328p\
|
||||||
-flto\
|
-flto\
|
||||||
-fno-fat-lto-objects\
|
-fno-fat-lto-objects\
|
||||||
-fuse-linker-plugin\
|
-fuse-linker-plugin\
|
||||||
-Wall
|
-Wall\
|
||||||
|
# -finline-functions\
|
||||||
|
# -fipa-sra\
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CXXFLAGS?=-Datmega328p\
|
CXXFLAGS?=-Datmega328p\
|
||||||
-std=c++11\
|
-std=c++11\
|
||||||
|
@ -45,6 +49,9 @@ CXXFLAGS?=-Datmega328p\
|
||||||
-fno-fat-lto-objects\
|
-fno-fat-lto-objects\
|
||||||
-fuse-linker-plugin\
|
-fuse-linker-plugin\
|
||||||
-Wall\
|
-Wall\
|
||||||
|
# -finline-functions\
|
||||||
|
# -fipa-sra\
|
||||||
|
|
||||||
|
|
||||||
INC_DIRS?=-I./\
|
INC_DIRS?=-I./\
|
||||||
-I./$(ARDUINO_DIR)/libraries/SPI/src\
|
-I./$(ARDUINO_DIR)/libraries/SPI/src\
|
||||||
|
|
37
collar.cpp
37
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
|
// 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 };
|
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)
|
// LoRaWAN end-device address (DevAddr)
|
||||||
// See http://thethingsnetwork.org/wiki/AddressSpace
|
// See http://thethingsnetwork.org/wiki/AddressSpace
|
||||||
// The library converts the address to network byte order as needed.
|
// 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;
|
static const u4_t DEVADDR = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// void printf(char *str) {
|
||||||
|
// Serial.println(str);
|
||||||
|
// }
|
||||||
|
|
||||||
static osjob_t sendjob;
|
static osjob_t sendjob;
|
||||||
|
void debug_function(char *str) {
|
||||||
|
Serial.println(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Schedule TX every this many seconds (might become longer due to duty
|
// Schedule TX every this many seconds (might become longer due to duty
|
||||||
// cycle limitations).
|
// cycle limitations).
|
||||||
|
@ -42,9 +55,9 @@ TinyGPSPlus gps;
|
||||||
|
|
||||||
|
|
||||||
uint8_t general_int;
|
uint8_t general_int;
|
||||||
|
volatile uint8_t n_poly;
|
||||||
#define isr general_int
|
#define isr general_int
|
||||||
#define timeout general_int
|
#define timeout general_int
|
||||||
#define n_poly general_int
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
* Track each pair of X and Y coordinates
|
* Track each pair of X and Y coordinates
|
||||||
* - arrays are used by the pnpoly function
|
* - 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;i<isr && i<N_POLY_MAX;i++) {
|
for(uint8_t i=0;i<isr && i<N_POLY_MAX;i++) {
|
||||||
memcpy(&polyx[i], ptr + i*12, 4);
|
memcpy(&polyx[i], ptr + i*12, 4);
|
||||||
memcpy(&polyy[i], ptr + i*12+5, 4);
|
memcpy(&polyy[i], ptr + i*12+5, 4);
|
||||||
Serial.print((int)polyx[i]);
|
Serial.print((int)(polyx[i]*100));
|
||||||
Serial.print(' ');
|
Serial.print(' ');
|
||||||
Serial.print((int)polyy[i]);
|
Serial.print((int)(polyy[i]*100));
|
||||||
Serial.print('\n');
|
Serial.print('\n');
|
||||||
}
|
}
|
||||||
// n_poly = isr; - n_poly is isr
|
n_poly = isr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static volatile uint8_t is_sending = 0;
|
static volatile uint8_t is_sending = 0;
|
||||||
|
@ -158,17 +171,17 @@ void do_send(osjob_t* j){
|
||||||
const float latitude = gps.location.lat();
|
const float latitude = gps.location.lat();
|
||||||
const float longitude = gps.location.lng();
|
const float longitude = gps.location.lng();
|
||||||
if(n_poly>0) {
|
if(n_poly>0) {
|
||||||
const uint8_t oob = !check_bounds(latitude, longitude);
|
uint8_t out_of_bounds = !check_bounds(latitude, longitude);
|
||||||
if(oob) {
|
if(out_of_bounds) {
|
||||||
Serial.println(oob);
|
Serial.println(oob);
|
||||||
} else {
|
} else {
|
||||||
Serial.println(inb);
|
Serial.println(inb);
|
||||||
}
|
}
|
||||||
|
digitalWrite(LED_BUILTIN, out_of_bounds);
|
||||||
memcpy(buffer+13, (void*)&oob, 1);
|
buffer[13] = out_of_bounds;
|
||||||
} else {
|
} else {
|
||||||
const uint8_t oob = 0;
|
uint8_t out_of_bounds = 0;
|
||||||
memcpy(buffer+13, (void*)&oob, 1);
|
buffer[13] = out_of_bounds;
|
||||||
}
|
}
|
||||||
memcpy(buffer+3, (void*)&latitude, 4);
|
memcpy(buffer+3, (void*)&latitude, 4);
|
||||||
memcpy(buffer+8, (void*)&longitude, 4);
|
memcpy(buffer+8, (void*)&longitude, 4);
|
||||||
|
@ -196,6 +209,8 @@ void setup() {
|
||||||
delay(100);
|
delay(100);
|
||||||
Serial.println(F("Starting"));
|
Serial.println(F("Starting"));
|
||||||
|
|
||||||
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
|
|
||||||
// LMIC init
|
// LMIC init
|
||||||
os_init();
|
os_init();
|
||||||
// Reset the MAC state. Session and pending data transfers will be discarded.
|
// 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
|
// Set data rate and transmit power for uplink
|
||||||
LMIC_setDrTxpow(DR_SF7,14);
|
LMIC_setDrTxpow(DR_SF7,14);
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
|
@ -13,3 +13,9 @@
|
||||||
#define DISABLE_BEACONS
|
#define DISABLE_BEACONS
|
||||||
// #define DISABLE_LMIC_FAILURE_TO
|
// #define DISABLE_LMIC_FAILURE_TO
|
||||||
#define USE_IDEETRON_AES
|
#define USE_IDEETRON_AES
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LORA_DEBUG_F
|
||||||
|
#define LORA_DEBUG_F
|
||||||
|
extern void debug_function(char*);
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user