Add argument for callbacks structure

This commit is contained in:
Hossein.M 2023-12-06 10:03:29 +03:30
parent 18207a40fe
commit 8aca15dfc9
2 changed files with 12 additions and 1 deletions

View File

@ -1575,6 +1575,11 @@ nmbs_error nmbs_server_poll(nmbs_t* nmbs) {
return NMBS_ERROR_NONE;
}
void nmbs_set_callbacks_arg(nmbs_t* nmbs, void* arg)
{
nmbs->callbacks.arg = arg;
}
#endif

View File

@ -195,7 +195,7 @@ typedef struct nmbs_callbacks {
#endif
#endif
char _nonempty; // Struct may become empty, which is undefined behavior
void* arg; // User data, will be passed to functions above
} nmbs_callbacks;
@ -272,6 +272,12 @@ nmbs_error nmbs_server_create(nmbs_t* nmbs, uint8_t address_rtu, const nmbs_plat
* @return NMBS_ERROR_NONE if successful, other errors otherwise.
*/
nmbs_error nmbs_server_poll(nmbs_t* nmbs);
/** Set the pointer to user data argument passed to server request callbacks.
* @param nmbs pointer to the nmbs_t instance
* @param arg user data argument
*/
void nmbs_set_callbacks_arg(nmbs_t* nmbs, void* arg);
#endif
#ifndef NMBS_CLIENT_DISABLED