gobee

package module
v0.0.0-...-b7a3c1a Latest Latest
Warning

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

Go to latest
Published: May 6, 2016 License: Apache-2.0 Imports: 4 Imported by: 1

README

gobee

GoDoc Build Status

A simple Go library for working with ZigBee/XBee modules over a serial interface.

Installation
go get github.com/jerluc/gobee
Usage

TBW

Contributing

TBW

License

Apache License Version 2.0

Documentation

Index

Constants

View Source
const (
	// Frame start delimiter
	FrameHeader byte = 0x7E
	// TX frame type (64-bit address)
	Tx64FrameType byte = 0x00
	// TX status frame type
	TxStatusFrameType byte = 0x89
	// RX frame type (64-bit address)
	Rx64FrameType byte = 0x80
)

Variables

View Source
var BroadcastAddress = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF}

Broadcast address for use by 64-bit TX frames

Functions

func BytesToUint16

func BytesToUint16(b []byte) uint

Converts a 2-byte big Endian array into an unsigned 16-bit integer

func Checksum

func Checksum(data []byte) byte

Computes an 8-bit checksum of XBee frame data

func PackBytes

func PackBytes(parts ...interface{}) []byte

Takes a variable number of single bytes or byte arrays and concatenates them into a single byte array

func Uint16ToBytes

func Uint16ToBytes(n uint) []byte

Converts an unsigned 16-bit integer to a 2-byte big Endian array

func VerifyChecksum

func VerifyChecksum(data []byte, receivedChecksum byte) bool

Verifies the computed checksum of XBee frame data with the checksum received over the wire. It is encouraged that you discard any XBee frame which does not pass this check

Types

type Frame

type Frame interface {
	FrameData() []byte
}

Represents a generic XBee frame type

func BuildFrame

func BuildFrame(fd []byte) Frame

Given raw frame data, this function attempts to construct the appropriate frame object by inspecting the first byte of the frame data (presumed to be the frame type byte). If the frame type cannot be identified by this software, a "generic" frame object is constructed preserving the raw data for other implementations to handle

func BuildGenericFrame

func BuildGenericFrame(fd []byte) Frame

Constructs a new "generic" frame object from the provided frame data

func BuildRx64Frame

func BuildRx64Frame(fd []byte) Frame

Constructs a new RX64 frame from the provided frame data

func BuildTx64Frame

func BuildTx64Frame(fd []byte) Frame

Constructs a new TX64 frame object from the provided frame data

func BuildTxStatusFrame

func BuildTxStatusFrame(fd []byte) Frame

Constructs a new TX status frame object from the provided frame data

type FrameBuffer

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

A generic full-duplex frame buffer that allows for reading/ writing XBee frames to the underlying serial device (or any other kind of io.ReadWriter

func NewFrameBuffer

func NewFrameBuffer(rw io.ReadWriter) *FrameBuffer

Creates a new FrameBuffer object

func (*FrameBuffer) ReadFrame

func (fb *FrameBuffer) ReadFrame() Frame

Reads a single XBee frame from the underlying serial device. Note that this method will block on reads until the full frame has been consumed. Additionally, this method will skip any bytes received between the presumed end of the previous frame and the beginning (0x7E) of the next

func (*FrameBuffer) WriteFrame

func (fb *FrameBuffer) WriteFrame(frame Frame) (n int, err error)

Writes a Frame object to the underlying serial device. Note that this does *not* buffer writes nor does it do packet fragmentation

type GenericFrame

type GenericFrame struct {
	Type    byte
	RawData []byte
}

Represents a "generic" (unimplemented) XBee frame

func (*GenericFrame) FrameData

func (g *GenericFrame) FrameData() []byte

func (*GenericFrame) String

func (g *GenericFrame) String() string

type Mailbox

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

func NewMailbox

func NewMailbox(rw io.ReadWriter) *Mailbox

func (*Mailbox) Inbox

func (m *Mailbox) Inbox() <-chan Frame

func (*Mailbox) Outbox

func (m *Mailbox) Outbox() chan<- Frame

type Rx64Frame

type Rx64Frame struct {
	Source  []byte
	RSSI    byte
	Options byte
	Data    []byte
}

Represents a 64-bit addressed RX frame

func (*Rx64Frame) FrameData

func (rx *Rx64Frame) FrameData() []byte

func (*Rx64Frame) String

func (rx *Rx64Frame) String() string

type Tx64Frame

type Tx64Frame struct {
	ID          byte
	Destination []byte
	Options     byte
	Data        []byte
}

Represents a 64-bit addressed TX frame

func (*Tx64Frame) FrameData

func (tx *Tx64Frame) FrameData() []byte

func (*Tx64Frame) String

func (tx *Tx64Frame) String() string

type TxStatusFrame

type TxStatusFrame struct {
	ID     byte
	Status byte
}

Represents a TX status frame

func (*TxStatusFrame) FrameData

func (tx *TxStatusFrame) FrameData() []byte

func (*TxStatusFrame) String

func (tx *TxStatusFrame) String() string

Jump to

Keyboard shortcuts

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