2019-04-03 15:16:51 +00:00
|
|
|
|
|
|
|
#ifndef Sonde_h
|
2019-05-22 11:50:47 +00:00
|
|
|
#define Sonde_h
|
2019-04-03 15:16:51 +00:00
|
|
|
|
2020-11-30 14:44:49 +00:00
|
|
|
enum DbgLevel { DEBUG_OFF=0, DEBUG_INFO=1, DEBUG_SPARSER=16, DEBUG_DISPLAY=8 }; // to be extended for configuring serial debug output
|
2020-11-29 15:01:54 +00:00
|
|
|
extern uint8_t debug;
|
|
|
|
|
|
|
|
#define DebugPrint(l,x) if(debug&l) { Serial.print(x); }
|
|
|
|
#define DebugPrintln(l,x) if(debug&l) { Serial.println(x); }
|
|
|
|
#define DebugPrintf(l,...) if(debug&l) { Serial.printf(__VA_ARGS__); }
|
|
|
|
|
2019-04-05 18:05:18 +00:00
|
|
|
// RX_TIMEOUT: no header detected
|
|
|
|
// RX_ERROR: header detected, but data not decoded (crc error, etc.)
|
|
|
|
// RX_OK: header and data ok
|
2019-06-02 19:19:57 +00:00
|
|
|
enum RxResult { RX_OK, RX_TIMEOUT, RX_ERROR, RX_UNKNOWN, RX_NOPOS };
|
2019-06-02 09:28:00 +00:00
|
|
|
#define RX_UPDATERSSI 0xFFFE
|
2019-04-05 18:05:18 +00:00
|
|
|
|
2019-05-24 21:49:50 +00:00
|
|
|
// Events that change what is displayed (mode, sondenr)
|
|
|
|
// Keys:
|
|
|
|
// 1 Button (short) or Touch (short)
|
|
|
|
// 2 Button (double) or Touch (double)
|
|
|
|
// 3 Button (mid) or Touch (mid)
|
|
|
|
// 4 Button (long) or Touch (long)
|
|
|
|
// 5 Touch1/2 (short)
|
|
|
|
// 6 Touch1/2 (double)
|
|
|
|
// 7 Touch1/2 (mid)
|
|
|
|
// 8 Touch1/2 (long)
|
|
|
|
|
|
|
|
/* Keypress => Sonde++ / Sonde-- / Display:=N*/
|
|
|
|
enum Events { EVT_NONE, EVT_KEY1SHORT, EVT_KEY1DOUBLE, EVT_KEY1MID, EVT_KEY1LONG,
|
|
|
|
EVT_KEY2SHORT, EVT_KEY2DOUBLE, EVT_KEY2MID, EVT_KEY2LONG,
|
|
|
|
EVT_VIEWTO, EVT_RXTO, EVT_NORXTO,
|
|
|
|
EVT_MAX };
|
|
|
|
extern const char *evstring[];
|
2019-05-30 20:19:45 +00:00
|
|
|
extern const char *RXstr[];
|
2019-05-24 21:49:50 +00:00
|
|
|
#define EVENTNAME(s) evstring[s]
|
|
|
|
|
|
|
|
//int8_t actions[EVT_MAX];
|
2019-06-08 06:47:57 +00:00
|
|
|
#define ACT_NONE 255
|
2019-05-24 21:49:50 +00:00
|
|
|
#define ACT_DISPLAY(n) (n)
|
2019-10-19 07:23:18 +00:00
|
|
|
#define ACT_MAXDISPLAY 50
|
|
|
|
#define ACT_DISPLAY_SCANNER 0
|
2019-10-18 21:29:43 +00:00
|
|
|
#define ACT_DISPLAY_NEXT 64
|
2019-06-08 06:47:57 +00:00
|
|
|
#define ACT_DISPLAY_DEFAULT 63
|
|
|
|
#define ACT_DISPLAY_SPECTRUM 62
|
|
|
|
#define ACT_DISPLAY_WIFI 61
|
2019-05-24 21:49:50 +00:00
|
|
|
#define ACT_NEXTSONDE 65
|
2019-06-08 06:47:57 +00:00
|
|
|
#define ACT_PREVSONDE 66
|
2019-11-10 11:04:59 +00:00
|
|
|
#define ACT_ADDFREQ(n) ((n)+64)
|
2019-06-08 06:47:57 +00:00
|
|
|
#define ACT_SONDE(n) ((n)+128)
|
2019-05-24 21:49:50 +00:00
|
|
|
|
|
|
|
// 0000nnnn => goto display nnnn
|
|
|
|
// 01000000 => goto sonde -1
|
|
|
|
// 01000001 => goto sonde +1
|
|
|
|
|
2021-04-02 21:02:12 +00:00
|
|
|
#define NSondeTypes 8
|
|
|
|
enum SondeType { STYPE_DFM, STYPE_DFM09_OLD, STYPE_RS41, STYPE_RS92, STYPE_M10, STYPE_M20, STYPE_DFM06_OLD, STYPE_MP3H };
|
2019-11-01 17:16:06 +00:00
|
|
|
extern const char *sondeTypeStr[NSondeTypes];
|
2020-11-29 15:01:54 +00:00
|
|
|
extern const char *sondeTypeLongStr[NSondeTypes];
|
2020-12-15 20:15:15 +00:00
|
|
|
extern const char sondeTypeChar[NSondeTypes];
|
2021-05-04 18:14:23 +00:00
|
|
|
extern const char *manufacturer_string[NSondeTypes];
|
2019-04-05 18:05:18 +00:00
|
|
|
|
2020-11-30 14:44:49 +00:00
|
|
|
#define TYPE_IS_DFM(t) ( (t)==STYPE_DFM || (t)==STYPE_DFM09_OLD || (t)==STYPE_DFM06_OLD )
|
2020-12-15 20:15:15 +00:00
|
|
|
#define TYPE_IS_METEO(t) ( (t)==STYPE_M10 || (t)==STYPE_M20 )
|
2019-04-05 18:05:18 +00:00
|
|
|
|
2019-11-02 12:18:17 +00:00
|
|
|
typedef struct st_sondeinfo {
|
|
|
|
// receiver configuration
|
|
|
|
bool active;
|
|
|
|
SondeType type;
|
2021-08-12 22:33:23 +00:00
|
|
|
int8_t subtype; /* 0 for none/unknown, hex type for dfm, 1/2 for M10/M20 */
|
2019-11-02 12:18:17 +00:00
|
|
|
float freq;
|
|
|
|
// decoded ID
|
2020-11-30 14:44:49 +00:00
|
|
|
char typestr[5]; // decoded type (use type if *typestr==0)
|
2019-11-02 12:18:17 +00:00
|
|
|
char id[10];
|
|
|
|
char ser[12];
|
|
|
|
bool validID;
|
|
|
|
char launchsite[18];
|
|
|
|
// decoded position
|
|
|
|
float lat; // latitude
|
|
|
|
float lon; // longitude
|
|
|
|
float alt; // altitude
|
2020-11-18 09:05:37 +00:00
|
|
|
float vs; // vertical speed in m/s
|
|
|
|
float hs; // horizontal speed in m/s
|
2019-11-02 12:18:17 +00:00
|
|
|
float dir; // 0..360
|
|
|
|
uint8_t sats; // number of sats
|
2019-11-25 09:51:51 +00:00
|
|
|
uint8_t validPos; // bit pattern for validity of above 7 fields; 0x80: position is old
|
2019-11-02 12:18:17 +00:00
|
|
|
// decoded GPS time
|
|
|
|
uint32_t time;
|
|
|
|
uint16_t sec;
|
|
|
|
uint32_t frame;
|
|
|
|
bool validTime;
|
|
|
|
// RSSI from receiver
|
|
|
|
int rssi; // signal strength
|
|
|
|
int32_t afc; // afc correction value
|
|
|
|
// statistics
|
|
|
|
uint8_t rxStat[20];
|
|
|
|
uint32_t rxStart; // millis() timestamp of continuous rx start
|
|
|
|
uint32_t norxStart; // millis() timestamp of continuous no rx start
|
|
|
|
uint32_t viewStart; // millis() timestamp of viewinf this sonde with current display
|
|
|
|
int8_t lastState; // -1: disabled; 0: norx; 1: rx
|
2019-12-21 14:30:54 +00:00
|
|
|
// shut down timers, currently only for RS41; -1=disabled
|
|
|
|
int16_t launchKT, burstKT, countKT;
|
|
|
|
uint16_t crefKT; // frame number in which countKT was last sent
|
2021-03-14 20:31:39 +00:00
|
|
|
// sonde specific extra data, NULL if unused or not yet initialized, currently used for RS41 subframe data (calibration)
|
|
|
|
void *extra;
|
2021-02-08 17:45:17 +00:00
|
|
|
float temperature = -300.0; // platinum resistor temperature
|
|
|
|
float tempRHSensor = -300.0; // temperature of relative humidity sensor
|
|
|
|
float relativeHumidity = -1.0; // relative humidity
|
2019-11-02 12:18:17 +00:00
|
|
|
} SondeInfo;
|
2019-12-21 14:30:54 +00:00
|
|
|
// rxStat: 3=undef[empty] 1=timeout[.] 2=errro[E] 0=ok[|] 4=no valid position[°]
|
2019-11-02 12:18:17 +00:00
|
|
|
|
2019-05-30 20:19:45 +00:00
|
|
|
// Used for interacting with the RX background task
|
|
|
|
typedef struct st_RXTask {
|
|
|
|
// Variables set by Arduino main loop to value >=0 for requesting
|
2019-06-08 06:47:57 +00:00
|
|
|
// mode change to sonde reception for sonde <value) in RXTask.
|
|
|
|
// Will be reset to -1 by RXTask
|
2019-05-30 20:19:45 +00:00
|
|
|
int activate;
|
2019-06-08 06:47:57 +00:00
|
|
|
// Variables set by RXTask, corresponding to mode ST_DECODER (if active) or something else,
|
|
|
|
// and currently received sonde
|
2019-05-30 20:19:45 +00:00
|
|
|
int mainState;
|
|
|
|
int currentSonde;
|
|
|
|
// Variable set by RXTask to communicate status to Arduino task
|
|
|
|
// via waitRXcomplete function
|
|
|
|
uint16_t receiveResult;
|
2019-06-08 06:47:57 +00:00
|
|
|
uint16_t receiveSonde; // sonde inde corresponding to receiveResult
|
2019-05-30 20:19:45 +00:00
|
|
|
// status variabe set by decoder to indicate something is broken
|
2019-06-08 06:47:57 +00:00
|
|
|
// int fifoOverflow;
|
2019-05-30 20:19:45 +00:00
|
|
|
} RXTask;
|
|
|
|
|
|
|
|
extern RXTask rxtask;
|
|
|
|
|
2019-05-05 23:18:41 +00:00
|
|
|
struct st_rs41config {
|
|
|
|
int agcbw;
|
|
|
|
int rxbw;
|
|
|
|
};
|
2019-06-02 19:19:57 +00:00
|
|
|
struct st_rs92config {
|
|
|
|
int rxbw;
|
|
|
|
int alt2d;
|
|
|
|
};
|
|
|
|
struct st_dfmconfig {
|
|
|
|
int agcbw;
|
|
|
|
int rxbw;
|
|
|
|
};
|
2020-12-30 02:35:49 +00:00
|
|
|
struct st_m10m20config {
|
|
|
|
int agcbw;
|
|
|
|
int rxbw;
|
|
|
|
};
|
2021-04-02 21:02:12 +00:00
|
|
|
struct st_mp3hconfig {
|
|
|
|
int agcbw;
|
|
|
|
int rxbw;
|
|
|
|
};
|
2019-05-05 23:18:41 +00:00
|
|
|
|
2019-11-02 12:18:17 +00:00
|
|
|
|
|
|
|
enum IDTYPE { ID_DFMDXL, ID_DFMGRAW, ID_DFMAUTO };
|
|
|
|
|
|
|
|
struct st_feedinfo {
|
|
|
|
bool active;
|
|
|
|
int type; // 0:UDP(axudp), 1:TCP(aprs.fi)
|
|
|
|
char host[64];
|
|
|
|
int port;
|
|
|
|
char symbol[3];
|
|
|
|
int lowrate;
|
|
|
|
int highrate;
|
|
|
|
int lowlimit;
|
|
|
|
int idformat; // 0: dxl 1: real 2: auto
|
|
|
|
};
|
|
|
|
|
|
|
|
// maybe extend for external Bluetooth interface?
|
|
|
|
// internal bluetooth consumes too much memory
|
|
|
|
struct st_kisstnc {
|
|
|
|
bool active;
|
|
|
|
int idformat;
|
|
|
|
};
|
|
|
|
|
2020-11-25 10:01:18 +00:00
|
|
|
struct st_mqtt {
|
2020-11-26 07:33:58 +00:00
|
|
|
int active;
|
2020-11-25 10:01:18 +00:00
|
|
|
char id[64];
|
|
|
|
char host[64];
|
|
|
|
int port;
|
|
|
|
char username[64];
|
|
|
|
char password[64];
|
|
|
|
char prefix[64];
|
|
|
|
};
|
2019-11-02 12:18:17 +00:00
|
|
|
|
2021-04-22 14:55:46 +00:00
|
|
|
struct st_sondehub {
|
|
|
|
int active;
|
2021-06-14 01:55:26 +00:00
|
|
|
int chase;
|
2021-04-22 14:55:46 +00:00
|
|
|
char host[64];
|
|
|
|
char callsign[64];
|
2021-08-10 22:29:29 +00:00
|
|
|
double lat;
|
|
|
|
double lon;
|
2021-04-22 14:55:46 +00:00
|
|
|
char alt[20];
|
|
|
|
char antenna[64];
|
2021-05-14 08:57:43 +00:00
|
|
|
char email[64];
|
2021-04-22 14:55:46 +00:00
|
|
|
};
|
|
|
|
|
2019-04-15 18:28:50 +00:00
|
|
|
typedef struct st_rdzconfig {
|
2019-10-18 13:22:43 +00:00
|
|
|
// hardware configuration
|
2019-05-24 21:49:50 +00:00
|
|
|
int button_pin; // PIN port number menu button (+128 for touch mode)
|
|
|
|
int button2_pin; // PIN port number menu button (+128 for touch mode)
|
2020-01-31 18:33:55 +00:00
|
|
|
int button2_axp; // Use AXP192 power button as button2
|
2019-05-25 08:49:26 +00:00
|
|
|
int touch_thresh; // Threshold value (0..100) for touch input button
|
2019-04-26 17:21:11 +00:00
|
|
|
int led_pout; // POUT port number of LED (used as serial monitor)
|
2019-10-18 13:22:43 +00:00
|
|
|
int power_pout; // Power control pin (for Heltec v2)
|
2019-09-29 13:50:35 +00:00
|
|
|
int disptype; // 0=OLED; 1=ILI9225
|
|
|
|
int oled_sda; // OLED/TFT data pin
|
|
|
|
int oled_scl; // OLED/TFT clock pin
|
|
|
|
int oled_rst; // OLED/TFT reset pin
|
|
|
|
int tft_rs; // TFT RS pin
|
|
|
|
int tft_cs; // TFT CS pin
|
2019-10-27 14:36:25 +00:00
|
|
|
int tft_orient; // TFT orientation (default: 1)
|
2021-08-06 20:11:46 +00:00
|
|
|
int tft_spifreq; // SPI transfer speed (default 40M is out of spec for some TFT)
|
2019-06-08 06:47:57 +00:00
|
|
|
int gps_rxd; // GPS module RXD pin. We expect 9600 baud NMEA data.
|
|
|
|
int gps_txd; // GPS module TXD pin
|
2019-10-18 13:22:43 +00:00
|
|
|
// software configuration
|
2019-04-23 11:08:02 +00:00
|
|
|
int debug; // show port and config options after reboot
|
|
|
|
int wifi; // connect to known WLAN 0=skip
|
|
|
|
int wifiap; // enable/disable WiFi AccessPoint mode 0=disable
|
2020-11-30 14:44:49 +00:00
|
|
|
int screenfile;
|
2019-10-18 21:29:43 +00:00
|
|
|
int8_t display[30]; // list of display mode (0:scanner, 1:default, 2,... additional modes)
|
2019-04-23 11:08:02 +00:00
|
|
|
int startfreq; // spectrum display start freq (400, 401, ...)
|
|
|
|
int channelbw; // spectrum channel bandwidth (valid: 5, 10, 20, 25, 50, 100 kHz)
|
2019-10-18 13:22:43 +00:00
|
|
|
int spectrum; // show freq spectrum for n seconds -1=disable; 0=forever
|
2019-04-23 11:08:02 +00:00
|
|
|
int marker; // show freq marker in spectrum 0=disable
|
|
|
|
int maxsonde; // number of max sonde in scan (range=1-99)
|
2019-05-05 23:18:41 +00:00
|
|
|
int norx_timeout; // Time after which rx mode switches to scan mode (without rx signal)
|
2019-04-15 18:28:50 +00:00
|
|
|
int noisefloor; // for spectrum display
|
2019-12-21 17:41:34 +00:00
|
|
|
char mdnsname[15]; // mDNS-Name, defaults to rdzsonde
|
2019-10-18 13:22:43 +00:00
|
|
|
// receiver configuration
|
2019-05-06 15:25:54 +00:00
|
|
|
int freqofs; // frequency offset (tuner config = rx frequency + freqofs) in Hz
|
2019-05-05 23:18:41 +00:00
|
|
|
struct st_rs41config rs41; // configuration options specific for RS41 receiver
|
2019-06-02 19:19:57 +00:00
|
|
|
struct st_rs92config rs92;
|
|
|
|
struct st_dfmconfig dfm;
|
2020-12-30 02:35:49 +00:00
|
|
|
struct st_m10m20config m10m20;
|
2021-04-02 21:02:12 +00:00
|
|
|
struct st_mp3hconfig mp3h;
|
2021-02-05 15:51:26 +00:00
|
|
|
char ephftp[40];
|
2019-10-18 13:22:43 +00:00
|
|
|
// data feed configuration
|
2019-04-15 18:28:50 +00:00
|
|
|
// for now, one feed for each type is enough, but might get extended to more?
|
2019-11-02 12:18:17 +00:00
|
|
|
char call[10]; // APRS callsign
|
2019-10-18 13:22:43 +00:00
|
|
|
char passcode[9]; // APRS passcode
|
2019-04-15 18:28:50 +00:00
|
|
|
struct st_feedinfo udpfeed; // target for AXUDP messages
|
|
|
|
struct st_feedinfo tcpfeed; // target for APRS-IS TCP connections
|
2019-09-11 18:53:58 +00:00
|
|
|
struct st_kisstnc kisstnc; // target for KISS TNC (via TCP, mainly for APRSdroid)
|
2020-11-25 10:01:18 +00:00
|
|
|
struct st_mqtt mqtt;
|
2021-04-22 14:55:46 +00:00
|
|
|
struct st_sondehub sondehub;
|
2019-04-15 18:28:50 +00:00
|
|
|
} RDZConfig;
|
|
|
|
|
2019-04-05 18:05:18 +00:00
|
|
|
|
2019-04-23 11:08:02 +00:00
|
|
|
#define MAXSONDE 99
|
2019-04-03 15:16:51 +00:00
|
|
|
|
2019-10-13 16:14:33 +00:00
|
|
|
extern int fingerprintValue[];
|
|
|
|
extern const char *fingerprintText[];
|
|
|
|
|
2019-04-03 15:16:51 +00:00
|
|
|
class Sonde
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
public:
|
2019-04-15 18:28:50 +00:00
|
|
|
RDZConfig config;
|
2019-10-13 16:14:33 +00:00
|
|
|
int fingerprint = 0;
|
2019-04-09 22:29:11 +00:00
|
|
|
int currentSonde = 0;
|
2019-04-08 17:22:08 +00:00
|
|
|
int nSonde;
|
2019-10-13 16:14:33 +00:00
|
|
|
String ipaddr;
|
|
|
|
bool isAP;
|
2019-06-02 09:28:00 +00:00
|
|
|
// moved to heap, saving space in .bss
|
|
|
|
//SondeInfo sondeList[MAXSONDE+1];
|
|
|
|
SondeInfo *sondeList;
|
2019-04-08 17:22:08 +00:00
|
|
|
|
2019-04-15 18:59:30 +00:00
|
|
|
Sonde();
|
2019-10-13 17:20:23 +00:00
|
|
|
void defaultConfig();
|
2019-04-16 15:51:41 +00:00
|
|
|
void setConfig(const char *str);
|
2019-04-15 18:59:30 +00:00
|
|
|
|
2019-04-05 18:05:18 +00:00
|
|
|
void clearSonde();
|
2019-04-23 11:08:02 +00:00
|
|
|
void addSonde(float frequency, SondeType type, int active, char *launchsite);
|
2019-04-05 18:05:18 +00:00
|
|
|
void nextConfig();
|
2019-05-30 20:19:45 +00:00
|
|
|
void nextRxSonde();
|
2019-11-10 11:04:59 +00:00
|
|
|
void nextRxFreq(int addkhz);
|
2019-04-05 18:05:18 +00:00
|
|
|
|
2019-05-30 20:19:45 +00:00
|
|
|
/* new interface */
|
|
|
|
void setup();
|
|
|
|
void receive();
|
|
|
|
uint16_t waitRXcomplete();
|
|
|
|
/* old and temp interface */
|
|
|
|
#if 0
|
|
|
|
void processRXbyte(uint8_t data);
|
2019-04-05 18:05:18 +00:00
|
|
|
int receiveFrame();
|
2019-05-30 20:19:45 +00:00
|
|
|
#endif
|
|
|
|
|
2019-04-05 18:05:18 +00:00
|
|
|
SondeInfo *si();
|
|
|
|
|
2019-06-08 06:47:57 +00:00
|
|
|
uint8_t timeoutEvent(SondeInfo *si);
|
|
|
|
uint8_t updateState(uint8_t event);
|
2019-05-24 21:49:50 +00:00
|
|
|
|
2019-04-03 15:16:51 +00:00
|
|
|
void updateDisplayPos();
|
|
|
|
void updateDisplayPos2();
|
|
|
|
void updateDisplayID();
|
|
|
|
void updateDisplayRSSI();
|
|
|
|
void updateDisplayRXConfig();
|
2019-04-05 18:05:18 +00:00
|
|
|
void updateStat();
|
|
|
|
void updateDisplayIP();
|
2019-04-03 15:16:51 +00:00
|
|
|
void updateDisplay();
|
2019-04-05 18:05:18 +00:00
|
|
|
void clearDisplay();
|
2019-10-13 16:14:33 +00:00
|
|
|
|
|
|
|
void setIP(String ip, bool isAP);
|
2019-04-03 15:16:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Sonde sonde;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|