Documentation ¶
Index ¶
- Constants
- Variables
- type ErrorFunc
- type Handler
- func (h *Handler) Close() error
- func (h *Handler) IsRunning() bool
- func (h *Handler) OnError(fn ErrorFunc) *Handler
- func (h *Handler) OnResponse(fn ResponseFunc) *Handler
- func (h *Handler) ReadQuiescence(delay time.Duration) *Handler
- func (h *Handler) Reset()
- func (h *Handler) ResponseBytes() []byte
- func (h *Handler) Run()
- func (h *Handler) RunContext(ctx context.Context)
- func (h *Handler) TakeResponse(id uuid.UUID) *SerialData
- func (h *Handler) WaitDone() error
- func (h *Handler) WaitDoneContext(ctx context.Context) error
- func (h *Handler) Write(cmd []byte) (int, error)
- func (h *Handler) WriteBytes(cmd []byte, fn ResponseFunc) (uuid.UUID, int, error)
- func (h *Handler) WriteString(cmd string, fn ResponseFunc) (uuid.UUID, int, error)
- type ResponseFunc
- type SerialData
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 Handler ¶
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) OnResponse ¶
func (h *Handler) OnResponse(fn ResponseFunc) *Handler
OnResponse Handler
func (*Handler) ReadQuiescence ¶
ReadQuiescence set time delay between consecutive read
func (*Handler) ResponseBytes ¶
ResponseBytes read all data
func (*Handler) TakeResponse ¶
func (h *Handler) TakeResponse(id uuid.UUID) *SerialData
TakeResponse from buffer
func (*Handler) WaitDoneContext ¶
WaitDone wait until done
func (*Handler) WriteBytes ¶
WriteBytes write command with given context
func (*Handler) WriteString ¶
type ResponseFunc ¶
type ResponseFunc func(data *SerialData, err error)
ResponseFunc handle response from device.
Click to show internal directories.
Click to hide internal directories.