nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches
ssf_client_notif.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef SSF_CLIENT_NOTIF_H__
8#define SSF_CLIENT_NOTIF_H__
9
10#include <stdbool.h>
11#include <stddef.h>
12#include <stdint.h>
13
15
20typedef int (*ssf_notif_decoder)(const uint8_t *payload, size_t payload_len, void *result,
21 size_t *payload_len_out);
22
28 /* Notification data start */
29 const uint8_t *data;
30 /* Length of notification data */
31 size_t data_len;
32 /*
33 * Start of received packet. For releasing underlying buffer
34 * with ssf_client_transport_decoding_done.
35 */
36 const uint8_t *pkt;
37 /* Notification packet decoder */
39};
40
49typedef int (*ssf_notif_handler)(struct ssf_notification *notif, void *context);
50
55 /* Service ID */
56 uint16_t id;
57 /* Client's version number for the service */
58 uint16_t version;
59 /* Packet decoder for notification */
61 /* Handler for notification */
63 /* Optional user context */
64 void *context;
65 /* Is listener registered */
67};
68
83#define SSF_CLIENT_NOTIF_LISTENER_DEFINE(_name, _srvc_name, _notif_decode, _handler) \
84 static int _handler(struct ssf_notification *notif, void *context); \
85 static struct ssf_client_notif_listener _name = { \
86 .id = (CONFIG_SSF_##_srvc_name##_SERVICE_ID), \
87 .version = (CONFIG_SSF_##_srvc_name##_SERVICE_VERSION), \
88 .notif_decode = (ssf_notif_decoder)_notif_decode, \
89 .handler = _handler, \
90 .is_registered = false \
91 }
92
104int ssf_client_notif_decode(const struct ssf_notification *notif, void *decoded_notif);
105
113
128int ssf_client_notif_register(struct ssf_client_notif_listener *listener, void *context);
129
142
143#endif /* SSF_CLIENT_NOTIF_H__ */
int ssf_client_notif_deregister(struct ssf_client_notif_listener *listener)
De-register a listener. Stops the listener's handler from being called when receiving notifications f...
int(* ssf_notif_decoder)(const uint8_t *payload, size_t payload_len, void *result, size_t *payload_len_out)
SSF notification decode function prototype. Functions of this type are typically generated from cddl ...
Definition ssf_client_notif.h:20
int(* ssf_notif_handler)(struct ssf_notification *notif, void *context)
SSF notification handler prototype.
Definition ssf_client_notif.h:49
void ssf_client_notif_decode_done(struct ssf_notification *notif)
Must be invoked from ssf_notif_handler to free transport layer buffer when the request have been deco...
int ssf_client_notif_decode(const struct ssf_notification *notif, void *decoded_notif)
Decode a received notification.
int ssf_client_notif_register(struct ssf_client_notif_listener *listener, void *context)
Register a listener. Enables the listener's handler to be called when receiving notifications from se...
ssf_notif_handler handler
Definition ssf_client_notif.h:62
ssf_notif_decoder notif_decode
Definition ssf_client_notif.h:60
uint16_t id
Definition ssf_client_notif.h:56
void * context
Definition ssf_client_notif.h:64
bool is_registered
Definition ssf_client_notif.h:66
uint16_t version
Definition ssf_client_notif.h:58
SSF notification listener.
Definition ssf_client_notif.h:54
size_t data_len
Definition ssf_client_notif.h:31
const uint8_t * data
Definition ssf_client_notif.h:29
const uint8_t * pkt
Definition ssf_client_notif.h:36
ssf_notif_decoder notif_decode
Definition ssf_client_notif.h:38
Structure to hold an incoming notification. Decode with ssf_client_notif_decode.
Definition ssf_client_notif.h:27