Introduce USB product name as a dynamic field.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2024-12-17 16:25:47 +01:00
parent 86999d8cdd
commit 7805131d92
2 changed files with 15 additions and 0 deletions

View File

@@ -49,6 +49,11 @@ int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len) {
*p++ = PHY_UP_BTN;
*p++ = phy->up_btn;
}
if (phy->usb_product_present) {
*p++ = PHY_USB_PRODUCT;
strcpy((char *)p, phy->usb_product);
p += strlen(phy->usb_product);
}
*len = p - data;
return PICOKEY_OK;
@@ -86,6 +91,12 @@ int phy_unserialize_data(const uint8_t *data, uint16_t len, phy_data_t *phy) {
phy->up_btn = *p++;
phy->up_btn_present = true;
break;
case PHY_USB_PRODUCT:
memset(phy->usb_product, 0, sizeof(phy->usb_product));
strlcpy(phy->usb_product, (const char *)p, sizeof(phy->usb_product));
phy->usb_product_present = true;
p += strlen(phy->usb_product);
break;
}
}
return PICOKEY_OK;