mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 06:02:05 +00:00
Added map report precision bounds (#6862)
Some checks failed
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native-tft (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-deb-amd64 (push) Waiting to run
CI / docker-deb-amd64-tft (push) Waiting to run
CI / docker-alp-amd64 (push) Waiting to run
CI / docker-alp-amd64-tft (push) Waiting to run
CI / docker-deb-arm64 (push) Waiting to run
CI / docker-deb-armv7 (push) Waiting to run
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
Nightly / Trunk Check and Upload (push) Has been cancelled
Nightly / Trunk Upgrade (PR) (push) Has been cancelled
Some checks failed
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native-tft (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-deb-amd64 (push) Waiting to run
CI / docker-deb-amd64-tft (push) Waiting to run
CI / docker-alp-amd64 (push) Waiting to run
CI / docker-alp-amd64-tft (push) Waiting to run
CI / docker-deb-arm64 (push) Waiting to run
CI / docker-deb-armv7 (push) Waiting to run
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
Nightly / Trunk Check and Upload (push) Has been cancelled
Nightly / Trunk Upgrade (PR) (push) Has been cancelled
* Added map report precision bounds * Log warning * Precision range should be 12-15 * Missed commit * Update tests * That method was renamed * Removed now-defunct test call * Remove defunct test
This commit is contained in:
parent
ba1ef45024
commit
beba1b4882
@ -773,14 +773,19 @@ void MQTT::perhapsReportToMap()
|
||||
!(moduleConfig.mqtt.proxy_to_client_enabled || isConnectedDirectly()))
|
||||
return;
|
||||
|
||||
// Coerce the map position precision to be within the valid range
|
||||
// This removes obtusely large radius and privacy problematic ones from the map
|
||||
if (map_position_precision < 12 || map_position_precision > 15) {
|
||||
LOG_WARN("MQTT Map report position precision %u is out of range, using default %u", map_position_precision,
|
||||
default_map_position_precision);
|
||||
map_position_precision = default_map_position_precision;
|
||||
}
|
||||
|
||||
if (Throttle::isWithinTimespanMs(last_report_to_map, map_publish_interval_msecs))
|
||||
return;
|
||||
|
||||
if (map_position_precision == 0 || (localPosition.latitude_i == 0 && localPosition.longitude_i == 0)) {
|
||||
if (localPosition.latitude_i == 0 && localPosition.longitude_i == 0) {
|
||||
last_report_to_map = millis();
|
||||
if (map_position_precision == 0)
|
||||
LOG_WARN("MQTT Map report enabled, but precision is 0");
|
||||
if (localPosition.latitude_i == 0 && localPosition.longitude_i == 0)
|
||||
LOG_WARN("MQTT Map report enabled, but no position available");
|
||||
return;
|
||||
}
|
||||
@ -805,15 +810,11 @@ void MQTT::perhapsReportToMap()
|
||||
mapReport.has_opted_report_location = true;
|
||||
|
||||
// Set position with precision (same as in PositionModule)
|
||||
if (map_position_precision < 32 && map_position_precision > 0) {
|
||||
mapReport.latitude_i = localPosition.latitude_i & (UINT32_MAX << (32 - map_position_precision));
|
||||
mapReport.longitude_i = localPosition.longitude_i & (UINT32_MAX << (32 - map_position_precision));
|
||||
mapReport.latitude_i += (1 << (31 - map_position_precision));
|
||||
mapReport.longitude_i += (1 << (31 - map_position_precision));
|
||||
} else {
|
||||
mapReport.latitude_i = localPosition.latitude_i;
|
||||
mapReport.longitude_i = localPosition.longitude_i;
|
||||
}
|
||||
|
||||
mapReport.altitude = localPosition.altitude;
|
||||
mapReport.position_precision = map_position_precision;
|
||||
|
||||
|
@ -708,42 +708,21 @@ void test_reportToMapDefaultImprecise(void)
|
||||
TEST_ASSERT_EQUAL(1, pubsub->published_.size());
|
||||
const auto &[topic, payload] = pubsub->published_.front();
|
||||
TEST_ASSERT_EQUAL_STRING("msh/2/map/", topic.c_str());
|
||||
verifyLatLong(std::get<DecodedServiceEnvelope>(payload), 70123520, 30015488);
|
||||
}
|
||||
|
||||
// Precise location is reported when configured.
|
||||
void test_reportToMapPrecise(void)
|
||||
{
|
||||
unitTest->reportToMap(/*precision=*/32);
|
||||
|
||||
TEST_ASSERT_EQUAL(1, pubsub->published_.size());
|
||||
const auto &[topic, payload] = pubsub->published_.front();
|
||||
TEST_ASSERT_EQUAL_STRING("msh/2/map/", topic.c_str());
|
||||
verifyLatLong(std::get<DecodedServiceEnvelope>(payload), localPosition.latitude_i, localPosition.longitude_i);
|
||||
}
|
||||
|
||||
// Location is sent over the phone proxy.
|
||||
void test_reportToMapPreciseProxied(void)
|
||||
void test_reportToMapImpreciseProxied(void)
|
||||
{
|
||||
moduleConfig.mqtt.proxy_to_client_enabled = true;
|
||||
MQTTUnitTest::restart();
|
||||
|
||||
unitTest->reportToMap(/*precision=*/32);
|
||||
unitTest->reportToMap(/*precision=*/14);
|
||||
|
||||
TEST_ASSERT_EQUAL(1, mockMeshService->messages_.size());
|
||||
const meshtastic_MqttClientProxyMessage &message = mockMeshService->messages_.front();
|
||||
TEST_ASSERT_EQUAL_STRING("msh/2/map/", message.topic);
|
||||
TEST_ASSERT_EQUAL(meshtastic_MqttClientProxyMessage_data_tag, message.which_payload_variant);
|
||||
const DecodedServiceEnvelope env(message.payload_variant.data.bytes, message.payload_variant.data.size);
|
||||
verifyLatLong(env, localPosition.latitude_i, localPosition.longitude_i);
|
||||
}
|
||||
|
||||
// No location is reported when the precision is invalid.
|
||||
void test_reportToMapInvalidPrecision(void)
|
||||
{
|
||||
unitTest->reportToMap(/*precision=*/0);
|
||||
|
||||
TEST_ASSERT_TRUE(pubsub->published_.empty());
|
||||
}
|
||||
|
||||
// isUsingDefaultServer returns true when using the default server.
|
||||
@ -920,9 +899,7 @@ void setup()
|
||||
RUN_TEST(test_publishTextMessageDirect);
|
||||
RUN_TEST(test_publishTextMessageWithProxy);
|
||||
RUN_TEST(test_reportToMapDefaultImprecise);
|
||||
RUN_TEST(test_reportToMapPrecise);
|
||||
RUN_TEST(test_reportToMapPreciseProxied);
|
||||
RUN_TEST(test_reportToMapInvalidPrecision);
|
||||
RUN_TEST(test_reportToMapImpreciseProxied);
|
||||
RUN_TEST(test_usingDefaultServer);
|
||||
RUN_TEST(test_usingDefaultServerWithPort);
|
||||
RUN_TEST(test_usingDefaultServerWithInvalidPort);
|
||||
|
Loading…
Reference in New Issue
Block a user