message

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 9 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMessageTruncated      = errors.New("message is truncated")
	ErrMessageInvalidVersion = errors.New("message has invalid version")
)

Functions

func GetMID

func GetMID() uint16

GetMID generates a message id for UDP-coap

func RandMID added in v2.5.0

func RandMID() uint16

Types

type Message

type Message struct {
	Token   message.Token
	Payload []byte

	Options message.Options //Options must be sorted by ID
	Code    codes.Code

	MessageID uint16
	Type      Type
}

TcpMessage is a CoAP MessageBase that can encode itself for Message transport.

func (Message) Marshal

func (m Message) Marshal() ([]byte, error)

func (Message) MarshalTo

func (m Message) MarshalTo(buf []byte) (int, error)

func (Message) Size

func (m Message) Size() (int, error)

func (*Message) Unmarshal

func (m *Message) Unmarshal(data []byte) (int, error)

type Type

type Type uint8

Type represents the message type. It's only part of CoAP UDP messages. Reliable transports like TCP do not have a type.

const (
	// Confirmable messages require acknowledgements.
	Confirmable Type = 0
	// NonConfirmable messages do not require acknowledgements.
	NonConfirmable Type = 1
	// Acknowledgement is a message indicating a response to confirmable message.
	Acknowledgement Type = 2
	// Reset indicates a permanent negative acknowledgement.
	Reset Type = 3
)

func (Type) String

func (t Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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