From 5c8bf78f723e2bbf4fda11a5f3784c342a23386d Mon Sep 17 00:00:00 2001 From: sessionm21 Date: Fri, 15 May 2020 23:14:53 +0100 Subject: [PATCH] working changes --- collar.cpp | 26 +++++++++----------------- fenceless_lmic_config.h | 2 +- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/collar.cpp b/collar.cpp index 8310729..1012e83 100644 --- a/collar.cpp +++ b/collar.cpp @@ -19,14 +19,6 @@ static const u4_t DEVADDR = 0x260212B6; static const u4_t DEVADDR = 0; #endif -// These callbacks are only used in over-the-air activation, so they are -// left empty here (we cannot leave them out completely unless -// DISABLE_JOIN is set in arduino-lmic/project_config/lmic_project_config.h, -// otherwise the linker will complain). -void os_getArtEui (u1_t* buf) { } -void os_getDevEui (u1_t* buf) { } -void os_getDevKey (u1_t* buf) { } - static osjob_t sendjob; // Schedule TX every this many seconds (might become longer due to duty @@ -58,17 +50,18 @@ uint8_t general_int; * - arrays are used by the pnpoly function ***************************************************/ const uint8_t N_POLY_MAX=10; -float polyx[N_POLY_MAX]; -float polyy[N_POLY_MAX]; -//int n_poly=0; +float polyx[N_POLY_MAX*2+5]; +float * const polyy = polyx + N_POLY_MAX; + /**************************************************** * Check a pair of coordinates against two lists * of vertices * - https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html ***************************************************/ -const int pnpoly(int nvert, const float *vertx, const float *verty, const float testx, const float testy) +const int pnpoly +(const uint8_t nvert, const float *vertx, const float *verty, const float testx, const float testy) { - int i, j, c = 0; + uint8_t i, j, c = 0; for (i = 0, j = nvert-1; i < nvert; j = i++) { if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) ) @@ -179,16 +172,15 @@ void do_send(osjob_t* j){ } memcpy(buffer+3, (void*)&latitude, 4); memcpy(buffer+8, (void*)&longitude, 4); - LMIC_setTxData2(1, buffer, sizeof(buffer)-2, 0); + LMIC_setTxData2(1, buffer, sizeof(buffer)-1, 0); } } #define GPS_MAX_ENCODES 60 void read_gps(){ - timeout = 0; - while(softserial_available()>0 && timeout < GPS_MAX_ENCODES) { + general_int = softserial_available(); + while(--general_int > 0) { gps.encode(softserial_read()); - timeout ++; } if(!is_sending && gps.location.isValid()) { Serial.println("gps"); diff --git a/fenceless_lmic_config.h b/fenceless_lmic_config.h index 587899e..b69ece1 100644 --- a/fenceless_lmic_config.h +++ b/fenceless_lmic_config.h @@ -11,5 +11,5 @@ #define DISABLE_JOIN #define DISABLE_PING #define DISABLE_BEACONS -#define DISABLE_LMIC_FAILURE_TO +// #define DISABLE_LMIC_FAILURE_TO #define USE_IDEETRON_AES