#include #include "usb_state_event.h" static const char *usb_state_name(enum usb_state state) { switch (state) { case USB_STATE_DISABLED: return "disabled"; case USB_STATE_DISCONNECTED: return "disconnected"; case USB_STATE_POWERED: return "powered"; case USB_STATE_ACTIVE: return "active"; case USB_STATE_SUSPENDED: return "suspended"; default: return "?"; } } static void log_usb_state_event(const struct app_event_header *aeh) { const struct usb_state_event *event = cast_usb_state_event(aeh); APP_EVENT_MANAGER_LOG(aeh, "state:%s", usb_state_name(event->state)); } static void profile_usb_state_event(struct log_event_buf *buf, const struct app_event_header *aeh) { const struct usb_state_event *event = cast_usb_state_event(aeh); nrf_profiler_log_encode_uint8(buf, event->state); } APP_EVENT_INFO_DEFINE(usb_state_event, ENCODE(NRF_PROFILER_ARG_U8), ENCODE("state"), profile_usb_state_event); APP_EVENT_TYPE_DEFINE(usb_state_event, log_usb_state_event, &usb_state_event_info, APP_EVENT_FLAGS_CREATE( APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));