Skip to content

Commit

Permalink
SkyWatch: use of LilyGO T-Watch as a Uni or Dongle companion device
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jun 22, 2020
1 parent 24c2fb1 commit 32df032
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 49 deletions.
9 changes: 4 additions & 5 deletions software/firmware/source/SkyWatch/Platform_ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,10 @@ static int ESP32_WiFi_clients_count()
static void ESP32_swSer_begin(unsigned long baud)
{
if (settings->m.connection == CON_SERIAL_MAIN) {
SerialInput.begin(
baud,
hw_info.model == SOFTRF_MODEL_SKYWATCH ? SERIAL_IN_BITS : SERIAL_8N1,
SOC_GPIO_PIN_GNSS_RX,
SOC_GPIO_PIN_GNSS_TX);
uint32_t config = hw_info.model == SOFTRF_MODEL_SKYWATCH &&
baud == SERIAL_IN_BR ?
SERIAL_IN_BITS : SERIAL_8N1;
SerialInput.begin(baud, config, SOC_GPIO_PIN_GNSS_RX, SOC_GPIO_PIN_GNSS_TX);
} else {
Serial.updateBaudRate(baud);
}
Expand Down
40 changes: 40 additions & 0 deletions software/firmware/source/SkyWatch/SkyWatch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,26 @@ void setup()
break;
}

/* If a Dongle is connected - try to wake it up */
if (settings->m.protocol == PROTOCOL_NMEA) {
const char *on_msg = "$PSRFC,?*47\r\n";

switch (settings->m.connection)
{
case CON_SERIAL_MAIN:
SerialInput.write(on_msg);
SerialInput.flush();
break;
case CON_SERIAL_AUX:
Serial.write(on_msg);
Serial.flush();
break;
case CON_NONE:
default:
break;
}
}

SoC->WDT_setup();
}

Expand Down Expand Up @@ -231,6 +251,26 @@ void shutdown(const char *msg)
{
SoC->WDT_fini();

/* If a Dongle is connected - try to shut it down */
if (settings->m.protocol == PROTOCOL_NMEA) {
const char *off_msg = "$PSRFC,OFF*37\r\n";

switch (settings->m.connection)
{
case CON_SERIAL_MAIN:
SerialInput.write(off_msg);
SerialInput.flush();
break;
case CON_SERIAL_AUX:
Serial.write(off_msg);
Serial.flush();
break;
case CON_NONE:
default:
break;
}
}

NMEA_fini();

Web_fini();
Expand Down
79 changes: 35 additions & 44 deletions software/firmware/source/SkyWatch/WebHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,7 @@ void handleSettings() {
<body>\
<h1 align=center>Settings</h1>\
<form action='/input' method='GET'>\
<table width=100%%>"));

len = strlen(offset);
offset += len;
size -= len;

if (hw_info.model == SOFTRF_MODEL_WEBTOP) {
/* SoC specific part 6 */
snprintf_P ( offset, size,
PSTR("\
<table width=100%%>\
<tr>\
<th align=left>Connection port</th>\
<td align=right>\
Expand Down Expand Up @@ -249,45 +240,44 @@ void handleSettings() {
<option %s value='%d'>19200</option>\
<option %s value='%d'>38400</option>\
<option %s value='%d'>57600</option>"),
(settings->m.connection == CON_SERIAL_MAIN ? "selected" : ""), CON_SERIAL_MAIN,
(settings->m.connection == CON_SERIAL_AUX ? "selected" : ""), CON_SERIAL_AUX,
(settings->m.connection == CON_WIFI_UDP ? "selected" : ""), CON_WIFI_UDP,
(settings->m.connection == CON_BLUETOOTH ? "selected" : ""), CON_BLUETOOTH,
(settings->m.protocol == PROTOCOL_NMEA ? "selected" : ""), PROTOCOL_NMEA,
(settings->m.protocol == PROTOCOL_GDL90 ? "selected" : ""), PROTOCOL_GDL90,
(settings->m.baudrate == B4800 ? "selected" : ""), B4800,
(settings->m.baudrate == B9600 ? "selected" : ""), B9600,
(settings->m.baudrate == B19200 ? "selected" : ""), B19200,
(settings->m.baudrate == B38400 ? "selected" : ""), B38400,
(settings->m.baudrate == B57600 ? "selected" : ""), B57600
);
(settings->m.connection == CON_SERIAL_MAIN ? "selected" : ""), CON_SERIAL_MAIN,
(settings->m.connection == CON_SERIAL_AUX ? "selected" : ""), CON_SERIAL_AUX,
(settings->m.connection == CON_WIFI_UDP ? "selected" : ""), CON_WIFI_UDP,
(settings->m.connection == CON_BLUETOOTH ? "selected" : ""), CON_BLUETOOTH,
(settings->m.protocol == PROTOCOL_NMEA ? "selected" : ""), PROTOCOL_NMEA,
(settings->m.protocol == PROTOCOL_GDL90 ? "selected" : ""), PROTOCOL_GDL90,
(settings->m.baudrate == B4800 ? "selected" : ""), B4800,
(settings->m.baudrate == B9600 ? "selected" : ""), B9600,
(settings->m.baudrate == B19200 ? "selected" : ""), B19200,
(settings->m.baudrate == B38400 ? "selected" : ""), B38400,
(settings->m.baudrate == B57600 ? "selected" : ""), B57600
);

len = strlen(offset);
offset += len;
size -= len;
len = strlen(offset);
offset += len;
size -= len;

/* SoC specific part 7 */
if (SoC->id == SOC_ESP32) {
snprintf_P ( offset, size,
PSTR("\
/* SoC specific part 1 */
if (SoC->id == SOC_ESP32) {
snprintf_P ( offset, size,
PSTR("\
<option %s value='%d'>115200</option>\
<option %s value='%d'>2000000</option>"),
(settings->m.baudrate == B115200 ? "selected" : ""), B115200,
(settings->m.baudrate == B2000000 ? "selected" : ""), B2000000
);
len = strlen(offset);
offset += len;
size -= len;
}

snprintf_P ( offset, size,
PSTR("</select></td></tr><tr><th>&nbsp;</th><td>&nbsp;</td></tr>"));

(settings->m.baudrate == B115200 ? "selected" : ""), B115200,
(settings->m.baudrate == B2000000 ? "selected" : ""), B2000000
);
len = strlen(offset);
offset += len;
size -= len;
}

snprintf_P ( offset, size,
PSTR("</select></td></tr><tr><th>&nbsp;</th><td>&nbsp;</td></tr>"));

len = strlen(offset);
offset += len;
size -= len;

#if 0
/* Common part 2 */
snprintf_P ( offset, size,
Expand Down Expand Up @@ -1071,10 +1061,11 @@ void handleStatus() {
NMEA_hasFLARM() ? "FLARM" : "",
NMEA_has3DFix() ? "3D" : "NONE",
ThisDevice.addr,
ThisDevice.protocol == RF_PROTOCOL_LEGACY ? "Legacy" :
ThisDevice.protocol == RF_PROTOCOL_OGNTP ? "OGNTP" :
ThisDevice.protocol == RF_PROTOCOL_P3I ? "P3I" :
ThisDevice.protocol == RF_PROTOCOL_FANET ? "FANET" : "UNK",
ThisDevice.protocol == RF_PROTOCOL_LEGACY ? "Legacy" :
ThisDevice.protocol == RF_PROTOCOL_OGNTP ? "OGNTP" :
ThisDevice.protocol == RF_PROTOCOL_P3I ? "P3I" :
ThisDevice.protocol == RF_PROTOCOL_ADSB_UAT ? "UAT" :
ThisDevice.protocol == RF_PROTOCOL_FANET ? "FANET" : "UNK",
tx_packets_counter, rx_packets_counter
);
break;
Expand Down

0 comments on commit 32df032

Please sign in to comment.