#include #include "mode_switch_event.h" static const char *mode_name(enum mode_switch_mode mode) { switch (mode) { case MODE_SWITCH_INVALID: return "INVALID"; case MODE_SWITCH_USB: return "USB"; case MODE_SWITCH_24G: return "2.4G"; case MODE_SWITCH_BLE: return "BLE"; default: return "?"; } } static void log_mode_switch_event(const struct app_event_header *aeh) { const struct mode_switch_event *event = cast_mode_switch_event(aeh); APP_EVENT_MANAGER_LOG(aeh, "mode:%s voltage:%" PRIu16 "mV", mode_name(event->mode), event->voltage_mv); } static void profile_mode_switch_event(struct log_event_buf *buf, const struct app_event_header *aeh) { const struct mode_switch_event *event = cast_mode_switch_event(aeh); nrf_profiler_log_encode_uint8(buf, event->mode); nrf_profiler_log_encode_uint16(buf, event->voltage_mv); } APP_EVENT_INFO_DEFINE(mode_switch_event, ENCODE(NRF_PROFILER_ARG_U8, NRF_PROFILER_ARG_U16), ENCODE("mode", "voltage_mv"), profile_mode_switch_event); APP_EVENT_TYPE_DEFINE(mode_switch_event, log_mode_switch_event, &mode_switch_event_info, APP_EVENT_FLAGS_CREATE( APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));