Added support to configure LED GPIO, LED brightness and LED dimming.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2024-09-27 20:56:33 +02:00
parent 720c2e45f3
commit 2d09a5c8e5
5 changed files with 109 additions and 13 deletions

View File

@@ -244,18 +244,13 @@ int cbor_config(const uint8_t *data, size_t len) {
}
}
else if (vendorCommandId == CTAP_CONFIG_PHY_LED_GPIO || vendorCommandId == CTAP_CONFIG_PHY_LED_BTNESS) {
if (vendorParam != 0) {
if (vendorCommandId == CTAP_CONFIG_PHY_LED_GPIO) {
tmp[PHY_LED_GPIO] = (uint8_t)vendorParam;
opts |= PHY_OPT_GPIO;
}
else if (vendorCommandId == CTAP_CONFIG_PHY_LED_BTNESS) {
tmp[PHY_LED_BTNESS] = (uint8_t)vendorParam;
opts |= PHY_OPT_BTNESS;
}
if (vendorCommandId == CTAP_CONFIG_PHY_LED_GPIO) {
tmp[PHY_LED_GPIO] = (uint8_t)vendorParam;
opts |= PHY_OPT_GPIO;
}
else {
CBOR_ERROR(CTAP2_ERR_MISSING_PARAMETER);
else if (vendorCommandId == CTAP_CONFIG_PHY_LED_BTNESS) {
tmp[PHY_LED_BTNESS] = (uint8_t)vendorParam;
opts |= PHY_OPT_BTNESS;
}
}
else if (vendorCommandId == CTAP_CONFIG_PHY_OPTS) {

View File

@@ -249,6 +249,21 @@ int cbor_vendor_generic(uint8_t cmd, const uint8_t *data, size_t len) {
goto err;
}
}
else if (cmd == CTAP_VENDOR_PHY_OPTS) {
if (vendorCmd == 0x01) {
uint16_t opts = 0;
if (file_has_data(ef_phy)) {
uint8_t *data = file_get_data(ef_phy);
opts = (data[PHY_OPTS] << 8) | data[PHY_OPTS+1];
}
CBOR_CHECK(cbor_encoder_create_map(&encoder, &mapEncoder, 1));
CBOR_CHECK(cbor_encode_uint(&mapEncoder, 0x01));
CBOR_CHECK(cbor_encode_uint(&mapEncoder, opts));
}
else {
CBOR_ERROR(CTAP2_ERR_UNSUPPORTED_OPTION);
}
}
else {
CBOR_ERROR(CTAP2_ERR_UNSUPPORTED_OPTION);
}

View File

@@ -125,6 +125,7 @@ typedef struct {
#define CTAP_VENDOR_MSE 0x02
#define CTAP_VENDOR_UNLOCK 0x03
#define CTAP_VENDOR_EA 0x04
#define CTAP_VENDOR_PHY_OPTS 0x05
#define CTAP_PERMISSION_MC 0x01 // MakeCredential
#define CTAP_PERMISSION_GA 0x02 // GetAssertion