message

package
v2.3.0-on-1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MESSAGE_LEN13_BASE = 13
	MESSAGE_LEN14_BASE = 269
	MESSAGE_LEN15_BASE = 65805
	MESSAGE_MAX_LEN    = 0x7fff0000 // Large number that works in 32-bit builds.
)

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

Types

type Message

type Message struct {
	Code codes.Code

	Token   message.Token
	Payload []byte

	MessageID uint16
	Type      Type

	Options message.Options //Options must be sorted by ID
}

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