Skip to content

Commit

Permalink
Low-end ESP8266 SkyWatch firmware is re-branded as SoftRF WebTop (WT)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jun 3, 2020
1 parent b6a65f1 commit dade4f6
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 56 deletions.
7 changes: 4 additions & 3 deletions software/firmware/source/SkyWatch/BluetoothHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@

#include "esp_gap_bt_api.h"

#include "WiFiHelper.h" // HOSTNAME

BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;

cbuf *BLE_FIFO_RX, *BLE_FIFO_TX;
BluetoothSerial SerialBT;
String BT_name = HOSTNAME;
String BT_name;

static unsigned long BLE_Notify_TimeMarker = 0;
static unsigned long BLE_Advertising_TimeMarker = 0;
Expand Down Expand Up @@ -83,6 +81,9 @@ class MyCallbacks: public BLECharacteristicCallbacks {
static void ESP32_Bluetooth_setup()
{

BT_name += hw_info.model == SOFTRF_MODEL_SKYWATCH ?
SKYWATCH_IDENT : SOFTRF_IDENT;
BT_name += "-";
BT_name += String(SoC->getChipId() & 0x00FFFFFFU, HEX);

switch(settings->s.bluetooth)
Expand Down
7 changes: 7 additions & 0 deletions software/firmware/source/SkyWatch/NMEAHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,13 @@ bool NMEA_hasFLARM()
return (S_RX.isValid() && S_RX.age() < NMEA_EXP_TIME);
}

bool NMEA_has3DFix()
{
return (S_GPS.isValid() &&
S_GPS.age() < NMEA_EXP_TIME &&
NMEA_Status.GPS == GNSS_STATUS_3D_MOVING);
}

void NMEA_Out(byte *buf, size_t size, bool nl)
{
switch(settings->s.nmea_out)
Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SkyWatch/NMEAHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ bool NMEA_Save_Settings(void);
bool NMEA_isConnected(void);
bool NMEA_hasGNSS(void);
bool NMEA_hasFLARM(void);
bool NMEA_has3DFix(void);
void NMEA_Out(byte *, size_t, bool);
void NMEA_fini();

Expand Down
5 changes: 3 additions & 2 deletions software/firmware/source/SkyWatch/SkyWatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
#include <Arduino.h>
#endif /* ARDUINO */

#define SKYWATCH_FIRMWARE_VERSION "0.9"
#define SKYWATCH_IDENT "SkyWatch-"
#define SKYWATCH_FIRMWARE_VERSION "1.0-rc7"
#define SKYWATCH_IDENT "SkyWatch"
#define SOFTRF_IDENT "SoftRF"

#define DEFAULT_AP_SSID "SoftRF-abc123"
#define DEFAULT_AP_PSK "12345678"
Expand Down
10 changes: 8 additions & 2 deletions software/firmware/source/SkyWatch/SkyWatch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ void setup()
Serial.println();

Serial.println();
Serial.print(F(SKYWATCH_IDENT));
Serial.print(hw_info.model == SOFTRF_MODEL_SKYWATCH ?
F(SKYWATCH_IDENT "-") : F(SOFTRF_IDENT "-"));
Serial.print(SoC->name);
Serial.print(F(" FW.REV: " SKYWATCH_FIRMWARE_VERSION " DEV.ID: "));
Serial.println(String(SoC->getChipId(), HEX));
Expand Down Expand Up @@ -145,9 +146,12 @@ void setup()

void loop()
{
#if defined(EXPERIMENTAL)
if (inServiceMode) {
service_loop();
} else {
} else
#endif /* EXPERIMENTAL */
{
normal_loop();
}
}
Expand Down Expand Up @@ -191,6 +195,7 @@ void normal_loop()
yield();
}

#if defined(EXPERIMENTAL)
void service_loop()
{
bool bypass_inactive = true;
Expand Down Expand Up @@ -220,6 +225,7 @@ void service_loop()
// Battery_loop();
}
}
#endif /* EXPERIMENTAL */

void shutdown(const char *msg)
{
Expand Down
113 changes: 67 additions & 46 deletions software/firmware/source/SkyWatch/WebHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,36 +959,56 @@ void handleStatus() {

snprintf_P ( offset, size,
PSTR("<html>\
<head>\
<meta name='viewport' content='width=device-width, initial-scale=1'>\
<title>SkyWatch status</title>\
</head>\
<head>\
<meta name='viewport' content='width=device-width, initial-scale=1'>\
<title>%s status</title>\
</head>\
<body>\
<table width=100%%>\
<table width=100%%>\
<tr><!-- <td align=left><h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h1></td> -->\
<td align=center><h1>SkyWatch status</h1></td>\
<td align=center><h1>%s status</h1></td>\
<!-- <td align=right><img src='/logo.png'></td> --></tr>\
</table>\
<table width=100%%>\
<tr><th align=left>Device Id</th><td align=right>%X</td></tr>\
<tr><th align=left>Software Version</th><td align=right>%s&nbsp;&nbsp;%s</td></tr>\
<tr><th align=left>Uptime</th><td align=right>%02d:%02d:%02d</td></tr>\
<tr><th align=left>Free memory</th><td align=right>%u</td></tr>\
<tr><th align=left>Battery voltage</th><td align=right><font color=%s>%s</font></td></tr>\
<tr><th align=left>&nbsp;</th><td align=right>&nbsp;</td></tr>\
<tr><th align=left>Display</th><td align=right>%s</td></tr>\
<tr><th align=left>Storage</th><td align=right>%s</td></tr>\
<tr><th align=left>Baro</th><td align=right>%s</td></tr>\
<tr><th align=left>Connection type</th><td align=right>%s</td></tr>"),
</table>\
<table width=100%%>\
<tr><th align=left>Device Id</th><td align=right>%X</td></tr>\
<tr><th align=left>Software Version</th><td align=right>%s&nbsp;&nbsp;%s</td></tr>\
<tr><th align=left>Uptime</th><td align=right>%02d:%02d:%02d</td></tr>\
<tr><th align=left>Free memory</th><td align=right>%u</td></tr>\
<tr><th align=left>Battery voltage</th><td align=right><font color=%s>%s</font></td></tr>\
<tr><th align=left>&nbsp;</th><td align=right>&nbsp;</td></tr>"),
hw_info.model == SOFTRF_MODEL_SKYWATCH ? SKYWATCH_IDENT : SOFTRF_IDENT " WT",
hw_info.model == SOFTRF_MODEL_SKYWATCH ? SKYWATCH_IDENT : SOFTRF_IDENT " WT",
SoC->getChipId() & 0xFFFFFF, SKYWATCH_FIRMWARE_VERSION,
(SoC == NULL ? "NONE" : SoC->name),
hr, min % 60, sec % 60, ESP.getFreeHeap(),
low_voltage ? "red" : "green", str_Vcc,
hw_info.display == DISPLAY_EPD_2_7 ? "e-Paper" :
hw_info.display == DISPLAY_OLED_2_4 ? "OLED" :
hw_info.display == DISPLAY_TFT_TTGO ? "LCD" : "NONE",
hw_info.storage == STORAGE_uSD ? "uSD" : "NONE",
(baro_chip == NULL ? "NONE" : baro_chip->name),
low_voltage ? "red" : "green", str_Vcc
);

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

if (hw_info.model == SOFTRF_MODEL_SKYWATCH) {

snprintf_P ( offset, size,
PSTR("\
<tr><th align=left>Display</th><td align=right>%s</td></tr>\
<tr><th align=left>Storage</th><td align=right>%s</td></tr>\
<tr><th align=left>Baro</th><td align=right>%s</td></tr>"),
hw_info.display == DISPLAY_EPD_2_7 ? "e-Paper" :
hw_info.display == DISPLAY_OLED_2_4 ? "OLED" :
hw_info.display == DISPLAY_TFT_TTGO ? "LCD" : "NONE",
hw_info.storage == STORAGE_uSD ? "uSD" : "NONE",
(baro_chip == NULL ? "NONE" : baro_chip->name)
);

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

snprintf_P ( offset, size,
PSTR("<tr><th align=left>Connection type</th><td align=right>%s</td></tr>"),
settings->m.connection == CON_SERIAL_MAIN ? "Main Serial" :
settings->m.connection == CON_SERIAL_AUX ? "AUX Serial" :
settings->m.connection == CON_BLUETOOTH ? "Bluetooth" :
Expand All @@ -1004,9 +1024,9 @@ void handleStatus() {
case CON_WIFI_UDP:
snprintf_P ( offset, size,
PSTR("\
<tr><th align=left>Link partner</th><td align=right>%s</td></tr>\
<tr><th align=left>Link status</th><td align=right>%s established</td></tr>\
<tr><th align=left>Assigned IP address</th><td align=right>%s</td></tr>"),
<tr><th align=left>Link partner</th><td align=right>%s</td></tr>\
<tr><th align=left>Link status</th><td align=right>%s established</td></tr>\
<tr><th align=left>Assigned IP address</th><td align=right>%s</td></tr>"),
settings->m.ssid && strlen(settings->m.ssid) > 0 ? settings->m.ssid : "NOT SET",
WiFi.status() == WL_CONNECTED ? "" : "not",
WiFi.localIP().toString().c_str()
Expand All @@ -1022,9 +1042,8 @@ void handleStatus() {
case PROTOCOL_GDL90:
snprintf_P ( offset, size,
PSTR("\
<tr><th align=left>Connection status</th><td align=right>%s connected</td></tr>\
<tr><th align=left>Data type</th><td align=right>%s %s</td></tr>\
"),
<tr><th align=left>Connection status</th><td align=right>%s connected</td></tr>\
<tr><th align=left>Data type</th><td align=right>%s %s</td></tr>"),
GDL90_isConnected() ? "" : "not",
GDL90_isConnected() && !GDL90_hasHeartBeat() ? "UNK" : "",
GDL90_hasHeartBeat() ? "GDL90" : ""
Expand All @@ -1034,22 +1053,23 @@ void handleStatus() {
default:
snprintf_P ( offset, size,
PSTR("\
<tr><th align=left>Connection status</th><td align=right>%s connected</td></tr>\
<tr><th align=left>Data type</th><td align=right>%s %s %s</td></tr>\
<tr><th align=left>Slave Id</th><td align=right>%X</td></tr>\
<tr><th align=left>RF protocol</th><td align=right>%s</td></tr>\
</table>\
<table width=100%%>\
<tr><th align=left>Packets</th>\
<td align=right><table><tr>\
<th align=left>Tx&nbsp;&nbsp;</th><td align=right>%u</td>\
<th align=left>&nbsp;&nbsp;&nbsp;&nbsp;Rx&nbsp;&nbsp;</th><td align=right>%u</td>\
</tr></table></td></tr>\
"),
<tr><th align=left>Connection status</th><td align=right>%s connected</td></tr>\
<tr><th align=left>Data type</th><td align=right>%s %s %s</td></tr>\
<tr><th align=left>GNSS fix</th><td align=right>%s</td></tr>\
<tr><th align=left>Slave Id</th><td align=right>%X</td></tr>\
<tr><th align=left>RF protocol</th><td align=right>%s</td></tr>\
</table>\
<table width=100%%>\
<tr><th align=left>Packets</th>\
<td align=right><table><tr>\
<th align=left>Tx&nbsp;&nbsp;</th><td align=right>%u</td>\
<th align=left>&nbsp;&nbsp;&nbsp;&nbsp;Rx&nbsp;&nbsp;</th><td align=right>%u</td>\
</tr></table></td></tr>"),
NMEA_isConnected() ? "" : "not",
NMEA_isConnected() && !(NMEA_hasGNSS() || NMEA_hasFLARM()) ? "UNK" : "",
NMEA_hasGNSS() ? "GNSS" : "",
NMEA_hasFLARM() ? "FLARM" : "",
NMEA_has3DFix() ? "3D" : "NONE",
ThisDevice.addr,
ThisDevice.protocol == RF_PROTOCOL_LEGACY ? "Legacy" :
ThisDevice.protocol == RF_PROTOCOL_OGNTP ? "OGNTP" :
Expand All @@ -1071,14 +1091,14 @@ void handleStatus() {

snprintf_P ( offset, size,
PSTR(" </table>\
<hr>\
<table width=100%%>\
<hr>\
<table width=100%%>\
<tr>\
<td align=left><input type=button onClick=\"location.href='/settings'\" value='Settings'></td>\
<td align=center><input type=button onClick=\"location.href='/about'\" value='About'></td>\
<td align=right><input type=button onClick=\"location.href='/firmware'\" value='Firmware update'></td>\
</tr>\
</table>\
</table>\
</body>\
</html>")
);
Expand Down Expand Up @@ -1179,7 +1199,7 @@ PSTR("<html>\
<head>\
<meta http-equiv='refresh' content='15; url=/'>\
<meta name='viewport' content='width=device-width, initial-scale=1'>\
<title>SkyWatch Settings</title>\
<title>%s Settings</title>\
</head>\
<body>\
<h1 align=center>New settings:</h1>\
Expand Down Expand Up @@ -1225,6 +1245,7 @@ PSTR("<html>\
<p align=center><h1 align=center>Restart is in progress... Please, wait!</h1></p>\
</body>\
</html>"),
hw_info.model == SOFTRF_MODEL_SKYWATCH ? SKYWATCH_IDENT : SOFTRF_IDENT " WT",
settings->s.mode, settings->s.rf_protocol, settings->s.band,
settings->s.aircraft_type, settings->s.alarm, settings->s.txpower,
settings->s.volume, settings->s.pointer, settings->s.bluetooth,
Expand Down
5 changes: 4 additions & 1 deletion software/firmware/source/SkyWatch/WiFiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
String station_ssid = MY_ACCESSPOINT_SSID ;
String station_psk = MY_ACCESSPOINT_PSK ;

String host_name = HOSTNAME;
String host_name;

IPAddress local_IP(192,168,1,1);
IPAddress gateway(192,168,1,1);
Expand Down Expand Up @@ -212,6 +212,9 @@ void WiFi_setup()
}

// Set Hostname.
host_name += hw_info.model == SOFTRF_MODEL_SKYWATCH ?
SKYWATCH_IDENT : SOFTRF_IDENT;
host_name += "-";
host_name += String((SoC->getChipId() & 0xFFFFFF), HEX);
SoC->WiFi_hostname(host_name);

Expand Down
2 changes: 0 additions & 2 deletions software/firmware/source/SkyWatch/WiFiHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include "SoCHelper.h"

#define HOSTNAME "SkyWatch-"
#define UDP_PACKET_BUFSIZE 256

enum
Expand All @@ -39,7 +38,6 @@ void WiFi_setup(void);
void WiFi_loop(void);
void WiFi_fini(void);

extern String host_name;
#if defined(ARDUINO) && !defined(ENERGIA_ARCH_CC13XX)
extern WiFiUDP Uni_Udp;
#endif
Expand Down

0 comments on commit dade4f6

Please sign in to comment.