2026-04-13 16:43:17 +08:00
|
|
|
#ifndef BLINKY_DATETIME_EVENT_H_
|
|
|
|
|
#define BLINKY_DATETIME_EVENT_H_
|
|
|
|
|
|
2026-04-14 16:42:04 +08:00
|
|
|
#include <errno.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2026-04-13 16:43:17 +08:00
|
|
|
#include <app_event_manager.h>
|
|
|
|
|
#include <app_event_manager_profiler_tracer.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define DATETIME_EVENT_DATE_TEXT_LEN 16
|
|
|
|
|
#define DATETIME_EVENT_TIME_TEXT_LEN 16
|
|
|
|
|
|
|
|
|
|
struct datetime_event {
|
|
|
|
|
struct app_event_header header;
|
|
|
|
|
char date_text[DATETIME_EVENT_DATE_TEXT_LEN];
|
|
|
|
|
char time_text[DATETIME_EVENT_TIME_TEXT_LEN];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
APP_EVENT_TYPE_DECLARE(datetime_event);
|
|
|
|
|
|
2026-04-14 16:42:04 +08:00
|
|
|
static inline int submit_datetime_event(const char *date_text, const char *time_text)
|
|
|
|
|
{
|
|
|
|
|
struct datetime_event *event = new_datetime_event();
|
|
|
|
|
|
|
|
|
|
if ((date_text == NULL) || (time_text == NULL)) {
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strncpy(event->date_text, date_text, sizeof(event->date_text));
|
|
|
|
|
event->date_text[sizeof(event->date_text) - 1] = '\0';
|
|
|
|
|
strncpy(event->time_text, time_text, sizeof(event->time_text));
|
|
|
|
|
event->time_text[sizeof(event->time_text) - 1] = '\0';
|
|
|
|
|
APP_EVENT_SUBMIT(event);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-13 16:43:17 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* BLINKY_DATETIME_EVENT_H_ */
|