Get CoCan Mirror

Shopping opens soon.

Scan with WeChat to buy CoCan Mirror

Developer reference · open interface

Topics, commands, telemetry, and local metrics.

A reference for CoCan's MQTT interface: the topic structure, commands and responses, telemetry streams, and the local metrics endpoints. The firmware is open-sourced at go.ifanr.com/ionbridge-open-source; everything here maps to a .proto definition.

Connecting

Connect over MQTT v5, addressed by PSN.

Each device is addressed by its PSN — its product serial number. A client can talk to the official cloud or point the device at your own broker; with TLS on, device and broker authenticate each other with certificates.

Every topic starts with device/<psn>/ and falls into two families: end-user commands and telemetry pushes. A request goes to request; the device publishes its reply to the matching response, correlated by a shared id.

Topic model

Topic model

device/<psn>/enduser/request/<cmd>     # client to device   user commands
device/<psn>/enduser/response/<cmd>    # device to client   replies
device/<psn>/telemetry/<type>          # device to client   push streams

Permissions

End-user commands and a one-time pairing.

Every command needs a token, except pairing. End-user commands cover everyday control — Wi-Fi, charging strategy, ports, display, and telemetry.

Pairing is one step: a client sends ASSOCIATE_DEVICE with the PIN shown on the device. The device checks the PIN, mints a token, and hands it back; every command afterward carries it. That is the one command that needs no token.

Message envelope

Request and response

// binary protobuf on the wire
CommandRequest  { id: uint32;  oneof payload { ... } }
CommandResponse { id: uint32;  status: CommandStatus;  oneof payload { ... } }

CommandStatus = SUCCESS(0) | FAILURE(1) | FLASH_NOT_WRITABLE_AT_HIGH_TEMPERATURE(2)

Command reference

Commonly used commands

Commands are binary protobuf, published to device/<psn>/enduser/request/<code>. Here is a commonly used set; the full definitions are in command.proto, embedded below.

DomainCommandCodeWhat it does
DeviceGET_DEVICE_INFO0x92Full snapshot — model, firmware versions, MACs, Wi-Fi
DeviceGET_DEVICE_SERIAL_NO0x13The device PSN
DeviceSET_DEVICE_POWER_STATE0x1APower the unit on or off
DeviceREBOOT_DEVICE0x11Reboot the device
DeviceRESET_DEVICE0x12Factory reset, with per-namespace keep flags
PairingASSOCIATE_DEVICE0x10Pair a client with a PIN — the only token-free command
Wi-FiSCAN_WIFI0x30Scan nearby networks (SSID, RSSI, auth)
Wi-FiSET_WIFI_SSID_AND_PASSWORD0x36Join a network
Wi-FiGET_WIFI_STATUS0x34Current link — SSID, BSSID, RSSI, channel
Wi-FiOPERATE_WIFI_RECORD0x38Add / update / delete a saved network
PowerGET_CHARGING_STATUS0x44Per-port charging state
PowerSET_CHARGING_STRATEGY0x43Fast / Slow / High-performance / single-port turbo
PowerGET_ALL_POWER_STATISTICS0x4APer-port V / A / battery
PowerGET_PORT_PD_STATUS0x49Full PD and cable detail for a port
PowerGET_POWER_HISTORICAL_STATS0x45Historical voltage / current for a port
PowerSET_PORT_PRIORITY0x46Order ports by charging priority
PowerTURN_ON_PORT / OFF0x4C / 0x4DEnable or disable ports
PowerSET_TEMPERATURE_MODE0x5BPower-priority vs temperature-priority mode
PowerSET_TEMPORARY_ALLOCATOR0x5CApply a one-shot per-port watt allocation
PowerSET_PORT_CONFIG0x5DPer-port protocol feature flags
PowerSET_CUSTOM_PDO_VOLTAGE0x61Custom PDO voltage on a port
PowerSET_CABLE_COMPENSATION0x62Compensate cable resistance / voltage drop
PowerSET_PORT_TYPE0x60Mark a port USB-A or USB-C
PowerSUBSCRIBE_PD_PCAP_STREAMING0x5FStream raw PD packets for a port
DisplaySET_DISPLAY_CONFIG0x7FMode, brightness, rotation, idle animation, hourly chime
DisplayGET_DISPLAY_CONFIG0x7DRead the current display config
TelemetrySTART / STOP_TELEMETRY_STREAM0x90 / 0x91Turn the telemetry push stream on or off
OTASTART_OTA0x9CUpgrade app / protocol-chip / FPGA firmware

Telemetry streams

What the device pushes

Subscribe with START_TELEMETRY_STREAM and the device pushes these on device/<psn>/telemetry/<type>; while subscribed it also streams live port and device status every ~100-500 ms.

TelemetryCodeReports
DEVICE_BOOT_INFO0x10Versions, chip, MACs, IPs, uptime, reset reason — on connect
DEVICE_STATS_DATA0x11Heap, Wi-Fi / MQTT counters, RSSI — periodic
POWER_HISTORICAL_DATA0x30Per-port voltage / current over time
POWER_ALLOCATION_DATA0x31Budget, remaining, per-port cap vs usage
PD_PCAP_DATA0x32Raw PD negotiation packets for a subscribed port
UPGRADE_DATA0x40OTA result — versions, status, failure reason
SW3566_BOOTLOADER_INFO0x51Per-port protocol-chip bootloader versions
OUT_OF_MEMORY_ALERT0x60Low-heap alert with threshold
PD_CHARGING_ALERT0x62PD soft / hard / cable-reset and error counts on a port
ACDC_SELF_TEST_INFO0x63AC-DC converter self-test result
TASK_EXECUTION_RESULT0x70Scheduled-task completion — pending / succeeded / failed
CONFIG_REPORT0x80The device's current machine config

Local metrics

No cloud needed — Prometheus and JSON, served locally.

The firmware runs a small local web server that serves port voltage and current, memory, and Wi-Fi metrics directly — the data never leaves your network. Point a Prometheus + Grafana at it for charts over time, or hit the JSON endpoint once for a snapshot.

Local endpoints

Local endpoints

GET http://<device-ip>/metrics        # Prometheus exposition format
GET http://<device-ip>/metrics.json   # device + ports + system + wifi, as JSON
GET http://<device-ip>/porthistoryz?limit=20   # recent per-port V / A samples
GET http://<device-ip>/heapz          # heap diagnostics

# sample /metrics
ionbridge_port_voltage{id="0"} 5000
ionbridge_port_current{id="0"} 2500
ionbridge_uptime_seconds 3600
ionbridge_free_heap 102400
ionbridge_wifi_signal{ssid="...",channel="6"} -50

Schemas

The .proto files

The exact wire schemas, straight from the open-source firmware at go.ifanr.com/ionbridge-open-source. Every command, response, and telemetry message above is defined here. Click to expand; use download for the raw file.

command.protodownload
syntax = "proto3";

package pb;

import "data_types.proto";

message CommandRequest {
  uint32 id = 1;
  oneof payload {
    EnableReleaseModeReq enable_release_mode = 4;

    RebootDeviceReq reboot_device = 10;
    ResetDeviceReq reset_device = 11;
    GetDevicePSNReq get_device_psn = 12;
    GetAPVersionReq get_ap_version = 13;
    SetDevicePowerStateReq set_power_state = 14;
    GetDevicePowerStateReq get_power_state = 15;
    GetDeviceInfoReq get_device_info = 16;
    GetHardwareRevisionReq get_hardware_revision = 17;
    GetDeviceUptimeReq get_device_uptime = 130;

    ScanWiFiReq scan_wifi = 20;
    SetWiFiSSIDReq set_wifi_ssid = 21;
    SetWiFiPasswordReq set_wifi_password = 22;
    ResetWiFiReq reset_wifi = 23;
    GetWiFiStatusReq get_wifi_status = 24;
    GetWiFiMACReq get_wifi_mac = 25;
    SetWiFiSSIDAndPasswordReq set_wifi_ssid_and_password = 26;
    GetWiFiRecordsReq get_wifi_records = 27;
    OperateWiFiRecordReq operate_wifi_record = 28;
    GetWiFiStateMachineReq get_wifi_state_machine = 29;
    SetWiFiStateMachineReq set_wifi_state_machine = 30;

    GetChargeDurationReq get_charge_duration = 39;
    SetChargingStrategyReq set_charging_strategy = 40;
    GetChargingStatusReq get_charging_status = 41;
    GetPowerHistoricalStatsReq get_power_historical_stats = 42;
    SetPortPriorityReq set_port_priority = 43;
    GetPortPriorityReq get_port_priority = 44;
    GetChargingStrategyReq get_charging_strategy = 45;
    GetPortPDStatusReq get_port_pd_status = 46;
    GetAllPowerStatisticsReq get_all_power_statistics = 47;
    TurnOnPortReq turn_on_port = 48;
    TurnOffPortReq turn_off_port = 49;
    SetStaticAllocatorReq set_static_allocator = 50;
    GetStaticAllocatorReq get_static_allocator = 51;
    SetPortConfigReq set_port_config = 52;
    GetPortConfigReq get_port_config = 53;
    SetPortCompatibilitySettingsReq set_port_compatibility_settings = 54;
    GetPortCompatibilitySettingsReq get_port_compatibility_settings = 55;
    SetTemperatureModeReq set_temperature_mode = 56;
    SetTemporaryAllocatorReq set_temporary_allocator = 57;
    SubscribePDPcapStreamingReq subscribe_pdpcap_streaming = 58;
    SetPortTypeReq set_port_type = 59;
    SetCustomPdoVoltageReq set_custom_pdo_voltage = 60;
    SetCableCompensationReq set_cable_compensation = 61;
    GetCableCompensationReq get_cable_compensation = 62;

    SetDisplayIntensityReq set_display_intensity = 80;
    SetDisplayModeReq set_display_mode = 81;
    GetDisplayIntensityReq get_display_intensity = 82;
    GetDisplayModeReq get_display_mode = 83;
    SetDisplayFlipReq set_display_flip = 84;
    GetDisplayFlipReq get_display_flip = 85;
    SetDisplayConfigDepreReq set_display_config = 86 [deprecated = true];
    GetDisplayRotationReq get_display_rotation = 87;
    SetDisplayRotationReq set_display_rotation = 88;
    GetDisplayConfigReq get_display_config = 89;
    SetDisplayConfigReq display_config = 91;

    StartTelemetryStreamReq start_telemetry_stream = 100;
    StopTelemetryStreamReq stop_telemetry_stream = 101;

    SetBleStateReq set_ble_state = 110;
    StartOTAReq start_ota = 111;
    ClearFactoryDMFlagReq clear_factory_dm_flag = 113;
    NotifyMcpConnectedReq notify_mcp_connected = 118;
    GetBleRSSIReq get_ble_rssi = 131;
    GetBleMTUReq get_ble_mtu = 132;
  }
  reserved 18, 114, 115;
}

message CommandResponse {
  uint32 id = 1;
  CommandStatus status = 2;
  oneof payload {
    EnableReleaseModeResp enable_release_mode = 12;

    RebootDeviceResp reboot_device = 20;
    ResetDeviceResp reset_device = 21;
    GetDevicePSNResp get_device_psn = 22;
    GetAPVersionResp get_ap_version = 23;
    SetDevicePowerStateResp set_power_state = 24;
    GetDevicePowerStateResp get_power_state = 25;
    GetDeviceInfoResp get_device_info = 26;
    GetHardwareRevisionResp get_hardware_revision = 27;
    GetDeviceUptimeResp get_device_uptime = 130;

    ScanWiFiResp scan_wifi = 30;
    SetWiFiSSIDResp set_wifi_ssid = 31;
    SetWiFiPasswordResp set_wifi_password = 32;
    ResetWiFiResp reset_wifi = 33;
    GetWiFiStatusResp get_wifi_status = 34;
    GetWiFiMACResp get_wifi_mac = 35;
    SetWiFiSSIDAndPasswordResp set_wifi_ssid_and_password = 36;
    GetWiFiRecordsResp get_wifi_records = 37;
    OperateWiFiRecordResp operate_wifi_record = 38;
    GetWiFiStateMachineResp get_wifi_state_machine = 39;
    SetWiFiStateMachineResp set_wifi_state_machine = 40;

    GetChargeDurationResp get_charge_duration = 49;
    SetChargingStrategyResp set_charging_strategy = 50;
    GetChargingStatusResp get_charging_status = 51;
    GetPowerHistoricalStatsResp get_power_historical_stats = 52;
    SetPortPriorityResp set_port_priority = 53;
    GetPortPriorityResp get_port_priority = 54;
    GetChargingStrategyResp get_charging_strategy = 55;
    GetPortPDStatusResp get_port_pd_status = 56;
    GetAllPowerStatisticsResp get_all_power_statistics = 57;
    TurnOnPortResp turn_on_port = 58;
    TurnOffPortResp turn_off_port = 59;
    SetStaticAllocatorResp set_static_allocator = 60;
    GetStaticAllocatorResp get_static_allocator = 61;
    SetPortConfigResp set_port_config = 62;
    GetPortConfigResp get_port_config = 63;
    SetPortCompatibilitySettingsResp set_port_compatibility_settings = 64;
    GetPortCompatibilitySettingsResp get_port_compatibility_settings = 65;
    SetTemperatureModeResp set_temperature_mode = 66;
    SetTemporaryAllocatorResp set_temporary_allocator = 67;
    SubscribePDPcapStreamingResp subscribe_pdpcap_streaming = 70;
    SetPortTypeResp set_port_type = 71;
    SetCustomPdoVoltageResp set_custom_pdo_voltage = 72;
    SetCableCompensationResp set_cable_compensation = 73;
    GetCableCompensationResp get_cable_compensation = 74;

    SetDisplayIntensityResp set_display_intensity = 90;
    SetDisplayModeResp set_display_mode = 91;
    GetDisplayIntensityResp get_display_intensity = 92;
    GetDisplayModeResp get_display_mode = 93;
    SetDisplayFlipResp set_display_flip = 94;
    GetDisplayFlipResp get_display_flip = 95;
    SetDisplayConfigDepreResp set_display_config = 96 [deprecated = true];
    GetDisplayRotationResp get_display_rotation = 97;
    SetDisplayRotationResp set_display_rotation = 98;
    GetDisplayConfigResp get_display_config = 99;
    SetDisplayConfigResp display_config = 101;

    StartTelemetryStreamResp start_telemetry_stream = 110;
    StopTelemetryStreamResp stop_telemetry_stream = 111;
    StreamPortStatus stream_port_status = 112;
    StreamDeviceStatus stream_device_status = 113;
    StreamPortPDStatus stream_port_pd_status = 114;

    SetBleStateResp set_ble_state = 120;
    StartOTAResp start_ota = 121;
    ClearFactoryDMFlagResp clear_factory_dm_flag = 123;
    NotifyMcpConnectedResp notify_mcp_connected = 128;
    GetBleRSSIResp get_ble_rssi = 131;
    GetBleMTUResp get_ble_mtu = 132;
  }
  reserved 28, 124, 125;
}

message EnableReleaseModeReq {}
message EnableReleaseModeResp {}

message GetHardwareRevisionReq {}
message GetHardwareRevisionResp {
  string revision = 1;
}

message RebootDeviceReq {}
message RebootDeviceResp {}

message ResetDeviceReq {
  // NVS namespaces to keep after reset
  optional bool keep_wifi_nvs = 1;
  optional bool keep_mqtt_nvs = 2;
  optional bool keep_ble_nvs = 3;
  optional bool keep_display_nvs = 4;
  optional bool keep_power_nvs = 5;
  optional bool keep_system_nvs = 6;
  optional bool keep_syslog_nvs = 8;
  optional bool keep_fpga_nvs = 9;
  optional bool keep_ota_nvs = 10;
  // Reset operations
  optional bool prevent_reboot = 31;
  optional bool reset_ports = 32;
  optional bool reset_power_strategy = 33;
  optional bool reset_wifi = 34;
  optional bool reset_display = 35;
  optional bool reset_fc_protocol = 36;
  optional bool reset_temperature_mode = 37;
  optional bool reset_cable_compensation = 38;
}
message ResetDeviceResp {}

message GetDevicePSNReq {}
message GetDevicePSNResp {
  string psn = 1;
}

message GetAPVersionReq {}
message GetAPVersionResp {
  Version version = 1;
}

message GetDeviceUptimeReq {}
message GetDeviceUptimeResp {
  int64 uptime_us = 1;  // Device uptime in microseconds
}

message SetDevicePowerStateReq {
  PowerState state = 1;
}
message SetDevicePowerStateResp {}

message GetDevicePowerStateReq {}
message GetDevicePowerStateResp {
  PowerState state = 1;
}

message ScanWiFiReq {}

message ScanWiFiResp {
  repeated SSIDInfo ssid_list = 1;
}

message SetWiFiSSIDReq {
  string ssid = 1;
}
message SetWiFiSSIDResp {}

message SetWiFiPasswordReq {
  string password = 1;
}
message SetWiFiPasswordResp {}

message ResetWiFiReq {}
message ResetWiFiResp {}

message GetWiFiStatusReq {}
message GetWiFiStatusResp {
  string bssid = 1;
  sint32 rssi = 2;
  uint32 channel = 3;
  uint32 protocol = 4;
  string ssid = 5;
}

message GetWiFiMACReq {}
message GetWiFiMACResp {
  string mac = 1;
}

message SetWiFiSSIDAndPasswordReq {
  string ssid = 1;
  string password = 2;
  WiFiAuthMode auth_mode = 3;
}
message SetWiFiSSIDAndPasswordResp {}

message GetWiFiRecordsReq {}
message GetWiFiRecordsResp {
  repeated WiFiRecord records = 1;
}

message OperateWiFiRecordReq {
  ManageAction action = 1;
  string ssid = 2;
  string password = 3;
  WiFiAuthMode auth_mode = 4;
}
message OperateWiFiRecordResp {}

message GetWiFiStateMachineReq {}
message GetWiFiStateMachineResp {
  WiFiState state = 1;
}

message SetWiFiStateMachineReq {
  WiFiState state = 1;
}
message SetWiFiStateMachineResp {}

message SetChargingStrategyReq {
  ChargingStrategy charging_strategy = 1;
}
message SetChargingStrategyResp {}

message GetChargeDurationReq {}
message GetChargeDurationResp {
  uint32 duration_minutes = 1; // Charging duration in minutes
}

message GetChargingStatusReq {}
message GetChargingStatusResp {
  uint32 status = 1; // bitfield, e.g. 00011111
}

message GetPowerHistoricalStatsReq {
  uint32 port = 1;
  uint32 offset = 2;
}
message GetPowerHistoricalStatsResp {
  uint32 offset = 1;
  repeated PowerHistoricalStats data = 2;
}

message SetPortPriorityReq {
  repeated uint32 priority = 1;
}
message SetPortPriorityResp {}

message GetPortPriorityReq {}
message GetPortPriorityResp {
  repeated uint32 priority = 1;
}

message GetChargingStrategyReq {}
message GetChargingStrategyResp {
  ChargingStrategy charging_strategy = 1;
}

message GetPortPDStatusReq {
  uint32 port = 1;
}
message GetPortPDStatusResp {
  ClientPDStatus pd_status = 1;
}

message GetAllPowerStatisticsReq {}
message GetAllPowerStatisticsResp {
  repeated PowerStatistics stats = 1;
}

message TurnOnPortReq {
  repeated uint32 ports = 1;
}
message TurnOnPortResp {}

message TurnOffPortReq {
  repeated uint32 ports = 1;
}
message TurnOffPortResp {}

message SetStaticAllocatorReq {
  uint32 identifier = 1;
  PowerAllocationTable table = 2;
}
message SetStaticAllocatorResp {
  uint32 identifier = 1;
}

message GetStaticAllocatorReq {}
message GetStaticAllocatorResp {
  uint32 identifier = 1;
  uint32 version = 2;
}

message SetPortConfigReq {
  uint32 ports = 1;
  repeated PortConfig configs = 2;
}
message SetPortConfigResp {}

message GetPortConfigReq {
  uint32 version = 1;
}
message GetPortConfigResp {
  repeated PortConfig configs = 1;
}

message SetPortCompatibilitySettingsReq {
  CompatibilitySettings settings = 1;
}
message SetPortCompatibilitySettingsResp {}

message GetPortCompatibilitySettingsReq {}
message GetPortCompatibilitySettingsResp {
  CompatibilitySettings settings = 1;
}

message SetTemperatureModeReq {
  TemperatureMode mode = 1;
}
message SetTemperatureModeResp {}

message SetTemporaryAllocatorReq {
  repeated uint32 power_allocation = 1;
}
message SetTemporaryAllocatorResp {}

message SubscribePDPcapStreamingReq {
  uint32 port = 1;
  bool subscribe = 2;
}
message SubscribePDPcapStreamingResp {}

message SetPortTypeReq {
  uint32 port = 1;
  PortType port_type = 2;
}
message SetPortTypeResp {}

message SetCustomPdoVoltageReq {
  uint32 port = 1;
  uint32 voltage_mv = 2;
}
message SetCustomPdoVoltageResp {}

message SetCableCompensationReq {
    uint32 port_mask = 1;
    bool disable = 2;
    CableCompensation resistance = 3;
    FixedVoltageOffset voltage_offset = 4;
}
message SetCableCompensationResp {}

message GetCableCompensationReq {
    uint32 port = 1;
}
message GetCableCompensationResp {
    bool enable = 1;
    CableCompensation resistance = 2;
    FixedVoltageOffset voltage_offset = 3;
}

message SetDisplayIntensityReq {
  uint32 intensity = 1;
}
message SetDisplayIntensityResp {}

message SetDisplayModeReq {
  DisplayMode mode = 1;
}
message SetDisplayModeResp {}

message GetDisplayIntensityReq {}
message GetDisplayIntensityResp {
  uint32 intensity = 1;
}

message GetDisplayModeReq {}
message GetDisplayModeResp {
  DisplayMode mode = 1;
}

// Deprecated: Use SetDisplayRotationReq instead
message SetDisplayFlipReq {
  option deprecated = true;
  DisplayFlip flip = 1;
}
message SetDisplayFlipResp {
  option deprecated = true;
}

// Deprecated: Use GetDisplayRotationReq instead
message GetDisplayFlipReq {
  option deprecated = true;
}
message GetDisplayFlipResp {
  option deprecated = true;
  DisplayFlip flip = 1;
}

// Deprecated: Use SetDisplayConfigReq instead
message SetDisplayConfigDepreReq {
  option deprecated = true;
  DisplayConfiguration config = 1;
}
message SetDisplayConfigDepreResp {
  option deprecated = true;
}

message SetDisplayConfigReq {
  DisplayConfig config = 1;
}
message SetDisplayConfigResp {}

message GetDisplayConfigReq {}
message GetDisplayConfigResp {
  DisplayConfiguration config = 1;
}

message GetDisplayRotationReq {}
message GetDisplayRotationResp {
  DisplayRotation rotation = 1;
}

message SetDisplayRotationReq {
  DisplayRotation rotation = 1;
}
message SetDisplayRotationResp {}

message StartTelemetryStreamReq {}
message StartTelemetryStreamResp {}

message StopTelemetryStreamReq {}
message StopTelemetryStreamResp {}

message GetDeviceInfoReq {}
message GetDeviceInfoResp {
  DeviceInfo info = 1;
  optional Version ch32_version = 2;
}

message SetBleStateReq {
  bool enable = 1;
}
message SetBleStateResp {}

message StartOTAReq {
  Version sw3566_version = 1;
  optional Version fpga_version = 2;
  Version esp32_version = 3;
  bool force = 4;
  optional Version animation_version = 5;
  reserved 6;
  optional Version ch32_version = 7;
}

message StartOTAResp {}

message StreamPortStatus {
  uint32 port_status_map = 1;
  repeated PortStatusData ports = 2;
}

message StreamPortPDStatus {
  uint32 port = 1;
  ClientPDStatus pd_status = 2;
}

message StreamDeviceStatus {
  uint32 allocator = 1;
  DisplayConfiguration display_config = 2 [deprecated = true];
  uint32 device_uptime = 3; // second
  FeatureFlag feature_flag = 4;
  uint32 charging_minutes = 5;
  uint32 power_allocator_param = 6;
  TemperatureMode temperature_mode = 7;
  DisplayConfig new_display_config = 9;
}

message ClearFactoryDMFlagReq {}

message ClearFactoryDMFlagResp {}

message NotifyMcpConnectedReq {}

message NotifyMcpConnectedResp {}

message GetBleRSSIReq {}

message GetBleRSSIResp {
  int32 rssi = 1;  // dBm, negative values
}

message GetBleMTUReq {}

message GetBleMTUResp {
  uint32 mtu = 1;  // bytes
}
telemetry.protodownload
syntax = "proto3";

package pb;

import "data_types.proto";

message TelemetryData {
    oneof data {
        PingInfo ping_info = 1;
        CoredumpPartitionSlice coredump_slice = 2;

        DeviceBootInfo device_boot_info = 10;
        DeviceStatsData device_stats_data = 11;

        PowerHistoricalData power_historical_data = 30;
        PowerAllocationData power_allocation_data = 31;
        PDPCapData pdp_cap_data = 32;

        UpgradeData upgrade_data = 40;

        UartMetricsData uart_metrics_data = 50;
        SW3566BootloaderInfo sw3566_bootloader_info = 51;

        OutOfMemoryAlertInfo out_of_memory_alert_info = 60;
        ChargingAlertInfo charging_alert_info = 62;
        ACDCSelfTestInfo acdc_self_test_info = 63;

        TaskExecutionResult task_execution_result = 70;

        ConfigReport config_report = 80;
        ConfigRequest config_request = 81;

    }
}
data_types.protodownload
syntax = "proto3";

package pb;

enum CommandStatus {
  SUCCESS = 0; // success
  FAILURE = 1; // failure
  FLASH_NOT_WRITABLE_AT_HIGH_TEMPERATURE = 2; // flash not writable while hot
}

enum ConfigOperation {
  CONFIG_UPDATE = 0; // Update device config (config field required)
  CONFIG_REQUEST_UPLOAD = 1; // Request device to upload its config via telemetry
}

enum PowerState {
  POWER_OFF = 0;
  POWER_ON = 1;
}

enum WiFiState {
  CONFIGURATION = 0;
  SCAN_AND_CONNECT = 1;
  CONNECTING = 2;
  CONNECTED = 3;
  CHECKING_CONN = 4;
  IDLE = 5;
  DISCONNECTED = 6;
  RECONNECTING = 7;
  WAITING_FOR_NEXT = 8;
  SCANNING = 9;
  CONNECTION_ABORT = 10;
  WAITING_FOR_DEFAULT = 11;
}

enum TemperatureMode {
  POWER_PRIORITY = 0x00; // power priority
  TEMPERATURE_PRIORITY = 0x01; // temperature priority
}

enum DisplayMode {
  OFF = 0;
  MANUAL = 1;
  POWER_METER = 2;
}

enum CableCompensation {
  RESISTANCE_65_MOHM = 0; // 65mΩ(default)
  RESISTANCE_100_MOHM = 1; // 100mΩ
}

enum FixedVoltageOffset {
  OFFSET_0_MV = 0; // 0mV
  OFFSET_100_MV = 1; // 100mV
  OFFSET_150_MV = 2; // 150mV
  OFFSET_200_MV = 3; // 200mV
}

// Deprecated: Use rotation field (uint32 degrees) instead
enum DisplayFlip {
  option deprecated = true;
  NORMAL = 0; // normal
  FLIP = 1; // flipped
}

enum FastChargingProtocol {
  NONE = 0; // none
  QC2 = 1; // Qc2
  QC3 = 2; // Qc3
  QC3P = 3; // Qc3+
  SFCP = 4; // SFCP
  AFC = 5; // AFC
  FCP = 6; // FCP
  SCP = 7; // SCP
  VOOC1P0 = 8; // VOOC1.0
  VOOC4P0 = 9; // VOOC4.0
  SVOOC2P0 = 10; // SupperVooc2.0
  TFCP = 11; // TFCP
  UFCS = 12; // UFCS
  PE1 = 13; // PE1.0
  PE2 = 14; // PE2.0
  PD_FIX5V = 15; // PD fix 5v
  PD_FIXHV = 16; // PD fix high voltage
  PD_SPR_AVS = 17; // PD SPR AVS
  PD_PPS = 18; // PD PPS
  PD_EPR_HV = 19; // PD EPR high voltage
  PD_AVS = 20; // PD AVS
  PD_MIPPS = 21; // MiPPS (Xiaomi PD 2717)
  NOT_CHARGING = 255; // not charging
}

enum PortType {
  TYPE_A = 0;
  TYPE_C = 1;
}

enum TaskExecutionStatus {
  PENDING = 0;
  SUCCEEDED = 1;
  FAILED = 2;
}

// Deprecated: Use uint32 rotation field storing degrees directly (0, 90, 180, 270)
enum DisplayRotation {
  option deprecated = true;
  ROTATION_0 = 0; // 0 degrees
  ROTATION_90 = 1; // 90 degrees
  ROTATION_180 = 2; // 180 degrees
  ROTATION_270 = 3; // 270 degrees
}

enum IdleAnimationType {
  IDLE_NONE = 0; // No idle animation (default)
  IDLE_METEOR = 1; // Meteor animation
  IDLE_GAME_OF_LIFE = 2; // GPU built-in Game of Life
  IDLE_RIPPLE = 3; // Ripple animation
  IDLE_TIME_DISPLAY = 4; // Time display animation
}

enum ManageAction {
  CREATE = 0;
  UPDATE = 1;
  DELETE = 2;
  READ = 3;
}

enum ManageOperation {
  OP_READ = 0;
  OP_WRITE = 1;
  OP_DELETE = 2;
}

enum WiFiAuthMode {
  WIFI_AUTH_OPEN = 0; //< Authenticate mode : open */
  WIFI_AUTH_WEP = 1; //< Authenticate mode : WEP */
  WIFI_AUTH_WPA_PSK = 2; //< Authenticate mode : WPA_PSK */
  WIFI_AUTH_WPA2_PSK = 3; //< Authenticate mode : WPA2_PSK */
  WIFI_AUTH_WPA_WPA2_PSK = 4; //< Authenticate mode : WPA_WPA2_PSK */
  WIFI_AUTH_ENTERPRISE = 5; //< Authenticate mode : Wi-Fi EAP security */
  WIFI_AUTH_WPA3_PSK = 6; //< Authenticate mode : WPA3_PSK */
  WIFI_AUTH_WPA2_WPA3_PSK = 7; //< Authenticate mode : WPA2_WPA3_PSK */
  WIFI_AUTH_WAPI_PSK = 8; //< Authenticate mode : WAPI_PSK */
  WIFI_AUTH_OWE = 9; //< Authenticate mode : OWE */
  WIFI_AUTH_WPA3_ENT_192 = 10; //< Authenticate mode : WPA3_ENT_SUITE_B_192_BIT */
  WIFI_AUTH_WPA3_EXT_PSK = 11; //< This authentication mode will yield same result as WIFI_AUTH_WPA3_PSK and not recommended to be used. It will be deprecated in future, please use WIFI_AUTH_WPA3_PSK instead. */
  WIFI_AUTH_WPA3_EXT_PSK_MIXED_MODE = 12; //< This authentication mode will yield same result as WIFI_AUTH_WPA3_PSK and not recommended to be used. It will be deprecated in future, please use WIFI_AUTH_WPA3_PSK instead.*/
  WIFI_AUTH_DPP = 13; //< Authenticate mode : DPP */
  WIFI_AUTH_WPA3_ENTERPRISE = 14; //< Authenticate mode : WPA3-Enterprise Only Mode */
  WIFI_AUTH_WPA2_WPA3_ENTERPRISE = 15; //< Authenticate mode : WPA3-Enterprise Transition Mode */
}

enum ChargingStrategy {
  FAST_CHARGING = 0;
  SLOW_CHARGING = 1;
  HIGH_PERFORMANCE_CHARGING = 7;
  ULTRA_FAST_SINGLE_PORT_CHARGING = 8;
}

enum UpgradeStatus {
  UPGRADE_START = 0;
  UPGRADE_FAIL = 1;
  UPGRADE_SUCCESS = 2;
}

enum UpgradeFailureReason {
  REASON_NONE = 0;
  REASON_ESP_ERROR = 1;
  REASON_CONFIRM_FAILED = 2;
  REASON_CONFIRM_TIMEOUT = 3;
}

enum ManageFeature {
  FPGA_POWER_CONTROL = 0;
  POWER_ALLOCATOR = 1;
}

enum ManageResourceType {
  RESOURCE_FPGA_CONFIG = 0;
  RESOURCE_POWER_CONFIG = 1;
  RESOURCE_FPGA_POWER_CONTROL = 2;
  RESOURCE_POWER_ALLOCATOR = 3;
  RESOURCE_DEVICE_MODEL = 4;
}

enum DeviceModel {
  DEVB = 0;
  PRO = 1;
  ULTRA = 2;
  BIRD = 3;
  FAKE = 4;
}

enum DeviceConfigEntity {
  ENTITY_HARDWARE_REVISION = 0;
  ENTITY_PRODUCT_FAMILY = 1;
  ENTITY_DEVICE_MODEL = 2;
  ENTITY_DEVICE_COLOR = 3;
  ENTITY_DEVICE_NAME = 4;
  ENTITY_DATA_MATRIX_FLAG = 5;
}

message Version {
  uint32 major = 1;
  uint32 minor = 2;
  uint32 patch = 3;
}

message PowerFeatures {
  // BYTE 1
  optional bool enable_tfcp = 1;
  optional bool enable_pe = 2;
  optional bool enable_qc2p0 = 3;
  optional bool enable_qc3p0 = 4;
  optional bool enable_qc3plus = 5;
  optional bool enable_afc = 6;
  optional bool enable_fcp = 7;
  optional bool enable_hv_scp = 8;

  // BYTE 2
  optional bool enable_lv_scp = 9;
  optional bool enable_sfcp = 10;
  optional bool enable_apple = 11;
  optional bool enable_samsung = 12;
  optional bool enable_ufcs = 13;
  optional bool enable_pd = 14;
  optional bool enable_pd_compat_mode = 15;
  optional bool limited_current_mode = 16;

  // BYTE 3
  optional bool enable_pd_lvpps = 17;
  optional bool enable_pd_epr = 18;
  optional bool enable_pd_rpi = 19;
  optional bool enable_pd_hvpps = 20;
  optional bool enable_pd_hard_reset_on_refusal = 21;
  optional bool enable_pd_spr_avs = 22;
  optional bool enable_pd_mipps = 23; // BYTE 3 bit 6: MiPPS (Xiaomi PD 2717)
}

message ClientPDStatus {
  uint32 battery_vid = 1;
  uint32 battery_pid = 2;
  uint32 battery_design_capacity = 3;
  uint32 battery_last_full_charge_capacity = 4;
  uint32 battery_present_capacity = 5;
  bool battery_invalid = 6;
  bool battery_present = 7;
  uint32 battery_status = 8;
  bool cable_is_active = 9;
  bool cable_termination_type = 10;
  bool cable_epr_mode_capable = 11;
  uint32 cable_active_phy_type = 12;
  uint32 cable_latency = 13;
  uint32 cable_max_vbus_voltage = 14;
  uint32 cable_max_vbus_current = 15;
  uint32 cable_usb_highest_speed = 16;
  uint32 cable_active_element = 17;
  bool cable_active_usb4 = 18;
  bool cable_active_usb2p0 = 19;
  bool cable_active_usb3p2 = 20;
  bool cable_active_usb_lanes = 21;
  bool cable_active_optically_isolated = 22;
  bool cable_active_usb4_asym = 23;
  bool cable_active_usb_gen = 24;
  bool request_epr_mode_capable = 25;
  uint32 request_pdo_id = 26;
  bool request_usb_communications_capable = 27;
  bool request_capability_mismatch = 28;
  uint32 sink_capabilities = 29;
  uint32 sink_cap_pdo_count = 30;
  uint32 cable_vid = 32;
  uint32 cable_pid = 33;
  uint32 manufacturer_vid = 34;
  uint32 manufacturer_pid = 35;
  uint32 sink_minimum_pdp = 36;
  uint32 sink_operational_pdp = 37;
  uint32 sink_maximum_pdp = 38;
  uint32 operating_current = 40;
  uint32 pd_revision = 41;
  bool pps_charging_supported = 42;
  bool has_battery = 43;
  bool dual_role_power = 44;
  bool has_emarker = 45;
  uint32 operating_voltage = 46;
  bool request_ppsavs = 47;
  uint32 cable_xid = 48;
  uint32 bcd_device = 49;
}

// Deprecated: Use DisplayConfig instead
message DisplayConfiguration {
  option deprecated = true;
  uint32 intensity = 1;
  DisplayMode mode = 2;
  DisplayFlip flip = 3;
  uint32 mode_param = 4;
  uint32 rotation = 5;
  IdleAnimationType idle_animation = 6;
  uint32 charging_animation_duration = 7; // 0=always show, non-0=show N seconds
}

// DEPRECATED: Use DisplayConfiguration instead (will be removed in v2.0.0)
message DisplayConfig {
  option deprecated = true;
  DisplayMode mode = 1;
  uint32 intensity = 2;
  DisplayFlip flip = 3 [deprecated = true]; // Use rotation instead
  uint32 rotation = 4; // Degrees: 0, 90, 180, 270
  IdleAnimationType idle_animation = 5;
  uint32 charging_animation_duration = 6; // 0=always show, non-0=show N seconds
  optional bool hourly_chime = 7; // Hourly chime enable, default true
}

message PortDetails {
  uint64 session_charge = 1;
  uint32 session_id = 2;
  uint32 manufacturer_vid = 3;
  uint32 manufacturer_pid = 4;
  uint32 battery_vid = 5;
  uint32 battery_pid = 6;
  uint32 iout_value = 7;
  uint32 vout_value = 8;
  uint32 vin_value = 10;
  bool connected = 11;
  FastChargingProtocol fc_protocol = 12;
  uint32 power_budget = 13;
}

message MachineConfig {
  uint64 timestamp = 1;
  repeated MachinePortConfig ports = 2;
  ChargingStrategyData charging = 3;
  TemperatureMode temperature_mode = 4;
  DisplayConfig display = 5 [deprecated = true]; // DEPRECATED - use display_config instead
  DisplayConfiguration display_config = 6; // New canonical display configuration
}

message MachinePortConfig {
  uint32 port_id = 1;
  PortConfigData config = 2;
}

message PortConfigData {
  bool enabled = 1;
  PowerFeatures features = 2;
  uint32 custom_pdo_voltage_mv = 3;
}

// Power allocation structures (moved from command.proto)
message PowerAllocationEntry {
  repeated uint32 power_allocation = 1;
}

message PowerAllocationTable {
  uint32 version = 1;
  repeated PowerAllocationEntry entries = 2;
}

message ChargingStrategyData {
  uint32 strategy_type = 1; // StrategyType enum (0,1,2,4,5 - NOT 3)

  // Fields only for STATIC_CHARGING (type == 2)
  optional uint32 identifier = 2;
  optional PowerAllocationTable static_table = 3;
}

message PortConfig {
  uint32 version = 1; // current version is 2
  PowerFeatures features = 2;
}

message CompatibilitySettings {
  bool enable_tfcp = 1;
  bool enable_fcp = 2;
  bool enable_ufcs = 3;
  bool enable_hv_scp = 4;
  bool enable_lv_scp = 5;
}

message PowerHistoricalStats {
  uint32 current = 1;
  uint32 voltage = 2;
}

message PowerStatistics {
  uint32 charging_protocol_version = 1;
  uint32 current = 2;
  uint32 voltage = 3;
  uint32 battery_last_full_charge_capacity = 5;
  uint32 battery_present_capacity = 6;
}

message SSIDInfo {
  string ssid = 1;
  sint32 rssi = 2;
  WiFiAuthMode auth_mode = 3;
  bool saved = 4;
}

message WiFiRecord {
  string ssid = 1;
  WiFiAuthMode auth_mode = 2;
}

message PortStatusData {
  uint32 charging_minutes = 1;
  PowerFeatures features = 2;
  PortDetails details = 3;
  PortType port_type = 4;
  uint32 custom_pdo_voltage_mv = 5;
  bool cable_compensation_enable = 6;
  CableCompensation cable_resistance = 7;
  FixedVoltageOffset cable_voltage_offset = 8;
}

message FeatureFlag {
  bool device_power_on = 1;
  bool ble_on = 2;
  bool syslog_on = 3;
  bool mcp_server_on = 4;
}

message DeviceInfo {
  string psn = 1;
  string model = 2;
  Version ap_version = 3;
  Version bp_version = 4;
  Version fpga_version = 5;
  Version zrlib_version = 6;
  string ble_mac = 7;
  string wifi_mac = 8;
  string bssid = 9;
  string ssid = 10;
  sint32 rssi = 11;
  uint32 wifi_protocol = 12;
  uint32 channel = 13;
}

message DeviceBootInfo {
  Version esp32_version = 1;
  Version sw3566_version = 2;
  Version fpga_version = 3;
  Version zrlib_version = 4;
  Version esp_idf_version = 5;
  uint32 chip_cores = 6; // number of CPU cores
  uint32 chip_model = 7; // chip model
  uint32 chip_features = 8; // chip features
  uint32 chip_revision = 9; // chip revision
  bytes ble_mac = 10; // BLE address
  bytes ipv4 = 11; // IPv4 address
  bytes ipv6 = 12; // IPv6 address
  uint64 uptime = 13; // uptime in milliseconds
  sint32 wifi_max_tx_power = 14; // Maximum WiFi transmitting power, unit is 0.25dBm.
  uint32 active_mcu_count = 15; // Active MCU count
  uint32 fs_total_size = 16; // filesystem total bytes
  uint32 fs_used_size = 17; // filesystem used bytes
  uint32 reset_reason = 18; // reason of last reset
  string hardware_revision = 19; // hardware revision
  string device_model = 20; // device model
  string product_family = 21; // product family
  string mcp_auth_token = 22; // mcp auth token, SHA-1 hex (40 chars)
  optional Version ch32_version = 23;
}

message DeviceStatsData {
  bool initial_boot = 1; // Initial boot
  uint32 free_heap_size = 2; // Available heap size, in bytes
  uint32 free_internal_heap_size = 3; // Available internal heap size, in bytes
  uint32 minimum_free_heap_size = 4; // Minimum free heap size, in bytes

  uint32 wifi_association_count = 5;
  uint32 wifi_disassociation_count = 6;
  sint32 wifi_rssi = 7;
  uint32 wifi_channel = 8;
  uint32 wifi_connection_time = 9; // seconds from start connection to connected
  uint32 mqtt_connection_time = 10; // seconds from start connection to connected
  uint32 connectivity_failure_count = 11; // count of failed connection test
  uint32 dns_resolution_failure_count = 12; // count of failed DNS resolve test
  uint32 mqtt_connection_count = 13; // count of MQTT connections
  uint32 mqtt_message_tx_count = 14; // count of MQTT messages transmitted
  uint32 mqtt_message_rx_count = 15; // count of MQTT messages received

}

message PortStatsData {
  uint32 voltage = 1; // in mV
  uint32 amperage = 2; // in mA
  uint32 vin_value = 4; // in mV
  uint32 session_id = 5;
  uint64 session_charge = 6;
  uint32 manufacturer_vid = 7;
  uint32 manufacturer_pid = 8;
  uint32 battery_vid = 9;
  uint32 battery_pid = 10;
}

message PortStatsEntry {
  uint32 port = 1;
  repeated PortStatsData stats = 2;
}

message PowerHistoricalData {
  repeated PortStatsEntry data = 1;
}

message PowerAllocationData {
  uint32 power_budget = 1;
  uint32 remaining_power = 2;
  uint32 adc_value = 3;

  message PortAllocation {
    uint32 source_cap = 1;
    uint32 usage = 2;
  }

  repeated PortAllocation port_allocations = 5;
}

message PDPCapData {
  uint32 port = 1;
  bytes data = 2;
}

message UpgradeData {
  Version esp32_version = 1;
  Version mcu_version = 2;
  Version fpga_version = 3;
  UpgradeStatus status = 4;
  UpgradeFailureReason reason = 5;
  sint32 esp_err = 6;
  uint32 active_port_count = 7; // number of chips that booted normally
  optional Version ch32_version = 8;
}

message UartMetricsData {
  uint32 reset_state_count = 1;
  uint32 resend_count = 2;
  uint32 sent_failed_count = 3;
  uint32 sent_count = 4;
  uint32 overflow_count = 5;
  uint32 stream_drop_count = 6;
}

message PingInfo {
  int32 dummy = 1; // Dummy field to make the message non-empty
}

message SW3566BootloaderInfo {
  message BootloaderInfo {
    uint32 version = 1;
    uint32 flash_timestamp = 2;
  }

  repeated BootloaderInfo infos = 1;
}

message OutOfMemoryAlertInfo {
  uint32 free_heap_size = 1; // Available heap size, in bytes
  uint32 free_internal_heap_size = 2; // Available internal heap size, in bytes
  uint32 minimum_free_heap_size = 3; // Minimum free heap size, in bytes
  uint32 free_heap_size_threshold = 4; // Threshold for free heap size, in bytes
}

message ChargingAlertInfo {
  uint32 port = 1;
  uint32 pd_rx_soft_reset_count = 2;
  uint32 pd_rx_hard_reset_count = 3;
  uint32 pd_rx_error_count = 4;
  uint32 pd_rx_cable_reset_count = 5;
}

// ACDC self-test status (single enum encodes both result and failed level)
enum ACDCSelfTestStatus {
  ACDC_SELF_TEST_NOT_RUN = 0; // Test hasn't executed yet
  ACDC_SELF_TEST_PASSED = 1; // All voltage levels passed
  ACDC_SELF_TEST_NO_PORT = 2; // No activated port for measurement
  // Voltage errors: 0x10 + failed_level
  ACDC_SELF_TEST_FAIL_L0 = 16; // Failed at level 0
  ACDC_SELF_TEST_FAIL_L1 = 17; // Failed at level 1
  ACDC_SELF_TEST_FAIL_L2 = 18; // Failed at level 2
  ACDC_SELF_TEST_FAIL_L3 = 19; // Failed at level 3
}

// ACDC self-test info
message ACDCSelfTestInfo {
  ACDCSelfTestStatus status = 1;
}

// Task execution result notification
message TaskExecutionResult {
  uint32 task_id = 1;
  TaskExecutionStatus status = 2; // SUCCEEDED or FAILED
}

// coredump partition: 128K
message CoredumpPartitionSlice {
  uint32 timestamp = 1; // unix timestamp
  uint32 offset = 2;
  uint32 size = 3;
  bool last = 4; // last slice
  repeated uint32 data = 5; // 2K
}

// Configuration sync report
message ConfigReport {
  uint64 timestamp = 1;
  MachineConfig config = 2;
}

message ConfigRequest {
  string reason = 1; // Optional reason for the request
}

message FPGAConfig {
  uint32 adc_threshold_low = 1;
  uint32 adc_threshold_high = 2;
  uint32 action_deadzone = 3;
}

message PowerConfig {
  uint32 version = 1;
  uint32 power_budget = 2;

  uint32 device_high_temp_threshold = 3;
  uint32 device_high_temp_min_power = 4;
  uint32 device_low_temp_threshold = 5;
  uint32 device_over_temp_decrement = 6;
  uint32 device_under_temp_increment = 7;
  uint32 device_power_cooldown_time = 8;

  uint32 overprovisioning_threshold = 9;
  uint32 cap_increase_min_threshold = 10;
  uint32 cap_decrease_min_threshold = 11;
  uint32 port_power_cap_increase_threshold = 12;
  uint32 port_power_cap_increase_step = 13;
  uint32 port_power_cap_decrease_threshold = 14;
  uint32 high_power_usage_threshold = 15;
  uint32 low_power_usage_threshold = 16;
  uint32 port_power_adjustment_threshold = 17;
}

message Task {
  uint32 id = 1;
  uint32 run_at = 2; // unix timestamp

  message Command {
    uint32 service = 1;
    bytes data = 2;
  }
  repeated Command commands = 3;
}
Tester sign-up

Leave a message