Documentation
¶
Index ¶
- Variables
- type Acknowledgement
- type Advert
- type AnonymousRequest
- type CompanionError
- type Contact
- type Control
- type ControlDiscoverRequest
- type ControlDiscoverResponse
- type ControlType
- type EncryptedData
- type EncryptedGroupData
- type Group
- type GroupData
- type GroupText
- type GroupTextContent
- type Identity
- type Multipart
- type Node
- type NodeType
- type Packet
- type Path
- type Payload
- type PayloadType
- type Position
- type RawCustom
- type Request
- type RequestContent
- type RequestType
- type Response
- type ResponseContent
- type RouteType
- type Text
- type TextContent
- type TextType
- type Trace
Constants ¶
This section is empty.
Variables ¶
View Source
var Logger = logrus.New()
Logger used by this package.
Functions ¶
This section is empty.
Types ¶
type Acknowledgement ¶
type Acknowledgement struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
// Checksum of message timestamp, text and sender public key.
Checksum uint32 `json:"checksum"`
}
func (*Acknowledgement) Marshal ¶
func (ack *Acknowledgement) Marshal() []byte
func (*Acknowledgement) Packet ¶
func (ack *Acknowledgement) Packet() *Packet
func (*Acknowledgement) String ¶
func (ack *Acknowledgement) String() string
func (*Acknowledgement) Unmarshal ¶
func (ack *Acknowledgement) Unmarshal(b []byte) error
type Advert ¶
type Advert struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
PublicKey *crypto.PublicKey `json:"public_key"`
Time time.Time `json:"time"`
Signature crypto.Signature `json:"signature"`
Type NodeType `json:"node_type"`
Position *Position `json:"position,omitempty"`
Feature1 *uint16 `json:"feature1,omitempty"`
Feature2 *uint16 `json:"feature2,omitempty"`
Name string `json:"name,omitempty"`
}
type AnonymousRequest ¶
type AnonymousRequest struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
// Destination hash is the first byte of the recipient public key.
Destination byte `json:"dst"`
// PublicKey of the sender.
PublicKey *crypto.PublicKey `json:"public_key"`
// CipherMAC is the message authenticator.
CipherMAC uint16 `json:"cipher_mac"`
// CipherText is the encrypted message.
CipherText []byte `json:"cipher_text"`
}
func (*AnonymousRequest) Marshal ¶
func (req *AnonymousRequest) Marshal() []byte
func (*AnonymousRequest) Packet ¶
func (req *AnonymousRequest) Packet() *Packet
func (*AnonymousRequest) String ¶
func (req *AnonymousRequest) String() string
func (*AnonymousRequest) Unmarshal ¶
func (req *AnonymousRequest) Unmarshal(b []byte) error
type CompanionError ¶
type CompanionError struct {
Code byte
}
func (CompanionError) Error ¶
func (err CompanionError) Error() string
type Control ¶
type Control struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
// Type of control packet.
Type ControlType `json:"type"`
// Request for discovery.
Request *ControlDiscoverRequest `json:"request,omitempty"`
// Response for discovery.
Response *ControlDiscoverResponse `json:"response,omitempty"`
// Data contains the data bytes for unknown/unparsed control types.
Data []byte `json:"data"`
}
type ControlDiscoverRequest ¶
type ControlDiscoverRequest struct {
Flags byte `json:"flags"` // upper 4 bits
PrefixOnly bool `json:"prefix_only"` // lower 1 bit
TypeFilter byte `json:"type_filter"`
Tag uint32 `json:"tag"`
Since *time.Time `json:"since,omitempty"`
}
func (ControlDiscoverRequest) String ¶
func (req ControlDiscoverRequest) String() string
type ControlDiscoverResponse ¶
type ControlDiscoverResponse struct {
Flags byte `json:"flags"` // upper 4 bits
NodeType NodeType `json:"node_type"` // lower 4 bits
SNR float64 `json:"snr"`
Tag uint32 `json:"tag"`
PublicKey []byte `json:"public_key"` // 8 or 32 bytes
}
func (ControlDiscoverResponse) String ¶
func (res ControlDiscoverResponse) String() string
type ControlType ¶
type ControlType byte
const ( DiscoverRequest ControlType = 0x80 DiscoverResponse ControlType = 0x90 )
type EncryptedData ¶
type EncryptedData struct {
// Destination hash is the first byte of the recipient public key.
Destination byte `json:"dst"`
// Source hash is the first byte of the sender public key.
Source byte `json:"src"`
// CipherMAC is the message authenticator.
CipherMAC uint16 `json:"cipher_mac"`
// CipherText is the encrypted message.
CipherText []byte `json:"cipher_text"`
}
func (*EncryptedData) Marshal ¶
func (enc *EncryptedData) Marshal() []byte
func (*EncryptedData) String ¶
func (enc *EncryptedData) String() string
func (*EncryptedData) Unmarshal ¶
func (enc *EncryptedData) Unmarshal(b []byte) error
type EncryptedGroupData ¶
type EncryptedGroupData struct {
// ChannelHash is the first byte of the channel public key.
ChannelHash byte `json:"channel_hash"`
// CipherMAC is the message authenticator.
CipherMAC uint16 `json:"cipher_mac"`
// CipherText is the encrypted message.
CipherText []byte `json:"cipher_text"`
}
func (*EncryptedGroupData) Marshal ¶
func (enc *EncryptedGroupData) Marshal() []byte
func (*EncryptedGroupData) String ¶
func (enc *EncryptedGroupData) String() string
func (*EncryptedGroupData) Unmarshal ¶
func (enc *EncryptedGroupData) Unmarshal(b []byte) error
type Group ¶
type Group struct {
Name string `json:"name"`
Hash [32]byte `json:"hash"`
Secret crypto.SharedSecret `json:"-"`
}
func PublicGroup ¶
func SecretGroup ¶
func (Group) ChannelHash ¶
func (*Group) MarshalJSON ¶
func (*Group) UnmarshalJSON ¶
type GroupData ¶
type GroupData struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
EncryptedGroupData
// Content contains the group datagram.
Content []byte `json:"content,omitempty"`
}
type GroupText ¶
type GroupText struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
EncryptedGroupData
// Only available after successful decryption:
Content *GroupTextContent `json:"content,omitempty"`
}
type GroupTextContent ¶
type GroupTextContent struct {
// Group this was sent on (not part of the packet).
Group *Group `json:"group"`
// Time of sending.
Time time.Time `json:"time"`
// Flags is generally 0x00 indicating a plain text message.
Type TextType `json:"type"`
// Attempt is the number of retries.
Attempt uint8 `json:"attempt"`
// Text sent to the group. Typically contains a "<name>: " prefix.
Text string `json:"text"`
}
func (*GroupTextContent) String ¶
func (text *GroupTextContent) String() string
type Identity ¶
type Identity struct {
Name string
PrivateKey *crypto.PrivateKey
}
type Multipart ¶
type Multipart struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
Remaining uint8 `json:"remaining"`
Type PayloadType `json:"type"`
Data []byte `json:"data"`
}
type Node ¶
type Node struct {
OnPacket (*Packet)
// contains filtered or unexported fields
}
Node can be any type of MeshCore node.
func NewCompanion ¶
func NewCompanion(conn io.ReadWriteCloser) (*Node, error)
NewCompanion connects to a companion device type (over serial, TCP or BLE).
func (*Node) RawPackets ¶
type Packet ¶
type Packet struct {
// SNR is the signal-to-noise ratio.
SNR float64 `json:"snr"`
// RSSI is the received signal strength indicator (in dBm).
RSSI int8 `json:"rssi"`
// Raw bytes (optional).
Raw []byte `json:"raw,omitempty"`
// RouteType is the type of route for this packet.
RouteType RouteType `json:"route_type"`
// PayloadType is the type of payload for this packet.
PayloadType PayloadType `json:"payload_type"`
// TransportCodes are set by transport route types.
TransportCodes []uint16 `json:"transport_codes,omitempty"`
// Path are repeater hashes.
Path []byte `json:"path"`
// Payload is the raw (encoded) payload.
Payload []byte `json:"payload,omitempty"`
}
func (*Packet) MarshalBytes ¶
func (*Packet) MarshalJSON ¶
func (*Packet) UnmarshalBytes ¶
type Path ¶
type Path struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
EncryptedData
}
type Payload ¶
type PayloadType ¶
type PayloadType byte
const ( TypeRequest PayloadType = iota TypeResponse TypeText TypeAck TypeAdvert TypeGroupText TypeGroupData TypeAnonRequest TypePath TypeTrace TypeMultipart TypeControl TypeRawCustom )
Payload types.
func (PayloadType) String ¶
func (pt PayloadType) String() string
type RawCustom ¶
type Request ¶
type Request struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
EncryptedData
// Only available after successful decryption:
Content *RequestContent `json:"content,omitempty"`
}
type RequestContent ¶
type RequestContent struct {
// Time of sending the request.
Time time.Time `json:"time"`
// Type of request.
Type RequestType `json:"type"`
// Data is the request payload.
Data []byte `json:"data"`
}
func (*RequestContent) String ¶
func (req *RequestContent) String() string
type RequestType ¶
type RequestType byte
const ( GetStats RequestType = iota + 1 KeepAlive GetTelemetryData GetMinMaxAvgData GetAccessList GetNeighbors GetOwnerInfo )
func (RequestType) String ¶
func (rt RequestType) String() string
type Response ¶
type Response struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
EncryptedData
// Only available after successful decryption:
Content *ResponseContent `json:"content,omitempty"`
}
type ResponseContent ¶
type ResponseContent struct {
// Tag.
Tag uint32 `json:"tag"`
// Content of the response.
Content []byte `json:"content"`
}
func (*ResponseContent) String ¶
func (res *ResponseContent) String() string
type RouteType ¶
type RouteType byte
func (RouteType) HasTransportCodes ¶
HasTransportCodes indicates if this route type has transport codes in the packet.
type Text ¶
type Text struct {
// Raw packet (optional).
Raw *Packet `json:"-"`
EncryptedData
// Only available after successful decryption:
Content *TextContent `json:"content,omitempty"`
}
type TextContent ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.