Files
story/firmware/echoear-platform-agent/main/ble_name.h
T
Codex Local bf1233d5df
ci / verify (push) Canceled after 0s
feat: expand companion platform, device controls, and memoir workflows
Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
2026-10-08 10:06:44 +08:00

26 lines
912 B
C

#ifndef VOICELINK_BLE_NAME_H
#define VOICELINK_BLE_NAME_H
#include <stdio.h>
#include <string.h>
// Legacy scan response: 31 bytes minus AD length/type = 29 name bytes.
// "vl-" (3) + model (<=17 UTF-8 bytes) + "-" (1) + ID (8).
#define VOICELINK_BLE_NAME_CAPACITY 30
static inline void voicelink_ble_name(char out[VOICELINK_BLE_NAME_CAPACITY],
const char *model, const char *factory_id)
{
size_t model_len = strlen(model);
if (model_len > 17) {
model_len = 17;
// Do not truncate inside a UTF-8 code point.
while (model_len && ((unsigned char)model[model_len] & 0xc0) == 0x80)
model_len--;
}
size_t id_len = strlen(factory_id);
const char *suffix = id_len >= 8 ? factory_id + id_len - 8 : factory_id;
snprintf(out, VOICELINK_BLE_NAME_CAPACITY, "vl-%.*s-%s",
(int)model_len, model, suffix);
}
#endif