working changes

This commit is contained in:
sessionm21 2020-05-15 23:14:53 +01:00
parent 5e8c891a60
commit 5c8bf78f72
2 changed files with 10 additions and 18 deletions

View File

@ -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");

View File

@ -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