feat(protocol): 添加时间同步和主题颜色协议支持

- 添加CDC_PROTO_TYPE_LED_STATE、CDC_PROTO_TYPE_TIME_SYNC和
  CDC_PROTO_TYPE_THEME_RGB协议类型定义
- 在protobuf中定义LedState、TimeSync和ThemeRgb消息结构
- 更新CdcPacketBody消息以包含新的协议类型
- 增加协议能力标志位以支持新功能
This commit is contained in:
2026-04-13 16:43:17 +08:00
parent 23e23f63a7
commit c342a8d3f0
13 changed files with 579 additions and 5 deletions

View File

@@ -0,0 +1,27 @@
#include "datetime_event.h"
static void log_datetime_event(const struct app_event_header *aeh)
{
const struct datetime_event *event = cast_datetime_event(aeh);
APP_EVENT_MANAGER_LOG(aeh, "date:%s time:%s",
event->date_text, event->time_text);
}
static void profile_datetime_event(struct log_event_buf *buf,
const struct app_event_header *aeh)
{
ARG_UNUSED(buf);
ARG_UNUSED(aeh);
}
APP_EVENT_INFO_DEFINE(datetime_event,
ENCODE(),
ENCODE(),
profile_datetime_event);
APP_EVENT_TYPE_DEFINE(datetime_event,
log_datetime_event,
&datetime_event_info,
APP_EVENT_FLAGS_CREATE(
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));

View File

@@ -0,0 +1,34 @@
#include "theme_rgb_update_event.h"
static void log_theme_rgb_update_event(const struct app_event_header *aeh)
{
const struct theme_rgb_update_event *event =
cast_theme_rgb_update_event(aeh);
APP_EVENT_MANAGER_LOG(aeh, "r:%u g:%u b:%u",
event->theme.r, event->theme.g, event->theme.b);
}
static void profile_theme_rgb_update_event(struct log_event_buf *buf,
const struct app_event_header *aeh)
{
const struct theme_rgb_update_event *event =
cast_theme_rgb_update_event(aeh);
nrf_profiler_log_encode_uint8(buf, event->theme.r);
nrf_profiler_log_encode_uint8(buf, event->theme.g);
nrf_profiler_log_encode_uint8(buf, event->theme.b);
}
APP_EVENT_INFO_DEFINE(theme_rgb_update_event,
ENCODE(NRF_PROFILER_ARG_U8,
NRF_PROFILER_ARG_U8,
NRF_PROFILER_ARG_U8),
ENCODE("r", "g", "b"),
profile_theme_rgb_update_event);
APP_EVENT_TYPE_DEFINE(theme_rgb_update_event,
log_theme_rgb_update_event,
&theme_rgb_update_event_info,
APP_EVENT_FLAGS_CREATE(
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));

View File

@@ -0,0 +1,41 @@
#include "time_sync_event.h"
static void log_time_sync_event(const struct app_event_header *aeh)
{
const struct time_sync_event *event = cast_time_sync_event(aeh);
APP_EVENT_MANAGER_LOG(aeh,
"ver:%u flags:0x%08x tz:%d utc_ms:%llu acc:%u",
event->version,
event->flags,
event->timezone_min,
event->utc_ms,
event->accuracy_ms);
}
static void profile_time_sync_event(struct log_event_buf *buf,
const struct app_event_header *aeh)
{
const struct time_sync_event *event = cast_time_sync_event(aeh);
nrf_profiler_log_encode_uint32(buf, event->version);
nrf_profiler_log_encode_uint32(buf, event->flags);
nrf_profiler_log_encode_int32(buf, event->timezone_min);
nrf_profiler_log_encode_uint32(buf, (uint32_t)(event->utc_ms & 0xFFFFFFFFULL));
nrf_profiler_log_encode_uint32(buf, event->accuracy_ms);
}
APP_EVENT_INFO_DEFINE(time_sync_event,
ENCODE(NRF_PROFILER_ARG_U32,
NRF_PROFILER_ARG_U32,
NRF_PROFILER_ARG_S32,
NRF_PROFILER_ARG_U32,
NRF_PROFILER_ARG_U32),
ENCODE("version", "flags", "timezone_min", "utc_ms_lo", "accuracy_ms"),
profile_time_sync_event);
APP_EVENT_TYPE_DEFINE(time_sync_event,
log_time_sync_event,
&time_sync_event_info,
APP_EVENT_FLAGS_CREATE(
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));