Skip to content

Conversation

@ethan-duckett-brill
Copy link

Add return value to callbacks and do not write the value if the pre write callback fails

@ethan-duckett-brill ethan-duckett-brill force-pushed the userbranch/ethan/callback_rework branch from 2660436 to cafa37c Compare September 26, 2024 15:15

/** 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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful to add the thingset_data_object as a parameter. You can then call this inside the first deserialize_child loop (where some validation is done already).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably have more of a think about value validation tbh. The more important part right now is state checking (which this MR should now allow), and I guess the idea in my head was to permit specific ranges for specific values (I'm thinking imposing the limits from the BQ reference manual on the corresponding values etc) but that functionality likely wouldn't be elegant when calling a group callback.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ultimately, that can probably be added separately regardless IMO as it's nice to have, but not absolutely required right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants