Lora-net/packet_forwarder

time field empty when no GPS present

Closed this issue · 2 comments

Looking at the PROTOCOL

time | string | UTC time of pkt RX, us precision, ISO 8601 'compact' format
tmms | number | GPS time of pkt RX, number of milliseconds since 06.Jan.1980
tmst | number | Internal timestamp of "RX finished" event (32b unsigned)

And then at the code

/* Packet RX time (GPS based), 37 useful chars */
if (ref_ok == true) {
/* convert packet timestamp to UTC absolute time */
j = lgw_cnt2utc(local_ref, p->count_us, &pkt_utc_time);
if (j == LGW_GPS_SUCCESS) {
/* split the UNIX timestamp to its calendar components */
x = gmtime(&(pkt_utc_time.tv_sec));
j = snprintf((char *)(buff_up + buff_index), TX_BUFF_SIZE-buff_index, ",\"time\":\"%04i-%02i-%02iT%02i:%02i:%02i.%06liZ\"", (x->tm_year)+1900, (x->tm_mon)+1, x->tm_mday, x->tm_hour, x->tm_min, x->tm_sec, (pkt_utc_time.tv_nsec)/1000); /* ISO 8601 format */
if (j > 0) {
buff_index += j;
} else {
MSG("ERROR: [up] snprintf failed line %u\n", (__LINE__ - 4));
exit(EXIT_FAILURE);
}
}
/* convert packet timestamp to GPS absolute time */
j = lgw_cnt2gps(local_ref, p->count_us, &pkt_gps_time);
if (j == LGW_GPS_SUCCESS) {
pkt_gps_time_ms = pkt_gps_time.tv_sec * 1E3 + pkt_gps_time.tv_nsec / 1E6;
j = snprintf((char *)(buff_up + buff_index), TX_BUFF_SIZE-buff_index, ",\"tmms\":%llu",
pkt_gps_time_ms); /* GPS time in milliseconds since 06.Jan.1980 */
if (j > 0) {
buff_index += j;
} else {
MSG("ERROR: [up] snprintf failed line %u\n", (__LINE__ - 4));
exit(EXIT_FAILURE);
}
}
}

time should contain an ISO time, irrelevant if the gateway is GPS synced or not. Maybe it's NTP synced, and the should be good enough to indicate at what time a packet was received.

tmms should contain the GPS timestamp in case a GPS is present.

tmst contains the concentrator clock counter value used to schedule downlinks accurately.

My opinion is that this line

if (j == LGW_GPS_SUCCESS) {

should be removed.

I was expecting to see the time field being added when fake_gps is enabled, but that does not seem to work.

Fake GPS off (metadata from TTN):

{
   "gtw_id":"eui-60c5a8fffeXXXXXX",
   "timestamp":11257844,
   "time":"",
   "channel":5,
   "rssi":-38,
   "snr":9.5,
   "rf_chain":0
}

Fake GPS on:

{
   "gtw_id":"eui-60c5a8fffeXXXXXX",
   "timestamp":600364156,
   "time":"",
   "channel":5,
   "rssi":-38,
   "snr":9,
   "rf_chain":0,
   "latitude":"<REDACTED>",
   "longitude":"<REDACTED>",
   "altitude":190
}

Thank you for your inquiry.

Customers are encouraged to submit technical questions via our dedicated support portal at https://semtech.force.com/ldp/ldp_support.

We invite all users to visit the LoRa Developer Portal Forum at https://forum.lora-developers.semtech.com and to join the thriving LoRa development community!