mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-18 20:35:57 +02:00
format_tlv_len() accepts NULL argument.
In that case, it returns the length of the length in bytes. Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -1495,18 +1495,23 @@ void led_off_all() {
|
|||||||
|
|
||||||
int format_tlv_len(size_t len, uint8_t *out) {
|
int format_tlv_len(size_t len, uint8_t *out) {
|
||||||
if (len < 128) {
|
if (len < 128) {
|
||||||
|
if (out)
|
||||||
*out = len;
|
*out = len;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (len < 256) {
|
else if (len < 256) {
|
||||||
|
if (out) {
|
||||||
*out++ = 0x81;
|
*out++ = 0x81;
|
||||||
*out++ = len;
|
*out++ = len;
|
||||||
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (out) {
|
||||||
*out++ = 0x82;
|
*out++ = 0x82;
|
||||||
*out++ = (len >> 8) & 0xff;
|
*out++ = (len >> 8) & 0xff;
|
||||||
*out++ = len & 0xff;
|
*out++ = len & 0xff;
|
||||||
|
}
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user