nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
at_monitor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef AT_MONITOR_H_
8#define AT_MONITOR_H_
9
10#include <stddef.h>
11#include <stdbool.h>
12#include <zephyr/kernel.h>
13#include <zephyr/sys/util_macro.h>
14#include <zephyr/toolchain.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
35typedef void (*at_monitor_handler_t)(const char *notif);
36
42 const char *filter;
45 struct {
46 uint8_t paused : 1; /* Monitor is paused. */
47 uint8_t direct : 1; /* Dispatch in ISR. */
49};
50
52#define ANY NULL
54#define PAUSED 1
56#define ACTIVE 0
57
68#define AT_MONITOR(name, _filter, _handler, ...) \
69 static void _handler(const char *); \
70 static STRUCT_SECTION_ITERABLE(at_monitor_entry, name) = { \
71 .filter = _filter, \
72 .handler = _handler, \
73 .flags.direct = false, \
74 COND_CODE_1(__VA_ARGS__, (.flags.paused = __VA_ARGS__,), ()) \
75 }
76
87#define AT_MONITOR_ISR(name, _filter, _handler, ...) \
88 static void _handler(const char *); \
89 static STRUCT_SECTION_ITERABLE(at_monitor_entry, name) = { \
90 .filter = _filter, \
91 .handler = _handler, \
92 .flags.direct = true, \
93 COND_CODE_1(__VA_ARGS__, (.flags.paused = __VA_ARGS__,), ()) \
94 }
95
103static inline void at_monitor_pause(struct at_monitor_entry *mon)
104{
105 mon->flags.paused = true;
106}
107
115static inline void at_monitor_resume(struct at_monitor_entry *mon)
116{
117 mon->flags.paused = false;
118}
119
122#ifdef __cplusplus
123}
124#endif
125
126#endif /* AT_MONITOR_H_ */
void(* at_monitor_handler_t)(const char *notif)
AT monitor callback.
Definition: at_monitor.h:35
static void at_monitor_pause(struct at_monitor_entry *mon)
Pause monitor.
Definition: at_monitor.h:103
static void at_monitor_resume(struct at_monitor_entry *mon)
Resume monitor.
Definition: at_monitor.h:115
uint8_t direct
Definition: at_monitor.h:47
const char * filter
Definition: at_monitor.h:42
struct at_monitor_entry::@174 flags
const at_monitor_handler_t handler
Definition: at_monitor.h:44
uint8_t paused
Definition: at_monitor.h:46
AT monitor entry.
Definition: at_monitor.h:40