cleanup
This commit is contained in:
parent
f51f10574c
commit
f6156743cf
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -16,3 +16,6 @@
|
||||||
[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 = https://github.com/mcci-catena/arduino-lmic.git
|
||||||
|
[submodule "libraries/arduino-base64"]
|
||||||
|
path = libraries/arduino-base64
|
||||||
|
url = https://github.com/adamvr/arduino-base64.git
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -32,6 +32,7 @@ INC_DIRS?=-I./$(ARDUINO_DIR)/libraries/SPI/src\
|
||||||
-I./libraries/arduino-LoRa/src\
|
-I./libraries/arduino-LoRa/src\
|
||||||
-I./libraries/TinyGPSPlus/src\
|
-I./libraries/TinyGPSPlus/src\
|
||||||
-I./libraries/TinyLoRa\
|
-I./libraries/TinyLoRa\
|
||||||
|
-I./libraries/arduino-base64\
|
||||||
-I./$(NANOPB_DIR)\
|
-I./$(NANOPB_DIR)\
|
||||||
-I./protobuf\
|
-I./protobuf\
|
||||||
-I./$(ARDUINO_DIR)/libraries/SoftwareSerial/src/
|
-I./$(ARDUINO_DIR)/libraries/SoftwareSerial/src/
|
||||||
|
@ -57,6 +58,7 @@ SRC_FILES?=./$(ARDUINO_DIR)/cores/arduino/main.cpp\
|
||||||
./libraries/arduino-LoRa/src/LoRa.cpp\
|
./libraries/arduino-LoRa/src/LoRa.cpp\
|
||||||
./libraries/TinyGPSPlus/src/TinyGPS++.cpp\
|
./libraries/TinyGPSPlus/src/TinyGPS++.cpp\
|
||||||
./libraries/TinyLoRa/TinyLoRa.cpp\
|
./libraries/TinyLoRa/TinyLoRa.cpp\
|
||||||
|
./libraries/arduino-base64/Base64.cpp\
|
||||||
./$(NANOPB_DIR)/pb_encode.c\
|
./$(NANOPB_DIR)/pb_encode.c\
|
||||||
./$(NANOPB_DIR)/pb_decode.c\
|
./$(NANOPB_DIR)/pb_decode.c\
|
||||||
./$(NANOPB_DIR)/pb_common.c\
|
./$(NANOPB_DIR)/pb_common.c\
|
||||||
|
@ -96,6 +98,7 @@ run: flash
|
||||||
|
|
||||||
start: flash
|
start: flash
|
||||||
systemctl start lora-gateway-bridge loraserver
|
systemctl start lora-gateway-bridge loraserver
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:nothing.hex:i
|
avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:nothing.hex:i
|
||||||
systemctl stop lora-gateway-bridge loraserver
|
systemctl stop lora-gateway-bridge loraserver
|
||||||
|
|
18
README.md
18
README.md
|
@ -7,3 +7,21 @@
|
||||||
# Python3 dependencies
|
# Python3 dependencies
|
||||||
- protobuf
|
- protobuf
|
||||||
- grpcio-tools
|
- grpcio-tools
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
On a clean clone one would most likely have to run
|
||||||
|
```
|
||||||
|
git submodule update --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
# Makefile Stuff
|
||||||
|
|
||||||
|
The most helpful makefile recipies are start, stop, and run
|
||||||
|
|
||||||
|
- start flashes the arduino and starts system services for lorawan
|
||||||
|
|
||||||
|
- stop flashes a dummy program to the arduino and stops services for lorawan
|
||||||
|
|
||||||
|
- run flashes the arduino and connects to uart using screen
|
||||||
|
|
||||||
|
|
75
collar.cpp
75
collar.cpp
|
@ -9,8 +9,11 @@
|
||||||
//
|
//
|
||||||
// Modified by Brent Rubell for Adafruit Industries, 2018
|
// Modified by Brent Rubell for Adafruit Industries, 2018
|
||||||
/************************** Configuration ***********************************/
|
/************************** Configuration ***********************************/
|
||||||
|
#include <TinyGPS++.h>
|
||||||
|
#include <SoftwareSerial.h>
|
||||||
#include <TinyLoRa.h>
|
#include <TinyLoRa.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
#include "Base64.h"
|
||||||
#include "gateway/message.pb.h"
|
#include "gateway/message.pb.h"
|
||||||
|
|
||||||
#include "pb_common.h"
|
#include "pb_common.h"
|
||||||
|
@ -42,6 +45,8 @@ const unsigned int sendInterval = 60;
|
||||||
|
|
||||||
// Pinout for Adafruit Feather 32u4 LoRa
|
// Pinout for Adafruit Feather 32u4 LoRa
|
||||||
TinyLoRa lora = TinyLoRa(2, 10, 9);
|
TinyLoRa lora = TinyLoRa(2, 10, 9);
|
||||||
|
TinyGPSPlus gps;
|
||||||
|
SoftwareSerial ss(6, 7);
|
||||||
|
|
||||||
// Pinout for Adafruit Feather M0 LoRa
|
// Pinout for Adafruit Feather M0 LoRa
|
||||||
//TinyLoRa lora = TinyLoRa(3, 8, 4);
|
//TinyLoRa lora = TinyLoRa(3, 8, 4);
|
||||||
|
@ -140,14 +145,30 @@ void on_recieve(int n) {
|
||||||
}
|
}
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
delay(2000);
|
delay(1000);
|
||||||
|
// start uart
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
// start software uart for GPS
|
||||||
|
ss.begin(4800);
|
||||||
while (! Serial);
|
while (! Serial);
|
||||||
|
|
||||||
delay(4000);
|
delay(1000);
|
||||||
// Initialize pin LED_BUILTIN as an output
|
// Initialize pin LED_BUILTIN as an output
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
|
|
||||||
|
// Initialize GPS - GPS does not work indoors - This will block until GPS available
|
||||||
|
// Serial.println("Starting GPS");
|
||||||
|
// while(!gps.location.isValid()) {
|
||||||
|
// while(ss.available()>0) {
|
||||||
|
// gps.encode(ss.read());
|
||||||
|
// }
|
||||||
|
// if (millis() > 5000 && gps.charsProcessed() < 10)
|
||||||
|
// {
|
||||||
|
// Serial.println(F("No GPS detected: check wiring."));
|
||||||
|
// while(true);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// Initialize LoRa
|
// Initialize LoRa
|
||||||
Serial.print("Starting LoRa...");
|
Serial.print("Starting LoRa...");
|
||||||
// define multi-channel sending
|
// define multi-channel sending
|
||||||
|
@ -161,13 +182,6 @@ void setup()
|
||||||
while(true);
|
while(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fenceless_CollarResponse coord;
|
|
||||||
coord.loc.x = 0;
|
|
||||||
coord.loc.y = 0;
|
|
||||||
|
|
||||||
pb_ostream_t stream;
|
|
||||||
stream = pb_ostream_from_buffer(loraData, sizeof(loraData));
|
|
||||||
int err = pb_encode(&stream, Fenceless_CollarResponse_fields, &coord);
|
|
||||||
// Optional set transmit power. If not set default is +17 dBm.
|
// Optional set transmit power. If not set default is +17 dBm.
|
||||||
// Valid options are: -80, 1 to 17, 20 (dBm).
|
// Valid options are: -80, 1 to 17, 20 (dBm).
|
||||||
// For safe operation in 20dBm: your antenna must be 3:1 VWSR or better
|
// For safe operation in 20dBm: your antenna must be 3:1 VWSR or better
|
||||||
|
@ -186,30 +200,55 @@ void setup()
|
||||||
Serial.println("OK");
|
Serial.println("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TIMER1_OVF_vect is called once per second
|
||||||
int sendCounter = 0;
|
int sendCounter = 0;
|
||||||
ISR(TIMER1_OVF_vect) {
|
ISR(TIMER1_OVF_vect) {
|
||||||
digitalWrite(LED_BUILTIN, sendCounter%2);
|
digitalWrite(LED_BUILTIN, sendCounter%2);
|
||||||
if(sendCounter==0) {
|
if(sendCounter==0 && gps.location.isValid()) {
|
||||||
|
Serial.println("Valid gps");
|
||||||
|
|
||||||
|
// reset send counter
|
||||||
sendCounter = sendInterval;
|
sendCounter = sendInterval;
|
||||||
|
|
||||||
|
Fenceless_CollarResponse coord;
|
||||||
|
coord.loc.x = gps.location.lat();
|
||||||
|
coord.loc.y = gps.location.lng();
|
||||||
|
|
||||||
|
pb_ostream_t stream;
|
||||||
|
stream = pb_ostream_from_buffer(loraData, sizeof(loraData));
|
||||||
|
int err = pb_encode(&stream, Fenceless_CollarResponse_fields, &coord);
|
||||||
|
|
||||||
|
// Generate copy pasteable base64
|
||||||
|
// char base64[50];
|
||||||
|
// base64_encode(base64, (char*)loraData, stream.bytes_written);
|
||||||
|
// Serial.println(stream.bytes_written);
|
||||||
|
// Serial.println(base64);
|
||||||
|
|
||||||
Serial.println("Sending LoRa Data...");
|
Serial.println("Sending LoRa Data...");
|
||||||
lora.sendData(loraData, sizeof(loraData), lora.frameCounter);
|
lora.sendData(loraData, stream.bytes_written, lora.frameCounter);
|
||||||
// Optionally set the Frame Port (1 to 255)
|
// Optionally set the Frame Port (1 to 255)
|
||||||
// uint8_t framePort = 1;
|
// uint8_t framePort = 1;
|
||||||
// lora.sendData(loraData, sizeof(loraData), lora.frameCounter, framePort);
|
// lora.sendData(loraData, sizeof(loraData), lora.frameCounter, framePort);
|
||||||
Serial.print("Frame Counter: ");Serial.println(lora.frameCounter);
|
Serial.print("Frame Counter: ");Serial.println(lora.frameCounter);
|
||||||
lora.frameCounter++;
|
lora.frameCounter++;
|
||||||
|
}
|
||||||
Serial.println("delaying...");
|
else if (!gps.location.isValid()) {
|
||||||
|
Serial.println("waiting for gps");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Serial.println("delaying til next frame counter");
|
||||||
}
|
}
|
||||||
sendCounter--;
|
sendCounter--;
|
||||||
}
|
}
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
if(recieved) {
|
// For later when recieving from gateway is implemented
|
||||||
Serial.println("Recieved something");
|
// if(recieved) {
|
||||||
} else {
|
// Serial.println("Recieved something");
|
||||||
Serial.println("Nothing yet");
|
// } else {
|
||||||
}
|
// Serial.println("Nothing yet");
|
||||||
|
// }
|
||||||
|
if(ss.available()>0)
|
||||||
|
gps.encode(ss.read());
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user