add Cayenne LPP

This commit is contained in:
Scobber 2019-07-10 22:32:44 +10:00
parent 19c9e0806d
commit cc953e1e96
6 changed files with 93 additions and 28 deletions

4
main/.vscode/arduino.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"board": "arduino:avr:yun",
"sketch": "main.ino"
}

19
main/.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\Program Files (x86)\\Arduino\\tools\\**",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**"
],
"forcedInclude": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
],
"intelliSenseMode": "msvc-x64",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}

View File

@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <Arduino.h> #include <Arduino.h>
#include <lmic.h> #include <lmic.h>
void ttn_register(void (*callback)(uint8_t message)); void ttn_register(void (*callback)(uint8_t message));
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -40,6 +39,7 @@ void ttn_register(void (*callback)(uint8_t message));
// Configuration // Configuration
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define USE_CAYENNE
#define DEBUG_PORT Serial // Serial debug port #define DEBUG_PORT Serial // Serial debug port
#define SERIAL_BAUD 115200 // Serial debug baud rate #define SERIAL_BAUD 115200 // Serial debug baud rate
#define SLEEP_BETWEEN_MESSAGES 0 // Do sleep between messages #define SLEEP_BETWEEN_MESSAGES 0 // Do sleep between messages

68
main/dataformats.h Normal file
View File

@ -0,0 +1,68 @@
/*
Packet Processor
*/
#pragma once
#ifdef USE_CAYENNE
// CAYENNE DF
static uint8_t txBuffer[11] = {0x03, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void buildPacket(uint8_t txBuffer[11])
{
LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
int32_t Height = gps.altitude.meters() * 100;
sprintf(t, "Lat: %f", _gps.location.lat());
Serial.println(t);
sprintf(t, "Lng: %f", _gps.location.lng());
Serial.println(t);
sprintf(t, "Alt: %f", _gps.altitude.meters());
Serial.println(t);
txBuffer[2] = ( LatitudeBinary >> 16 ) & 0xFF;
txBuffer[3] = ( LatitudeBinary >> 8 ) & 0xFF;
txBuffer[4] = LatitudeBinary & 0xFF;
txBuffer[5] = ( LongitudeBinary >> 16 ) & 0xFF;
txBuffer[6] = ( LongitudeBinary >> 8 ) & 0xFF;
txBuffer[7] = LongitudeBinary & 0xFF;
txBuffer[8] = Height >> 16;
txBuffer[9] = Height >> 8;
txBuffer[10] = Height;
}
#else
uint8_t txBuffer[9];
void buildPacket(uint8_t txBuffer[9])
{
LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
sprintf(t, "Lat: %f", _gps.location.lat());
Serial.println(t);
sprintf(t, "Lng: %f", _gps.location.lng());
Serial.println(t);
txBuffer[0] = ( LatitudeBinary >> 16 ) & 0xFF;
txBuffer[1] = ( LatitudeBinary >> 8 ) & 0xFF;
txBuffer[2] = LatitudeBinary & 0xFF;
txBuffer[3] = ( LongitudeBinary >> 16 ) & 0xFF;
txBuffer[4] = ( LongitudeBinary >> 8 ) & 0xFF;
txBuffer[5] = LongitudeBinary & 0xFF;
altitudeGps = _gps.altitude.meters();
txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
txBuffer[7] = altitudeGps & 0xFF;
hdopGps = _gps.hdop.value()/10;
txBuffer[8] = hdopGps & 0xFF;
}
#endif

View File

@ -63,29 +63,4 @@ static void gps_loop() {
} }
} }
void buildPacket(uint8_t txBuffer[9])
{
LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
sprintf(t, "Lat: %f", _gps.location.lat());
Serial.println(t);
sprintf(t, "Lng: %f", _gps.location.lng());
Serial.println(t);
txBuffer[0] = ( LatitudeBinary >> 16 ) & 0xFF;
txBuffer[1] = ( LatitudeBinary >> 8 ) & 0xFF;
txBuffer[2] = LatitudeBinary & 0xFF;
txBuffer[3] = ( LongitudeBinary >> 16 ) & 0xFF;
txBuffer[4] = ( LongitudeBinary >> 8 ) & 0xFF;
txBuffer[5] = LongitudeBinary & 0xFF;
altitudeGps = _gps.altitude.meters();
txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
txBuffer[7] = altitudeGps & 0xFF;
hdopGps = _gps.hdop.value()/10;
txBuffer[8] = hdopGps & 0xFF;
}

View File

@ -23,8 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "configuration.h" #include "configuration.h"
#include <rom/rtc.h> #include <rom/rtc.h>
#include "dataformats.h"
uint8_t txBuffer[9];
// Message counter, stored in RTC memory, survives deep sleep // Message counter, stored in RTC memory, survives deep sleep
RTC_DATA_ATTR uint32_t count = 0; RTC_DATA_ATTR uint32_t count = 0;