com.webos.service.peripheralmanager

Note
This API has been available since API level 13.

API Summary

The peripheralmanager is a service to provide APIs to monitor sensors and control actuators connected to I/O peripherals using industry-standard protocols. 

Currently, supported protocols are UART ,GPIO, SPI and I2C.

This service manages parallel requests from multiple applications to access peripherals and control the hardware.

Overview of the API

NA

Methods

gpio/close

ACG: peripheralmanager.gpio.operation
  • Added: API level 13

Description

Closes the opened GPIO pin, so that the pin is available for other applications to use.

Parameters

Name

Required

Type

Description

pinRequiredString

ID of the pin.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example Code

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/close '{"pin":"gpio4"}'

Response:

{
    "returnValue": true
}

gpio/getDirection

ACG: peripheralmanager.query
  • Added: API level 13

Description

Returns the direction of the required GPIO pin.

Parameters

Name

Required

Type

Description

pinRequiredString

ID of the pin.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
directionOptionalString

Indicates the direction of the pin.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getDirection '{"pin":"gpio4"}'

Response:

{
    "returnValue": true,
    "direction": "out"
}

gpio/getPollingFd

ACG: peripheralmanager.gpio.operation
  • Added: API level 13

Description

Returns the file descriptor for the GPIO pin specified in the input.

Parameters

Name

Required

Type

Description

idRequiredString

ID of the pin.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
fdOptionalString

File descriptor of the interface.

Example

Example Code

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getPollingFd '{"id" : "gpio4"}'

Response:

{
    "fd": 8,
    "returnValue": true
}

gpio/getValue

ACG: peripheralmanager.gpio.operation
  • Added: API level 13

Description

Reads the value of the opened input pin

Parameters

Name

Required

Type

Description

pinRequiredString

ID of the pin.

subscribeOptionalBoolean

Indicates if subscribed to get notified when there is a change in value. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.

Default: false

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

subscribedOptionalBoolean

Indicates if subscribed to get notifications. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.
valueOptionalString

Indicates the value. Possible values are: "low" or "high".

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example Code

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/getValue '{"pin":"gpio4"}'

Response:

{
    "subscribed": false,
    "returnValue": true,
    "value": "low"
}

gpio/list

ACG: peripheralmanager.query
  • Added: API level 13

Description

Provides the list of available GPIO pins in the target hardware.

Parameters

Name

Required

Type

Description

subscribeOptionalBoolean

Indicates if subscribed to get notified when there is a change in available pins. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.

Default: false

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

subscribedOptionalBoolean

Indicates if subscribed to get notifications. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.
gpioListOptionalObject array: gpioList

List of available GPIO pins with the status.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example without Subscription

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/list '{}'

Response:

{
   "subscribed":false,
   "returnValue":true,
   "gpioList":[
      {
         "pin":"gpio12",
         "status":"available"
      },
      {
         "pin":"gpio13",
         "status":"available"
      },
      {
         "pin":"gpio16",
         "status":"available"
      },
      {
         "pin":"gpio17",
         "status":"available"
      },
      {
         "pin":"gpio18",
         "status":"available"
      },
      {
         "pin":"gpio19",
         "status":"available"
      },
      {
         "pin":"gpio20",
         "status":"available"
      },
      {
         "pin":"gpio21",
         "status":"available"
      },
      {
         "pin":"gpio22",
         "status":"available"
      },
      {
         "pin":"gpio23",
         "status":"available"
      },
      {
         "pin":"gpio24",
         "status":"available"
      },
      {
         "pin":"gpio25",
         "status":"available"
      },
      {
         "pin":"gpio4",
         "status":"available"
      },
      {
         "pin":"gpio5",
         "status":"available"
      },
      {
         "pin":"gpio6",
         "status":"available"
      }
   ]
}

gpio/open

ACG: peripheralmanager.gpio.operation
  • Added: API level 13

Description

Opens the GPIO pin, if not already opened by other applications.

Parameters

Name

Required

Type

Description

pinRequiredString

ID of the pin.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example Code

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/open ' {"pin":"gpio4"}'

Response:

{
    "returnValue": true
}

gpio/setDirection

ACG: peripheralmanager.gpio.operation
  • Added: API level 13

Description

Sets the direction of the GPIO pin to input or output

Parameters

Name

Required

Type

Description

pinRequiredString

ID of the pin.

directionRequiredString

Direction of the pin. Possible values are: "in", "outLow", "outHigh"

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example Code

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/setDirection ' {"pin":"gpio4", "direction":"outHigh"}'

Response:

{
    "returnValue": true
}

gpio/setValue

ACG: peripheralmanager.gpio.operation
  • Added: API level 13

Description

Sets the value of the opened output pin to "low" or "high"

Parameters

Name

Required

Type

Description

pinRequiredString

ID of the pin.

valueRequiredString

Value of the output pin. Possible values are: "low" or "high".

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example Code

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/gpio/setValue ' {"pin":"gpio4", "value":"low"}'

Response:

{
    "returnValue": true
}

i2c/close

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Closes the opened I2C device connected to the bus.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device to be closed, which is connected to the I2C bus.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/close '{"name":"I2C1", "address":104}'

Response:

{
    "returnValue": true
}

i2c/getPollingFd

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Returns the file descriptor for the I2c if specified in the input.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C pin.

addressRequiredNumber

Address of the I2C device connected to the interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

Indicates the status of operation.Possible values are:
true - Indicates that the operation was successful.
false - Indicates that the operation failed.

fdOptionalString

File descriptor of the interface.

Example

/i2c/getPollingFd

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/getPollingFd '{"name" : "I2C1", "address" :104}'

Response:

{
    "fd": 10,
    "returnValue": true
}

i2c/list

ACG: peripheralmanager.query
  • Added: API level 13

Description

Provides the list of available I2C buses.

Parameters

Name

Required

Type

Description

verboseOptionalBoolean

Provide a list of I2C buses with slaveAddress and more details.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
i2cListOptionalString array

List of I2C buses.

If verbose input parameter is set, also returns the slave address.

Example

Example : List of available I2C buses without verbose

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/list '{}'

Response:

{
    "returnValue": true,
    "i2cBusList": [
        "I2C1",
        "I2C4"
    ]
}

Example : List of available I2C buses with verbose

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/list '{"verbose":true}'

Response:

{
    "returnValue": true,
    "i2cBusList": [
        {
            "slaveAddress": [
             "66",
             "77"
            ],
            "name": "I2C1"
        },
        {
            "slaveAddress": [
            "66",
            "77"
            ],
            "name": "I2C4"
        }
    ]
}

i2c/open

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Opens the device connected to I2C bus.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device to be opened, which is connected to the I2C bus

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

open

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/open '{"name":"I2C1", "address":104}'

Response:

{
    "returnValue": true
}

i2c/read

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Reads data from the I2C device.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C device.

addressRequiredString

Address of the device that is being used.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeOptionalNumber

Size of the data read.

dataOptionalObject array

Data read from the device.

Example

read

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/read '{"name":"I2C1", "address":104, "size":4}'

Response:

{
    "data": [
        4,
        18,
        1,
        0
    ],
    "returnValue": true,
    "size": 4
}

i2c/readRegBuffer

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Reads a value from the register buffer.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
dataOptionalObject array

Data read.

Example

readRegBuffer

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/readRegBuffer '{"name":"I2C1", "address":104, "reg":0, "size":4}'

Response:

{
    "data": [
        1,
        2,
        3,
        4
    ],
    "returnValue": true,
    "size": 4
}

i2c/readRegByte

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Reads a byte from a given register of the I2C device.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
dataOptionalNumber

Read value from the register.

Example

readRegByte

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/readRegByte '{"name":"I2C1","address":104, "reg":0}'

Response:

{
    "data": 22,
    "returnValue": true
}

i2c/readRegWord

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Reads a word from the register of the i2c device.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
dataOptionalNumber

Read value from the register.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/readRegWord '{"name":"I2C1","address":104, "reg":0}'

Response:

{
    "data": 1111,
    "returnValue": true
}

i2c/write

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Writes the data to the opened I2C device.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

dataRequiredObject array

Data to be written.

sizeOptionalNumber

Size of data to be written.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeOptionalNumber

Bytes written.

Example

write

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/write '{"name":"I2C1", "address":104, "data":[1,2,3,4]}'

Response:

{
    "returnValue": true,
    "size": 4
}

i2c/writeRegBuffer

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Writes data to the register buffer of the connected I2C device.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

dataRequiredObject array

Data that needs to be written.

sizeRequiredNumber

Size of the data.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeRequiredNumber

Bytes to be written into register.

Example

writeRegBuffer

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/writeRegBuffer '{"name":"I2C1", "address":104, "reg":0, "data":[1,2,3,4]}'

Response:

{
    "returnValue": true,
    "size": 4
}

i2c/writeRegByte

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Writes a byte from a given register.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

dataRequiredNumber

Data to write into register.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredNumber

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

writeRegByte

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/writeRegByte '{"name":"I2C1", "address":104, "reg":0, "data":22}'

Response:

{
    "returnValue": true
}

i2c/writeRegWord

ACG: peripheralmanager.i2c.operation
  • Added: API level 13

Description

Writes a word to the register of the I2C device.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of the I2C interface.

addressRequiredNumber

Address of the I2C device connected to the interface.

regRequiredNumber

Register address.

dataRequiredNumber

Data to write into register.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

writeRegWord

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/i2c/writeRegWord '{"name":"I2C1","address":104, "reg":0, "data":1111}'

Response:

{
    "returnValue": true
}

spi/close

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Closes the opened SPI bus, for other applications to use.

Parameters

None

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:
true - Indicates that the operation was successful.
false - Indicates that the operation failed.

Example

close

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/close '{"name":"SPI00"}'

Response:

{
    "returnValue": true
}

spi/list

ACG: peripheralmanager.query
  • Added: API level 13

Description

Provides the list of available SPI buses in the target hardware.

Parameters

None

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

listOptionalString array

List of available SPI buses.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

list

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/list '{}'

Response:

{
    "returnValue": true,
    "list": [
        "SPI00"
    ]
}

spi/open

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Opens the SPI bus, if not already opened by other applications.

Parameters

Name

Required

Type

Description

nameRequiredString

ID of the SPI bus interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

open

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/open '{"name" :"SPI00"}'

Response:

{
    "returnValue": true
}

spi/setBitJustification

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Sets bit justification of the data transferred in the SPI bus i.e MSB-first or LSB-first

Parameters

Name

Required

Type

Description

nameRequiredString

ID of the SPI interface.

lsb_firstRequiredBoolean

Bit Justification for the data transfer (true = LSB-first, false* = MSB-first)

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

setBitJustification

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setBitJustification '{"name":"SPI00", "lsb_first": false}'

Response:

{
    "returnValue": true
}

spi/setBitsPerWord

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Configures the number of bits in each SPI transfer word.

Parameters

Name

Required

Type

Description

nameRequiredString

ID of the SPI interface.

nbitsRequiredNumber

Setting up bit PerWord.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

setBitsPerWord

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setBitsPerWord '{"name":"SPI00", "nbits":8}'

Response:

{
    "returnValue": true
}

spi/setDelay

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Sets the delay after a transfer before the chip select status is changed and the next transfer is triggered.

Parameters

Name

Required

Type

Description

nameRequiredString

ID of the SPI interface.

delay_usecsRequiredNumber

Delay time in micro seconds.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

setDelay

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setDelay '{"name":"SPI00", "delay_usecs":0}'

Response:

{
    "returnValue": true
}

spi/setFrequency

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Sets the rate of data transfer (Hz)

Parameters

Name

Required

Type

Description

nameRequiredString

ID of the SPI interface.

frequencyRequiredNumber

Setting the frequency of the bus upto value that is allowed based on the bus max speed

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

setFrequency

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setFrequency '{"name":"SPI00", "frequency":9600}'

Response:

{
    "returnValue": true
}

spi/setMode

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Sets modes that correspond to the possible clocking configurations.

Parameters

Name

Required

Type

Description

nameRequiredString

ID of the SPI interface.

modeRequiredNumber

Mode to be set for the SPI device (possible values: 0 to 3).

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

setMode

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/setMode '{"name":"SPI00", "mode":0}'

Response:

{
    "returnValue": true
}

spi/transfer

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Opens a connection for receiving/transmitting data to/from a particular slave device.

Parameters

Name

Required

Type

Description

nameRequiredString

ID of the SPI interface.

dataOptionalObject array

Data to be transferred to the SPI device.

sizeRequiredNumber

Size of the data to be written/read, if data field is not present.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
tx_sizeOptionalNumber

Size of the data transferred to the SPI device.

rx_sizeOptionalNumber

Size of the data read from the SPI device.

rx_dataOptionalObject array

Receiving of the data from slave.

Example

transfer

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/transfer '{"name":"SPI00", "data":[1,2,3,4], "size":4}'

Response:

{
    "returnValue": true,
    "rx_size": 4,
    "tx_size": 4,
    "rx_data": [
        1,
        2,
        3,
        4
    ]
}

spi/writeBuffer

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Writes a chunk of data to SPI device.

Parameters

Name

Required

Type

Description

nameRequiredString

ID of the SPI interface.

dataRequiredObject array

Data to be written to the SPI device.

sizeRequiredNumber

Size of the data.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeOptionalNumber

Size of the data written to the device.

Example

writeBuffer

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/writeBuffer '{"name":"SPI00", "data":[1,2,3,4]}'

Response:

{
    "returnValue": true,
    "size": 4
}

spi/writeByte

ACG: peripheralmanager.spi.operation
  • Added: API level 13

Description

Writes a byte of data to the SPI device connected to the bus.

Parameters

Name

Required

Type

Description

dataRequiredNumber

Data to be written.

nameRequiredString

ID of the SPI interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

writeByte

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/spi/writeByte '{"name":"SPI00", "data":10}'

Response:

{
    "returnValue": true
}

uart/close

ACG: peripheralmanager.uart.operation
  • Added: API level 13

Description

Closes the opened UART device so that the interface is available for other apps to use.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example Code

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/close '{"interfaceId":"UART1"}'

Response:

{
    "returnValue": true
}

uart/getBaudrate

ACG: peripheralmanager.query
  • Added: API level 13

Description

Reads the baud rate of the opened UART device.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
baudrateOptionalNumber

Value of the baud rate.

Example

getBaudrate

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/getBaudrate '{"interfaceId":"UART1"}'

Response:

{
    "returnValue": true,
    "baudrate": 9600
}

uart/getPollingFd

ACG: peripheralmanager.uart.operation
  • Added: API level 13

Description

Returns the file descriptor for the UART interface specified in the input.

Parameters

Name

Required

Type

Description

idRequiredString

ID of the UART interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
fdOptionalString

File descriptor of the interface.

Example

getPollingFd

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/getPollingFd '{"id" : "UART1"}'

Response:

{
    "fd": 7,
    "returnValue": true
}

uart/list

ACG: peripheralmanager.query
  • Added: API level 13

Description

Provides the list of available UART interfaces in the target hardware.

Parameters

Name

Required

Type

Description

subscribeOptionalBoolean

Indicates if subscribed to get notified when there is a change in available interfaces. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.

Default: false

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

subscribedOptionalString

Indicates if subscribed to get notifications. Possible values are:

  • true: Subscribed for notifications.
  • false: Not subscribed.
uartListOptionalObject array: uartList

List of available UART interfaces.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example without Subscription

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/list '{}'

Response:

{
   "subscribed":false,
   "returnValue":true,
   "uartList":[
      {
         "status":"used",
         "interfaceId":"UART1"
      }
   ]
}

uart/open

ACG: peripheralmanager.uart.operation
  • Added: API level 13

Description

Opens the UART interface, if not already opened by other applications.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

configOptionalObject: config

The configurations to be set for the opened UART Interface.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

Example : Open the UART interface

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/open '{"interfaceId":"UART1"}'

Response:

{
    "returnValue": true
}

Example : Set configs for opened UART interface

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/open '{"interfaceId":"ttyACM0", "config":{"canonical" : true}}'

Response:

{
    "returnValue": true
}

uart/read

ACG: peripheralmanager.uart.operation
  • Added: API level 13

Description

Reads the data from the opened UART device.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

dataTypeOptionalString

The format of data to be returned.

sizeOptionalNumber

Size of the data to be read. If not specified, all available data is read.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
dataOptionalString

Value read from the opened UART interface.

dataTypeOptionalString

Type of data in the data field.

Example

Example : Read data from the UART interface

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/read '{"interfaceId":"ttyACM0", "dataType":"text"}'

Response:

{
    "data": "Temperature(Celcius)\":30.6598,\"Humidity(%rH)\":71.40324,\"GasResistance(Ohms)\":659577,\"sensorName\":\"Arduino_BME680\"}}\r\n",
    "returnValue": true,
    "dataType": "text"
}

uart/setBaudrate

ACG: peripheralmanager.uart.operation
  • Added: API level 13

Description

Sets the baud rate of the opened UART device to the required value.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

baudrateRequiredNumber

Value of the baud rate.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalString

The error code for the failed operation.

returnValueRequiredString

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.

Example

setBaudrate

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/setBaudrate '{"interfaceId":"UART1", "baudrate":9600}'

Response:

{
    "returnValue": true
}

uart/write

ACG: peripheralmanager.uart.operation
  • Added: API level 13

Description

Writes the data to the opened UART device.

Parameters

Name

Required

Type

Description

interfaceIdRequiredString

ID of the UART interface.

dataRequiredString

Data to write into the UART device.

dataTypeRequiredString

Type of data in the data field.

sizeRequiredString

Size of the data passed to be written.

Call Returns

Name

Required

Type

Description

errorTextOptionalString

The reason for the failure of the operation. See the API Error Codes Reference section for details.

errorCodeOptionalNumber

The error code for the failed operation.

returnValueRequiredBoolean

The status of the operation. Possible values are:

  • true: Indicates that the operation was successful.
  • false: Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
sizeOptionalNumber

Size of the data written to the device.

Example

Example : Write to the UART interface

# luna-send -n 1 -f luna://com.webos.service.peripheralmanager/uart/write '{
    "interfaceId":"ttyACM0",
    "data": "xyzabc",
    "dataType":"text",
    "size":6
}'

Response:

{
    "returnValue": true,
    "size": 6
}

Objects

config

Configurations to be set for the opened UART Interface.

Name

Required

Type

Description

canonicalOptionalBoolean

Enable or disable canonical mode for the opened UART interface.

gpioList

Provides the list of available GPIO pins with the status.

Name

Required

Type

Description

pinRequiredString

ID of the pin as maintained by the service.

statusRequiredString

Status of the pin as to whether "available" or "used" by other applications

i2cBusList

List of I2C buses and the slave address.

Name

Required

Type

Description

slaveAddressOptionalString array

Address of I2C slaves.

nameOptionalString

I2C bus name.

uartList

Provide List of UART interfaces along with the status

Name

Required

Type

Description

statusRequiredString

Status of the interface.

Possible values are:

  • used - The interface is currently being used.
  • available - The interface is available for the app to use
interfaceIdRequiredString

Interface ID as maintained by the service.

API Error Codes Reference

Error Code

Error Text

Error Description

-997EBUSY

Pin is being accessed by other applications.

-996ENODEV

File system was not mounted.

-995kEPERM

Permission to access the pin is denied.

-994kEREMOTEIO

Remote IO error.

-993kEINVAL

Invalid argument.

Contents