robot

package
v0.0.0-...-c45ffd1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

package robot provides a high-level interface to the RDK client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Robot

type Robot struct {
	Client *client.RobotClient
	Board  board.Board
	// contains filtered or unexported fields
}

Robot is a high-level interface to the RDK client and board with logger. Client is the RDK client. Board is a robot board interface. logger is an RDK logger interface.

func New

func New(ctx context.Context, logger logging.Logger, hostname, locationSecret, boardName string) (Robot, error)

New creates a new Robot instance. hostname is the hostname of the robot. locationSecret is the location secret of the robot. boardName is the name of the board to use. Returns a Robot instance and an error.

func (Robot) Close

func (r Robot) Close(ctx context.Context)

Close closes the RDK client. ctx is the context.

func (Robot) GetPinState

func (r Robot) GetPinState(ctx context.Context, pinNum int, extra map[string]any) (pinState, error)

GetPinState returns the state of a pin. pinNum is the number of the pin. extra is a map of extra parameters. Returns the state of the pin and an error.

func (Robot) GetPinStateHandler

func (r Robot) GetPinStateHandler(w http.ResponseWriter, req *http.Request)

GetPinStateHandler handles a request to get the state of a pin.

func (Robot) PinByName

func (r Robot) PinByName(pinName string) (board.GPIOPin, error)

PinByName returns a GPIOPin by name. pinName is the name of the pin.

func (Robot) SetPinState

func (r Robot) SetPinState(ctx context.Context, pinNum int, state pinState, duration time.Duration, extra map[string]any) error

SetPinState sets the state of a pin. pinNum is the gpio number of the pin. state is the high/low state to set. duration is the duration to set the pin state for. If duration is greater than 0, the pin will be set to original state after the duration. extra is a map of extra parameters. Returns an error.

func (Robot) SetPinStateHandler

func (r Robot) SetPinStateHandler(w http.ResponseWriter, req *http.Request)

SetPinStateHandler handles a request to set the state of a pin.

type RobotRequest

type RobotRequest struct {
	Action   string         `json:"action"`
	PinNum   int            `json:"pin_num"`
	PinState pinState       `json:"pin_state"`
	Duration int            `json:"duration"`
	Extra    map[string]any `json:"extra"`
}

type RobotResponse

type RobotResponse struct {
	PinNum   int      `json:"pin_num"`
	PinState pinState `json:"pin_state"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL