tinkerforge: github.com/noxer/tinkerforge Index | Files | Directories

package tinkerforge

import "github.com/noxer/tinkerforge"

Package tinkerforge implements the tinkerforge protocol Author: Tim Scheuermann (https://github.com/noxer)

Index

Package Files

packet.go tinkerforge.go

Constants

const (
    // ECOkay says no errors occurred
    ECOkay ErrorCode = 0
    // ECInvalidParam says you sent an invalid parameter in the packet
    ECInvalidParam = 1
    // ECFuncNotSupported says the function number you sent is not available
    ECFuncNotSupported = 2
)

Variables

var (
    // ErrInvalidParam represents ECInvalidParam in Go
    ErrInvalidParam = errors.New("Invalid Parameter")
    // ErrFuncNotSupported represents ECFuncNotSupported in Go
    ErrFuncNotSupported = errors.New("Function is not supported")
)
var (
    // ErrTimeout represents a timeout while waiting for a callback
    ErrTimeout = errors.New("Timeout while waiting for callback")
)

type ErrorCode Uses

type ErrorCode uint8

ErrorCode represents the error value returned by the brick(let)s

type Handler Uses

type Handler interface {
    Handle(packet *Packet)
}

Handler to get callbacks

type Packet Uses

type Packet struct {
    // contains filtered or unexported fields
}

Packet holds all information about a sent or received packet

func NewPacket Uses

func NewPacket(uid uint32, funcID uint8, respExp bool, params ...interface{}) (*Packet, error)

NewPacket creates a new packet to be sent to the TinkerForge daemon

func (*Packet) Callback Uses

func (p *Packet) Callback() bool

Callback indicates if this packet is a callback

func (*Packet) Decode Uses

func (p *Packet) Decode(vars ...interface{}) error

Decode decodes the payload of a packet into a number of variables

func (*Packet) Error Uses

func (p *Packet) Error() error

Error returns the corresponding error for the error ID

func (*Packet) ErrorID Uses

func (p *Packet) ErrorID() ErrorCode

ErrorID returns the ID of the error (or ECOkay)

func (*Packet) FunctionID Uses

func (p *Packet) FunctionID() uint8

FunctionID returns the function ID of the packet

func (*Packet) Length Uses

func (p *Packet) Length() uint8

Length returns the overall length (header + payload) of the packet

func (*Packet) Payload Uses

func (p *Packet) Payload() []byte

Payload returns the payload of the packet

func (*Packet) ResponseExpected Uses

func (p *Packet) ResponseExpected() bool

ResponseExpected returns wether the caller expects an answer

func (*Packet) SequenceNum Uses

func (p *Packet) SequenceNum() uint8

SequenceNum returns the 4-bit sequence number of the packet.

func (*Packet) Serialize Uses

func (p *Packet) Serialize(wr io.Writer, seqNum byte) error

Serialize converts the packet into a byte slice for sending

func (*Packet) UID Uses

func (p *Packet) UID() uint32

UID returns the UID of the packet source / destination

type Tinkerforge Uses

type Tinkerforge interface {
    io.Closer
    Handler(uid uint32, funcID uint8, handler Handler)
    Send(packet *Packet) (*Packet, error)
}

Tinkerforge interface

func New Uses

func New(host string) (Tinkerforge, error)

New creates a new tinkerforge client

Directories

PathSynopsis
helpersPackage helpers has helper routines for tinkerforge Author: Tim Scheuermann (https://github.com/noxer)
ledstripPackage ledstrip has control routines for LED strips Author: Tim Scheuermann (https://github.com/noxer)

Package tinkerforge imports 9 packages (graph) and is imported by 2 packages. Updated 2019-06-07. Refresh now. Tools for package owners.