Documentation
¶
Index ¶
- Constants
- Variables
- func CRC(in []byte) uint16
- func CalculateHammingDistance(a, b uint32) int
- func CalculateSyndrome(codeword uint32) uint16
- func ConvolutionalEncode(in []byte, puncturePattern PuncturePattern, finalBit byte) (*[]Bit, error)
- func ConvolutionalEncodeStream(lichBits []Bit, sd StreamDatagram) (*[]Bit, error)
- func DecodeCallsign(encoded []byte) (string, error)
- func DecodeLICH(inp []SoftBit) []byte
- func Encode24(data uint16) uint32
- func EncodeCallsign(callsign string) (*[6]byte, error)
- func EncodeLICH(inp []uint8) []byte
- func EuclNorm(s1, s2 []Symbol, n int) float64
- func GetErrorCorrectionCapability() int
- func GetMinimumDistance() int
- func HardDecode24(codeword uint32) (uint16, error)
- func IntToSoft(out []SoftBit, value uint16, size uint8)
- func IsValidCodeword(codeword uint32) bool
- func NormalizeCallsignModule(callsign string) string
- func SoftCalcChecksum(out, value []SoftBit)
- func SoftDecode24(codeword [24]SoftBit) uint16
- func SoftDetectErrors(codeword []SoftBit) uint32
- func SoftPopCount(in []uint16, size uint8) uint32
- func SoftToInt(in []SoftBit, size uint8) uint16
- func SoftXOR(out, a, b []SoftBit, size uint8)
- type Bit
- type Bits
- type CC1200Modem
- func (m *CC1200Modem) Close() error
- func (m *CC1200Modem) Read(buf []byte) (n int, err error)
- func (m *CC1200Modem) Reset() error
- func (m *CC1200Modem) SetAFC(afc bool) error
- func (m *CC1200Modem) SetFreqCorrection(corr int16) error
- func (m *CC1200Modem) SetRXFreq(freq uint32) error
- func (m *CC1200Modem) SetTXFreq(freq uint32) error
- func (m *CC1200Modem) SetTXPower(dbm float32) error
- func (m *CC1200Modem) Start() error
- func (m *CC1200Modem) TransmitPacket(p Packet) error
- func (m *CC1200Modem) TransmitVoiceStream(sd StreamDatagram) error
- type DCFilter
- type Decoder
- type Downsampler
- type DummyModem
- func (m *DummyModem) Close() error
- func (m *DummyModem) Read(p []byte) (n int, err error)
- func (m *DummyModem) Reset() error
- func (m *DummyModem) SetAFC(afc bool) error
- func (m *DummyModem) SetFreqCorrection(corr int16) error
- func (m *DummyModem) SetRXFreq(freq uint32) error
- func (m *DummyModem) SetTXFreq(freq uint32) error
- func (m *DummyModem) SetTXPower(dbm float32) error
- func (m *DummyModem) Start() error
- func (m *DummyModem) TransmitPacket(p Packet) error
- func (m *DummyModem) TransmitVoiceStream(sd StreamDatagram) error
- func (m *DummyModem) Write(buf []byte) (n int, err error)
- type EncodedCallsign
- type Host
- type Hostfile
- type LSF
- type LSFDataType
- type LSFEncryptionSubtype
- type LSFEncryptionType
- type LSFType
- type Line
- type Modem
- type Number
- type Packet
- type PacketType
- type Preamble
- type PuncturePattern
- type Relay
- type SampleToSymbol
- type Scaler
- type SoftBit
- type StreamDatagram
- type Symbol
- type SymbolToSample
- type Transform
- type ViterbiDecoder
Constants ¶
const ( SymbolsPerSyncword = 8 //symbols per syncword SymbolsPerPayload = 184 //symbols per payload in a frame SymbolsPerFrame = 192 //symbols per whole 40 ms frame, 40ms * 4800 = 192 BitsPerSymbol = 2 BitsPerPayload = SymbolsPerPayload * BitsPerSymbol )
const ( PacketModeFinalBit = 5 // use 6 bits of final byte LSFFinalBit = 7 // use entire final byte )
const ( ConvolutionK = 5 //constraint length K=5 ConvolutionStates = (1 << (ConvolutionK - 1)) //number of states of the convolutional encoder )
const ( LSFSync = uint16(0x55F7) StreamSync = uint16(0xFF5D) PacketSync = uint16(0x75FF) BERTSync = uint16(0xDF55) EOTMarker = uint16(0x555D) )
const ( EncodedCallsignLen = 6 MaxCallsignLen = 9 DestinationAll = "@ALL" EncodedDestinationAll = 0xFFFFFFFFFFFF MaxEncodedCallsign = 0xEE6B27FFFFFF SpecialEncodedRange = 268697600000000 //40^9+40^8 )
const ( // SoftZero represents a confident 0 bit SoftZero = 0x0000 // SoftOne represents a confident 1 bit SoftOne = 0xFFFF // SoftErasure represents an uncertain/erased bit SoftErasure = 0x7FFF // SoftThreshold is the decision boundary SoftThreshold = 0x7FFF )
Constants for soft-decision logic
const ( LSFLen = 30 LSDLen = 28 )
const ( //CC1200 User's Guide, p. 24 //0xAD is `DEVIATION_M`, 2097152=2^21 //+1.0 is the symbol for +0.8kHz //40.0e3 is F_TCXO in kHz //129 is `CFM_RX_DATA_OUT` register value at max. F_DEV //datasheet might have this wrong (it says 64) RXSymbolScalingCoeff = (1.0 / (0.8 / (40.0e3 / 2097152 * 0xAD) * 129.0)) //0xAD is `DEVIATION_M`, 2097152=2^21 //+0.8kHz is the deviation for symbol +1 //40.0e3 is F_TCXO in kHz //64 is `CFM_TX_DATA_IN` register value for max. F_DEV TXSymbolScalingCoeff = (0.8 / ((40.0e3 / 2097152) * 0xAD) * 64.0) )
const CRCLen = 2
const ErrorDetectionFailed = 0xFFFFFFFF
ErrorDetectionFailed indicates the decoder could not correct the errors
Variables ¶
var ( // TX symbols SymbolMap = []Symbol{+1, +3, -1, -3} // symbol list (RX) SymbolList = []Symbol{-3, -1, +1, +3} // End of Transmission symbol pattern EOTSymbols = []Symbol{+3, +3, +3, +3, +3, +3, -3, +3} )
var ( LSFPreambleSymbols = []float64{+3, -3, +3, -3, +3, -3, +3, -3} LSFSyncSymbols = []float64{+3, +3, +3, +3, -3, -3, +3, -3} ExtLSFSyncSymbols = append(LSFPreambleSymbols, LSFSyncSymbols...) StreamSyncSymbols = []float64{-3, -3, -3, -3, +3, +3, -3, +3} PacketSyncSymbols = []float64{+3, -3, +3, +3, -3, -3, -3, -3} BERTSyncSymbols = []float64{-3, +3, -3, -3, +3, +3, +3, +3} )
var EncodedDestinationAllBytes = [6]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
var LSFPuncturePattern = PuncturePattern{ true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, true, false, true, true, }
var PacketPuncturePattern = PuncturePattern{true, true, true, true, true, true, true, false}
Functions ¶
func CalculateHammingDistance ¶
CalculateHammingDistance calculates the Hamming distance between two codewords
func CalculateSyndrome ¶
CalculateSyndrome calculates the syndrome for error detection
func ConvolutionalEncode ¶
func ConvolutionalEncode(in []byte, puncturePattern PuncturePattern, finalBit byte) (*[]Bit, error)
ConvolutionalEncode takes a slice of bytes and a puncture pattern and returns an a slice of bool with each element representing one bit in the encoded message
in Input bytes puncturePattern the puncture pattern to use finalBit The last bit of the final byte to encode. A number between 0 and 7. (That is, the number of bits from the last byte to use minus one.)
func ConvolutionalEncodeStream ¶
func ConvolutionalEncodeStream(lichBits []Bit, sd StreamDatagram) (*[]Bit, error)
func DecodeCallsign ¶
func DecodeLICH ¶
DecodeLICH decodes LICH into a 6-byte array inp: pointer to an array of 96 soft bits
func Encode24 ¶
Encode24 encodes a 12-bit value with Golay(24, 12) data: 12-bit input value (right justified) returns: 24-bit Golay codeword
func EncodeCallsign ¶
func EncodeLICH ¶
EncodeLICH encodes 6 bytes into 12 bytes using Golay encoding
func GetErrorCorrectionCapability ¶
func GetErrorCorrectionCapability() int
GetErrorCorrectionCapability returns the maximum number of errors that can be corrected
func GetMinimumDistance ¶
func GetMinimumDistance() int
GetMinimumDistance returns the minimum Hamming distance of the code
func HardDecode24 ¶
HardDecode24 performs hard-decision decoding of a Golay(24,12) codeword This is a simpler version that works with hard bits (0 or 1)
func IsValidCodeword ¶
IsValidCodeword checks if a 24-bit word is a valid Golay codeword
func NormalizeCallsignModule ¶
For regular callsigns, if the callsign ends with a space followed by a module letter, put the module letter in position 9 (the convention) with spaces preceding it
func SoftCalcChecksum ¶
func SoftCalcChecksum(out, value []SoftBit)
SoftCalcChecksum calculates checksum for soft-valued data This follows the C implementation exactly
func SoftDecode24 ¶
SoftDecode24 performs soft decode of Golay(24, 12) codeword
func SoftDetectErrors ¶
SoftDetectErrors detects errors in a soft-valued Golay(24, 12) codeword
func SoftPopCount ¶
SoftPopCount performs soft-valued equivalent of popcount
Types ¶
type CC1200Modem ¶
type CC1200Modem struct {
// contains filtered or unexported fields
}
func NewCC1200Modem ¶
func (*CC1200Modem) Read ¶
func (m *CC1200Modem) Read(buf []byte) (n int, err error)
Read received symbols
func (*CC1200Modem) SetAFC ¶
func (m *CC1200Modem) SetAFC(afc bool) error
func (*CC1200Modem) SetFreqCorrection ¶
func (m *CC1200Modem) SetFreqCorrection(corr int16) error
func (*CC1200Modem) SetRXFreq ¶
func (m *CC1200Modem) SetRXFreq(freq uint32) error
func (*CC1200Modem) SetTXFreq ¶
func (m *CC1200Modem) SetTXFreq(freq uint32) error
func (*CC1200Modem) SetTXPower ¶
func (m *CC1200Modem) SetTXPower(dbm float32) error
func (*CC1200Modem) Start ¶
func (m *CC1200Modem) Start() error
func (*CC1200Modem) TransmitPacket ¶
func (m *CC1200Modem) TransmitPacket(p Packet) error
func (*CC1200Modem) TransmitVoiceStream ¶
func (m *CC1200Modem) TransmitVoiceStream(sd StreamDatagram) error
type Downsampler ¶
Downsample a stream by returning one out of each N values
func NewDownsampler ¶
func NewDownsampler[T any](sink chan T, factor int, offset int) (Downsampler[T], error)
type DummyModem ¶
type DummyModem struct {
In io.ReadCloser
Out io.WriteCloser
// contains filtered or unexported fields
}
func (*DummyModem) Close ¶
func (m *DummyModem) Close() error
func (*DummyModem) Reset ¶
func (m *DummyModem) Reset() error
func (*DummyModem) SetAFC ¶
func (m *DummyModem) SetAFC(afc bool) error
func (*DummyModem) SetFreqCorrection ¶
func (m *DummyModem) SetFreqCorrection(corr int16) error
func (*DummyModem) SetRXFreq ¶
func (m *DummyModem) SetRXFreq(freq uint32) error
func (*DummyModem) SetTXFreq ¶
func (m *DummyModem) SetTXFreq(freq uint32) error
func (*DummyModem) SetTXPower ¶
func (m *DummyModem) SetTXPower(dbm float32) error
func (*DummyModem) Start ¶
func (m *DummyModem) Start() error
func (*DummyModem) TransmitPacket ¶
func (m *DummyModem) TransmitPacket(p Packet) error
func (*DummyModem) TransmitVoiceStream ¶
func (m *DummyModem) TransmitVoiceStream(sd StreamDatagram) error
type EncodedCallsign ¶
type EncodedCallsign [EncodedCallsignLen]byte
func (EncodedCallsign) Callsign ¶
func (e EncodedCallsign) Callsign() string
type Hostfile ¶ added in v0.1.7
func NewHostfile ¶ added in v0.1.7
type LSF ¶
type LSF struct {
Dst EncodedCallsign
Src EncodedCallsign
Type [typeLen]byte
Meta [metaLen]byte
CRC [CRCLen]byte
}
Link Setup Frame
func NewEmptyLSF ¶
func NewEmptyLSF() LSF
func NewLSFFromBytes ¶
func NewLSFFromLSD ¶
func (*LSF) ToLSDBytes ¶
Convert this LSF to a byte slice suitable for transmission
type LSFDataType ¶
type LSFDataType byte
const ( LSFDataTypeReserved LSFDataType = iota LSFDataTypeData LSFDataTypeVoice LSFDataTypeVoiceData )
type LSFEncryptionSubtype ¶
type LSFEncryptionSubtype byte
type LSFEncryptionType ¶
type LSFEncryptionType byte
const ( LSFEncryptionTypeNone LSFEncryptionType = iota LSFEncryptionTypeScrambler LSFEncryptionTypeAES LSFEncryptionTypeOther )
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}
type Packet ¶
type Packet struct {
LSF LSF
Type PacketType
Payload []byte
CRC uint16
}
M17 packet
func NewPacketFromBytes ¶
func (*Packet) PayloadBytes ¶
Convert the payload (type, message and CRC) to a byte slice suitable for transmission
type PacketType ¶
type PacketType rune
const ( PacketTypeRAW PacketType = 0x00 PacketTypeAX25 PacketType = 0x01 PacketTypeAPRS PacketType = 0x02 PacketType6LoWPAN PacketType = 0x03 PacketTypeIPv4 PacketType = 0x04 PacketTypeSMS PacketType = 0x05 PacketTypeWinlink PacketType = 0x06 )
type PuncturePattern ¶
type PuncturePattern []Bit
type Relay ¶
type Relay struct {
Server string
Port uint
Module byte
EncodedCallsign [6]byte
Callsign string
// contains filtered or unexported fields
}
func (*Relay) SendPacket ¶
type SampleToSymbol ¶
Transform int8 samples to float32 symbols by RRC filtering them
func NewSampleToSymbol ¶
func NewSampleToSymbol(sink chan int8, rrcTaps []float32, scalingCoeff float32) SampleToSymbol
func (*SampleToSymbol) Source ¶
func (t *SampleToSymbol) Source() chan float32
type SoftBit ¶
type SoftBit uint16
func DeinterleaveSoftBits ¶
func DerandomizeSoftBits ¶
func SoftBitXOR ¶
SoftBitXOR performs XOR operation on soft-valued bits This should match the C test expectations exactly
type StreamDatagram ¶
type StreamDatagram struct {
StreamID uint16
FrameNumber uint16
LastFrame bool
LSF LSF
Payload [16]byte
}
func NewStreamDatagram ¶
func NewStreamDatagram(encodedCallsign [6]byte, buffer []byte) (StreamDatagram, error)
type Symbol ¶
type Symbol float32
func AppendBits ¶
func AppendPreamble ¶
AppendPreamble generates symbol stream for a preamble.
func AppendSyncword ¶
AppendSyncword generates the symbol stream for a syncword.
type SymbolToSample ¶
type SymbolToSample struct {
// contains filtered or unexported fields
}
Transform float32 symbols to int8 samples
func NewSymbolToSample ¶
func NewSymbolToSample(rrcTaps []float32, scalingCoeff float32, phaseInvert bool, samplesPerSymbol int) SymbolToSample
func (*SymbolToSample) Transform ¶
func (t *SymbolToSample) Transform(symbols []Symbol) []byte
type ViterbiDecoder ¶
type ViterbiDecoder struct {
// contains filtered or unexported fields
}
func (*ViterbiDecoder) DecodePunctured ¶
func (v *ViterbiDecoder) DecodePunctured(puncturedSoftBits []SoftBit, puncturePattern PuncturePattern) ([]byte, float64)
func (*ViterbiDecoder) Init ¶
func (v *ViterbiDecoder) Init(l int)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
m17-gateway
command
|
|
|
m17-message
command
|
|
|
m17-text-cli
command
|
|
|
modem-emulator
command
|