12constexpr size_t NVS_NAMESPACE_MAX_LEN = 15;
20constexpr uint32_t LINEAR_MEMORY_MIN_KB = 16;
21constexpr uint32_t LINEAR_MEMORY_MAX_KB = 4096;
24bool isValidUuid128(
const std::string& s)
26 static constexpr size_t kLen = 36;
27 static constexpr size_t kDashPos[] = {8, 13, 18, 23};
28 if (s.size() != kLen)
return false;
29 for (
size_t pos : kDashPos)
if (s[pos] !=
'-')
return false;
30 for (
size_t i = 0; i < kLen; ++i) {
31 if (i == 8 || i == 13 || i == 18 || i == 23)
continue;
33 bool digit = (c >=
'0' && c <=
'9');
34 bool lower = (c >=
'a' && c <=
'f');
35 if (!digit && !lower)
return false;
54 "linear_memory_kb out of [" +
55 std::to_string(LINEAR_MEMORY_MIN_KB) +
", " +
56 std::to_string(LINEAR_MEMORY_MAX_KB) +
"]" };
60 if (
name.empty() ||
name.size() > RMEM_NAME_MAX_LEN) {
62 "rmem name '" +
name +
"' must be 1-" +
63 std::to_string(RMEM_NAME_MAX_LEN) +
" chars" };
70 "ecc name '" +
name +
"' must be 1-" +
78 "GPIO " + std::to_string(pin) +
" is reserved by firmware hardware" };
82 "GPIO " + std::to_string(pin) +
" not on plugin whitelist" };
89 "PWM pin " + std::to_string(pin) +
" is reserved by firmware hardware" };
93 "PWM pin " + std::to_string(pin) +
" not on plugin whitelist" };
100 "ADC pin " + std::to_string(pin) +
" is reserved by firmware hardware" };
104 "ADC pin " + std::to_string(pin) +
" not on plugin whitelist" };
113 "I2C bus 0 is reserved for internal hardware" };
119 if (ns.size() > NVS_NAMESPACE_MAX_LEN) {
121 "nvs_namespace exceeds " +
122 std::to_string(NVS_NAMESPACE_MAX_LEN) +
" chars" };
124 const bool prefixOk = ns.rfind(
"plg_", 0) == 0 ||
125 ns.rfind(
"plugin_", 0) == 0;
128 "nvs_namespace must start with 'plg_' or 'plugin_'" };
131 bool ok = (c >=
'a' && c <=
'z') || (c >=
'0' && c <=
'9') || c ==
'_';
134 "nvs_namespace must be [a-z0-9_]" };
139 "nvs_namespace required when persistent state used" };
143 if (!isValidUuid128(uuid)) {
145 "ble_service_uuid '" + uuid +
146 "' not a 128-bit lowercase UUID" };
Load-time validation of plugin capabilities + manifest sanity.
Single source of truth for plugin-accessible GPIO pins.
char name[cdc::hal::ISecureElement::RMEM_NAME_LEN]
static CapabilityCheckResult validate(const PluginManifest &manifest)
#define HOST_ECC_NAME_MAX
#define HOST_RMEM_NAME_MAX
CDC Badge OS plugin host API - canonical C ABI contract.
#define HOST_API_LEVEL_MAJOR
#define HOST_API_LEVEL_STR
#define HOST_API_LEVEL_MINOR
bool isAllowed(uint8_t pin)
bool isBlocked(uint8_t pin)
std::vector< std::string > rmem
std::vector< std::string > ecc
std::vector< uint8_t > i2c_bus
std::vector< uint8_t > adc_pins
std::vector< uint8_t > gpio_pins
std::string nvs_namespace
std::vector< std::string > ble_service_uuids
std::vector< uint8_t > pwm_pins
uint32_t linear_memory_kb
std::string host_api_level_min
PluginCapabilities capabilities