Vehicle & ITS-G5 overlay: a stdlib MQTT subscriber (MQTT_URL/USERNAME/PASSWORD) keeps the car's LTE tracker position and the ITS-G5 stations heard by mcu-its-g5 (decoded header, stations expire after 60 s), served by /api/live and drawn as a car badge plus stations colored by type with DENM in red; Meshtastic noted in TODO
This commit is contained in:
1 parent
b381ca289f
commit
02c2ef05f8
12 files changed
+608
-12
No files matched your search
@@ -108,6 +108,28 @@ class AppTest < Minitest::Test
|
||||
assert_equal 401, request.get("/api/gnss/position").status
|
||||
end
|
||||
|
||||
def test_live_requires_login
|
||||
assert_equal 401, request.get("/api/live").status
|
||||
end
|
||||
|
||||
# The car's last position stays (with its age); ITS stations expire.
|
||||
def test_live_keeps_the_vehicle_and_drops_stale_its_stations
|
||||
app = Maptool::App
|
||||
now = Time.now.to_f
|
||||
app.record_live(app::TRACKER_TOPIC, '{"latitude":48.1,"longitude":17.1,"speed":3}', at: now - 600)
|
||||
app.record_live(app::ITS_TOPIC, '{"id":"old","msg":"CAM","lat":48,"lon":17}', at: now - app::ITS_STALE_AFTER - 5)
|
||||
app.record_live(app::ITS_TOPIC, '{"id":"new","msg":"DENM","lat":48.2,"lon":17.2}', at: now)
|
||||
app.record_live(app::ITS_TOPIC, "not json")
|
||||
body = json_body(request.get("/api/live", **logged_in_env))
|
||||
assert_equal 48.1, body["vehicle"]["latitude"]
|
||||
assert_in_delta 600, body["vehicle"]["age"], 2
|
||||
refute body["vehicle"].key?("received_at")
|
||||
assert_equal ["new"], body["its"].map { |s| s["id"] }
|
||||
assert_equal false, body["available"] # no MQTT_URL in tests
|
||||
ensure
|
||||
app::LIVE_MUTEX.synchronize { app::LIVE.replace(vehicle: nil, its: {}) }
|
||||
end
|
||||
|
||||
# --- auth guard ---
|
||||
|
||||
def test_write_routes_require_login
|
||||
|
||||
Reference in new issue
Block a user