客户侧能力:RTC、开机锁键与 BLE 协议收敛

1、新增 usr_periph RTC,DEVICEINFO 自动对时;对外精简为 get_time(sys_time*),开发板 RTC 时钟改用 LRC
2、iokey 开机锁键改为公开 start/stop 接口,板级宏 TCFG_IOKEY_BOOT_LOCK_ENABLE 可关闭
3、对齐模组 BLE 收发/组包与公开 API,更新 libusr_le_code.a;Release 包命名调整为 JBao_JL7016_SOC_SDK_Vx.x.x
This commit is contained in:
2026-08-19 15:26:35 +08:00
parent 3e9fb2cd06
commit aa724c6758
21 changed files with 1118 additions and 600 deletions
+58 -3
View File
@@ -671,6 +671,55 @@ int bleproto_appdata_serialize(bleproto_appdata_t *appdata,
return (offset);
}
int bleproto_appdata_wrap_raw(uint8_t *txbuf,
uint16_t txbuf_size,
const bleproto_appdata_header_t *header,
const uint8_t *payload,
uint16_t payload_len)
{
uint16_t total;
if (!txbuf || !header) {
BLEPROTO_T_E("Invalid parameters");
return -1;
}
if (payload_len > 0 && !payload) {
BLEPROTO_T_E("Invalid payload");
return -1;
}
/* 单帧 this_frame_len 为 uint8,超过 255 需走分包 serialize */
if (payload_len > 255u) {
BLEPROTO_T_E("payload too long for single frame");
return -1;
}
total = (uint16_t)(BLEPROTO_APPDATA_HEADR_LEN + payload_len);
if (txbuf_size < total) {
BLEPROTO_T_E("txbuf too short");
return -1;
}
/* buf[0]: version[2:0] | datafmt[3:3] | msgtype[7:4] */
txbuf[0] = UTILS_BITFIELD_SET(header->version, 2, 0) |
UTILS_BITFIELD_SET(header->datafmt, 3, 3) |
UTILS_BITFIELD_SET(header->msgtype, 7, 4);
/* buf[1]: msgid[3:0] | encrypt[4:4] | reserve[7:5] */
txbuf[1] = UTILS_BITFIELD_SET(header->msgid, 3, 0) |
UTILS_BITFIELD_SET(header->encrypt, 4, 4) |
UTILS_BITFIELD_SET(header->reserve, 7, 5);
txbuf[2] = 1; /* totalframe */
txbuf[3] = 0; /* frameseq:单帧为 0 */
txbuf[4] = (uint8_t)payload_len; /* this frame payload len */
txbuf[5] = header->serviceid;
proto_bytes_put_le16(&txbuf[6], payload_len);
if (payload_len > 0) {
memcpy(&txbuf[BLEPROTO_APPDATA_HEADR_LEN], payload, payload_len);
}
return (int)total;
}
int bleproto_appdata_deserialize(uint8_t * buf,
uint16_t len,
bleproto_appdata_t *appdata)
@@ -1958,8 +2007,12 @@ int bleproto_encbin_otadata_rsp(const bleproto_otadata_rsp_t *p,
data[offset++] = (uint8_t)((p->len >> 16) & 0xFF);
data[offset++] = (uint8_t)((p->len >> 24) & 0xFF);
/* serialize data */
/* serialize datadata 为外部指针,不再内嵌数组) */
if (p->len > 0 && p->len <= BLEPROTO_APPDATA_OTADATA_SZ) {
if (!p->data) {
BLEPROTO_T_E("otadata_rsp.data is NULL");
return -1;
}
memcpy(&data[offset], p->data, p->len);
offset += p->len;
}
@@ -2984,10 +3037,12 @@ int bleproto_debin_otadata_rsp(const uint8_t * data,
return -1;
}
/* deserialize data */
/* 零拷贝:指向输入缓冲,调用方须在下次 decode 前用完 */
if (rsp->len > 0) {
memcpy(rsp->data, &data[offset], rsp->len);
rsp->data = &data[offset];
offset += rsp->len;
} else {
rsp->data = NULL;
}
return offset;