nmcoap

package
v0.0.0-...-691c107 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareMsgCriteria

func CompareMsgCriteria(mc1 MsgCriteria, mc2 MsgCriteria) int

func CreateMsg

func CreateMsg(isTcp bool, mp MsgParams) (coap.Message, error)

func Encode

func Encode(m coap.Message) ([]byte, error)

func MatchMsgCriteria

func MatchMsgCriteria(listenc MsgCriteria, msgc MsgCriteria) bool

Determines if a listener matches an incoming message.

func NextMessageId

func NextMessageId() uint16

func ParseOp

func ParseOp(op string) (coap.COAPCode, error)

func SortListeners

func SortListeners(listeners []*Listener)

Types

type Dispatcher

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

The dispatcher is the owner of the listeners it points to. Only the dispatcher writes to these listeners.

func NewDispatcher

func NewDispatcher(isTcp bool, logDepth int) *Dispatcher

func (*Dispatcher) AddListener

func (d *Dispatcher) AddListener(mc MsgCriteria) (*Listener, error)

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(data []byte) bool

Returns true if the response was dispatched.

func (*Dispatcher) ErrorAll

func (d *Dispatcher) ErrorAll(err error)

func (*Dispatcher) ErrorOne

func (d *Dispatcher) ErrorOne(mc MsgCriteria, err error) error

func (*Dispatcher) ProcessCoapReq

func (d *Dispatcher) ProcessCoapReq(data []byte) (coap.Message, error)

func (*Dispatcher) RemoveListener

func (d *Dispatcher) RemoveListener(mc MsgCriteria) *Listener

type Listener

type Listener struct {
	Criteria MsgCriteria
	RspChan  chan coap.Message
	ErrChan  chan error
	// contains filtered or unexported fields
}

func NewListener

func NewListener(mc MsgCriteria) *Listener

func (*Listener) AfterTimeout

func (ol *Listener) AfterTimeout(tmo time.Duration) <-chan time.Time

func (*Listener) Close

func (ol *Listener) Close()

type MsgCriteria

type MsgCriteria struct {
	Token []byte
	Path  string
}

func CriteriaFromMsg

func CriteriaFromMsg(msg coap.Message) MsgCriteria

func (*MsgCriteria) String

func (mc *MsgCriteria) String() string

type MsgParams

type MsgParams struct {
	Code    coap.COAPCode
	Uri     string
	Observe ObserveCode
	Token   []byte
	Payload []byte
}

type ObserveCode

type ObserveCode int
const (
	OBSERVE_NONE ObserveCode = iota
	OBSERVE_START
	OBSERVE_STOP
)

These observe codes differ from those specified in the CoAP spec. It is done this way so that the default value (0) implies no observe action.

func (ObserveCode) Spec

func (o ObserveCode) Spec() int

type Reassembler

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

func NewReassembler

func NewReassembler() *Reassembler

func (*Reassembler) RxFrag

func (r *Reassembler) RxFrag(frag []byte) *coap.TcpMessage

type Receiver

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

func NewReceiver

func NewReceiver(isTcp bool) Receiver

func (*Receiver) Rx

func (r *Receiver) Rx(data []byte) coap.Message

type RxFilterFunc

type RxFilterFunc func(msg coap.Message) (coap.Message, error)

func (RxFilterFunc) Filter

func (f RxFilterFunc) Filter(msg coap.Message) (coap.Message, error)

type RxMsgFilter

type RxMsgFilter interface {
	Filter(msg coap.Message) (coap.Message, error)
}

type TxMsgFilter

type TxMsgFilter interface {
	// Filter applies the filter to an outgoing CoAP message.
	Filter(msg coap.Message) (coap.Message, error)

	// Freeze makes the filter use the same parameters for all transmits until
	// unfrozen.  The parameters will be different from the previous message,
	// but they will not change while the session is frozen.
	Freeze()

	// Unfreeze makes the filter use new parameters for all subsequent
	// messages.
	Unfreeze()
}

Jump to

Keyboard shortcuts

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