Service - GPIO

Github Repo C Header C source JS source
mongoose-os-libs/rpc-service-gpio mgos_gpio_service.h    

This service provides an ability to manage GPIO on devices remotely. It is possible to call this service programmatically via serial, HTTP/RESTful, Websocket, MQTT or other transports (see RPC section) or use mos tool.

Below is a list of exported RPC methods and arguments:

GPIO.Read

Set given pin in INPUT mode, read GPIO pin, return its value. Arguments:

{
  "pin": 15     // Required. Pin number.
}

Example usage:

mos call GPIO.Read '{"pin": 0}'
{
  "value": 1
}

GPIO.Write

Set given pin in OUTPUT mode, set GPIO pin. Arguments:

{
  "pin": 15,    // Required. Pin number.
  "value": 0    // Required. Voltage level. Either 0 (low) or 1 (high).
}

Example usage:

mos call GPIO.Write '{"pin": 2, "value": 0}'

GPIO.Toggle

Set given pin in OUTPUT mode, toggle voltage level and return that level. Arguments:

{
  "pin: 15     // Required. Pin number.
}

Example usage:

mos call GPIO.Toggle '{"pin": 2}'
{
  "value": 1
}

mgos_rpc_service_gpio_init

bool mgos_rpc_service_gpio_init(void);

__cplusplus

edit this doc