rak811

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: Apache-2.0 Imports: 14 Imported by: 1

README

rak811

RAK811 Golang Library for use with LoRa pHAT & MicroBIT Node

Build

Example

func main() {
	cfg := &serial.Config{
		Name:        "/dev/ttyAMA0",
	}

	lora, err := rak811.New(cfg)
	if err != nil {
		log.Fatal("failed to create rak811 instance: ", err)
	}

	resp, err := lora.HardReset()
	if err != nil {
		log.Fatal("failed to reset: ", err)
	}

	resp, err = lora.Version()
	if err != nil {
		log.Fatal("failed to get version: ", err)
	}

	fmt.Println(resp)
}

To run the example, use sudo:

sudo go run main.go

You can find a more complete example and usage in resources.

Resources

Wiki

RPi project example

Documentation

Index

Constants

View Source
const (
	CodeArgErr        = -1
	CodeArgNotFind    = -2
	CodeJoinAbpErr    = -3
	CodeJoinOtaaErr   = -4
	CodeNotJoin       = -5
	CodeMacBusyErr    = -6
	CodeTxErr         = -7
	CodeInterErr      = -8
	CodeWrCfgErr      = -11
	CodeRdCfgErr      = -12
	CodeTxLenLimitErr = -13
	CodeUnknownErr    = -20

	StatusRecvData         = 0
	StatusTxConfirmed      = 1
	StatusTxUnconfirmed    = 2
	StatusJoinedSuccess    = 3
	StatusJoinedFailed     = 4
	StatusTxTimeout        = 5
	StatusRx2Timeout       = 6
	StatusDownlinkRepeated = 7
	StatusWakeUp           = 8
	StatusP2pComplete      = 9
	StatusUnknown          = 100

	// JoinSuccess successful join.
	JoinSuccess = "at+recv=3,0,0"
	// JoinFail incorrect join config parameters.
	JoinFail = "at+recv=4,0,0"
	// JoinTimeout no response from a gateway.
	JoinTimeout = "at+recv=6,0,0"

	OK    = "OK"
	ERROR = "ERROR"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.0.1

type Config struct {
	Name     string
	Baud     int64
	Parity   Parity
	StopBits StopBits
	Size     int
}

type EventResponse

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

func WhichEventResponse

func WhichEventResponse(resp string) *EventResponse

func (*EventResponse) Code

func (e *EventResponse) Code() int

func (*EventResponse) Description

func (e *EventResponse) Description() string

type Lora

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

func New

func New(conf *Config) (*Lora, error)

func (*Lora) ClearRadioStatus

func (l *Lora) ClearRadioStatus() (string, error)

SetStatus clear radio statistics

func (*Lora) Close

func (l *Lora) Close()

Close the serial conn.

func (*Lora) Debug added in v1.0.1

func (l *Lora) Debug(mode bool)

Debug set debug mode on or off

func (*Lora) GetABPInfo

func (l *Lora) GetABPInfo() (string, error)

GetABPInfo

func (*Lora) GetBand

func (l *Lora) GetBand() (string, error)

GetBand LoRaWAN band region

func (*Lora) GetConfig

func (l *Lora) GetConfig(key string) (string, error)

GetConfig LoRaWAN configuration

func (*Lora) GetDataRate

func (l *Lora) GetDataRate() (string, error)

GetDataRate get next send data rate

func (*Lora) GetLinkCnt

func (l *Lora) GetLinkCnt() (string, error)

GetLinkCnt get LoRaWAN uplink and downlink counter

func (*Lora) GetMode

func (l *Lora) GetMode() (string, error)

GetMode get module mode

func (*Lora) GetRadioStatus

func (l *Lora) GetRadioStatus() (string, error)

GetStatus get radio statistics

func (*Lora) GetRecvEx

func (l *Lora) GetRecvEx() (string, error)

GetRecvEx get RSSI & SNR report on receive flag (Enabled/Disabled).

func (*Lora) GetRfConfig

func (l *Lora) GetRfConfig() (string, error)

GetRfConfig get RF parameters

func (*Lora) GetUART

func (l *Lora) GetUART() (string, error)

GetUART get UART configurations

func (*Lora) HardReset

func (l *Lora) HardReset() (string, error)

HardReset the module by reseting the hat pins.

func (*Lora) JoinABP

func (l *Lora) JoinABP() (string, error)

JoinABP join the configured network in ABP mode

func (*Lora) JoinOTAA

func (l *Lora) JoinOTAA() (string, error)

JoinOTAA join the configured network in OTAA mode. The module doesn't accept any other command before it returns a response. Response: JoinSuccess, JoinFail, JoinTimeout

func (*Lora) Recv

func (l *Lora) Recv(data string) (string, error)

Recv receive event and data from LoRaWAN or LoRaP2P network

func (*Lora) Reload

func (l *Lora) Reload() (string, error)

Reload set LoRaWAN and LoraP2P configurations to default

func (*Lora) Reset

func (l *Lora) Reset(mode int) (string, error)

Reset module or LoRaWAN stack 0: reset and restart module 1: reset LoRaWAN stack and the module will reload LoRa configuration from EEPROM

func (*Lora) RxStop

func (l *Lora) RxStop() (string, error)

RxStop LoraP2P RX

func (*Lora) Rxc

func (l *Lora) Rxc(enable int) (string, error)

Rxc set module in LoraP2P receive mode

func (*Lora) Send

func (l *Lora) Send(data string) (string, error)

Send sends data to LoRaWAN network, returns the event response

func (*Lora) SetBand

func (l *Lora) SetBand(band string) (string, error)

SetBand LoRaWAN band region

func (*Lora) SetConfig

func (l *Lora) SetConfig(config string) (string, error)

SetConfig set LoRaWAN configurations

func (*Lora) SetDataRate

func (l *Lora) SetDataRate(datarate string) (string, error)

SetDataRate set next send data rate

func (*Lora) SetLinkCnt

func (l *Lora) SetLinkCnt(uplinkCnt, downlinkCnt float32) (string, error)

SetLinkCnt set LoRaWAN uplink and downlink counter

func (*Lora) SetMode

func (l *Lora) SetMode(mode int) (string, error)

SetMode set module to work for LoRaWAN or LoraP2P mode, defaults to 0

func (*Lora) SetRecvEx

func (l *Lora) SetRecvEx(mode int) (string, error)

SetRecvEx set RSSI & SNR report on receive flag (Enabled/Disabled).

func (*Lora) SetRfConfig

func (l *Lora) SetRfConfig(parameters string) (string, error)

SetRfConfig Set RF parameters

func (*Lora) SetUART

func (l *Lora) SetUART(configuration string) (string, error)

SetUART set UART configurations

func (*Lora) Signal

func (l *Lora) Signal() (string, error)

Signal check the radio rssi, snr, update by latest received radio packet

func (*Lora) Sleep

func (l *Lora) Sleep() (string, error)

Sleep enter sleep mode

func (*Lora) TxStop

func (l *Lora) TxStop() (string, error)

TxStop stops LoraP2P TX

func (*Lora) Txc

func (l *Lora) Txc(parameters string) (string, error)

Txc send LoraP2P message

func (*Lora) Version

func (l *Lora) Version() (string, error)

Version get module version

type LoraError

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

LoraError type that describes the LoRaWAN errors

func WhichError

func WhichError(error string) *LoraError

WhichError translates an error string to a LoraError

func (*LoraError) Code

func (e *LoraError) Code() int

Code returns the error code

func (*LoraError) Error

func (e *LoraError) Error() string

Error returns the error description

type Parity added in v1.0.1

type Parity byte
const (
	ParityNone  Parity = 'N'
	ParityOdd   Parity = 'O'
	ParityEven  Parity = 'E'
	ParityMark  Parity = 'M' // parity bit is always 1
	ParitySpace Parity = 'S' // parity bit is always 0
)

type StopBits added in v1.0.1

type StopBits int8
const (
	Stop1     StopBits = 1
	Stop1Half StopBits = 15
	Stop2     StopBits = 2
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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