This module provides functions for myGPIOd connection management.
More...
This module provides functions for myGPIOd connection management.
◆ mygpio_conn_state
myGPIOd connections states
| Enumerator |
|---|
| MYGPIO_STATE_OK | OK state.
|
| MYGPIO_STATE_ERROR | Error state, read the error with mygpio_connection_get_error and clear it with mygpio_connection_clear_error.
|
| MYGPIO_STATE_FATAL | Fatal state, read the error with mygpio_connection_get_error. You must reconnect to recover.
|
◆ mygpio_connection_clear_error()
Clears the current error message. MYGPIO_STATE_FATAL messages can not be cleared.
- Parameters
-
| connection | Pointer to the connection struct returned by mygpio_connection_new. |
- Returns
- true on success, else false
◆ mygpio_connection_free()
Closes the connection and frees the t_mygpio_connection struct
- Parameters
-
| connection | Pointer to the connection struct returned by mygpio_connection_new. |
◆ mygpio_connection_get_error()
Gets the current error message.
- Parameters
-
| connection | Pointer to the connection struct returned by mygpio_connection_new. |
- Returns
- Error message or NULL if no error is present
◆ mygpio_connection_get_fd()
Returns the file descriptor of the underlying socket. You can use it to poll the file descriptor in an external event loop.
- Parameters
-
| connection | Pointer to the connection struct returned by mygpio_connection_new. |
- Returns
- File descriptor
◆ mygpio_connection_get_state()
Gets the current connection state. Use mygpio_connection_get_error to get the error message and mygpio_connection_clear_error to clear it.
- Parameters
-
| connection | Pointer to the connection struct returned by mygpio_connection_new. |
- Returns
- The connection state
◆ mygpio_connection_get_version()
Gets the server version.
- Parameters
-
| connection | Pointer to the connection struct returned by mygpio_connection_new. |
- Returns
- Unsigned array consisting of major, minor and patch version.
◆ mygpio_connection_new()
| struct t_mygpio_connection * mygpio_connection_new |
( |
const char * | socket_path, |
|
|
int | timeout_ms ) |
Creates a new connection to the myGPIOd socket and tries to connect. Check the state with mygpio_connection_get_state. It must be freed by the caller with mygpio_connection_free.
- Parameters
-
| socket_path | Server socket to connect to. |
| timeout_ms | The read timeout in milliseconds |
- Returns
- Returns the t_mygpio_connection struct on NULL in a out of memory condition.