updated the sheet
This commit is contained in:
@@ -46,10 +46,11 @@ class DeviceTelemetry {
|
||||
/// problem as a rider at 12% and riding.
|
||||
final bool? isCharging;
|
||||
|
||||
/// `wifi`, `mobile`, `none` … as the platform names it.
|
||||
/// `WiFi`, `4G` or `none` — the contract's vocabulary, not the plugin's.
|
||||
/// See [_connectionName].
|
||||
final String? connection;
|
||||
|
||||
/// `enabled`, `disabled`, `denied`, `denied_forever`, `unknown`.
|
||||
/// `enabled` or `disabled`. See [_locationServiceName].
|
||||
///
|
||||
/// The one field here that is about a *choice the rider made*, which is why
|
||||
/// it is worth a column of its own on the console: a disabled location
|
||||
@@ -86,9 +87,7 @@ class DeviceTelemetry {
|
||||
String? connection;
|
||||
try {
|
||||
final result = await Connectivity().checkConnectivity();
|
||||
connection = result.isNotEmpty
|
||||
? result.first.toString().split('.').last
|
||||
: 'none';
|
||||
connection = _connectionName(result);
|
||||
} catch (e) {
|
||||
debugPrint('[TELEMETRY] connectivity unavailable: $e');
|
||||
}
|
||||
@@ -104,6 +103,7 @@ class DeviceTelemetry {
|
||||
service = null;
|
||||
}
|
||||
}
|
||||
service = _locationServiceName(service);
|
||||
|
||||
return DeviceTelemetry(
|
||||
battery: level,
|
||||
@@ -113,6 +113,48 @@ class DeviceTelemetry {
|
||||
);
|
||||
}
|
||||
|
||||
/// `WiFi` / `4G` / `none`, which is the vocabulary `/miler/logs` documents.
|
||||
///
|
||||
/// ── The plugin's own spelling is not the contract's ──
|
||||
///
|
||||
/// This was `result.first.toString().split('.').last`, which is the *enum
|
||||
/// constant* — `wifi`, `mobile`, `ethernet`, `vpn`, `bluetooth`, `other`.
|
||||
/// Two of those happen to look right in lower case and the rest do not
|
||||
/// appear in the contract at all, so the console's Connection column was
|
||||
/// rendering whatever `connectivity_plus` happened to call the transport
|
||||
/// this release.
|
||||
///
|
||||
/// `first` was also the wrong pick: the list is every active transport, so a
|
||||
/// phone on Wi-Fi with mobile data up could report either depending on the
|
||||
/// order the platform returned them. Wi-Fi wins where both are present,
|
||||
/// because it is the one that explains a rider whose data has run out.
|
||||
static String _connectionName(List<ConnectivityResult> results) {
|
||||
if (results.isEmpty) return 'none';
|
||||
if (results.contains(ConnectivityResult.wifi)) return 'WiFi';
|
||||
if (results.contains(ConnectivityResult.mobile)) return '4G';
|
||||
if (results.contains(ConnectivityResult.ethernet)) return 'ethernet';
|
||||
if (results.every((r) => r == ConnectivityResult.none)) return 'none';
|
||||
return 'other';
|
||||
}
|
||||
|
||||
/// `enabled` or `disabled` — the two values the contract names.
|
||||
///
|
||||
/// The richer answers the fix lookup produces — `denied`, `denied_forever`,
|
||||
/// `unknown` — are more useful to a dispatcher, and they are not what this
|
||||
/// field accepts. On a backend that validates its enums (and this one does
|
||||
/// silently: see the `Break` / `On_Break` note in [MilerApi]) an unrecognised
|
||||
/// value risks the whole row, which costs the battery and the connection
|
||||
/// alongside it.
|
||||
///
|
||||
/// So anything that is not `enabled` is `disabled` here, which is the fact
|
||||
/// the column exists to report — this rider's location is not reaching us.
|
||||
/// The distinction between *off* and *denied* is not lost: it still rides on
|
||||
/// the MQTT `location_turned_off` alert as `error_type`.
|
||||
static String? _locationServiceName(String? raw) {
|
||||
if (raw == null || raw.isEmpty) return null;
|
||||
return raw == 'enabled' ? 'enabled' : 'disabled';
|
||||
}
|
||||
|
||||
/// The heartbeat payload's own field names, ready to spread into it.
|
||||
///
|
||||
/// Only what was actually read: an absent key is a field the console draws as
|
||||
|
||||
Reference in New Issue
Block a user