diff --git a/armsrc/appmain.c b/armsrc/appmain.c index eebe43189..09f06dbec 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -4098,6 +4098,20 @@ static void PacketReceived(PacketCommandNG *packet) { SendCapabilities(); break; } + case CMD_CEP_STATUS: { + cep_status_t status = {0}; +#ifdef WITH_CEP + status.cep_active = cep_is_active(); +#endif +#ifdef WITH_BWM_STATUS + bwm_read_battery_info(&status.battery); +#endif + if (CheckValidInformationMagic(&g_version_information)) { + strncpy(status.fw_version, g_version_information.gitversion, sizeof(status.fw_version) - 1); + } + reply_ng(CMD_CEP_STATUS, PM3_SUCCESS, (uint8_t *)&status, sizeof(status)); + break; + } case CMD_PING: { reply_ng(CMD_PING, PM3_SUCCESS, packet->data.asBytes, packet->length); break; diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index d60f8204e..b1dbf03de 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -1008,6 +1008,23 @@ typedef struct { // underlying data source and by clients (e.g. the Flipper Zero FAP) that want the raw // numbers instead of hw status's free-text Dbprintf lines. #define CMD_PM5_BWM_GET_BATTERY 0x0184 +// PM5, live hardware-status snapshot (CEP handshake state, battery telemetry, +// firmware version) for the Flipper Zero FAP's status page and any future +// client. Always answers PM3_SUCCESS with every field it can - fields for a +// feature this build doesn't have (no WITH_CEP, no WITH_BWM_STATUS) read as +// zero/false rather than the command failing. A client that also wants to +// distinguish "zero" from "not built" should check CMD_CAPABILITIES' +// compiled_with_cep/compiled_with_bwm first. +// req: none. resp: cep_status_t. +#define CMD_CEP_STATUS 0x0185 +typedef struct { + uint8_t cep_active; // cep_is_active(): handshake complete, SPI transport live + bwm_battery_info_t battery; // bwm_read_battery_info(); all-zero if WITH_BWM_STATUS not built + char fw_version[24]; // g_version_information.gitversion, NUL-terminated, may truncate + // Appended in a future version once cep_is_attached() lands (PR #3687, + // not yet merged): a cep_attached byte distinguishing "physically + // present, handshake not yet complete" from "active". +} PACKED cep_status_t; #define BWM_OTA_ACTION_BEGIN 0x00 #define BWM_OTA_ACTION_WRITE 0x01 #define BWM_OTA_ACTION_END 0x02