From 6aff6ea554869c59f2a249a850e9523ff2ca6509 Mon Sep 17 00:00:00 2001 From: ppelikan-nordic Date: Wed, 24 Jul 2024 16:34:22 +0200 Subject: [PATCH] nrfs: error handling in NRFS dispatcher with unsolicited handler --- nrfs/include/internal/nrfs_hdr.h | 2 -- nrfs/include/internal/requests/nrfs_reqs_common.h | 2 -- nrfs/src/internal/nrfs_dispatcher.c | 10 ++++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nrfs/include/internal/nrfs_hdr.h b/nrfs/include/internal/nrfs_hdr.h index 035ebef6..773d7ce8 100644 --- a/nrfs/include/internal/nrfs_hdr.h +++ b/nrfs/include/internal/nrfs_hdr.h @@ -42,10 +42,8 @@ typedef struct __NRFS_PACKED { #define NRFS_HDR_FILTER_ERR_SET(_p_hdr) NRFS_FILTER_ERR_SET((_p_hdr)->req) -/* Warning! All "UNSOLICITED" features are not supported. This is intended for possible future use. */ #define NRFS_HDR_UNSOLICITED_GET(_p_hdr) NRFS_UNSOLICITED_GET((_p_hdr)->req) -/* Warning! All "UNSOLICITED" features are not supported. This is intended for possible future use. */ #define NRFS_HDR_UNSOLICITED_SET(_p_hdr) NRFS_UNSOLICITED_SET((_p_hdr)->req) #ifdef __cplusplus diff --git a/nrfs/include/internal/requests/nrfs_reqs_common.h b/nrfs/include/internal/requests/nrfs_reqs_common.h index 6f3edf2b..00ce1341 100644 --- a/nrfs/include/internal/requests/nrfs_reqs_common.h +++ b/nrfs/include/internal/requests/nrfs_reqs_common.h @@ -42,10 +42,8 @@ #define NRFS_FILTER_ERR_SET(_req) ((_req) |= NRFS_FILTER_ERR_MASK) -/* Warning! All "UNSOLICITED" features are not supported. This is intended for possible future use. */ #define NRFS_UNSOLICITED_GET(_req) (((_req) & NRFS_UNSOLICITED_MASK) >> NRFS_UNSOLICITED_BITPOS) -/* Warning! All "UNSOLICITED" features are not supported. This is intended for possible future use. */ #define NRFS_UNSOLICITED_SET(_req) ((_req) |= NRFS_UNSOLICITED_MASK) #ifdef __cplusplus diff --git a/nrfs/src/internal/nrfs_dispatcher.c b/nrfs/src/internal/nrfs_dispatcher.c index 34e1cbdd..8beba343 100644 --- a/nrfs/src/internal/nrfs_dispatcher.c +++ b/nrfs/src/internal/nrfs_dispatcher.c @@ -57,7 +57,13 @@ static const nrfs_service_cb_t services_callbacks[] = { #endif }; -/* Warning! All "UNSOLICITED" features are not supported. This is intended for possible future use. */ +/** + * @brief Callback function for general messages, not related to any service. + * + * @param p_buffer Data associated with the message, + * @param size Size of the data buffer. + * + */ void __attribute__((weak)) nrfs_unsolicited_handler(void *p_buffer, size_t size) { (void)p_buffer; @@ -79,7 +85,7 @@ void nrfs_dispatcher_notify(void *p_notification, size_t size) (services_callbacks[srv_id] != NULL)) { services_callbacks[srv_id](p_notification, size); } else { - /* TODO: error! unknown service */ + nrfs_unsolicited_handler(NULL, 0); } } }