Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
event.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Vogl Electronic GmbH
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
19#ifndef ZEPHYR_INCLUDE_MGMT_HAWKBIT_EVENT_H_
20#define ZEPHYR_INCLUDE_MGMT_HAWKBIT_EVENT_H_
21
22#include <zephyr/kernel.h>
23#include <zephyr/sys/slist.h>
24
61
62struct hawkbit_event_callback;
63
75typedef void (*hawkbit_event_callback_handler_t)(struct hawkbit_event_callback *cb,
76 enum hawkbit_event_type event);
77
90struct hawkbit_event_callback {
92 sys_snode_t node;
93
96
98 enum hawkbit_event_type event;
99};
100
113#define HAWKBIT_EVENT_CREATE_CALLBACK(_callback, _handler, _event) \
114 struct hawkbit_event_callback _callback = { \
115 .handler = _handler, \
116 .event = _event, \
117 }
118
126static inline void hawkbit_event_init_callback(struct hawkbit_event_callback *callback,
128 enum hawkbit_event_type event)
129{
130 __ASSERT(callback, "Callback pointer should not be NULL");
131 __ASSERT(handler, "Callback handler pointer should not be NULL");
132
133 callback->handler = handler;
134 callback->event = event;
135}
136
144int hawkbit_event_add_callback(struct hawkbit_event_callback *cb);
145
153int hawkbit_event_remove_callback(struct hawkbit_event_callback *cb);
154
159#endif /* ZEPHYR_INCLUDE_MGMT_HAWKBIT_EVENT_H_ */
static void hawkbit_event_init_callback(struct hawkbit_event_callback *callback, hawkbit_event_callback_handler_t handler, enum hawkbit_event_type event)
Helper to initialize a struct hawkbit_event_callback properly.
Definition event.h:126
void(* hawkbit_event_callback_handler_t)(struct hawkbit_event_callback *cb, enum hawkbit_event_type event)
Define the application callback handler function signature.
Definition event.h:75
int hawkbit_event_add_callback(struct hawkbit_event_callback *cb)
Add an application callback.
hawkbit_event_type
hawkBit event type.
Definition event.h:31
int hawkbit_event_remove_callback(struct hawkbit_event_callback *cb)
Remove an application callback.
@ HAWKBIT_EVENT_ERROR_ALLOC
Event triggered when there was an allocation error.
Definition event.h:43
@ HAWKBIT_EVENT_END_RUN
Event triggered after the hawkBit run ends.
Definition event.h:57
@ HAWKBIT_EVENT_BEFORE_REBOOT
Event triggered before hawkBit does a reboot.
Definition event.h:59
@ HAWKBIT_EVENT_ERROR_PERMISSION
Event triggered when there was a permission error.
Definition event.h:37
@ HAWKBIT_EVENT_ERROR
Event triggered when there was an error.
Definition event.h:33
@ HAWKBIT_EVENT_NO_UPDATE
Event triggered when there is no update available.
Definition event.h:47
@ HAWKBIT_EVENT_UPDATE_DOWNLOADED
Event triggered when a new update was downloaded.
Definition event.h:45
@ HAWKBIT_EVENT_ERROR_DOWNLOAD
Event triggered when there was a download error.
Definition event.h:41
@ HAWKBIT_EVENT_END_DOWNLOAD
Event triggered after the download ends.
Definition event.h:53
@ HAWKBIT_EVENT_START_DOWNLOAD
Event triggered before the download starts.
Definition event.h:51
@ HAWKBIT_EVENT_START_RUN
Event triggered before the hawkBit run starts.
Definition event.h:55
@ HAWKBIT_EVENT_ERROR_NETWORKING
Event triggered when there was a networking error.
Definition event.h:35
@ HAWKBIT_EVENT_CANCEL_UPDATE
Event triggered when the update was canceled by the server.
Definition event.h:49
@ HAWKBIT_EVENT_ERROR_METADATA
Event triggered when there was a metadata error.
Definition event.h:39
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
Public kernel APIs.