v0.9.0 Latest Latest

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

Go to latest
Published: Sep 1, 2018 License: AGPL-3.0 Imports: 8 Imported by: 8




View Source
const (
	TimeFormat = "2006-01-02T15:04:05.000"


This section is empty.


func NextPowerOf2

func NextPowerOf2(v int) int

func RegisterParser

func RegisterParser(name string, parserFn NewParserFunc)

Given a name and a parser, register a parser for use. Later used by underscore improting each parser package:

import _ ""


type Data

type Data struct {
	Idx   int
	Bits  string
	Bytes []byte

Used by parsers to interpret received bits/bytes into their appropriate fields.

func NewData

func NewData(data []byte) (d Data)

type Decoder

type Decoder struct {
	Cfg PacketConfig

	Signal    []float64
	Quantized []byte
	// contains filtered or unexported fields

Decoder contains buffers and radio configuration.

func NewDecoder

func NewDecoder() Decoder

func (*Decoder) Allocate

func (d *Decoder) Allocate()

Calculate lengths and allocate internal buffers.

func (Decoder) Decode

func (d Decoder) Decode(input []byte) chan Message

Decode accepts a sample block and returns a channel of messages.

func (Decoder) Filter

func (d Decoder) Filter(input []float64, output []byte)

Matched filter for Manchester coded signals. Output signal's sign at each sample determines the bit-value due to Manchester symbol odd symmetry.

func (Decoder) Log

func (d Decoder) Log()

func (*Decoder) RegisterProtocol

func (d *Decoder) RegisterProtocol(p Parser)

Using a single decoder, register protocols to pass off decoded packets to.

func (*Decoder) Search

func (d *Decoder) Search(preamble []byte) []int

Return a list of indices into the quantized signal at which a valid preamble exists.

func (Decoder) Slice

func (d Decoder) Slice(indices []int) (pkts []Data)

Given a list of indices the preamble exists at, sample the appropriate bits of the signal's bit-decision. Pack bits of each index into an array of bytes and return each packet.

type Demodulator

type Demodulator interface {
	Execute([]byte, []float64)

A Demodulator knows how to demodulate an array of uint8 IQ samples into an array of float64 samples.

type FilterChain

type FilterChain []MessageFilter

A FilterChain takse a list of filters and applies them iteratively to messages sent through the chain.

func (*FilterChain) Add

func (fc *FilterChain) Add(filter MessageFilter)

func (FilterChain) Match

func (fc FilterChain) Match(msg Message) bool

type LogMessage

type LogMessage struct {
	Time   time.Time `xml:",attr"`
	Offset int64     `xml:",attr"`
	Length int       `xml:",attr"`

A LogMessage associates a message with a point in time and an offset and length into a binary sample file.

func (LogMessage) Record

func (msg LogMessage) Record() (r []string)

func (LogMessage) String

func (msg LogMessage) String() string

func (LogMessage) StringNoOffset

func (msg LogMessage) StringNoOffset() string

type MagLUT

type MagLUT []float64

Default Magnitude Lookup Table

func NewMagLUT

func NewMagLUT() (lut MagLUT)

Pre-computes normalized squares with most common DC offset for rtl-sdr dongles.

func (MagLUT) Execute

func (lut MagLUT) Execute(input []byte, output []float64)

Calculates complex magnitude on given IQ stream writing result to output.

type Message

type Message interface {
	MsgType() string
	MeterID() uint32
	MeterType() uint8
	Checksum() []byte

type MessageFilter

type MessageFilter interface {
	Filter(Message) bool

type NewParserFunc

type NewParserFunc func(symbolLength int) Parser

type PacketConfig

type PacketConfig struct {
	Protocol string
	Preamble string

	DataRate int

	BlockSize, BlockSize2    int
	ChipLength, SymbolLength int
	SampleRate               int

	PreambleSymbols, PacketSymbols int
	PreambleLength, PacketLength   int

	BufferLength int
	CenterFreq   uint32

PacketConfig specifies packet-specific radio configuration.

type Parser

type Parser interface {
	Parse([]Data, chan Message, *sync.WaitGroup)
	Cfg() PacketConfig

A Parser converts slices of bytes to messages.

func NewParser

func NewParser(name string, symbolLength int) (Parser, error)

Given a name and symbolLength, lookup the parser and make a new one.

Jump to

Keyboard shortcuts

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