Documentation ¶
Index ¶
- Variables
- func EncodeBlockOption(szx SZX, blockNumber int64, moreBlocksFollowing bool) (uint32, error)
- func NewWriteRequestResponse(request Message, acquireMessage func(context.Context) Message, ...) *writeMessageResponse
- type BlockWise
- func (b *BlockWise) Do(r Message, maxSzx SZX, maxMessageSize int, ...) (Message, error)
- func (b *BlockWise) Handle(w ResponseWriter, r Message, maxSZX SZX, maxMessageSize int, ...)
- func (b *BlockWise) RemoveFromResponseCache(token message.Token)
- func (b *BlockWise) WriteMessage(request Message, maxSZX SZX, maxMessageSize int, ...) error
- type Message
- type ResponseWriter
- type SZX
Constants ¶
This section is empty.
Variables ¶
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") // ErrInvalidReponseCode response code has invalid value ErrInvalidReponseCode = 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 ¶
func EncodeBlockOption ¶
EncodeBlockOption encodes block values to coap option.
Types ¶
type BlockWise ¶
type BlockWise struct {
// contains filtered or unexported fields
}
func NewBlockWise ¶
func NewBlockWise( acquireMessage func(ctx context.Context) Message, releaseMessage func(Message), expiration time.Duration, errors func(error), autoCleanUpResponseCache bool, getSendedRequestFromOutside func(token message.Token) (Message, bool), ) *BlockWise
NewBlockWise provides blockwise. getSendedRequestFromOutside must returns a copy of request which will be released by function releaseMessage after use.
func (*BlockWise) Do ¶
func (b *BlockWise) Do(r Message, maxSzx SZX, maxMessageSize int, do func(req Message) (Message, error)) (Message, error)
Do sends an coap message and returns an coap response via blockwise transfer.
func (*BlockWise) Handle ¶
func (b *BlockWise) Handle(w ResponseWriter, r Message, maxSZX SZX, maxMessageSize int, next func(w ResponseWriter, r Message))
Handle middleware which constructs COAP request from blockwise transfer and send COAP response via blockwise.
func (*BlockWise) RemoveFromResponseCache ¶
RemoveFromResponseCache removes response from cache. It need's tu be used for udp coap.
type Message ¶
type Message interface { // getters Context() context.Context Code() codes.Code Token() message.Token GetOptionUint32(id message.OptionID) (uint32, error) GetOptionBytes(id message.OptionID) ([]byte, error) Options() message.Options Body() io.ReadSeeker BodySize() (int64, error) Sequence() uint64 // setters SetCode(codes.Code) SetToken(message.Token) SetOptionUint32(id message.OptionID, value uint32) Remove(id message.OptionID) ResetOptionsTo(message.Options) SetBody(r io.ReadSeeker) SetSequence(uint64) String() string }
Message defines message interface for blockwise transfer.
type ResponseWriter ¶
ResponseWriter defines response interface for blockwise transfer.
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 )