Documentation
¶
Index ¶
- Variables
- func EncodeBlockOption(szx SZX, blockNumber int64, moreBlocksFollowing bool) (uint32, error)
- type BlockWise
- func (b *BlockWise[C]) CheckExpirations(now time.Time)
- func (b *BlockWise[C]) Do(r *pool.Message, maxSzx SZX, maxMessageSize uint32, ...) (*pool.Message, error)
- func (b *BlockWise[C]) Handle(w *responsewriter.ResponseWriter[C], r *pool.Message, maxSZX SZX, ...)
- func (b *BlockWise[C]) WriteMessage(request *pool.Message, maxSZX SZX, maxMessageSize uint32, ...) error
- type Client
- type SZX
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBlockNumberExceedLimit block number exceeded the limit 1,048,576 ErrBlockNumberExceedLimit = errors.New("block number exceeded the limit 1,048,576") // ErrBlockInvalidSize block has invalid size ErrBlockInvalidSize = errors.New("block has invalid size") // ErrInvalidOptionBlock2 message has invalid value of Block2 ErrInvalidOptionBlock2 = errors.New("message has invalid value of Block2") // ErrInvalidOptionBlock1 message has invalid value of Block1 ErrInvalidOptionBlock1 = errors.New("message has invalid value of Block1") // ErrInvalidResponseCode response code has invalid value ErrInvalidResponseCode = errors.New("response code has invalid value") // ErrInvalidPayloadSize invalid payload size ErrInvalidPayloadSize = errors.New("invalid payload size") // ErrInvalidSZX invalid block-wise transfer szx ErrInvalidSZX = errors.New("invalid block-wise transfer szx") )
Functions ¶
Types ¶
type BlockWise ¶
type BlockWise[C Client] struct { // contains filtered or unexported fields }
func New ¶
func New[C Client]( cc C, expiration time.Duration, errors func(error), getSentRequestFromOutside func(token message.Token) (*pool.Message, bool), ) *BlockWise[C]
New provides blockwise. getSentRequestFromOutside must returns a copy of request which will be released after use.
func (*BlockWise[C]) CheckExpirations ¶
CheckExpirations iterates over caches and remove expired items.
func (*BlockWise[C]) Do ¶
func (b *BlockWise[C]) Do(r *pool.Message, maxSzx SZX, maxMessageSize uint32, do func(req *pool.Message) (*pool.Message, error)) (*pool.Message, error)
Do sends an coap message and returns an coap response via blockwise transfer.
func (*BlockWise[C]) Handle ¶
func (b *BlockWise[C]) Handle(w *responsewriter.ResponseWriter[C], r *pool.Message, maxSZX SZX, maxMessageSize uint32, next func(w *responsewriter.ResponseWriter[C], r *pool.Message))
Handle middleware which constructs COAP request from blockwise transfer and send COAP response via blockwise.
type SZX ¶
type SZX uint8
SZX enum representation for the size of the block: https://tools.ietf.org/html/rfc7959#section-2.2
const ( // SZX16 block of size 16bytes SZX16 SZX = 0 // SZX32 block of size 32bytes SZX32 SZX = 1 // SZX64 block of size 64bytes SZX64 SZX = 2 // SZX128 block of size 128bytes SZX128 SZX = 3 // SZX256 block of size 256bytes SZX256 SZX = 4 // SZX512 block of size 512bytes SZX512 SZX = 5 // SZX1024 block of size 1024bytes SZX1024 SZX = 6 // SZXBERT block of size n*1024bytes SZXBERT SZX = 7 )
Click to show internal directories.
Click to hide internal directories.