Loading...
Searching...
No Matches
state.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024-2026 Carl Seifert
3 * SPDX-FileCopyrightText: 2024-2026 TU Dresden
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
9#include "ztimer.h"
10#include "random.h"
11#include "event.h"
12#include "container.h"
13
14#include "net/unicoap/server.h"
15
16#include "private/packet.h"
17
23
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
65typedef struct {
72 event_t super;
73
81 ztimer_t ztimer;
82} unicoap_scheduled_event_t;
83
87typedef struct unicoap_memo unicoap_memo_t;
88
89/* MARK: - Event Scheduling */
95#define UNICOAP_CLOCK ZTIMER_MSEC
96
105typedef void (*unicoap_event_callback_t)(unicoap_scheduled_event_t* event);
106
114void unicoap_event_schedule(unicoap_scheduled_event_t* event, unicoap_event_callback_t callback,
115 uint32_t duration);
116
126static inline void unicoap_event_reschedule(unicoap_scheduled_event_t* event, uint32_t duration)
127{
128 ztimer_set(UNICOAP_CLOCK, &event->ztimer, duration);
129}
130
139void unicoap_event_cancel(unicoap_scheduled_event_t* event);
141
142/* TODO: Client and advanced server features: Elaborate state management */
143
144#ifdef __cplusplus
145}
146#endif
147
Common macros and compiler attributes/pragmas configuration.
static void unicoap_event_reschedule(unicoap_scheduled_event_t *event, uint32_t duration)
Discards the currently set timeout, and reschedules the event to be posted in duration ms.
Definition state.h:126
void unicoap_event_cancel(unicoap_scheduled_event_t *event)
Cancels the event.
#define UNICOAP_CLOCK
The ztimer clock used for event scheduling.
Definition state.h:95
struct unicoap_memo unicoap_memo_t
Memo typealias.
Definition state.h:87
void(* unicoap_event_callback_t)(unicoap_scheduled_event_t *event)
Scheduled event callback.
Definition state.h:105
void unicoap_event_schedule(unicoap_scheduled_event_t *event, unicoap_event_callback_t callback, uint32_t duration)
Schedules an event on the internal unicoap queue.
struct event event_t
event structure forward declaration
Definition event.h:132
uint32_t ztimer_set(ztimer_clock_t *clock, ztimer_t *timer, uint32_t val)
Set a timer on a clock.
Packet.
Common interface to the software PRNG.
Server APIs.
event structure
Definition event.h:142
ztimer structure
Definition ztimer.h:316
ztimer API