Documentation ¶
Overview ¶
package robot provides a high-level interface to the RDK client.
Index ¶
- type Robot
- func (r Robot) Close(ctx context.Context)
- func (r Robot) GetPinState(ctx context.Context, pinNum int, extra map[string]any) (pinState, error)
- func (r Robot) GetPinStateHandler(w http.ResponseWriter, req *http.Request)
- func (r Robot) PinByName(pinName string) (board.GPIOPin, error)
- func (r Robot) SetPinState(ctx context.Context, pinNum int, state pinState, duration time.Duration, ...) error
- func (r Robot) SetPinStateHandler(w http.ResponseWriter, req *http.Request)
- type RobotRequest
- type RobotResponse
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) GetPinState ¶
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) 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 RobotResponse ¶
type RobotResponse struct { PinNum int `json:"pin_num"` PinState pinState `json:"pin_state"` }