diff --git a/Common/Source/Devices/devFlyBeeper.cpp b/Common/Source/Devices/devFlyBeeper.cpp index 39807fe7c..124fcd8b6 100644 --- a/Common/Source/Devices/devFlyBeeper.cpp +++ b/Common/Source/Devices/devFlyBeeper.cpp @@ -85,6 +85,24 @@ payload_t serialize_tracking(const NMEA_INFO& Basic, const DERIVED_INFO& Calcula return buffer; } +payload_t serialize_gound_tracking(const NMEA_INFO& Basic, const DERIVED_INFO& Calculated) { + payload_t buffer; + buffer.reserve(6); + auto out_it = std::back_inserter(buffer); + + /* position */ + Frame::coord2payload_absolut(Basic.Latitude, Basic.Longitude, out_it); + + + /* state & Online Tracking */ + constexpr uint8_t state = 0; + constexpr uint8_t online_tracking = 0x01; + + out_it = (state&0x0F)<<4 | online_tracking; + + return buffer; +} + payload_t serialize_name() { std::string name = to_utf8(PilotName_Config); return { name.begin(), name.end() }; @@ -94,22 +112,16 @@ MacAddr generate_id() { DeviceSettings settings(_T("FlyBeeper")); try { - return { - settings.get("fanet-manufacturer"), - settings.get("fanet-id") - }; + return MacAddr{ settings.get("fanet-id") }; } catch(std::exception& e) { } std::random_device rd; // a seed source for the random number engine std::mt19937 gen(rd()); // mersenne_twister_engine seeded with rd() - std::uniform_int_distribution distrib(1, std::numeric_limits::max()); + std::uniform_int_distribution distrib(1, 0xFFFE); MacAddr addr = { 0xFC, distrib(gen) }; - - settings.set("fanet-manufacturer", addr.manufacturer); - settings.set("fanet-id", addr.id); - + settings.set("fanet-id", addr.get()); return addr; } @@ -133,7 +145,12 @@ BOOL SendData(DeviceDescriptor_t* d, const NMEA_INFO& Basic, const DERIVED_INFO& static PeriodClock timeState; if (timeState.CheckUpdate(5000)) { // Every 5 second : Send current state - return SendData(d, FRM_TYPE_TRACKING, serialize_tracking(Basic, Calculated)); + if (Calculated.Flying) { + return SendData(d, FRM_TYPE_TRACKING, serialize_tracking(Basic, Calculated)); + } + else { + return SendData(d, FRM_TYPE_GROUNDTRACKING, serialize_gound_tracking(Basic, Calculated)); + } } static PeriodClock timeName;