Fork me on GitHub

RPC Service - GPIO

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 via the 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
}