aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tracker-stm32/platformio.ini26
-rw-r--r--tracker-stm32/src/main.cpp86
2 files changed, 29 insertions, 83 deletions
diff --git a/tracker-stm32/platformio.ini b/tracker-stm32/platformio.ini
index a622f22..1e3f966 100644
--- a/tracker-stm32/platformio.ini
+++ b/tracker-stm32/platformio.ini
@@ -1,18 +1,12 @@
-; PlatformIO Project Configuration File
-;
-; Build options: build flags, source filter
-; Upload options: custom upload port, speed and extra flags
-; Library options: dependencies, extra library storages
-; Advanced options: extra scripting
-;
-; Please visit documentation for the other options and examples
-; https://docs.platformio.org/page/projectconf.html
-
-[env:nucleo_h743zi]
+[env:hercules]
platform = ststm32
-board = nucleo_h743zi
+board = genericSTM32F103C8
+board_build.mcu = stm32f103c8t6
+board_build.f_cpu = 72000000L
+upload_protocol = stlink
framework = arduino
-lib_deps =
- jgromes/RadioLib@^6.0.0
- sparkfun/SparkFun u-blox GNSS Arduino Library@^2.2.22
- arduino-libraries/SD@^1.2.4
+lib_deps =
+ jgromes/RadioLib@^6.0.0
+ mikalhart/TinyGPSPlus @ 1.0.3
+ arduino-libraries/SD@^1.2.4
+
diff --git a/tracker-stm32/src/main.cpp b/tracker-stm32/src/main.cpp
index 1ae97e9..409c2c1 100644
--- a/tracker-stm32/src/main.cpp
+++ b/tracker-stm32/src/main.cpp
@@ -2,7 +2,7 @@
#include <Arduino.h>
#include <RadioLib.h>
#include <Wire.h>
-#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
+#include <TinyGPS++.h>
#include <SD.h>
#include "compression.h"
@@ -12,10 +12,11 @@ constexpr int DATA_TYPE_CODE_STATUS_REPORT = 1;
// TODO: read these settings from the SD Card
constexpr char CALLSIGN[] = "HB9EGM";
-constexpr int SSID = 12;
+constexpr int SSID = 7;
constexpr int PATH_CODE = 2; // metropolitan mobile
constexpr char SYMBOL_TABLE_IDENTIFIER = '/';
constexpr char SYMBOL_CODE_BICYCLE = 'b';
+constexpr char SYMBOL_CODE_FOOT = '[';
constexpr long REPORT_TX_INTERVAL = 15000;
constexpr long TEXT_TX_INTERVAL = 47000;
@@ -31,8 +32,9 @@ constexpr int SD_CS = 17;
// DIO0 pin: PF3 (Arduino 8)
// RESET pin: PF15 (Arduino 9)
RFM96 radio = new Module(10, 8, 9);
-HardwareSerial SerialGNSS(PD6, PD5);
-SFE_UBLOX_GNSS gnss;
+
+HardwareSerial serialGNSS(PA10, PA9);
+TinyGPSPlus gps;
long lastGnssPoll = 0;
long lastPositionReport = 0;
@@ -46,32 +48,6 @@ static char letterize(int x) {
return (char) x + 65;
}
-static char* get_mh(double lat, double lon, int size) {
- static char locator[11];
- double LON_F[]={20,2.0,0.083333,0.008333,0.0003472083333333333};
- double LAT_F[]={10,1.0,0.0416665,0.004166,0.0001735833333333333};
- int i;
- lon += 180;
- lat += 90;
-
- if (size <= 0 || size > 10) size = 6;
- size/=2; size*=2;
-
- for (i = 0; i < size/2; i++){
- if (i % 2 == 1) {
- locator[i*2] = (char) (lon/LON_F[i] + '0');
- locator[i*2+1] = (char) (lat/LAT_F[i] + '0');
- } else {
- locator[i*2] = letterize((int) (lon/LON_F[i]));
- locator[i*2+1] = letterize((int) (lat/LAT_F[i]));
- }
- lon = fmod(lon, LON_F[i]);
- lat = fmod(lat, LAT_F[i]);
- }
- locator[i*2]=0;
- return locator;
-}
-
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
@@ -87,22 +63,8 @@ void setup() {
Wire.begin();
- SerialGNSS.begin(9600);
- if (!gnss.begin(SerialGNSS)) {
- while (true) {
- Serial.println(F("Check GNSS"));
- delay(4000);
- }
- }
-
- //gnss.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
- Serial.print(F("Version: "));
- byte versionHigh = gnss.getProtocolVersionHigh();
- Serial.print(versionHigh);
- Serial.print(".");
- byte versionLow = gnss.getProtocolVersionLow();
- Serial.println(versionLow);
+ serialGNSS.begin(9600);
Serial.print(F("[RFM] Init "));
int state = radio.begin(433.900);
@@ -172,41 +134,38 @@ static void handle_radio_error(int state)
void loop()
{
+ while (serialGNSS.available() > 0) {
+ gps.encode(serialGNSS.read());
+ }
+
const auto now = millis();
if (now - lastGnssPoll > 1000) {
lastGnssPoll = now;
// longitude and latitude are in degrees*1e7
- const long latitude = gnss.getLatitude();
+ const long latitude = gps.location.lat();
Serial.print(F("Lat: "));
Serial.print(latitude);
- const long longitude = gnss.getLongitude();
+ const long longitude = gps.location.lng();
Serial.print(F(" Long: "));
Serial.print(longitude);
- char *locator = get_mh((double)latitude/1e7, (double)longitude/1e7, 10);
- Serial.print(F(" Loc: "));
- Serial.print(locator);
-
- const long altitude = gnss.getAltitude();
- Serial.print(F(" Alt: "));
- Serial.print(altitude);
- Serial.print(F(" (mm)"));
+ const long altitude = gps.altitude.feet();
- const long speed = gnss.getGroundSpeed();
+ const int speed = gps.speed.kmph();
Serial.print(F(" Speed: "));
Serial.print(speed);
Serial.print(F(" (mm/s)"));
// 1m/s = 900/463 knots
- const double speed_kn = speed / 1000.0 * 900.0 / 463.0;
+ const double speed_kn = gps.speed.knots();
- const long heading = gnss.getHeading();
+ const long heading = gps.course.deg();
Serial.print(F(" Heading: "));
Serial.print(heading);
Serial.print(F(" (degrees * 10^-5)"));
- const byte SIV = gnss.getSIV();
+ const byte SIV = gps.satellites.value();
Serial.print(F(" SIV: "));
Serial.print(SIV);
@@ -254,7 +213,7 @@ void loop()
}
// $ Symbol Code
- report[report_len++] = SYMBOL_CODE_BICYCLE;
+ report[report_len++] = SYMBOL_CODE_FOOT;
// cs Course and Speed
ax25_base91enc(tmp_base91, 1, heading * 10000 / 4);
@@ -263,13 +222,6 @@ void loop()
ax25_base91enc(tmp_base91, 1, (uint32_t)(log1p(speed_kn) / 0.07696));
report[report_len++] = tmp_base91[0];
- Serial.print(F("TX: "));
- // This is the old custom report I used before adopting aprs434.github.io,
- // it is just callsign SPACE locator sent as ASCII
- Serial.print(CALLSIGN);
- Serial.print(F(" "));
- Serial.println(locator);
-
// Debug print
Serial.println(F("Bytes: "));
for (int i = 0; i < report_len; i++) {