Utility

The RPCs listed in this section are not directly tied to any other part of PhoneIoT, but are helpers with using them.

RPCS

PhoneIoT.getColor(red: BoundedInteger<0, 255>, green: BoundedInteger<0, 255>, blue: BoundedInteger<0, 255>, alpha: BoundedInteger<0, 255>?)

Many of the Display RPCs take one or more optional parameters for controlling display color, which is specified as an integer. This RPC is a convenience function for constructing a color code from red, green, blue, and alpha values (each is 0-255).

The alpha value controls transparency, with 0 being invisible and 255 being opaque. If not specified, alpha will default to 255.

Arguments:

Returns: Color (Color) - Constructed color code (an integer)

PhoneIoT.getSensors()

This RPC returns a list containing the name of every sensor supported by PhoneIoT. Note that your specific device might not support all of these sensors, depending on the model.

See Sensors for more information.

Returns: List (List) - A list of sensor names

PhoneIoT.vibrate(device: Device, durations: AnyOf<List<VibrationDuration>, VibrationDuration>, strength: VibrationStrength?)

Causes the phone to vibrate with a specified duration (in seconds) and strength. durations can either be a single number representing a continuous vibration for that amount of time (in seconds), or it can be a list of durations. For instance, [1, 0.5, 2] would mean: vibrate for 1 second, stop for 0.5 seconds, then vibrate for 2 seconds.

Some older devices lack support for customizable vibration patterns/durations, in which case PhoneIoT may have to resort to an approximation of the desired pattern using longer vibrations.

Arguments:

  • device: Device (Device) - id of the device

  • durations: AnyOf<List<VibrationDuration>, VibrationDuration> (AnyOf | List | VibrationDuration) - the duration of a vibration or a pattern of on/off times

  • strength: VibrationStrength? (VibrationStrength) - the strength of vibration (default 100)