rf95modem-go

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-3.0

README

rf95modem-go

GoDoc Build Status

Golang library to send and receive data over LoRa via a rf95modem.

Library

The primary focus of this library is the sending and receiving of data via LoRa. An io.Reader and io.Writer are provided for this purpose.

package main

import (
	"fmt"

	"github.com/dtn7/rf95modem-go/rf95"
)

func main() {
	modem, modemErr := rf95.OpenModem("/dev/ttyUSB0")
	if modemErr != nil {
		panic(modemErr)
	}

	if _, err := modem.Write([]byte("hello world")); err != nil {
		panic(err)
	}

	buf := make([]byte, 64)
	if _, err := modem.Read(buf); err != nil {
		panic(err)
	} else {
		fmt.Printf("%x\n", buf)
	}

	if err := modem.Close(); err != nil {
		panic(err)
	}
}

Example: rf95pty

A small proof of concept is rf95pty to bind a rf95modem to a pseudoterminal device.

$ go build ./cmd/rf95pty

# Node A: provide a shell over LoRa - stupid idea, btw
$ ./rf95pty /dev/ttyUSB0
Opening pty device /dev/pts/5
$ socat /dev/pts/5,raw,nonblock,echo=0 exec:sh,pty,stderr,setsid,sigint,sane

# Node B: Uses shell
$ ./rf95pty /dev/ttyUSB1
Opening pty device /dev/pts/7
$ st -l /dev/pts/7

Directories

Path Synopsis
cmd
rf95pty command
Package rf95 provides a software interface for a rf95modem.
Package rf95 provides a software interface for a rf95modem.

Jump to

Keyboard shortcuts

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