diff --git a/include/thingset.h b/include/thingset.h index f6eae95..67a53f6 100644 --- a/include/thingset.h +++ b/include/thingset.h @@ -1365,10 +1365,10 @@ enum thingset_callback_reason }; /** Function to be called before/after read/write operations to groups. */ -typedef void (*thingset_group_callback_t)(enum thingset_callback_reason cb_reason); +typedef int (*thingset_group_callback_t)(enum thingset_callback_reason cb_reason); /** Function to be called before/after read/write operations to records. */ -typedef void (*thingset_records_callback_t)(enum thingset_callback_reason cb_reason, int index); +typedef int (*thingset_records_callback_t)(enum thingset_callback_reason cb_reason, int index); /** @cond INTERNAL_HIDDEN */ diff --git a/src/thingset_common.c b/src/thingset_common.c index 30cdc97..8bd089d 100644 --- a/src/thingset_common.c +++ b/src/thingset_common.c @@ -346,7 +346,10 @@ int thingset_common_update(struct thingset_context *ts) ts->api->deserialize_map_start(ts); if (ts->endpoint.object->data.group_callback != NULL) { - ts->endpoint.object->data.group_callback(THINGSET_CALLBACK_PRE_WRITE); + int ret = ts->endpoint.object->data.group_callback(THINGSET_CALLBACK_PRE_WRITE); + if (ret < 0) { + return ts->api->serialize_response(ts, THINGSET_ERR_BAD_REQUEST, "Callback error %i", ret); + } } /* actually write data */ @@ -364,7 +367,10 @@ int thingset_common_update(struct thingset_context *ts) } if (ts->endpoint.object->data.group_callback != NULL) { - ts->endpoint.object->data.group_callback(THINGSET_CALLBACK_POST_WRITE); + int ret = ts->endpoint.object->data.group_callback(THINGSET_CALLBACK_POST_WRITE); + if (ret < 0) { + return ts->api->serialize_response(ts, THINGSET_ERR_BAD_REQUEST, "Callback error %i", ret); + } } /*