18#define APP_NAME "CDCBos"
21#define APP_VERSION "unknown"
48 case 1:
return FEATURE_USB;
51 case 2:
return FEATURE_WIFI;
54 case 3:
return FEATURE_BLE;
57 case 4:
return FEATURE_FIDO2;
60 case 5:
return FEATURE_TOTP;
63 case 6:
return FEATURE_GPG;
68 default:
return false;
76 static uint64_t lastIdle = 0;
77 static uint64_t lastWall = 0;
78 static bool primed =
false;
79 static uint8_t cached = 0;
80 static constexpr uint64_t kRefreshUs = 500000ULL;
82 uint64_t now =
static_cast<uint64_t
>(esp_timer_get_time());
83 if (primed && (now - lastWall) < kRefreshUs)
return cached;
95 uint64_t denom = (wall - lastWall) * 2;
96 uint64_t idleDelta = idle - lastIdle;
99 if (denom == 0)
return cached;
100 if (idleDelta > denom) idleDelta = denom;
101 cached =
static_cast<uint8_t
>(100 - (idleDelta * 100) / denom);
static bool sample(uint64_t &idleUs, uint64_t &wallUs)
Snapshot cumulative idle CPU time and the wall-clock reference.
#define BUILD_PROFILE_BYTE
int host_get_build_profile(char *out, size_t out_size)
Copy the build profile name (e.g. "release", "debug") into out.
uint8_t host_cpu_load(void)
Aggregate CPU load across all cores as 0..100 percent. Sampled on demand from FreeRTOS run-time stats...
bool host_feature_enabled(uint16_t feature_id)
True when the firmware was built with the given feature id enabled.
int host_get_firmware_version(char *out, size_t out_size)
Copy the firmware semver string into out.
CDC Badge OS plugin host API - canonical C ABI contract.
#define HOST_ERR_INVALID_ARG