Versions in this module Expand all Collapse all v0 v0.0.1 Nov 17, 2019 Changes in this version + const DefaultPort + const DefaultSecurePort + const ErrBlockInvalidSize + const ErrBlockNumberExceedLimit + const ErrConnectionClosed + const ErrContentFormatNotSet + const ErrInvalidBlockWiseSzx + const ErrInvalidMaxMesssageSizeParameter + const ErrInvalidNetParameter + const ErrInvalidOptionBlock1 + const ErrInvalidOptionBlock2 + const ErrInvalidPayload + const ErrInvalidPayloadSize + const ErrInvalidReponseCode + const ErrInvalidRequest + const ErrInvalidResponse + const ErrInvalidServerConnParameter + const ErrInvalidServerListenerParameter + const ErrInvalidTokenLen + const ErrMaxMessageSizeLimitExceeded + const ErrMessageInvalidVersion + const ErrMessageNotInterested + const ErrMessageTruncated + const ErrMsgTooLarge + const ErrNotSupported + const ErrOptionGapTooLarge + const ErrOptionTooLong + const ErrOptionTruncated + const ErrOptionUnexpectedExtendMarker + const ErrRequestEntityIncomplete + const ErrServerAlreadyStarted + const ErrServerNotStarted + const ErrShortRead + const ErrTimeout + const ErrTokenAlreadyExist + const ErrTokenNotExist + const ErrUnexpectedReponseCode + const MaxTokenSize + const TCP_MESSAGE_LEN13_BASE + const TCP_MESSAGE_LEN14_BASE + const TCP_MESSAGE_LEN15_BASE + const TCP_MESSAGE_MAX_LEN + var DefaultServeMux = NewServeMux() + func ActivateAndServe(l Listener, p net.Conn, handler Handler) error + func CalcETag(payload []byte) []byte + func DefaultHandle(handler Handler) + func DefaultHandleFunc(handler func(w ResponseWriter, r *Request)) + func GenerateMessageID() uint16 + func GenerateToken() ([]byte, error) + func Handle(pattern string, handler Handler) + func HandleFailed(w ResponseWriter, req *Request) + func HandleFunc(pattern string, handler func(w ResponseWriter, r *Request)) + func HandleRemove(pattern string) + func ListenAndServe(network string, addr string, handler Handler) error + func ListenAndServeDTLS(network string, addr string, config *dtls.Config, handler Handler) error + func ListenAndServeTLS(network, addr string, config *tls.Config, handler Handler) error + func MarshalBlockOption(szx BlockWiseSzx, blockNumber uint, moreBlocksFollowing bool) (uint32, error) + type BlockWiseSzx uint8 + const BlockWiseSzx1024 + const BlockWiseSzx128 + const BlockWiseSzx16 + const BlockWiseSzx256 + const BlockWiseSzx32 + const BlockWiseSzx512 + const BlockWiseSzx64 + const BlockWiseSzxBERT + const BlockWiseSzxCount + func UnmarshalBlockOption(blockVal uint32) (szx BlockWiseSzx, blockNumber uint, moreBlocksFollowing bool, err error) + type COAPCode uint8 + const Abort + const BadGateway + const BadOption + const BadRequest + const CSM + const Changed + const Content + const Continue + const Created + const DELETE + const Deleted + const Empty + const Forbidden + const GET + const GatewayTimeout + const InternalServerError + const MethodNotAllowed + const NotAcceptable + const NotFound + const NotImplemented + const POST + const PUT + const Ping + const Pong + const PreconditionFailed + const ProxyingNotSupported + const Release + const RequestEntityIncomplete + const RequestEntityTooLarge + const ServiceUnavailable + const Unauthorized + const UnsupportedMediaType + const Valid + func (c COAPCode) String() string + type COAPType uint8 + const Acknowledgement + const Confirmable + const NonConfirmable + const Reset + func (t COAPType) String() string + type Client struct + BlockWiseTransfer *bool + BlockWiseTransferSzx *BlockWiseSzx + DTLSConfig *dtls.Config + DialTimeout time.Duration + DisablePeerTCPSignalMessageCSMs bool + DisableTCPSignalMessages bool + Handler HandlerFunc + HeartBeat time.Duration + MaxMessageSize uint32 + MulticastHopLimit int + Net string + NotifySessionEndFunc func(err error) + ReadTimeout time.Duration + TLSConfig *tls.Config + WriteTimeout time.Duration + func (c *Client) Dial(address string) (clientConn *ClientConn, err error) + func (c *Client) DialWithContext(ctx context.Context, address string) (clientConn *ClientConn, err error) + type ClientCommander struct + func (cc *ClientCommander) Close() error + func (cc *ClientCommander) Delete(path string) (Message, error) + func (cc *ClientCommander) DeleteWithContext(ctx context.Context, path string) (Message, error) + func (cc *ClientCommander) Equal(cc1 *ClientCommander) bool + func (cc *ClientCommander) Exchange(m Message) (Message, error) + func (cc *ClientCommander) ExchangeWithContext(ctx context.Context, m Message) (Message, error) + func (cc *ClientCommander) Get(path string) (Message, error) + func (cc *ClientCommander) GetWithContext(ctx context.Context, path string) (Message, error) + func (cc *ClientCommander) LocalAddr() net.Addr + func (cc *ClientCommander) NewDeleteRequest(path string) (Message, error) + func (cc *ClientCommander) NewGetRequest(path string) (Message, error) + func (cc *ClientCommander) NewMessage(p MessageParams) Message + func (cc *ClientCommander) NewPostRequest(path string, contentFormat MediaType, body io.Reader) (Message, error) + func (cc *ClientCommander) NewPutRequest(path string, contentFormat MediaType, body io.Reader) (Message, error) + func (cc *ClientCommander) Observe(path string, observeFunc func(req *Request)) (*Observation, error) + func (cc *ClientCommander) ObserveWithContext(ctx context.Context, path string, observeFunc func(req *Request), ...) (*Observation, error) + func (cc *ClientCommander) Ping(timeout time.Duration) error + func (cc *ClientCommander) PingWithContext(ctx context.Context) error + func (cc *ClientCommander) Post(path string, contentFormat MediaType, body io.Reader) (Message, error) + func (cc *ClientCommander) PostWithContext(ctx context.Context, path string, contentFormat MediaType, body io.Reader) (Message, error) + func (cc *ClientCommander) Put(path string, contentFormat MediaType, body io.Reader) (Message, error) + func (cc *ClientCommander) PutWithContext(ctx context.Context, path string, contentFormat MediaType, body io.Reader) (Message, error) + func (cc *ClientCommander) RemoteAddr() net.Addr + func (cc *ClientCommander) Sequence() uint64 + func (cc *ClientCommander) WriteMsg(m Message) error + func (cc *ClientCommander) WriteMsgWithContext(ctx context.Context, m Message) error + type ClientConn struct + func Dial(network, address string) (*ClientConn, error) + func DialDTLS(network, address string, config *dtls.Config) (conn *ClientConn, err error) + func DialDTLSWithTimeout(network, address string, config *dtls.Config, timeout time.Duration) (conn *ClientConn, err error) + func DialTLS(network, address string, tlsConfig *tls.Config) (conn *ClientConn, err error) + func DialTLSWithTimeout(network, address string, tlsConfig *tls.Config, timeout time.Duration) (conn *ClientConn, err error) + func DialTimeout(network, address string, timeout time.Duration) (*ClientConn, error) + func (co *ClientConn) Close() error + func (co *ClientConn) Delete(path string) (Message, error) + func (co *ClientConn) DeleteWithContext(ctx context.Context, path string) (Message, error) + func (co *ClientConn) Exchange(m Message) (Message, error) + func (co *ClientConn) ExchangeWithContext(ctx context.Context, m Message) (Message, error) + func (co *ClientConn) Get(path string) (Message, error) + func (co *ClientConn) GetWithContext(ctx context.Context, path string) (Message, error) + func (co *ClientConn) LocalAddr() net.Addr + func (co *ClientConn) NewDeleteRequest(path string) (Message, error) + func (co *ClientConn) NewGetRequest(path string) (Message, error) + func (co *ClientConn) NewMessage(p MessageParams) Message + func (co *ClientConn) NewPostRequest(path string, contentFormat MediaType, body io.Reader) (Message, error) + func (co *ClientConn) NewPutRequest(path string, contentFormat MediaType, body io.Reader) (Message, error) + func (co *ClientConn) Observe(path string, observeFunc func(req *Request)) (*Observation, error) + func (co *ClientConn) ObserveWithContext(ctx context.Context, path string, observeFunc func(req *Request), ...) (*Observation, error) + func (co *ClientConn) Ping(timeout time.Duration) error + func (co *ClientConn) PingWithContext(ctx context.Context) error + func (co *ClientConn) Post(path string, contentFormat MediaType, body io.Reader) (Message, error) + func (co *ClientConn) PostWithContext(ctx context.Context, path string, contentFormat MediaType, body io.Reader) (Message, error) + func (co *ClientConn) Put(path string, contentFormat MediaType, body io.Reader) (Message, error) + func (co *ClientConn) PutWithContext(ctx context.Context, path string, contentFormat MediaType, body io.Reader) (Message, error) + func (co *ClientConn) RemoteAddr() net.Addr + func (co *ClientConn) Sequence() uint64 + func (co *ClientConn) WriteMsg(m Message) error + func (co *ClientConn) WriteMsgWithContext(ctx context.Context, m Message) error + type DgramMessage struct + func NewDgramMessage(p MessageParams) *DgramMessage + func ParseDgramMessage(data []byte) (*DgramMessage, error) + func (m *DgramMessage) MarshalBinary(buf io.Writer) error + func (m *DgramMessage) MessageID() uint16 + func (m *DgramMessage) SetMessageID(messageID uint16) + func (m *DgramMessage) ToBytesLength() (int, error) + func (m *DgramMessage) UnmarshalBinary(data []byte) error + type Error string + func (e Error) Error() string + type Handler interface + ServeCOAP func(w ResponseWriter, r *Request) + type HandlerFunc func(ResponseWriter, *Request) + func (f HandlerFunc) ServeCOAP(w ResponseWriter, r *Request) + type Listener interface + AcceptWithContext func(ctx context.Context) (net.Conn, error) + Close func() error + type MediaType uint16 + const AppCBOR + const AppCWT + const AppCoapGroup + const AppCoseEncrypt + const AppCoseEncrypt0 + const AppCoseKey + const AppCoseKeySet + const AppCoseMac + const AppCoseMac0 + const AppCoseSign + const AppCoseSign1 + const AppExi + const AppJSON + const AppJsonMergePatch + const AppJsonPatch + const AppLinkFormat + const AppLwm2mJSON + const AppLwm2mTLV + const AppOcfCbor + const AppOctets + const AppXML + const TextPlain + func (c MediaType) String() string + type Message interface + AddOption func(opID OptionID, val interface{}) + AllOptions func() options + Code func() COAPCode + IsConfirmable func() bool + MarshalBinary func(buf io.Writer) error + MessageID func() uint16 + Option func(o OptionID) interface{} + Options func(o OptionID) []interface{} + Path func() []string + PathString func() string + Payload func() []byte + Query func() []string + QueryString func() string + RemoveOption func(opID OptionID) + SetCode func(code COAPCode) + SetMessageID func(messageID uint16) + SetObserve func(b uint32) + SetOption func(opID OptionID, val interface{}) + SetPath func(s []string) + SetPathString func(s string) + SetPayload func(p []byte) + SetQuery func([]string) + SetQueryString func(string) + SetToken func(t []byte) + SetType func(typ COAPType) + SetURIQuery func(s string) + ToBytesLength func() (int, error) + Token func() []byte + Type func() COAPType + UnmarshalBinary func(data []byte) error + type MessageBase struct + func (m *MessageBase) AddOption(opID OptionID, val interface{}) + func (m *MessageBase) AllOptions() options + func (m *MessageBase) Code() COAPCode + func (m *MessageBase) IsConfirmable() bool + func (m *MessageBase) Option(o OptionID) interface{} + func (m *MessageBase) Options(o OptionID) []interface{} + func (m *MessageBase) Path() []string + func (m *MessageBase) PathString() string + func (m *MessageBase) Payload() []byte + func (m *MessageBase) Query() []string + func (m *MessageBase) QueryString() string + func (m *MessageBase) RemoveOption(opID OptionID) + func (m *MessageBase) SetCode(code COAPCode) + func (m *MessageBase) SetObserve(b uint32) + func (m *MessageBase) SetOption(opID OptionID, val interface{}) + func (m *MessageBase) SetPath(s []string) + func (m *MessageBase) SetPathString(s string) + func (m *MessageBase) SetPayload(p []byte) + func (m *MessageBase) SetQuery(s []string) + func (m *MessageBase) SetQueryString(s string) + func (m *MessageBase) SetToken(p []byte) + func (m *MessageBase) SetType(typ COAPType) + func (m *MessageBase) SetURIQuery(s string) + func (m *MessageBase) Token() []byte + func (m *MessageBase) Type() COAPType + type MessageParams struct + Code COAPCode + MessageID uint16 + Payload []byte + Token []byte + Type COAPType + type MulticastClient struct + BlockWiseTransfer *bool + BlockWiseTransferSzx *BlockWiseSzx + DialTimeout time.Duration + Handler HandlerFunc + HeartBeat time.Duration + MaxMessageSize uint32 + MulticastHopLimit int + Net string + NotifySessionEndFunc func(err error) + ReadTimeout time.Duration + WriteTimeout time.Duration + func (c *MulticastClient) Dial(address string) (*MulticastClientConn, error) + func (c *MulticastClient) DialWithContext(ctx context.Context, address string) (*MulticastClientConn, error) + type MulticastClientConn struct + func (mconn *MulticastClientConn) Close() + func (mconn *MulticastClientConn) LocalAddr() net.Addr + func (mconn *MulticastClientConn) NewGetRequest(path string) (Message, error) + func (mconn *MulticastClientConn) NewMessage(p MessageParams) Message + func (mconn *MulticastClientConn) Publish(path string, responseHandler func(req *Request)) (*ResponseWaiter, error) + func (mconn *MulticastClientConn) PublishMsg(req Message, responseHandler func(req *Request)) (*ResponseWaiter, error) + func (mconn *MulticastClientConn) PublishMsgWithContext(ctx context.Context, req Message, responseHandler func(req *Request)) (*ResponseWaiter, error) + func (mconn *MulticastClientConn) PublishWithContext(ctx context.Context, path string, responseHandler func(req *Request)) (*ResponseWaiter, error) + func (mconn *MulticastClientConn) RemoteAddr() net.Addr + func (mconn *MulticastClientConn) WriteMsg(m Message) error + func (mconn *MulticastClientConn) WriteMsgWithContext(ctx context.Context, m Message) error + type Observation struct + func (o *Observation) Cancel() error + func (o *Observation) CancelWithContext(ctx context.Context) error + type OptionID uint16 + const Accept + const AlternativeAddress + const BadCSMOption + const Block1 + const Block2 + const BlockWiseTransfer + const ContentFormat + const Custody + const ETag + const HoldOff + const IfMatch + const IfNoneMatch + const LocationPath + const LocationQuery + const MaxAge + const MaxMessageSize + const NoResponse + const Observe + const ProxyScheme + const ProxyURI + const Size1 + const Size2 + const URIHost + const URIPath + const URIPort + const URIQuery + type Request struct + Client *ClientConn + Ctx context.Context + Msg Message + Sequence uint64 + type ResponseWaiter struct + func (r *ResponseWaiter) Cancel() error + type ResponseWriter interface + NewResponse func(code COAPCode) Message + SetCode func(code COAPCode) + SetContentFormat func(contentFormat MediaType) + Write func(p []byte) (n int, err error) + WriteMsg func(msg Message) error + WriteMsgWithContext func(ctx context.Context, msg Message) error + WriteWithContext func(ctx context.Context, p []byte) (n int, err error) + type ServeMux struct + func NewServeMux() *ServeMux + func (mux *ServeMux) DefaultHandle(handler Handler) + func (mux *ServeMux) DefaultHandleFunc(handler func(w ResponseWriter, r *Request)) + func (mux *ServeMux) Handle(pattern string, handler Handler) error + func (mux *ServeMux) HandleFunc(pattern string, handler func(w ResponseWriter, r *Request)) + func (mux *ServeMux) HandleRemove(pattern string) error + func (mux *ServeMux) ServeCOAP(w ResponseWriter, r *Request) + func (mux *ServeMux) Use(middlewares ...func(Handler) Handler) + type Server struct + Addr string + BlockWiseTransfer *bool + BlockWiseTransferSzx *BlockWiseSzx + Conn net.Conn + DTLSConfig *dtls.Config + DisablePeerTCPSignalMessageCSMs bool + DisableTCPSignalMessages bool + Handler Handler + HeartBeat time.Duration + Listener Listener + MaxMessageSize uint32 + Net string + NotifySessionEndFunc func(w *ClientConn, err error) + NotifySessionNewFunc func(w *ClientConn) + NotifyStartedFunc func() + ReadTimeout time.Duration + TLSConfig *tls.Config + UDPMcastInterfaces []net.Interface + WriteTimeout time.Duration + func (srv *Server) ActivateAndServe() error + func (srv *Server) ListenAndServe() error + func (srv *Server) Shutdown() error + type TcpMessage struct + func Decode(reader io.Reader) (*TcpMessage, error) + func NewTcpMessage(p MessageParams) *TcpMessage + func PullTcp(data []byte) (*TcpMessage, []byte, error) + func (m *TcpMessage) MarshalBinary(buf io.Writer) error + func (m *TcpMessage) MessageID() uint16 + func (m *TcpMessage) SetMessageID(messageID uint16) + func (m *TcpMessage) ToBytesLength() (int, error) + func (m *TcpMessage) UnmarshalBinary(data []byte) error + type TokenHandler struct + func (s *TokenHandler) Add(token []byte, handler func(w ResponseWriter, r *Request)) error + func (s *TokenHandler) Handle(w ResponseWriter, r *Request, next HandlerFunc) + func (s *TokenHandler) Remove(token []byte) error