atcmd

package
v0.0.0-...-dd098c7 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CR = 0x0D
	LF = 0x0A
)

list of constant

View Source
const (
	OkPattern  = "OK(.*)\\r\\n"
	ErrPattern = "ERROR:(.*)\\r\\n"
)

Variables

View Source
var (
	CRLF        = []byte{CR, LF}
	RegexpOk    = regexp.MustCompile(OkPattern)
	RegexpError = regexp.MustCompile(ErrPattern)
)

known data

Functions

This section is empty.

Types

type ErrorFunc

type ErrorFunc func(err error, done chan<- bool)

type Handler

type Handler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Handler

func NewDefaultHandler

func NewDefaultHandler(dev io.ReadWriter) *Handler

NewDefaultHandler return AT command with default parameters

func NewHandler

func NewHandler(dev io.ReadWriter, rqDuration time.Duration, onResp ResponseFunc, onErr ErrorFunc) *Handler

NewHandler creates AT+Command Handler. rq: read quiescence time, i.e. delay between consecutive read

func (*Handler) Close

func (h *Handler) Close() error

Close handler

func (*Handler) IsRunning

func (h *Handler) IsRunning() bool

IsRunning return true if read loop running

func (*Handler) OnError

func (h *Handler) OnError(fn ErrorFunc) *Handler

func (*Handler) OnResponse

func (h *Handler) OnResponse(fn ResponseFunc) *Handler

OnResponse Handler

func (*Handler) ReadQuiescence

func (h *Handler) ReadQuiescence(delay time.Duration) *Handler

ReadQuiescence set time delay between consecutive read

func (*Handler) Reset

func (h *Handler) Reset()

Reset content

func (*Handler) ResponseBytes

func (h *Handler) ResponseBytes() []byte

ResponseBytes read all data

func (*Handler) Run

func (h *Handler) Run()

Run read loop

func (*Handler) RunContext

func (h *Handler) RunContext(ctx context.Context)

RunContext handler

func (*Handler) TakeResponse

func (h *Handler) TakeResponse(id uuid.UUID) *SerialData

TakeResponse from buffer

func (*Handler) WaitDone

func (h *Handler) WaitDone() error

WaitDone wait until read loop is closed

func (*Handler) WaitDoneContext

func (h *Handler) WaitDoneContext(ctx context.Context) error

WaitDone wait until done

func (*Handler) Write

func (h *Handler) Write(cmd []byte) (int, error)

Write command to device

func (*Handler) WriteBytes

func (h *Handler) WriteBytes(cmd []byte, fn ResponseFunc) (uuid.UUID, int, error)

WriteBytes write command with given context

func (*Handler) WriteString

func (h *Handler) WriteString(cmd string, fn ResponseFunc) (uuid.UUID, int, error)

type ResponseFunc

type ResponseFunc func(data *SerialData, err error)

ResponseFunc handle response from device.

type SerialData

type SerialData struct {
	At       time.Time
	ID       uuid.UUID
	Cmd      []byte
	Response []byte
	// contains filtered or unexported fields
}

SerialData stores information about serial data

func (*SerialData) Copy

func (sd *SerialData) Copy() *SerialData

Copy serial data

Jump to

Keyboard shortcuts

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