Updated README for server callbacks args

This commit is contained in:
Valerio De Benedetto 2023-12-07 13:24:38 +01:00
parent 8518842709
commit 8a0f4af727
2 changed files with 6 additions and 7 deletions

View File

@ -122,12 +122,11 @@ Their return value should be the number of bytes actually read/written, or `< 0`
A return value between `0` and `count - 1` will be treated as if a timeout occurred on the transport side. All other
values will be treated as transport errors.
### Platform functions argument
### Callbacks and platform functions arguments
Platform functions and server callbacks can access arbitrary user data through their `void* arg` argument. The argument
is useful, for example, to pass the connection a function should operate on.
Its initial value can be set inside the `nmbs_platform_conf` struct when creating the `nmbs_t` instance, and changed at
any time via the `nmbs_set_platform_arg` API method.
Server callbacks and platform functions can access arbitrary user data through their `void* arg` argument. The argument
is useful, for example, to pass the connection a function should operate on.
Their initial values can be set via the `nmbs_set_callbacks_arg` and `nmbs_set_platform_arg` API methods.
## Tests and examples

View File

@ -274,8 +274,8 @@ nmbs_error nmbs_server_create(nmbs_t* nmbs, uint8_t address_rtu, const nmbs_plat
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
* @param nmbs pointer to the nmbs_t instance
* @param arg user data argument
*/
void nmbs_set_callbacks_arg(nmbs_t* nmbs, void* arg);
#endif