Documentation
¶
Overview ¶
Serial Smart Dust Mote connection.
Package moteconnection - A SerialForwarder connection library.
Package moteconnection - A SerialForwarder connection library.
Index ¶
- Constants
- Variables
- func DeserializePacket(m interface{}, data []byte) error
- func ListSerialPorts() ([]string, error)
- func SerializePacket(m interface{}) []byte
- type AMAddr
- type AMGroup
- type AMID
- type BaseMoteConnection
- type Dispatcher
- type EUI64
- type HexByte
- type HexString
- type LinkQualitySignalStrengthFooter
- type Message
- func (self *Message) Deserialize(data []byte) error
- func (self *Message) Destination() AMAddr
- func (self *Message) Dispatch() byte
- func (self *Message) GetPayload() []byte
- func (self *Message) Group() AMGroup
- func (self *Message) NewPacket() Packet
- func (self *Message) Serialize() ([]byte, error)
- func (self *Message) SetDestination(destination AMAddr)
- func (self *Message) SetDispatch(dispatch byte)
- func (self *Message) SetGroup(group AMGroup)
- func (self *Message) SetPayload(payload []byte) error
- func (self *Message) SetSource(source AMAddr)
- func (self *Message) SetType(ptype AMID)
- func (self *Message) Source() AMAddr
- func (self *Message) String() string
- func (self *Message) Type() AMID
- type MessageDispatcher
- func (md *MessageDispatcher) DeregisterMessageReceiver(amid AMID) error
- func (md *MessageDispatcher) Dispatch() byte
- func (md *MessageDispatcher) NewMessage() *Message
- func (md *MessageDispatcher) NewPacket() Packet
- func (md *MessageDispatcher) Receive(msg []byte) error
- func (md *MessageDispatcher) RegisterMessageReceiver(amid AMID, receiver chan Packet) error
- func (md *MessageDispatcher) RegisterMessageSnooper(receiver chan Packet) error
- type MessageDispatcherMessage
- type MistCloudConnection
- func (mcc *MistCloudConnection) AddNode(eui EUI64)
- func (mcc *MistCloudConnection) Autoconnect(period time.Duration)
- func (mcc *MistCloudConnection) Configure(name string, gateway EUI64)
- func (mcc *MistCloudConnection) Connect() error
- func (mcc *MistCloudConnection) Listen() error
- func (mdr *MistCloudConnection) RegisterReceiver(rchan chan Packet)
- func (mcc *MistCloudConnection) RemoveNode(eui EUI64)
- func (mcc *MistCloudConnection) Send(msg Packet) error
- type MistMessage
- func (*MistMessage) Descriptor() ([]byte, []int)deprecated
- func (x *MistMessage) GetAmid() uint32
- func (x *MistMessage) GetChannel() uint32
- func (x *MistMessage) GetDestination() uint64
- func (x *MistMessage) GetGateway() uint64
- func (x *MistMessage) GetGroup() uint32
- func (x *MistMessage) GetLqi() uint32
- func (x *MistMessage) GetPayload() []byte
- func (x *MistMessage) GetRssi() int32
- func (x *MistMessage) GetSource() uint64
- func (x *MistMessage) GetTimestamp() *timestamp.Timestamp
- func (*MistMessage) ProtoMessage()
- func (x *MistMessage) ProtoReflect() protoreflect.Message
- func (x *MistMessage) Reset()
- func (x *MistMessage) String() string
- type MistMessageDispatcher
- type MoteConnection
- type MoteMistMessage
- func (mmm *MoteMistMessage) Deserialize(data []byte) error
- func (mmm *MoteMistMessage) Destination() EUI64
- func (mmm *MoteMistMessage) Dispatch() byte
- func (mmm *MoteMistMessage) Gateway() EUI64
- func (mmm *MoteMistMessage) GetPayload() []byte
- func (mmm *MoteMistMessage) Group() AMGroup
- func (mmm *MoteMistMessage) NewPacket() Packet
- func (mmm *MoteMistMessage) Serialize() ([]byte, error)
- func (mmm *MoteMistMessage) SetDestination(destination EUI64)
- func (mmm *MoteMistMessage) SetDispatch(dispatch byte)
- func (mmm *MoteMistMessage) SetGateway(gateway EUI64)
- func (mmm *MoteMistMessage) SetGroup(group AMGroup)
- func (mmm *MoteMistMessage) SetPayload(payload []byte) error
- func (mmm *MoteMistMessage) SetSource(source EUI64)
- func (mmm *MoteMistMessage) SetType(amid AMID)
- func (mmm *MoteMistMessage) Source() EUI64
- func (mmm *MoteMistMessage) Type() AMID
- type Packet
- type PacketDispatcher
- type PacketFactory
- type RawPacket
- func (self *RawPacket) Deserialize(data []byte) error
- func (self *RawPacket) Dispatch() byte
- func (self *RawPacket) GetPayload() []byte
- func (self *RawPacket) NewPacket() Packet
- func (self *RawPacket) Serialize() ([]byte, error)
- func (self *RawPacket) SetPayload(payload []byte) error
- func (self *RawPacket) String() string
- type SerialConnection
- type SfConnection
- type UDPConnection
Constants ¶
const IncomingBufferSize = 10
Variables ¶
var File_mist_cloud_comm_mist_proto protoreflect.FileDescriptor
Functions ¶
func DeserializePacket ¶
DeserializePacket turns a bunch of bytes into the provided structure, if possible
func ListSerialPorts ¶
func SerializePacket ¶
func SerializePacket(m interface{}) []byte
SerializePacket turns a relatively generic structure into a bunch of bytes
Types ¶
type AMAddr ¶
type AMAddr uint16
AMAddr an address that should be represented as %04X
func (AMAddr) MarshalFlag ¶
MarshalFlag marshals AMAddr for the flags library
func (*AMAddr) UnmarshalFlag ¶
UnmarshalFlag unmarshals AMAddr for the flags library
type AMGroup ¶
type AMGroup uint8
AMGroup a group ID that should be represented as %02X
func (AMGroup) MarshalFlag ¶
MarshalFlag marshals AMGroup for the flags library
func (*AMGroup) UnmarshalFlag ¶
UnmarshalFlag unmarshals AMGroup for the flags library
type AMID ¶
type AMID uint8
AMID an ID that should be represented as %02X
func (AMID) MarshalFlag ¶
MarshalFlag marshals AMID for the flags library
func (*AMID) UnmarshalFlag ¶
UnmarshalFlag unmarshals AMID for the flags library
type BaseMoteConnection ¶
type BaseMoteConnection struct {
loggers.DIWEloggers
// contains filtered or unexported fields
}
BaseMoteConnection structure
func (*BaseMoteConnection) AddDispatcher ¶
func (bmc *BaseMoteConnection) AddDispatcher(dispatcher Dispatcher) error
AddDispatcher adds a dispatcher to the connection
func (*BaseMoteConnection) Connected ¶
func (bmc *BaseMoteConnection) Connected() bool
Connected checks if the connection is connected
func (*BaseMoteConnection) Disconnect ¶
func (bmc *BaseMoteConnection) Disconnect()
Disconnect disconnects the connection or stops a server
func (*BaseMoteConnection) RemoveDispatcher ¶
func (bmc *BaseMoteConnection) RemoveDispatcher(dispatcher Dispatcher) error
RemoveDispatcher removes a dispatcher from the connection
func (*BaseMoteConnection) Send ¶
func (bmc *BaseMoteConnection) Send(msg Packet) error
Send sends a packet
type Dispatcher ¶
Dispatcher interface
type EUI64 ¶
type EUI64 uint64
EUI64 address %016X
func (EUI64) MarshalFlag ¶
MarshalFlag marshals EUI64 for the flags library
func (*EUI64) UnmarshalFlag ¶
UnmarshalFlag unmarshals EUI64 for the flags library
type HexByte ¶
type HexByte byte
HexByte a byte object that should be converted to string with %02X
func (HexByte) MarshalFlag ¶
MarshalFlag marshals HexByte for the flags library
func (*HexByte) UnmarshalFlag ¶
UnmarshalFlag unmarshals HexByte for the flags library
type HexString ¶
type HexString []byte
HexString a bunch of bytes that should be converted to string with %02X
func (HexString) MarshalFlag ¶
MarshalFlag marshals HexStrings for the flags library
func (*HexString) UnmarshalFlag ¶
UnmarshalFlag unmarshals HexByte for the flags library
type LinkQualitySignalStrengthFooter ¶
type LinkQualitySignalStrengthFooter struct {
// contains filtered or unexported fields
}
type Message ¶
type Message struct {
Payload []byte
LQI uint8 // LQI is set if footer is exactly 2 bytes long
RSSI int8 // RSSI is set if footer is exactly 2 bytes long
// contains filtered or unexported fields
}
func NewMessage ¶
func (*Message) Deserialize ¶
func (*Message) Destination ¶
func (*Message) GetPayload ¶
func (*Message) SetDestination ¶
func (*Message) SetDispatch ¶
func (*Message) SetPayload ¶
type MessageDispatcher ¶
type MessageDispatcher struct {
// contains filtered or unexported fields
}
MessageDispatcher structure
func NewMessageDispatcher ¶
func NewMessageDispatcher(packetfactory MessageDispatcherMessage) *MessageDispatcher
NewMessageDispatcher creates a new dispatcher
func (*MessageDispatcher) DeregisterMessageReceiver ¶
func (md *MessageDispatcher) DeregisterMessageReceiver(amid AMID) error
DeregisterMessageReceiver removes a receiver
func (*MessageDispatcher) Dispatch ¶
func (md *MessageDispatcher) Dispatch() byte
Dispatch returns the dispatch ID of the dispatcher instance
func (*MessageDispatcher) NewMessage ¶
func (md *MessageDispatcher) NewMessage() *Message
NewMessage initializes a new message for use with this dispatcher
func (*MessageDispatcher) NewPacket ¶
func (md *MessageDispatcher) NewPacket() Packet
NewPacket initializes a new packet for use with this dispatcher
func (*MessageDispatcher) Receive ¶
func (md *MessageDispatcher) Receive(msg []byte) error
Receive distributes a packet to receivers and snoopers
func (*MessageDispatcher) RegisterMessageReceiver ¶
func (md *MessageDispatcher) RegisterMessageReceiver(amid AMID, receiver chan Packet) error
RegisterMessageReceiver registers a receiver
func (*MessageDispatcher) RegisterMessageSnooper ¶
func (md *MessageDispatcher) RegisterMessageSnooper(receiver chan Packet) error
RegisterMessageSnooper registers a snooper
type MistCloudConnection ¶
type MistCloudConnection struct {
BaseMoteConnection
// contains filtered or unexported fields
}
The MistCloudConnection object structure
func NewMistCloudConnection ¶
func NewMistCloudConnection(rabbiturl string) *MistCloudConnection
NewMistCloudConnection - Create a new MistCloudConnection
func (*MistCloudConnection) AddNode ¶
func (mcc *MistCloudConnection) AddNode(eui EUI64)
func (*MistCloudConnection) Autoconnect ¶
func (mcc *MistCloudConnection) Autoconnect(period time.Duration)
func (*MistCloudConnection) Configure ¶
func (mcc *MistCloudConnection) Configure(name string, gateway EUI64)
func (*MistCloudConnection) Connect ¶
func (mcc *MistCloudConnection) Connect() error
Connect to the cloud
func (*MistCloudConnection) Listen ¶
func (mcc *MistCloudConnection) Listen() error
func (*MistCloudConnection) RegisterReceiver ¶
func (mdr *MistCloudConnection) RegisterReceiver(rchan chan Packet)
func (*MistCloudConnection) RemoveNode ¶
func (mcc *MistCloudConnection) RemoveNode(eui EUI64)
func (*MistCloudConnection) Send ¶
func (mcc *MistCloudConnection) Send(msg Packet) error
type MistMessage ¶
type MistMessage struct {
Gateway uint64 `protobuf:"fixed64,1,opt,name=gateway,proto3" json:"gateway,omitempty"` // EUI64 of the gateway that the message is travelling through
Destination uint64 `protobuf:"fixed64,2,opt,name=destination,proto3" json:"destination,omitempty"` // EUI64 of the destination
Source uint64 `protobuf:"fixed64,3,opt,name=source,proto3" json:"source,omitempty"` // EUI64 of the source
Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` // Message payload
Amid uint32 `protobuf:"varint,5,opt,name=amid,proto3" json:"amid,omitempty"` // uint16 - extended Active Message ID
Rssi int32 `protobuf:"varint,6,opt,name=rssi,proto3" json:"rssi,omitempty"` // int8 - message RSSI (dB), -128 when not available
Lqi uint32 `protobuf:"varint,7,opt,name=lqi,proto3" json:"lqi,omitempty"` // uint8 - message LQI (0-255), 0 when not available
Group uint32 `protobuf:"varint,8,opt,name=group,proto3" json:"group,omitempty"` // uint16 - extended Active Message Group or PAN ID
Channel uint32 `protobuf:"varint,9,opt,name=channel,proto3" json:"channel,omitempty"` // uint8 - radio channel
Timestamp *timestamp.Timestamp `protobuf:"bytes,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp of the message as it entered the Mist daemon
// contains filtered or unexported fields
}
[START messages]
func (*MistMessage) Descriptor
deprecated
func (*MistMessage) Descriptor() ([]byte, []int)
Deprecated: Use MistMessage.ProtoReflect.Descriptor instead.
func (*MistMessage) GetAmid ¶
func (x *MistMessage) GetAmid() uint32
func (*MistMessage) GetChannel ¶
func (x *MistMessage) GetChannel() uint32
func (*MistMessage) GetDestination ¶
func (x *MistMessage) GetDestination() uint64
func (*MistMessage) GetGateway ¶
func (x *MistMessage) GetGateway() uint64
func (*MistMessage) GetGroup ¶
func (x *MistMessage) GetGroup() uint32
func (*MistMessage) GetLqi ¶
func (x *MistMessage) GetLqi() uint32
func (*MistMessage) GetPayload ¶
func (x *MistMessage) GetPayload() []byte
func (*MistMessage) GetRssi ¶
func (x *MistMessage) GetRssi() int32
func (*MistMessage) GetSource ¶
func (x *MistMessage) GetSource() uint64
func (*MistMessage) GetTimestamp ¶
func (x *MistMessage) GetTimestamp() *timestamp.Timestamp
func (*MistMessage) ProtoMessage ¶
func (*MistMessage) ProtoMessage()
func (*MistMessage) ProtoReflect ¶
func (x *MistMessage) ProtoReflect() protoreflect.Message
func (*MistMessage) Reset ¶
func (x *MistMessage) Reset()
func (*MistMessage) String ¶
func (x *MistMessage) String() string
type MistMessageDispatcher ¶
type MistMessageDispatcher struct {
// contains filtered or unexported fields
}
MessageDispatcher structure
func (*MistMessageDispatcher) Dispatch ¶
func (md *MistMessageDispatcher) Dispatch() byte
Dispatch returns the dispatch ID of the dispatcher instance
func (*MistMessageDispatcher) NewPacket ¶
func (md *MistMessageDispatcher) NewPacket() Packet
NewPacket initializes a new packet for use with this dispatcher
type MoteConnection ¶
type MoteConnection interface {
loggers.DIWElog
Listen() error
Connect() error
Autoconnect(period time.Duration)
Send(msg Packet) error
AddDispatcher(dispatcher Dispatcher) error
RemoveDispatcher(dispatch Dispatcher) error
Connected() bool
Disconnect()
}
MoteConnection interface
func CreateConnection ¶
func CreateConnection(connectionstring string) (MoteConnection, string, error)
CreateConnection - create a connection based on the format string
type MoteMistMessage ¶
type MoteMistMessage struct {
Payload []byte
LQI uint8
RSSI int8
Timestamp time.Time
// contains filtered or unexported fields
}
func NewMoteMistMessage ¶
func NewMoteMistMessage(defaultGroup AMGroup, defaultGateway EUI64, defaultSource EUI64) *MoteMistMessage
func (*MoteMistMessage) Deserialize ¶
func (mmm *MoteMistMessage) Deserialize(data []byte) error
func (*MoteMistMessage) Destination ¶
func (mmm *MoteMistMessage) Destination() EUI64
func (*MoteMistMessage) Dispatch ¶
func (mmm *MoteMistMessage) Dispatch() byte
func (*MoteMistMessage) Gateway ¶
func (mmm *MoteMistMessage) Gateway() EUI64
func (*MoteMistMessage) GetPayload ¶
func (mmm *MoteMistMessage) GetPayload() []byte
func (*MoteMistMessage) Group ¶
func (mmm *MoteMistMessage) Group() AMGroup
func (*MoteMistMessage) Serialize ¶
func (mmm *MoteMistMessage) Serialize() ([]byte, error)
func (*MoteMistMessage) SetDestination ¶
func (mmm *MoteMistMessage) SetDestination(destination EUI64)
func (*MoteMistMessage) SetDispatch ¶
func (mmm *MoteMistMessage) SetDispatch(dispatch byte)
func (*MoteMistMessage) SetGateway ¶
func (mmm *MoteMistMessage) SetGateway(gateway EUI64)
func (*MoteMistMessage) SetGroup ¶
func (mmm *MoteMistMessage) SetGroup(group AMGroup)
func (*MoteMistMessage) SetPayload ¶
func (mmm *MoteMistMessage) SetPayload(payload []byte) error
func (*MoteMistMessage) SetSource ¶
func (mmm *MoteMistMessage) SetSource(source EUI64)
func (*MoteMistMessage) SetType ¶
func (mmm *MoteMistMessage) SetType(amid AMID)
func (*MoteMistMessage) Source ¶
func (mmm *MoteMistMessage) Source() EUI64
func (*MoteMistMessage) Type ¶
func (mmm *MoteMistMessage) Type() AMID
type Packet ¶
type Packet interface {
Dispatch() byte
Serialize() ([]byte, error)
Deserialize([]byte) error
SetPayload([]byte) error
GetPayload() []byte
}
Packet interface
type PacketDispatcher ¶
type PacketDispatcher struct {
// contains filtered or unexported fields
}
PacketDispatcher structure
func NewPacketDispatcher ¶
func NewPacketDispatcher(packetfactory PacketFactory) *PacketDispatcher
NewPacketDispatcher creates a new dispatcher
func (*PacketDispatcher) Dispatch ¶
func (pd *PacketDispatcher) Dispatch() byte
Dispatch returns the dispatch ID of the dispatcher instance
func (*PacketDispatcher) NewPacket ¶
func (pd *PacketDispatcher) NewPacket() Packet
NewPacket initializes a new packet for use with this dispatcher
func (*PacketDispatcher) Receive ¶
func (pd *PacketDispatcher) Receive(msg []byte) error
Receive distributes a packet to receivers
func (*PacketDispatcher) RegisterReceiver ¶
func (pd *PacketDispatcher) RegisterReceiver(receiver chan Packet) error
RegisterReceiver registers a receiver
type PacketFactory ¶
PacketFactory interface
type RawPacket ¶
type RawPacket struct {
Payload []byte
// contains filtered or unexported fields
}
func NewRawPacket ¶
func (*RawPacket) Deserialize ¶
func (*RawPacket) GetPayload ¶
func (*RawPacket) SetPayload ¶
type SerialConnection ¶
type SerialConnection struct {
BaseMoteConnection
Port string
Baud int
// contains filtered or unexported fields
}
func NewSerialConnection ¶
func NewSerialConnection(port string, baud int) *SerialConnection
func (*SerialConnection) Autoconnect ¶
func (self *SerialConnection) Autoconnect(period time.Duration)
func (*SerialConnection) Connect ¶
func (self *SerialConnection) Connect() error
func (*SerialConnection) Listen ¶
func (self *SerialConnection) Listen() error
type SfConnection ¶
type SfConnection struct {
BaseMoteConnection
Host string
Port uint16
Protocol string
// contains filtered or unexported fields
}
SfConnection - A SerialForwarder connection
func NewSfConnection ¶
func NewSfConnection(host string, port uint16) *SfConnection
NewSfConnection - create a new connection
func (*SfConnection) Autoconnect ¶
func (sfc *SfConnection) Autoconnect(period time.Duration)
Autoconnect - initiate an asynchronous and self-maintaining connection
func (*SfConnection) Connect ¶
func (sfc *SfConnection) Connect() error
Connect - initiate a synchronous connect
func (*SfConnection) Listen ¶
func (sfc *SfConnection) Listen() error
Listen - Start a server and listen for incoming SF connections
type UDPConnection ¶
type UDPConnection struct {
BaseMoteConnection
Host string
Port uint16
// contains filtered or unexported fields
}
UDPConnection - A SerialForwarder connection
func NewUDPConnection ¶
func NewUDPConnection(host string, port uint16) *UDPConnection
NewUDPConnection - create a new connection
func (*UDPConnection) Autoconnect ¶
func (sfc *UDPConnection) Autoconnect(period time.Duration)
Autoconnect - initiate an asynchronous and self-maintaining connection
func (*UDPConnection) Connect ¶
func (sfc *UDPConnection) Connect() error
Connect - initiate a synchronous connect
func (*UDPConnection) Listen ¶
func (sfc *UDPConnection) Listen() error
Listen - Start a server and listen for incoming SF connections