Builder

class Builder(command: Command)

Builder class for Packet.

Each packet sent to the Pico device is expected to follow a specific format, starting with a single byte for the command and ending with an array of byte data.

This builder class enforces that format and provides simple functions for appending the necessary data to the request.

For example:

val packet = Packet.Builder(Command.CMD_SET_PIN_SINGLE)
.addData(pin)
.addData(value)
.build()

The above request sets the command to SET_PIN_SINGLE, appends the pin, appends the value to set for that pin, then compiles the data into a packet.

Parameters

command

The command to send with this packet of data

Constructors

Link copied to clipboard
constructor(command: Command)

Functions

Link copied to clipboard

Appends a single byte to the buffer.

Appends multiple bytes to the buffer.

Link copied to clipboard
fun build(): Packet

Compiles the byte data in the buffer into a Packet.