Skip to content

Commit

Permalink
Bringup of SkyWatch on generic ESP8266 hardware is completed: WiFi, W…
Browse files Browse the repository at this point in the history
…ebUI, SoftRF 'slave' (Uni or Dongle) settings change, NMEA UDP transfer are doing good.
  • Loading branch information
lyusupov committed Jun 2, 2020
1 parent f0993ea commit b6a65f1
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 57 deletions.
2 changes: 1 addition & 1 deletion software/firmware/source/SkyWatch/EEPROMHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void EEPROM_defaults()
/* SkyView defaults */
eeprom_block.field.settings.m.adapter = ADAPTER_NONE;

eeprom_block.field.settings.m.connection = CON_SERIAL;
eeprom_block.field.settings.m.connection = CON_SERIAL_MAIN;
if (hw_info.model == SOFTRF_MODEL_SKYWATCH) {
eeprom_block.field.settings.m.baudrate = B115200; /* S76G AN3155 BR */
} else {
Expand Down
20 changes: 9 additions & 11 deletions software/firmware/source/SkyWatch/GDL90Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ void GDL90_setup()

switch (settings->m.connection)
{
case CON_SERIAL:
case CON_SERIAL_MAIN:
case CON_SERIAL_AUX:
uint32_t SerialBaud;

switch (settings->m.baudrate)
Expand Down Expand Up @@ -271,24 +272,21 @@ void GDL90_loop()

switch (settings->m.connection)
{
case CON_SERIAL:
case CON_SERIAL_MAIN:
while (SerialInput.available() > 0) {
char c = SerialInput.read();
// Serial.print(c);
GDL90_Parse_Character(c);
GDL90_Data_TimeMarker = millis();
}
break;
case CON_SERIAL_AUX:
/* read data from microUSB port */
#if !defined(RASPBERRY_PI)
if (Serial != SerialInput)
#endif
{
while (Serial.available() > 0) {
char c = Serial.read();
while (Serial.available() > 0) {
char c = Serial.read();
// Serial.print(c);
GDL90_Parse_Character(c);
GDL90_Data_TimeMarker = millis();
}
GDL90_Parse_Character(c);
GDL90_Data_TimeMarker = millis();
}
break;
case CON_WIFI_UDP:
Expand Down
20 changes: 9 additions & 11 deletions software/firmware/source/SkyWatch/NMEAHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ void NMEA_setup()
if (settings->m.protocol == PROTOCOL_NMEA) {
switch (settings->m.connection)
{
case CON_SERIAL:
case CON_SERIAL_MAIN:
case CON_SERIAL_AUX:
uint32_t SerialBaud;

switch (settings->m.baudrate)
Expand Down Expand Up @@ -343,24 +344,21 @@ void NMEA_loop()

switch (settings->m.connection)
{
case CON_SERIAL:
case CON_SERIAL_MAIN:
while (SerialInput.available() > 0) {
c = SerialInput.read();
// Serial.print(c);
NMEA_Parse_Character(c);
NMEA_TimeMarker = millis();
}
break;
case CON_SERIAL_AUX:
/* read data from Type-C USB port */
#if !defined(RASPBERRY_PI)
if ((void *) &Serial != (void *) &SerialInput)
#endif
{
while (Serial.available() > 0) {
c = Serial.read();
while (Serial.available() > 0) {
c = Serial.read();
// Serial.print(c);
NMEA_Parse_Character(c);
NMEA_TimeMarker = millis();
}
NMEA_Parse_Character(c);
NMEA_TimeMarker = millis();
}
break;
case CON_WIFI_UDP:
Expand Down
14 changes: 9 additions & 5 deletions software/firmware/source/SkyWatch/Platform_ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,15 @@ static int ESP32_WiFi_clients_count()

static void ESP32_swSer_begin(unsigned long baud)
{
SerialInput.begin(
baud,
hw_info.model == SOFTRF_MODEL_SKYWATCH ? SERIAL_IN_BITS : SERIAL_8N1,
SOC_GPIO_PIN_GNSS_RX,
SOC_GPIO_PIN_GNSS_TX);
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);
} else {
Serial.updateBaudRate(baud);
}
}

static void ESP32_swSer_enableRx(boolean arg)
Expand Down
4 changes: 4 additions & 0 deletions software/firmware/source/SkyWatch/Platform_ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ static int ESP8266_WiFi_clients_count()
static void ESP8266_swSer_begin(unsigned long baud)
{
SerialInput.begin(baud, SERIAL_8N1);

if (settings->m.connection == CON_SERIAL_AUX) {
SerialInput.swap();
}
}

static void ESP8266_swSer_enableRx(boolean arg)
Expand Down
3 changes: 2 additions & 1 deletion software/firmware/source/SkyWatch/SkyWatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ enum
enum
{
CON_NONE,
CON_SERIAL,
CON_SERIAL_MAIN,
CON_SERIAL_AUX,
CON_WIFI_UDP,
CON_WIFI_TCP,
CON_BLUETOOTH
Expand Down
16 changes: 9 additions & 7 deletions software/firmware/source/SkyWatch/SkyWatch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ void setup()
SoC->Bluetooth->setup();
}

if (SoC->DB_init()) {
hw_info.storage = STORAGE_uSD;
}

Web_setup();
Traffic_setup();

Serial.flush();

switch (settings->m.protocol)
{
case PROTOCOL_GDL90:
Expand All @@ -131,13 +140,6 @@ void setup()
break;
}

if (SoC->DB_init()) {
hw_info.storage = STORAGE_uSD;
}

Web_setup();
Traffic_setup();

SoC->WDT_setup();
}

Expand Down
53 changes: 32 additions & 21 deletions software/firmware/source/SkyWatch/WebHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Copyright (C) 2019-2020     Linar Yusupov\
</body>\
</html>";

#if defined(EXPERIMENTAL)
static const char service_html[] PROGMEM = "<html>\
<head>\
<meta name='viewport' content='width=device-width, initial-scale=1'>\
Expand Down Expand Up @@ -184,6 +185,7 @@ void handleRoot() {
server.send_P ( 200, PSTR("text/html"), root_html);
SoC->swSer_enableRx(true);
}
#endif /* EXPERIMENTAL */

void handleSettings() {

Expand Down Expand Up @@ -219,11 +221,12 @@ void handleSettings() {
snprintf_P ( offset, size,
PSTR("\
<tr>\
<th align=left>Connection type</th>\
<th align=left>Connection port</th>\
<td align=right>\
<select name='connection'>\
<option %s value='%d'>Serial</option>\
<!-- <option %s value='%d'>WiFi UDP</option>\
<option %s value='%d'>MAIN</option>\
<option %s value='%d'>AUX</option>\
<!--<option %s value='%d'>WiFi UDP</option>\
<option %s value='%d'>Bluetooth SPP</option> -->\
</select>\
</td>\
Expand All @@ -246,16 +249,17 @@ 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 ? "selected" : ""), CON_SERIAL,
(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);
Expand Down Expand Up @@ -985,7 +989,8 @@ void handleStatus() {
hw_info.display == DISPLAY_TFT_TTGO ? "LCD" : "NONE",
hw_info.storage == STORAGE_uSD ? "uSD" : "NONE",
(baro_chip == NULL ? "NONE" : baro_chip->name),
settings->m.connection == CON_SERIAL ? "Serial" :
settings->m.connection == CON_SERIAL_MAIN ? "Main Serial" :
settings->m.connection == CON_SERIAL_AUX ? "AUX Serial" :
settings->m.connection == CON_BLUETOOTH ? "Bluetooth" :
settings->m.connection == CON_WIFI_UDP ? "WiFi" : "NONE"
);
Expand All @@ -1009,7 +1014,8 @@ void handleStatus() {
len = strlen(offset);
offset += len;
size -= len;
case CON_SERIAL:
case CON_SERIAL_MAIN:
case CON_SERIAL_AUX:
case CON_BLUETOOTH:
switch (settings->m.protocol)
{
Expand Down Expand Up @@ -1246,11 +1252,11 @@ PSTR("<html>\
}

void handleNotFound() {

#if defined(EXPERIMENTAL)
if (captivePortal()) { // If caprive portal redirect instead of displaying the page.
return;
}

#endif /* EXPERIMENTAL */
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
Expand All @@ -1269,10 +1275,14 @@ void handleNotFound() {

void Web_setup()
{
#if defined(EXPERIMENTAL)
server.on ( "/", handleRoot );
// server.on ( "/generate_204", handleRoot); // Android captive portal.
server.on ( "/fwlink", handleRoot); // Microsoft captive portal.
server.on ( "/status", handleStatus );
#else
server.on ( "/", handleStatus );
#endif /* EXPERIMENTAL */
server.on ( "/settings", handleSettings );
server.on ( "/about", []() {
SoC->swSer_enableRx(false);
Expand All @@ -1282,6 +1292,7 @@ void Web_setup()
server.send_P ( 200, PSTR("text/html"), about_html);
SoC->swSer_enableRx(true);
} );
#if defined(EXPERIMENTAL)
server.on ( "/service", []() {
SoC->swSer_enableRx(false);
server.sendHeader(String(F("Cache-Control")), String(F("no-cache, no-store, must-revalidate")));
Expand All @@ -1300,7 +1311,7 @@ void Web_setup()
SoC->swSer_enableRx(true);
SoC->Service_Mode(false);
} );

#endif /* EXPERIMENTAL */
server.on ( "/input", handleInput );
server.on ( "/inline", []() {
server.send ( 200, "text/plain", "this works as well" );
Expand All @@ -1320,7 +1331,7 @@ void Web_setup()
<body>\
<body>\
<h1 align=center>Firmware update</h1>\
<p align=center>(main board)</p>\
<!--<p align=center>(main board)</p>-->\
<hr>\
<table width=100%%>\
<tr>\
Expand Down Expand Up @@ -1363,9 +1374,9 @@ void Web_setup()
</td>\
</tr>\
</table>\
<hr>\
<!--<hr>\
<h1 align=center>Radio/GNSS board</h1>\
<p align=center><input type=button onClick=\"location.href='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/service'\" value='Service Mode'></p>\
<p align=center><input type=button onClick=\"location.href='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/service'\" value='Service Mode'></p>-->\
</body>\
</html>")
);
Expand Down

1 comment on commit b6a65f1

@lyusupov
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Please sign in to comment.