mirror of
https://github.com/sudomesh/disaster-radio.git
synced 2026-02-20 02:01:18 +01:00
print info when gps reading fails, related to #87
This commit is contained in:
@@ -476,6 +476,15 @@ void setupGPS()
|
||||
Serial.println("* Initializing GPS...");
|
||||
Serial1.begin(GPS_SERIAL);
|
||||
radio->connect(new GPSClient(&Serial1, beaconPeriod));
|
||||
Serial.printf(" --> GPS connected,");
|
||||
if(beaconPeriod == 0)
|
||||
{
|
||||
Serial.printf(" beacons disabled\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf(" beacons enabled with period of %ldms\r\n", beaconPeriod);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ void GPSClient::loop()
|
||||
long elapsed = millis() - beacon_last;
|
||||
if (elapsed > beacon_period && beacon_period > 0)
|
||||
{
|
||||
struct Datagram datagram = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
memset(datagram.message, 0, 233);
|
||||
size_t len;
|
||||
if (gps.location.isValid() && gps.location.age() < beacon_period)
|
||||
{
|
||||
// 04m|<user>{"pos":[48.75608,2.302038]}
|
||||
struct Datagram datagram = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
memset(datagram.message, 0, 233);
|
||||
datagram.type = 'm';
|
||||
size_t len;
|
||||
if (username.length() > 0)
|
||||
{
|
||||
len = snprintf((char *)datagram.message, 233, "m|<%s>{\"pos\":[%.3f,%.3f]}", username.c_str(), gps.location.lat(), gps.location.lng());
|
||||
@@ -27,12 +27,22 @@ void GPSClient::loop()
|
||||
{
|
||||
len = snprintf((char *)datagram.message, 233, "m|<%s>{\"pos\":[%.3f,%.3f]}", nodeAddress, gps.location.lat(), gps.location.lng());
|
||||
}
|
||||
len = len+DATAGRAM_HEADER;
|
||||
|
||||
Serial.printf("Sending GPS %s\n", (char *)datagram.message);
|
||||
// Send datagram with lat-long info
|
||||
server->transmit(this, datagram, len);
|
||||
// if debug is enabled, print coordinates to console
|
||||
datagram.type = 'i';
|
||||
len = snprintf((char *)datagram.message, 233, "Sent GPS reading [%.3f,%.3f]\r\n", gps.location.lat(), gps.location.lng());
|
||||
len = len+DATAGRAM_HEADER;
|
||||
server->transmit(this, datagram, len);
|
||||
beacon_last = millis();
|
||||
}
|
||||
else
|
||||
{
|
||||
datagram.type = 'i';
|
||||
len = snprintf((char *)datagram.message, 233, "Failed to get GPS reading\r\n");
|
||||
len = len+DATAGRAM_HEADER;
|
||||
server->transmit(this, datagram, len);
|
||||
}
|
||||
beacon_last = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -511,14 +511,16 @@ void Console::transmit(DisasterClient *client, struct Datagram datagram, size_t
|
||||
|
||||
void Console::receive(struct Datagram datagram, size_t len)
|
||||
{
|
||||
// only print chat and info messages, add more as needed
|
||||
if(datagram.type == 'i')
|
||||
{
|
||||
client->receive(datagram, len);
|
||||
}
|
||||
|
||||
// only print out additional formatting for chat messages
|
||||
if(datagram.type == 'c'){
|
||||
printf("\r\n");
|
||||
}
|
||||
|
||||
client->receive(datagram, len);
|
||||
|
||||
if(datagram.type == 'c'){
|
||||
client->receive(datagram, len);
|
||||
printPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user