mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-04-23 09:22:59 +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) {
|
||||
if (len < 128) {
|
||||
*out = len;
|
||||
if (out)
|
||||
*out = len;
|
||||
return 1;
|
||||
}
|
||||
else if (len < 256) {
|
||||
*out++ = 0x81;
|
||||
*out++ = len;
|
||||
if (out) {
|
||||
*out++ = 0x81;
|
||||
*out++ = len;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
*out++ = 0x82;
|
||||
*out++ = (len >> 8) & 0xff;
|
||||
*out++ = len & 0xff;
|
||||
if (out) {
|
||||
*out++ = 0x82;
|
||||
*out++ = (len >> 8) & 0xff;
|
||||
*out++ = len & 0xff;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user