Skip to content

Commit

Permalink
Merge branch 'ckuethe-mqtt_improvements' into dev2
Browse files Browse the repository at this point in the history
  • Loading branch information
dl9rdz committed Dec 22, 2024
2 parents 542e496 + 7d83e95 commit 56f8fe9
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 53 deletions.
1 change: 1 addition & 0 deletions RX_FSK/RX_FSK.ino
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ struct st_configitems config_list[] = {
{"mqtt.username", 63, &sonde.config.mqtt.username},
{"mqtt.password", 63, &sonde.config.mqtt.password},
{"mqtt.prefix", 63, &sonde.config.mqtt.prefix},
{"mqtt.report_interval", 0, &sonde.config.mqtt.report_interval},
#endif
#if FEATURE_SDCARD
/* SD-Card settings */
Expand Down
3 changes: 2 additions & 1 deletion RX_FSK/data/cfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ var cfgs = [
[ "tcp.chase", "APRS location reporting (0=off, 1=fixed, 2=chase/GPS, 3=auto)"],
[ "tcp.comment", "APRS location comment"],
[ "", "MQTT data feed configuration", "https://github.com/dl9rdz/rdz_ttgo_sonde/wiki/MQTT-configuration"],
[ "mqtt.active", "MQTT active (needs reboot)"],
[ "mqtt.active", "MQTT message selection bitfield: 1=Sondes, 2=Uptime, 4=PMU, 8=GPS, 16=Scanner/Spectrum Peak, 128=Debug. 0 to disable MQTT (needs reboot)"],
[ "mqtt.id", "MQTT client ID"],
[ "mqtt.host", "MQTT server hostname"],
[ "mqtt.port", "MQTT port"],
[ "mqtt.username", "MQTT username"],
[ "mqtt.password", "MQTT password"],
[ "mqtt.prefix", "MQTT prefix"],
[ "mqtt.report_interval", "MQTT reporting interval (ms)"],
[ "", "Chasemapper settings", "https://github.com/dl9rdz/rdz_ttgo_sonde/wiki/Chasemapper-configuration"],
[ "cm.active", "Chasemapper active (0=disabled, 1=active)"],
[ "cm.host", "Chasemapper UDP host"],
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/data/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ mqtt.port=1883
mqtt.username=
mqtt.password=
mqtt.prefix=rdz_sonde_server/
mqtt.report_interval=60000
#-------------------------------#
# Sondehub v2 settings
#-------------------------------#
Expand Down
9 changes: 6 additions & 3 deletions RX_FSK/src/Scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "SX1278FSK.h"
#include "Sonde.h"
#include "Display.h"
#include "src/conn-mqtt.h"


double STARTF;
Expand Down Expand Up @@ -179,7 +180,7 @@ void Scanner::scan()
int peakres=-9999;
for(int i=0; i<scanconfig.PLOT_W; i+=1) {
int r=scanresult[i*scanconfig.SMPL_PIX];
if(r>peakres+1) { peakres=r; peakidx=i*scanconfig.SMPL_PIX; }
if(r>peakres+1) { peakres=r; peakidx=i*scanconfig.SMPL_PIX; }
scandisp[i] = r;
for(int j=1; j<scanconfig.SMPL_PIX; j++) {
r = scanresult[i*scanconfig.SMPL_PIX+j];
Expand All @@ -200,8 +201,10 @@ void Scanner::scan()
Serial.print(scandisp[i]); Serial.print(", ");
}
Serial.println("\n");
Serial.print("Peak: ");
Serial.print(peakf);
Serial.printf("Peak: %f rssi %d\n", peakf, peakres);
#if FEATURE_MQTT
connMQTT.publishPeak(peakf, peakres);
#endif
}

Scanner scanner = Scanner();
8 changes: 8 additions & 0 deletions RX_FSK/src/Sonde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "SX1278FSK.h"
#include "Display.h"
#include <Wire.h>
#include "conn-mqtt.h"

RXTask rxtask = { -1, -1, -1, 0xFFFF, 0 };

Expand Down Expand Up @@ -340,6 +341,7 @@ void Sonde::defaultConfig() {
strcpy(config.mqtt.username, "/0");
strcpy(config.mqtt.password, "/0");
strcpy(config.mqtt.prefix, "rdz_sonde_server/");
config.mqtt.report_interval = 60000;
}

extern struct st_configitems config_list[];
Expand Down Expand Up @@ -535,6 +537,12 @@ void Sonde::setup() {
int afcbw = (int)sx1278.getAFCBandwidth();
int rxbw = (int)sx1278.getRxBandwidth();
LOG_I(TAG, "Sonde::setup() done: Type %s Freq %f, AFC BW: %d, RX BW: %d\n", sondeTypeStr[sondeList[rxtask.currentSonde].type], 0.000001*freq, afcbw, rxbw);
#if FEATURE_MQTT
connMQTT.publishQRG(
rxtask.currentSonde+1,
sondeTypeStr[sondeList[rxtask.currentSonde].type],
sondeList[rxtask.currentSonde].launchsite, freq/1e6);
#endif

// reset rxtimer / norxtimer state
sonde.sondeList[sonde.currentSonde].lastState = -1;
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/src/Sonde.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ struct st_mqtt {
char username[64];
char password[64];
char prefix[64];
int report_interval;
};

struct st_cm {
Expand Down
Loading

0 comments on commit 56f8fe9

Please sign in to comment.