Phone state reaches the instrument through the primary Wi-Fi connection using the managed FreeRTOS interface. Complete first adding and primary connection first.
Phone theme and battery
Managed configuration enables phone_state by default. Handle MOTO_EVENT_PHONE_STATE:
| Field | Use |
|---|---|
e.data.phone.theme |
MOTO_THEME_DAY / MOTO_THEME_NIGHT; switch the instrument theme |
e.data.phone.battery_percent |
Phone battery from 0–100; -1 means unknown |
e.data.phone.charging |
Phone charging state |
These are SDK structure values. The wire protocol uses CBOR null for unknown battery; the SDK maps it to battery_percent=-1. Zero is an actual zero-percent reading, not unknown.
The core equivalent is event->phone, borrowed until the callback returns. Copy it for asynchronous display. Report vehicle battery separately through vehicle data.
Copy the snapshot for the UI
Call this helper from the Managed event consumer. It accepts only phone-state events and preserves unknown battery as -1. Put a copy of snapshot into the UI queue; apply theme, battery and charging indicators on the UI thread.
#include <moto_freertos/terminal.h>
bool copy_phone_state(const moto_terminal_event *event,
moto_phone_state *snapshot) {
if (!event || !snapshot || event->kind != MOTO_EVENT_PHONE_STATE)
return false;
*snapshot = event->data.phone;
return true;
}
