xbee

package
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

README

xbee transport

A xbee API mode transport for bifrost.

This is an implementation of a bifrost transport that uses xbee radios.

  • Xbees are controlled with the gobee library in API mode.
  • Incoming packets are matched to a connection by transmitter ID
  • Incoming packet without a matching connection triggers an Accept() return
  • If configured, nodes may emit discovery pings, which contain a signed message with peer ID, timestamp, public key, device MAC.
  • Not hearing from a peer for a connection timeout length leads to a connection close event.

Note: discovery is not yet implemented in Bifrost.

Xbee Setup

Reset the xbees to default values, then set:

  • AP: 2 (API mode with escapes)
  • Baud: 115200

This will be automatic eventually.

E2E Test

Testing basic communications between two xbees connected via USB or another serial port is easily done with xbe2e. The tool accepts CLI arguments to set the baudrates and serial ports. It opens + configures both xbee using the xbserial common code, reads the local addresses, and transmits some data between them (unencrypted) as a basic test.

Documentation

Index

Constants

View Source
const ConfigID = ControllerID

ConfigID is the string used to identify this config object.

View Source
const ControllerID = "bifrost/xbee"

ControllerID is the xbee controller ID.

Variables

View Source
var (
	ErrInvalidLength        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflow          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group")
)
View Source
var File_github_com_aperturerobotics_bifrost_transport_xbee_xbee_proto protoreflect.FileDescriptor
View Source
var Version = semver.MustParse("0.0.1")

Version is the version of the xbee implementation.

Functions

This section is empty.

Types

type Config

type Config struct {

	// TransportPeerID sets the peer ID to attach the transport to.
	// If unset, attaches to any running peer with a private key.
	TransportPeerId string `protobuf:"bytes,1,opt,name=transport_peer_id,json=transportPeerId,proto3" json:"transport_peer_id,omitempty"`
	// DevicePath is the device path to open the serial stream.
	DevicePath string `protobuf:"bytes,2,opt,name=device_path,json=devicePath,proto3" json:"device_path,omitempty"`
	// DeviceBaud is the device baudrate.
	DeviceBaud int32 `protobuf:"varint,3,opt,name=device_baud,json=deviceBaud,proto3" json:"device_baud,omitempty"`
	// PacketOpts are options to set on the packet connection.
	// In lossy environments, set the data shards for error correction.
	PacketOpts *kcp.Opts `protobuf:"bytes,4,opt,name=packet_opts,json=packetOpts,proto3" json:"packet_opts,omitempty"`
	// Dialers maps peer IDs to dialers.
	Dialers map[string]*dialer.DialerOpts `` /* 155-byte string literal not displayed */
	// contains filtered or unexported fields
}

Config is the configuration for the udp transport.

func (*Config) CloneGenericVT added in v0.8.3

func (m *Config) CloneGenericVT() proto.Message

func (*Config) CloneVT added in v0.8.3

func (m *Config) CloneVT() *Config

func (*Config) Descriptor deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) EqualVT added in v0.3.0

func (this *Config) EqualVT(that *Config) bool

func (*Config) EqualsConfig

func (c *Config) EqualsConfig(other config.Config) bool

EqualsConfig checks if the other config is equal.

func (*Config) GetConfigID

func (c *Config) GetConfigID() string

GetConfigID returns the unique string for this configuration type. This string is stored with the encoded config.

func (*Config) GetDebugVals

func (c *Config) GetDebugVals() config.DebugValues

GetDebugVals returns the directive arguments as key/value pairs. This should be something like param1="test", param2="test". This is not necessarily unique, and is primarily intended for display.

func (*Config) GetDeviceBaud

func (x *Config) GetDeviceBaud() int32

func (*Config) GetDevicePath

func (x *Config) GetDevicePath() string

func (*Config) GetDialers

func (x *Config) GetDialers() map[string]*dialer.DialerOpts

func (*Config) GetPacketOpts

func (x *Config) GetPacketOpts() *kcp.Opts

func (*Config) GetTransportPeerId

func (x *Config) GetTransportPeerId() string

func (*Config) MarshalToSizedBufferVT added in v0.2.0

func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Config) MarshalToVT added in v0.2.0

func (m *Config) MarshalToVT(dAtA []byte) (int, error)

func (*Config) MarshalVT added in v0.2.0

func (m *Config) MarshalVT() (dAtA []byte, err error)

func (*Config) ParseNodePeerID

func (c *Config) ParseNodePeerID() (peer.ID, error)

ParseNodePeerID parses the node peer ID if it is not empty.

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect added in v0.2.0

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) SetTransportPeerId

func (c *Config) SetTransportPeerId(peerID string)

SetTransportPeerId sets the node peer ID field.

func (*Config) SizeVT added in v0.2.0

func (m *Config) SizeVT() (n int)

func (*Config) String

func (x *Config) String() string

func (*Config) UnmarshalVT added in v0.2.0

func (m *Config) UnmarshalVT(dAtA []byte) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration. This is a cursory validation to see if the values "look correct."

type Factory

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

Factory constructs a XBee transport.

func NewFactory

func NewFactory(bus bus.Bus) *Factory

NewFactory builds a XBee transport factory.

func (*Factory) Construct

func (t *Factory) Construct(
	conf config.Config,
	opts controller.ConstructOpts,
) (controller.Controller, error)

Construct constructs the associated controller given configuration. The transport's identity (private key) comes from a GetNode lookup.

func (*Factory) ConstructConfig

func (t *Factory) ConstructConfig() config.Config

ConstructConfig constructs an instance of the controller configuration.

func (*Factory) GetConfigID

func (t *Factory) GetConfigID() string

GetConfigID returns the configuration ID for the controller.

func (*Factory) GetControllerID

func (t *Factory) GetControllerID() string

GetControllerID returns the unique ID for the controller.

func (*Factory) GetVersion

func (t *Factory) GetVersion() semver.Version

GetVersion returns the version of this controller.

type Link = pconn.Link

Link represents a xbee-based connection/link.

type XBee

type XBee struct {
	*pconn.Transport
	// contains filtered or unexported fields
}

XBee implements a XBee transport.

func NewXBee

func NewXBee(
	ctx context.Context,
	le *logrus.Entry,
	opts *Config,
	pKey crypto.PrivKey,
	c transport.TransportHandler,
) (*XBee, error)

NewXBee builds a new XBee transport, opening the serial device.

func (*XBee) Execute

func (c *XBee) Execute(ctx context.Context) error

Execute executes the transport as configured, returning any fatal error.

Directories

Path Synopsis
toys

Jump to

Keyboard shortcuts

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