libmygpio
libmygpio API documentation
Loading...
Searching...
No Matches
Idle events

This module provides functions for the idle mode. More...

Enumerations

enum  mygpio_event {
  MYGPIO_EVENT_UNKNOWN = -1 , MYGPIO_EVENT_GPIO_FALLING , MYGPIO_EVENT_GPIO_RISING , MYGPIO_EVENT_GPIO_LONG_PRESS ,
  MYGPIO_EVENT_GPIO_LONG_PRESS_RELEASE , MYGPIO_EVENT_INPUT
}

Functions

enum mygpio_event mygpio_parse_event (const char *str)
const char * mygpio_lookup_event (enum mygpio_event event)
bool mygpio_send_idle (struct t_mygpio_connection *connection)
bool mygpio_send_noidle (struct t_mygpio_connection *connection)
bool mygpio_wait_idle (struct t_mygpio_connection *connection, int timeout)
struct t_mygpio_idle_eventmygpio_recv_idle_event (struct t_mygpio_connection *connection)
unsigned mygpio_idle_event_get_gpio (struct t_mygpio_idle_event *event)
enum mygpio_event mygpio_idle_event_get_event (struct t_mygpio_idle_event *event)
const char * mygpio_idle_event_get_event_name (struct t_mygpio_idle_event *event)
uint64_t mygpio_idle_event_get_timestamp_ms (struct t_mygpio_idle_event *event)
const char * mygpio_idle_event_get_input_device (struct t_mygpio_idle_event *event)
const char * mygpio_idle_event_get_input_type (struct t_mygpio_idle_event *event)
const char * mygpio_idle_event_get_input_code (struct t_mygpio_idle_event *event)
unsigned mygpio_idle_event_get_input_value (struct t_mygpio_idle_event *event)
void mygpio_free_idle_event (struct t_mygpio_idle_event *event)

Detailed Description

This module provides functions for the idle mode.

Enumeration Type Documentation

◆ mygpio_event

Possible event types

Enumerator
MYGPIO_EVENT_UNKNOWN 

unknown

MYGPIO_EVENT_GPIO_FALLING 

GPIO falling.

MYGPIO_EVENT_GPIO_RISING 

GPIO rising.

MYGPIO_EVENT_GPIO_LONG_PRESS 

GPIO long_press.

MYGPIO_EVENT_GPIO_LONG_PRESS_RELEASE 

GPIO long_press release.

MYGPIO_EVENT_INPUT 

Input event.

Function Documentation

◆ mygpio_free_idle_event()

void mygpio_free_idle_event ( struct t_mygpio_idle_event * event)

Frees the struct received by mygpio_recv_idle_event

Parameters
eventPointer to struct t_mygpio_idle_event.

◆ mygpio_idle_event_get_event()

enum mygpio_event mygpio_idle_event_get_event ( struct t_mygpio_idle_event * event)

Returns the event type from an idle event.

Parameters
eventPointer to struct t_mygpio_idle_event.
Returns
The event type, one of enum mygpio_event.

◆ mygpio_idle_event_get_event_name()

const char * mygpio_idle_event_get_event_name ( struct t_mygpio_idle_event * event)

Returns the event type name from an idle event.

Parameters
eventPointer to struct t_mygpio_idle_event.
Returns
The event type name

◆ mygpio_idle_event_get_gpio()

unsigned mygpio_idle_event_get_gpio ( struct t_mygpio_idle_event * event)

Returns the GPIO number from an idle event.

Parameters
eventPointer to struct t_mygpio_idle_event.
Returns
GPIO number.

◆ mygpio_idle_event_get_input_code()

const char * mygpio_idle_event_get_input_code ( struct t_mygpio_idle_event * event)

Returns the input event code

Parameters
eventPointer to struct t_mygpio_idle_event.
Returns
char * or NULL if not an input event

◆ mygpio_idle_event_get_input_device()

const char * mygpio_idle_event_get_input_device ( struct t_mygpio_idle_event * event)

Returns the input event device

Parameters
eventPointer to struct t_mygpio_idle_event.
Returns
char * or NULL if not an input event

◆ mygpio_idle_event_get_input_type()

const char * mygpio_idle_event_get_input_type ( struct t_mygpio_idle_event * event)

Returns the input event type

Parameters
eventPointer to struct t_mygpio_idle_event.
Returns
char * or NULL if not an input event

◆ mygpio_idle_event_get_input_value()

unsigned mygpio_idle_event_get_input_value ( struct t_mygpio_idle_event * event)

Returns the input event value

Parameters
eventPointer to struct t_mygpio_idle_event.
Returns
char * or NULL if not an input event

◆ mygpio_idle_event_get_timestamp_ms()

uint64_t mygpio_idle_event_get_timestamp_ms ( struct t_mygpio_idle_event * event)

Returns the timestamp from an idle event.

Parameters
eventPointer to struct t_mygpio_idle_event.
Returns
The timestamp in milliseconds.

◆ mygpio_lookup_event()

const char * mygpio_lookup_event ( enum mygpio_event event)

Lookups the name for the event.

Parameters
eventevent type
Returns
Event name as string

◆ mygpio_parse_event()

enum mygpio_event mygpio_parse_event ( const char * str)

Parses a string to the event type.

Parameters
strString to parse
Returns
enum mygpio_event

◆ mygpio_recv_idle_event()

struct t_mygpio_idle_event * mygpio_recv_idle_event ( struct t_mygpio_connection * connection)

Receives a list element of the waiting idle events. Access the values with the mygpio_idle_event_get_* functions. The caller must free it with mygpio_free_idle_event.

Parameters
connectionPointer to the connection struct returned by mygpio_connection_new.
Returns
Allocated struct t_mygpio_idle_event or NULL on list end or error.

◆ mygpio_send_idle()

bool mygpio_send_idle ( struct t_mygpio_connection * connection)

Enters the myGPIOd idle mode to get notifications about events. Retrieve the list of events with mygpio_recv_idle_event. In this mode no commands but mygpio_send_noidle are allowed. All timeouts are disabled.

Parameters
connectionPointer to the connection struct returned by mygpio_connection_new.
Returns
true on success, else false

◆ mygpio_send_noidle()

bool mygpio_send_noidle ( struct t_mygpio_connection * connection)

Exits the myGPIOd idle mode.

Parameters
connectionPointer to the connection struct returned by mygpio_connection_new.
Returns
true on success, else false

◆ mygpio_wait_idle()

bool mygpio_wait_idle ( struct t_mygpio_connection * connection,
int timeout )

Waits until an event occurs or the timeout expires. It returns instantly if events had occurred while not in idle mode.

Parameters
connectionPointer to the connection struct returned by mygpio_connection_new.
timeoutTimeout in milliseconds, -1 for no timeout
Returns
true if an event has occurred, false on timeout or error.