Refactored protocol and radio interfaces
This commit is contained in:
42
protocol/protocol.go
Normal file
42
protocol/protocol.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.maze.io/go/ham/radio"
|
||||
)
|
||||
|
||||
// Protocol standard names (as used in this package).
|
||||
const (
|
||||
ADSB = "adsb"
|
||||
APRS = "aprs"
|
||||
APRS_IS = "aprsis"
|
||||
AX25 = "ax25"
|
||||
LoRa = "lora"
|
||||
MeshCore = "meshcore"
|
||||
Meshtastic = "meshtastic"
|
||||
)
|
||||
|
||||
// Packet represents a raw packet.
|
||||
type Packet struct {
|
||||
Time time.Time `json:"time,omitempty"` // Receive time stamp
|
||||
Protocol string `json:"protocol"` // Protocol name
|
||||
SNR float64 `json:"snr"` // Signal-to-noise Ratio
|
||||
RSSI int8 `json:"rssi"` // Received Signal Strength Indicator
|
||||
Raw []byte `json:"raw"` // Raw packet
|
||||
}
|
||||
|
||||
// Receiver of packets.
|
||||
type PacketReceiver interface {
|
||||
radio.Device
|
||||
|
||||
// RawPackets starts receiving raw packets.
|
||||
RawPackets() <-chan *Packet
|
||||
}
|
||||
|
||||
type PacketTransmitter interface {
|
||||
radio.Device
|
||||
|
||||
// SendRawPacket sends a raw (encoded) packet.
|
||||
SendRawPacket(*Packet) error
|
||||
}
|
||||
Reference in New Issue
Block a user