Protobuf + DB Queries
This commit is contained in:
parent
97dbf3facb
commit
927f3dc6c6
25
main.c
25
main.c
|
@ -21,6 +21,8 @@
|
||||||
#include <wiringPi.h>
|
#include <wiringPi.h>
|
||||||
#include <wiringPiSPI.h>
|
#include <wiringPiSPI.h>
|
||||||
|
|
||||||
|
#include "protobuf.h"
|
||||||
|
#include "database.h"
|
||||||
|
|
||||||
// #############################################
|
// #############################################
|
||||||
// #############################################
|
// #############################################
|
||||||
|
@ -148,6 +150,8 @@ typedef unsigned char byte;
|
||||||
|
|
||||||
static const int CHANNEL = 0;
|
static const int CHANNEL = 0;
|
||||||
|
|
||||||
|
database_state db;
|
||||||
|
|
||||||
char message[256];
|
char message[256];
|
||||||
const char tok[2] = "|";
|
const char tok[2] = "|";
|
||||||
bool sx1272 = true;
|
bool sx1272 = true;
|
||||||
|
@ -171,7 +175,7 @@ int RST = 0;
|
||||||
sf_t sf = SF7;
|
sf_t sf = SF7;
|
||||||
|
|
||||||
// Set center frequency
|
// Set center frequency
|
||||||
uint32_t freq = 915000000; // in Mhz! (868.1)
|
uint32_t freq = 915000000; // in Mhz! (915)
|
||||||
|
|
||||||
byte hello[32] = "HELLO";
|
byte hello[32] = "HELLO";
|
||||||
|
|
||||||
|
@ -382,7 +386,14 @@ void receivepacket() {
|
||||||
printf("Payload: %s\n", message);
|
printf("Payload: %s\n", message);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf("Received message: %s", message);
|
Fenceless__CollarResponse * m = decode_update(sizeof(message), (uint8_t*) message);
|
||||||
|
printf("Received message (x, y): ");
|
||||||
|
printf("%f ", m->loc->x);
|
||||||
|
printf("%f", m->loc->y);
|
||||||
|
|
||||||
|
database_write_location(&db, 1, m->loc->x, m->loc->y);
|
||||||
|
|
||||||
|
|
||||||
} // received a message
|
} // received a message
|
||||||
|
|
||||||
} // dio0=1
|
} // dio0=1
|
||||||
|
@ -446,7 +457,12 @@ void txlora(byte *frame, byte datalen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
int main (int argc, char *argv[]) {
|
||||||
|
if (argc != 2) {
|
||||||
|
printf("./a.out [Database Location]");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
database_state_init(&db, argv[1]);
|
||||||
|
}
|
||||||
wiringPiSetup () ;
|
wiringPiSetup () ;
|
||||||
pinMode(ssPin, OUTPUT);
|
pinMode(ssPin, OUTPUT);
|
||||||
pinMode(dio0, INPUT);
|
pinMode(dio0, INPUT);
|
||||||
|
@ -466,6 +482,7 @@ int main (int argc, char *argv[]) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
database_state_free(&db);
|
||||||
|
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user