Skip to content

mongoose-os-libs/rpc-service-gpio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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.ReadOut

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

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

Example usage:

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

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
}