Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fine Timestamp property for concentratord-sx1302 backend #66

Merged
merged 6 commits into from
Jun 13, 2023

Conversation

LouneCode
Copy link
Contributor

@LouneCode LouneCode commented Jun 12, 2023

This pull-request add Fine Timestamp functionality to consentrator-sx1302 backend. Details and idea of this pull-request are described in issue #65 .

Changes

 
chirpstack-concentratord-sx1302/src/handler/uplink.rs

  • Added new fts (Fine TimeStamp) filed to Frame received, uplink_id -info message.

 
chirpstack-concentratord-sx1302/src/wrapper/mod.rs

  • Added fine_time_since_gps_epoch information into rx_info structure in uplink_to_proto() function

 
Fine Timestamp will exist in uplink message of the concentratord if:

  • Concentratord is connect to GPS and
  • PPS signal of the GPS device is connected to SX1302 hardware
  • concertrator.toml configuration file has foll0wing setup :
    model_flags=["USB","GNSS"]
    [gateway.fine_timestamp]
    enable=true
    mode="ALL_SF"

Fine_time_since_gps_epoch structure has a gps time in second field if GPS device support ubx protocol. Otherwise fine_time_since_gps_epoc.seconds is set to 0 (GPS device support PPS signaling and only NMEA messages)

In this example below GPS device not support ubx messages. Only nanos field has a PPS synchronized nano seconds (to be used for TDoA calculations).

fine_time_since_gps_epoch: Some(Duration { seconds: 0, nanos: 110119743 }

Pull-request includes also fine tuning to " GPS time reference is not valid, age" warning message. If GPS devise supports only NMEA (not ubx protocol) the warning message will be shown every 10 minutes on log if time_fallback_enabled=true flag is set in concentratord.toml file.

2023-06-12T15:33:08.797Z WARN  [chirpstack_concentratord_sx1302::handler::gps] Time fallback enabled. GPS time reference is not valid, age: 1686583988.797543062s

" Time fallback enabled. GPS time reference is not valid, age" warning message changes can be found in the following files:

  • chirpstack-concentratord-sx1302/src/cmd/root.rs
  • chirpstack-concentratord-sx1302/src/handler/gps.rs

Concentratord log

Log shows fts as follows.

2023-06-12T15:18:37.653Z INFO  [libconcentratord::events] Publishing stats event, rx_received: 0, rx_received_ok: 0, tx_received: 0, tx_emitted: 0
2023-06-12T15:18:49.520Z INFO  [chirpstack_concentratord_sx1302::handler::uplink] Frame received, uplink_id: 322597547, count_us: 2743161674, freq: 867700000, bw: 125000, mod: LoRa, dr: SF7, fts: 448177198 ns
2023-06-12T15:19:07.654Z INFO  [libconcentratord::events] Publishing stats event, rx_received: 1, rx_received_ok: 1, tx_received: 0, tx_emitted: 0
2023-06-12T15:19:19.554Z INFO  [chirpstack_concentratord_sx1302::handler::uplink] Frame received, uplink_id: 2725878167, count_us: 2773199919, freq: 868100000, bw: 125000, mod: LoRa, dr: SF7, fts: 486425155 ns
2023-06-12T15:19:37.655Z INFO  [libconcentratord::events] Publishing stats event, rx_received: 1, rx_received_ok: 1, tx_received: 0, tx_emitted: 0

Concentratord Up event

Topic: up
phy_payload: [64, 97, 158, 199, 1, 128, 10, 150, 3, 70, 233, 85, 33, 42, 215, 134, 37, 33, 95, 30, 124, 29, 171]
phy_payload: UplinkRxInfo { gateway_id: "0016c001ff1f1107", uplink_id: 1540664642, time: Some(Timestamp { seconds: 1686583691, nanos: 279423171 }), time_since_gps_epoch: None, fine_time_since_gps_epoch: Some(Duration { seconds: 0, nanos: 213832907 }), rssi: -98, snr: 12.0, channel: 4, rf_chain: 0, board: 0, antenna: 0, location: None, context: [196, 253, 48, 46], metadata: {}, crc_status: CrcOk }
Topic: up
phy_payload: [64, 80, 249, 160, 0, 128, 63, 32, 2, 119, 5, 64, 180, 223, 179, 179, 51, 182, 127, 219, 10, 203, 162, 132, 79, 172, 72, 204, 168, 94, 77, 63, 71, 249, 12, 214, 9]
phy_payload: UplinkRxInfo { gateway_id: "0016c001ff1f1107", uplink_id: 2066340510, time: Some(Timestamp { seconds: 1686583701, nanos: 199794942 }), time_since_gps_epoch: None, fine_time_since_gps_epoch: Some(Duration { seconds: 0, nanos: 110119743 }), rssi: -81, snr: 11.75, channel: 3, rf_chain: 0, board: 0, antenna: 0, location: None, context: [197, 148, 129, 140], metadata: {}, crc_status: CrcOk }

@LouneCode LouneCode changed the title Add Fine Timestamp property for consertrator-sx1302 backend Add Fine Timestamp property for consertratord-sx1302 backend Jun 12, 2023
@brocaar
Copy link
Collaborator

brocaar commented Jun 13, 2023

Thanks for you contribution @LouneCode 👍

I have made some small local edits, which I will push to this PR. Hopefully that is fine with you. These are the changes that I have made:

  • I have reverted the GPS time reference is not valid change. Let's discuss this in a separate issue. Non-ubx gateways have other issues (Support for non-UBlox GNSS modules? Lora-net/sx1302_hal#92).
  • Instead of the {:0>9} ns formatting, I renamed the log key to ftime_ns (this is consistent with count_us)
  • I removed the match to get the seconds with a map and unwrap_or_default. This avoids the nested match

@brocaar brocaar merged commit d3a3c7b into chirpstack:master Jun 13, 2023
@LouneCode
Copy link
Contributor Author

Thanks @brocaar . I'll test run this change....

@LouneCode
Copy link
Contributor Author

Test drive done and the changes seems to be good.

...But there is still one small issue with logging. "GPS time reference is not valid" warning writes now every second on the log which is not nice ( In a non-uxb GPS module case ).

I can live with this feature because I know how to handle this situation; )

2023-06-13T13:51:45.286Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664305.286058906s
2023-06-13T13:51:46.286Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664306.286429208s
2023-06-13T13:51:47.286Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664307.286803271s
2023-06-13T13:51:48.287Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664308.287309221s
2023-06-13T13:51:49.287Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664309.287672488s
2023-06-13T13:51:50.288Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664310.288174568s
2023-06-13T13:51:51.114Z INFO  [chirpstack_concentratord_sx1302::handler::uplink] Frame received, uplink_id: 698803152, count_us: 1790617276, freq: 867100000, bw: 125000, mod: LoRa, dr: SF7, ftime_received: true, ftime_ns: 46332323
2023-06-13T13:51:51.288Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664311.288556059s
2023-06-13T13:51:52.289Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664312.288915457s
2023-06-13T13:51:53.289Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664313.289311504s
2023-06-13T13:51:54.289Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664314.289701866s
2023-06-13T13:51:55.290Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664315.290091506s
2023-06-13T13:51:56.290Z WARN  [chirpstack_concentratord_sx1302::handler::gps] GPS time reference is not valid, age: 1686664316.290485665s
2

Thanks @brocaar once again. You have done very very good job!!!

@brocaar
Copy link
Collaborator

brocaar commented Jun 13, 2023

Thanks 👍

...But there is still one small issue with logging. "GPS time reference is not valid" warning writes now every second on the log which is not nice ( In a non-uxb GPS module case ).

I agree with this, but it is better to look at this as a separate issue. The Semtech HAL doesn't support non-ubx modules. I don't think we should make the behavior of these errors dependent on the time fallback feature. Let me think about this :)

Thanks again for adding the fine-timestamp support :-)

@LouneCode LouneCode changed the title Add Fine Timestamp property for consertratord-sx1302 backend Add Fine Timestamp property for concentratord-sx1302 backend Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants