Table of Contents
Servers
Paths
GET /api/v1/version
Get the device firmware version
Responses
▶ 200 - Object with version property with firmware string value
application/json
| Name | Type | Description | Accepted values |
|---|
| version (required) | string | | Any |
GET /api/v1/general
Get general settings of the device
Responses
▶ 200 - Response is an object with keys 'name', 'password', 'webURL'.
application/json
| Name | Type | Description | Accepted values |
|---|
| name | string | a user defined name for the device | Any |
| password | string | a REST API password for Basic access authentication where the username is ignored | Any |
| webURL | string | (advanced) a user defined URL serving custom HTML/JS to control the PI2c | Any |
POST /api/v1/general
Update the General settings of the PI2c device. Existing values are used for properties not sent.
Request body
application/json
| Name | Type | Description | Accepted values |
|---|
| name | string | a user defined name for the device | Any |
| password | string | a REST API password for Basic access authentication where the username is ignored | Any |
| webURL | string | (advanced) a user defined URL serving custom HTML/JS to control the PI2c | Any |
Example (generated)
{
"name": "string",
"password": "string",
"webURL": "string"
}
Responses
▶ 200 - Object with success of storing the instructions set
application/json
| Name | Type | Description | Accepted values |
|---|
| success (required) | boolean | | Any |
| error | -- | Common Error object among all requests | Any |
| error.code (required) | integer | Number to identify the error for tracking purposes | Any |
| error.message (required) | string | Information describing what caused the error | Any |
▶ default - Invalid packet, credentials, or some unexpected error
application/json
| Name | Type | Description | Accepted values |
|---|
| code (required) | integer | Number to identify the error for tracking purposes | Any |
| message (required) | string | Information describing what caused the error | Any |
POST /api/v1/instr/exec
Run instructions. All of the instructions can be found in schemas below.
Request body
application/json
| Name | Type | Description | Accepted values |
|---|
| body | array | Array of instructions. Each instruction is an object with a key, 'func' whose value is the name of the function. It also may contain keys 'arg1', 'arg2', 'arg3' and associated values corresponding to arguments for the function. | Any |
Example (generated)
[
{
"func": "open",
"arg1": 1,
"arg2": "INPUT",
"arg3": "PULL_UP"
}
]
Responses
▶ 200 - Response object with stats and success of instructions
application/json
| Name | Type | Description | Accepted values |
|---|
| success (required) | boolean | All of the instructions succeeded or false if any failed or did not execute | Any |
| beginTime (required) | string | Date and time of when set began to execute | Any |
| completeTime (required) | string | Date and time of when set finished executing | Any |
| instructions (required) | array(object) | | Any |
| instructions.success (required) | boolean | Instruction succeeded or not | Any |
| instructions.index (required) | integer | Array index from requested Instructions array | Any |
| instructions.returnValue | -- | If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number. | Any |
| instructions.returnValue.0 | string | | Any |
| instructions.returnValue.1 | number | | Any |
| instructions.error | string | Message possibly describing why instruction failed to execute | Any |
▶ default - Invalid packet, credentials, or some unexpected error
application/json
| Name | Type | Description | Accepted values |
|---|
| code (required) | integer | Number to identify the error for tracking purposes | Any |
| message (required) | string | Information describing what caused the error | Any |
GET /api/v1/instr/stored
Get names of all stored instruction sets
Responses
▶ 200 - Successfully retreived a list of stored instruction set names
application/json
| Name | Type | Description | Accepted values |
|---|
| Response | array(string) | Array of names of each instruction set | Any |
▶ default - Invalid packet, credentials, or some unexpected error
application/json
| Name | Type | Description | Accepted values |
|---|
| code (required) | integer | Number to identify the error for tracking purposes | Any |
| message (required) | string | Information describing what caused the error | Any |
GET /api/v1/instr/stored/{InstructionSetName}
Get instructions for given set name
Path parameters
▷ InstructionSetName
Name of stored instruction set to retreive.
| Name | Type | In | Description | Accepted values |
|---|
| InstructionSetName (required) | string | path | Name of stored instruction set to retreive. | Any |
Responses
▶ 200 - A List of instructions that are stored for requested name
application/json
| Name | Type | Description | Accepted values |
|---|
| Response | array | Array of instructions. Each instruction is an object with a key, 'func' whose value is the name of the function. It also may contain keys 'arg1', 'arg2', 'arg3' and associated values corresponding to arguments for the function. | Any |
▶ default - Invalid packet, credentials, or some unexpected error
application/json
| Name | Type | Description | Accepted values |
|---|
| code (required) | integer | Number to identify the error for tracking purposes | Any |
| message (required) | string | Information describing what caused the error | Any |
POST /api/v1/instr/stored/{InstructionSetName}
Store instructions. This is useful so that you can later execute a sequence of instructions with a simple name.
Path parameters
▷ InstructionSetName
Name of stored instruction set to store/save. When successfully added the special set with name 'initialize' will automatically be run every time the device starts up.
| Name | Type | In | Description | Accepted values |
|---|
| InstructionSetName (required) | string | path | Name of stored instruction set to store/save. When successfully added the special set with name 'initialize' will automatically be run every time the device starts up. | Any |
Request body
application/json
| Name | Type | Description | Accepted values |
|---|
| body | array | Array of instructions. Each instruction is an object with a key, 'func' whose value is the name of the function. It also may contain keys 'arg1', 'arg2', 'arg3' and associated values corresponding to arguments for the function. | Any |
Example (generated)
[
{
"func": "open",
"arg1": 1,
"arg2": "INPUT",
"arg3": "PULL_UP"
}
]
Responses
▶ 200 - Object with success of storing the instructions set
application/json
| Name | Type | Description | Accepted values |
|---|
| success (required) | boolean | | Any |
| error | -- | Common Error object among all requests | Any |
| error.code (required) | integer | Number to identify the error for tracking purposes | Any |
| error.message (required) | string | Information describing what caused the error | Any |
▶ default - Invalid packet, credentials, or some unexpected error
application/json
| Name | Type | Description | Accepted values |
|---|
| code (required) | integer | Number to identify the error for tracking purposes | Any |
| message (required) | string | Information describing what caused the error | Any |
POST /api/v1/instr/stored/{InstructionSetName}/exec
Execute named instruction set
Path parameters
▷ InstructionSetName
Name of stored instruction set to execute
| Name | Type | In | Description | Accepted values |
|---|
| InstructionSetName (required) | string | path | Name of stored instruction set to execute | Any |
Responses
▶ 200 - Response object with stats and success of each instruction
application/json
| Name | Type | Description | Accepted values |
|---|
| success (required) | boolean | All of the instructions succeeded or false if any failed or did not execute | Any |
| beginTime (required) | string | Date and time of when set began to execute | Any |
| completeTime (required) | string | Date and time of when set finished executing | Any |
| instructions (required) | array(object) | | Any |
| instructions.success (required) | boolean | Instruction succeeded or not | Any |
| instructions.index (required) | integer | Array index from requested Instructions array | Any |
| instructions.returnValue | -- | If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number. | Any |
| instructions.returnValue.0 | string | | Any |
| instructions.returnValue.1 | number | | Any |
| instructions.error | string | Message possibly describing why instruction failed to execute | Any |
▶ default - Invalid packet, credentials, or some unexpected error
application/json
| Name | Type | Description | Accepted values |
|---|
| code (required) | integer | Number to identify the error for tracking purposes | Any |
| message (required) | string | Information describing what caused the error | Any |
GET /api/v1/instr/stored/{InstructionSetName}/log
Get latest response for instruction set with given name when it last executed
Path parameters
▷ InstructionSetName
Name of stored instruction set's response log to retreive
| Name | Type | In | Description | Accepted values |
|---|
| InstructionSetName (required) | string | path | Name of stored instruction set's response log to retreive | Any |
Responses
▶ 200 - Object Response per each instruction
application/json
| Name | Type | Description | Accepted values |
|---|
| hasLog (required) | boolean | Has this stored instruction set executed. If so, the log key will be present with the response of the last execution. | Any |
| log | object | Object describing success and information of Instructions execution. It also contains an instructions key whose value is every instructions success status and returned data if applicapable. When a stored instruction set is executed the latest response object will be stored in it's corresponding log. | Any |
| log.success (required) | boolean | All of the instructions succeeded or false if any failed or did not execute | Any |
| log.beginTime (required) | string | Date and time of when set began to execute | Any |
| log.completeTime (required) | string | Date and time of when set finished executing | Any |
| log.instructions (required) | array(object) | | Any |
| log.instructions.success (required) | boolean | Instruction succeeded or not | Any |
| log.instructions.index (required) | integer | Array index from requested Instructions array | Any |
| log.instructions.returnValue | -- | If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number. | Any |
| log.instructions.returnValue.0 | string | | Any |
| log.instructions.returnValue.1 | number | | Any |
| log.instructions.error | string | Message possibly describing why instruction failed to execute | Any |
| error | -- | Common Error object among all requests | Any |
| error.code (required) | integer | Number to identify the error for tracking purposes | Any |
| error.message (required) | string | Information describing what caused the error | Any |
▶ default - Invalid packet, credentials, or some unexpected error
application/json
| Name | Type | Description | Accepted values |
|---|
| code (required) | integer | Number to identify the error for tracking purposes | Any |
| message (required) | string | Information describing what caused the error | Any |
Schemas
PI2c General Settings
| Name | Type | Description | Accepted values |
|---|
| name | string | a user defined name for the device | Any |
| password | string | a REST API password for Basic access authentication where the username is ignored | Any |
| webURL | string | (advanced) a user defined URL serving custom HTML/JS to control the PI2c | Any |
Example (generated)
{
"name": "string",
"password": "string",
"webURL": "string"
}
Pin reset type
| Name | Type | Description | Accepted values |
|---|
| PinResetType | string | How the pin is to be reset | PIN_RESET, PIN_PRESERVE |
Example (generated)
"PIN_RESET"
Poll Pin direction
| Name | Type | Description | Accepted values |
|---|
| PollPinDirection | string | Check falling or rising edge or both when polling | POLL_LOW, POLL_HIGH, POLL_BOTH |
Example (generated)
"POLL_LOW"
Pin
| Name | Type | Description | Accepted values |
|---|
| Pin | number | GPIO Pin number | 1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18 |
Example (generated)
1
Pin Mode
| Name | Type | Description | Accepted values |
|---|
| PinMode | string | Set whether GPIO Pin is input, output, or pwm if capable | INPUT, OUTPUT, PWM |
Example (generated)
"INPUT"
Pullup
| Name | Type | Description | Accepted values |
|---|
| PinInputModePullup | string | Pin Pullup in input mode | PULL_UP, PULL_DOWN, PULL_OFF |
Example (generated)
"PULL_UP"
Pin Value
| Name | Type | Description | Accepted values |
|---|
| PinOutputModeValue | string | Pin string value in output mode | HIGH, LOW |
Example (generated)
"HIGH"
Pin Numerical Value
| Name | Type | Description | Accepted values |
|---|
| PinOutputNumModeValue | number | Pin numerical value in output mode | 1, 0 |
Example (generated)
1
led
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | led |
| arg1 (required) | string | Which led (red or green). Note on startup when device is ready, red led will turn on for a second. | red, green |
| arg2 (required) | -- | | Any |
| arg2.0 | string | | HIGH, LOW |
| arg2.1 | number | | 1, 0 |
Example (generated)
{
"func": "led",
"arg1": "red",
"arg2": "HIGH"
}
open
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | open |
| arg1 (required) | number | GPIO Pin number | 1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18 |
| arg2 (required) | string | Set whether GPIO Pin is input, output, or pwm if capable | INPUT, OUTPUT, PWM |
| arg3 | -- | | Any |
| arg3.0 | string | | PULL_UP, PULL_DOWN, PULL_OFF |
| arg3.1 | string | | HIGH, LOW |
Example (generated)
{
"func": "open",
"arg1": 1,
"arg2": "INPUT",
"arg3": "PULL_UP"
}
stored
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | stored |
| arg1 (required) | string | Name of stored instruction set to execute | Any |
Example (generated)
{
"func": "stored",
"arg1": "string"
}
mode
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | mode |
| arg1 (required) | number | GPIO Pin number | 1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18 |
| arg2 (required) | string | Set whether GPIO Pin is input, output, or pwm if capable | INPUT, OUTPUT, PWM |
Example (generated)
{
"func": "mode",
"arg1": 1,
"arg2": "INPUT"
}
read
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | read |
| arg1 (required) | number | GPIO Pin number | 1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18 |
Example (generated)
{
"func": "read",
"arg1": 1
}
readBuf
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | readBuf |
| arg1 (required) | number | GPIO Pin number | 1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18 |
| arg2 (required) | integer | Number of bits to read | Any |
Example (generated)
{
"func": "readBuf",
"arg1": 1,
"arg2": 1
}
write
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | write |
| arg1 (required) | number | GPIO Pin number | 1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18 |
| arg2 (required) | -- | set the output of the pin using string or number types | Any |
| arg2.0 | string | | HIGH, LOW |
| arg2.1 | number | | 1, 0 |
Example (generated)
{
"func": "write",
"arg1": 1,
"arg2": "HIGH"
}
writeBuf
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | writeBuf |
| arg1 (required) | number | GPIO Pin number | 1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18 |
| arg2 (required) | string | base64 encoded data to be written. Each byte should be 1 or 0 to represent a bit | Any |
Example (generated)
{
"func": "writeBuf",
"arg1": 1,
"arg2": "string"
}
pud
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | pud |
| arg1 (required) | number | GPIO Pin number | 1, 3, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18 |
| arg2 (required) | string | Pin Pullup in input mode | PULL_UP, PULL_DOWN, PULL_OFF |
Example (generated)
{
"func": "pud",
"arg1": 1,
"arg2": "PULL_UP"
}
pwmSetClockDivider
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | pwmSetClockDivider |
| arg1 (required) | number | This is a power-of-two divisor of the base 19.2MHz rate, with a maximum value of 4096 (4.6875kHz). | Any |
Example (generated)
{
"func": "pwmSetClockDivider",
"arg1": 1
}
pwmSetRange
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | pwmSetRange |
| arg1 (required) | number | | 16, 18 |
| arg2 (required) | number | set range | Any |
Example (generated)
{
"func": "pwmSetRange",
"arg1": 16,
"arg2": 1
}
pwmSetData
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | pwmSetData |
| arg1 (required) | number | | 16, 18 |
| arg2 (required) | number | set data | Any |
Example (generated)
{
"func": "pwmSetData",
"arg1": 16,
"arg2": 1
}
i2cBegin
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Assign GPIO pins 1 and 3 to use i2c | i2cBegin |
Example (generated)
{
"func": "i2cBegin"
}
i2cSetSlaveAddress
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | i2cSetSlaveAddress |
| arg1 (required) | number | Configure the slave address. This is between 0 - 0x7f | Any |
Example (generated)
{
"func": "i2cSetSlaveAddress",
"arg1": 0
}
i2cSetBaudRate
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | i2cSetBaudRate |
| arg1 (required) | number | The i2c baudrate | Any |
Example (generated)
{
"func": "i2cSetBaudRate",
"arg1": 1000
}
i2cRead
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | i2cRead |
| arg1 (required) | number | Number of bytes to read | Any |
Example (generated)
{
"func": "i2cRead",
"arg1": 1
}
i2cWrite
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | i2cWrite |
| arg1 (required) | string | base64 representation of bytes to write | Any |
Example (generated)
{
"func": "i2cWrite",
"arg1": "string"
}
i2cUpdateReg
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | i2cUpdateReg |
| arg1 (required) | string | n-byte register value | Any |
| arg2 (required) | string | Mask - to 4 byte mask value base64. Num bytes should be equal to value | Any |
| arg3 (required) | string | Value - up to 4 byte data value base64. Num bytes should be equal to mask | Any |
Example (generated)
{
"func": "i2cUpdateReg",
"arg1": "stri",
"arg2": "string",
"arg3": "string"
}
i2cEnd
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | i2cEnd |
Example (generated)
{
"func": "i2cEnd"
}
spiBegin
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | spiBegin |
Example (generated)
{
"func": "spiBegin"
}
spiSetCSPolarity
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | spiSetCSPolarity |
| arg1 (required) | string | | HIGH |
Example (generated)
{
"func": "spiSetCSPolarity",
"arg1": "HIGH"
}
spiSetClockDivider
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | spiSetClockDivider |
| arg1 (required) | number | Even divisor of the base 250MHz rate ranging between 0 and 65536. If div is 128 set SPI speed to 1.95MHz | Any |
Example
{
"func": "spiSetClockDivider",
"arg1": 128
}
spiSetDataMode
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | spiSetDataMode |
| arg1 (required) | number | 0=CPOL(0)CPHA(0),1=CPOL(0)CPHA(1),2=CPOL(1)CPHA(0),3=CPOL(1)CPHA(1) | 0, 1, 3 |
Example (generated)
{
"func": "spiSetDataMode",
"arg1": 0
}
spiTransfer
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | spiTransfer |
| arg1 (required) | string | base64 representation of bytes to write | Any |
Example (generated)
{
"func": "spiTransfer",
"arg1": "string"
}
spiWrite
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | spiWrite |
| arg1 (required) | string | base64 representation of bytes to write | Any |
Example (generated)
{
"func": "spiWrite",
"arg1": "string"
}
spiEnd
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | spiEnd |
Example (generated)
{
"func": "spiEnd"
}
sleep
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | sleep |
| arg1 (required) | number | number of seconds to sleep | Any |
Example (generated)
{
"func": "sleep",
"arg1": 1
}
msleep
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | msleep |
| arg1 (required) | number | Number of milliseconds to sleep | Any |
Example (generated)
{
"func": "msleep",
"arg1": 1
}
usleep
| Name | Type | Description | Accepted values |
|---|
| func (required) | string | Instruction function name | usleep |
| arg1 (required) | number | Number of microseconds to sleep | Any |
Example (generated)
{
"func": "usleep",
"arg1": 100
}
Instructions
| Name | Type | Description | Accepted values |
|---|
| Instructions | array | Array of instructions. Each instruction is an object with a key, 'func' whose value is the name of the function. It also may contain keys 'arg1', 'arg2', 'arg3' and associated values corresponding to arguments for the function. | Any |
Example (generated)
[
{
"func": "open",
"arg1": 1,
"arg2": "INPUT",
"arg3": "PULL_UP"
}
]
Instruction Response
| Name | Type | Description | Accepted values |
|---|
| success (required) | boolean | Instruction succeeded or not | Any |
| index (required) | integer | Array index from requested Instructions array | Any |
| returnValue | -- | If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number. | Any |
| returnValue.0 | string | | Any |
| returnValue.1 | number | | Any |
| error | string | Message possibly describing why instruction failed to execute | Any |
Example
{
"success": true,
"index": 0,
"returnValue": "AAE="
}
Instructions Response
| Name | Type | Description | Accepted values |
|---|
| success (required) | boolean | All of the instructions succeeded or false if any failed or did not execute | Any |
| beginTime (required) | string | Date and time of when set began to execute | Any |
| completeTime (required) | string | Date and time of when set finished executing | Any |
| instructions (required) | array(object) | | Any |
| instructions.success (required) | boolean | Instruction succeeded or not | Any |
| instructions.index (required) | integer | Array index from requested Instructions array | Any |
| instructions.returnValue | -- | If instruction retrieved data, this will contain one of data of types listed below based on the output type specified by the instruction. For example a base64 string representing a buffer of 8-bit data, a utf-8 string, or a number. | Any |
| instructions.returnValue.0 | string | | Any |
| instructions.returnValue.1 | number | | Any |
| instructions.error | string | Message possibly describing why instruction failed to execute | Any |
Example (generated)
{
"success": true,
"beginTime": "2019-05-25T20:40:57Z",
"completeTime": "2019-05-25T20:40:57Z",
"instructions": [
{
"success": true,
"index": 0,
"returnValue": "AAE="
}
]
}
Error
| Name | Type | Description | Accepted values |
|---|
| code (required) | integer | Number to identify the error for tracking purposes | Any |
| message (required) | string | Information describing what caused the error | Any |
Example (generated)
{
"code": 0,
"message": "string"
}