sx127x

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

go-sx127x

Semtech sx1276/7/8/9 library written in Go

Documentation

Index

Constants

View Source
const (
	ModulationFskOok uint8 = iota
	ModulationLoRa
)

Modulation modes

View Source
const (
	PaSelectRfo uint8 = iota
	PaSelectPaBoost
)

Pa select

View Source
const (
	SpreadingFactor7 uint8 = iota + 7
	SpreadingFactor8
	SpreadingFactor9
	SpreadingFactor10
	SpreadingFactor11
	SpreadingFactor12
)

Spreading factors

View Source
const (
	CodingRate4to5 uint8 = iota + 1
	CodingRate4to6
	CodingRate4to7
	CodingRate4to8
)

Coding rates

View Source
const (
	BandWidth125KHz uint8 = iota + 7
	BandWidth250KHz
	BandWidth500KHz
)

Band widths

View Source
const (
	DeviceModeSLEEP uint8 = iota
	DeviceModeSTDBY
	DeviceModeFSTX
	DeviceModeTX
	DeviceModeFSRX
	DeviceModeRXCONTINUOUS
	DeviceModeRXSINGLE
	DeviceModeCAD
)

device mode

View Source
const (
	FlagRxTimeout         uint8 = (1 << 7)
	FlagRxDone            uint8 = (1 << 6)
	FlagPayloadCrcError   uint8 = (1 << 5)
	FlagValidHeader       uint8 = (1 << 4)
	FlagTxDone            uint8 = (1 << 3)
	FlagCadDone           uint8 = (1 << 2)
	FlagFhssChangeChannel uint8 = (1 << 1)
	FlagCadDetected       uint8 = (1 << 0)
)

IRQ Flags

View Source
const (
	DIO0Mapping = 14
	DIO1Mapping = 12
	DIO2Mapping = 10
	DIO3Mapping = 8
	DIO4Mapping = 6
	DIO5Mapping = 4

	DIOMode0       = 0
	DIOMode1       = 1
	DIOMode2       = 2
	DIOModeDISABLE = 3
)

DIO Modes

View Source
const (
	Version = 0x12
)

Default regVersion value

Variables

View Source
var (
	ErrorPayloadLength  = fmt.Errorf("wrong payload length")
	ErrorFrequency      = fmt.Errorf("frequency out of range")
	ErrorNoDevice       = fmt.Errorf("no device found")
	ErrorWrongParameter = fmt.Errorf("wrong parameter")
	ErrorCrc            = fmt.Errorf("CRC mistmatch")
	ErrorNoCrc          = fmt.Errorf("no CRC presented")
	ErrorTimeout        = fmt.Errorf("timeout")
)

Errors

Functions

This section is empty.

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device ...

func NewDevice

func NewDevice(pins *Gpios) *Device

NewDevice ...

func (*Device) Close

func (d *Device) Close() error

Close ...

func (*Device) GetBandWidth

func (d *Device) GetBandWidth() (uint8, error)

GetBandWidth ...

func (*Device) GetCodingRate

func (d *Device) GetCodingRate() (uint8, error)

GetCodingRate ...

func (*Device) GetFrequency

func (d *Device) GetFrequency() (uint32, error)

GetFrequency ...

func (*Device) GetLastPacketRSSI

func (d *Device) GetLastPacketRSSI() (int, error)

GetLastPacketRSSI ...

func (*Device) GetLastPacketSNR

func (d *Device) GetLastPacketSNR() (int, error)

GetLastPacketSNR ...

func (*Device) GetModulationMode

func (d *Device) GetModulationMode() (uint8, error)

GetModulationMode ...

func (*Device) GetPaSelect

func (d *Device) GetPaSelect() (uint8, error)

GetPaSelect ...

func (*Device) GetPayloadCrcOn

func (d *Device) GetPayloadCrcOn() (bool, error)

GetPayloadCrcOn ...

func (*Device) GetPower

func (d *Device) GetPower() (uint8, error)

GetPower ...

func (*Device) GetPreambleLength

func (d *Device) GetPreambleLength() (uint16, error)

GetPreambleLength ...

func (*Device) GetRSSI

func (d *Device) GetRSSI() (int, error)

GetRSSI ...

func (*Device) GetSpreadingFactor

func (d *Device) GetSpreadingFactor() (uint8, error)

GetSpreadingFactor ...

func (*Device) GetSyncWord

func (d *Device) GetSyncWord() (uint8, error)

GetSyncWord ...

func (*Device) GetVersion

func (d *Device) GetVersion() (uint8, error)

GetVersion ...

func (*Device) Initialize

func (d *Device) Initialize(settings *Settings) error

Initialize ...

func (*Device) LoadCurrentParameters

func (d *Device) LoadCurrentParameters() error

LoadCurrentParameters ...

func (*Device) Open

func (d *Device) Open(device string) error

Open ...

func (*Device) ReceiveContinuous

func (d *Device) ReceiveContinuous() ([]byte, error)

ReceiveContinuous ...

func (*Device) ReceiveContinuousIt

func (d *Device) ReceiveContinuousIt() error

ReceiveContinuousIt ...

func (*Device) ReceiveSingle

func (d *Device) ReceiveSingle() ([]byte, error)

ReceiveSingle ...

func (*Device) ReceiveSingleIt

func (d *Device) ReceiveSingleIt() error

ReceiveSingleIt ...

func (*Device) Reset

func (d *Device) Reset()

Reset ...

func (*Device) SetBandWidth

func (d *Device) SetBandWidth(bandwidth uint8) error

SetBandWidth ...

func (*Device) SetCodingRate

func (d *Device) SetCodingRate(codingrate uint8) error

SetCodingRate ...

func (*Device) SetFrequency

func (d *Device) SetFrequency(frequency uint32) error

SetFrequency ...

func (*Device) SetModulationMode

func (d *Device) SetModulationMode(modulation uint8) error

SetModulationMode ...

func (*Device) SetPaSelect

func (d *Device) SetPaSelect(input uint8) error

SetPaSelect ...

func (*Device) SetPayloadCrcOn

func (d *Device) SetPayloadCrcOn(crcon bool) error

SetPayloadCrcOn ...

func (*Device) SetPower

func (d *Device) SetPower(power uint8) error

SetPower ...

func (*Device) SetPreambleLength

func (d *Device) SetPreambleLength(preamblelength uint16) error

SetPreambleLength ...

func (*Device) SetRxCrcErrorCallback

func (d *Device) SetRxCrcErrorCallback(callback func())

SetRxCrcErrorCallback ...

func (*Device) SetRxDoneCallback

func (d *Device) SetRxDoneCallback(callback func([]byte))

SetRxDoneCallback ...

func (*Device) SetRxTimeoutCallback

func (d *Device) SetRxTimeoutCallback(callback func())

SetRxTimeoutCallback ...

func (*Device) SetSleep

func (d *Device) SetSleep() error

SetSleep ...

func (*Device) SetSpreadingFactor

func (d *Device) SetSpreadingFactor(spreadingfactor uint8) error

SetSpreadingFactor ...

func (*Device) SetStandby

func (d *Device) SetStandby() error

SetStandby ...

func (*Device) SetSyncWord

func (d *Device) SetSyncWord(syncword uint8) error

SetSyncWord ...

func (*Device) SetTxDoneCallback

func (d *Device) SetTxDoneCallback(callback func())

SetTxDoneCallback ...

func (*Device) Transmit

func (d *Device) Transmit(buffer []byte, delay uint) error

Transmit ...

func (*Device) TransmitIt

func (d *Device) TransmitIt(buffer []byte) error

TransmitIt ...

type Gpio

type Gpio interface {
	High()
	Low()
	Watch(func(Gpio)) error
	Unwatch()
}

Gpio ...

type Gpios

type Gpios struct {
	Reset uint8
	Dio0  uint8
	Dio1  uint8
	Dio3  uint8
}

Gpios ...

type SPI

type SPI interface {
	Open(dev string, speed int) error
	Close() error
	Transfer(buffer []byte) error
}

SPI ...

type Settings

type Settings struct {
	Modulation      uint8
	PaSelect        uint8
	Power           uint8
	SpreadingFactor uint8
	BandWidth       uint8
	CodingRate      uint8
	PayloadCrcOn    bool
	PreambleLength  uint16
	Frequency       uint32
	SyncWord        uint8
	// contains filtered or unexported fields
}

Settings ...

Jump to

Keyboard shortcuts

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