mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
net/nanocoap: add block slicer init function
This commit is contained in:
parent
a6f919ef3e
commit
64b4e0ad2d
@ -610,6 +610,18 @@ static inline void coap_block2_finish(coap_block_slicer_t *slicer)
|
||||
*/
|
||||
void coap_block2_init(coap_pkt_t *pkt, coap_block_slicer_t *slicer);
|
||||
|
||||
/**
|
||||
* @brief Initialize a block slicer struct from content information
|
||||
*
|
||||
* @param[out] slicer slicer struct to initialize
|
||||
* @param[in] blknum offset from the beginning of content, in terms of
|
||||
@p blksize byte blocks
|
||||
* @param[in] blksize size of each block; must be a power of 2 between 16
|
||||
* and 2 raised to #NANOCOAP_BLOCK_SIZE_EXP_MAX
|
||||
*/
|
||||
void coap_block_slicer_init(coap_block_slicer_t *slicer, size_t blknum,
|
||||
size_t blksize);
|
||||
|
||||
/**
|
||||
* @brief Add a byte array to a block2 reply.
|
||||
*
|
||||
|
@ -883,6 +883,14 @@ void coap_block_object_init(coap_block1_t *block, size_t blknum, size_t blksize,
|
||||
block->more = more;
|
||||
}
|
||||
|
||||
void coap_block_slicer_init(coap_block_slicer_t *slicer, size_t blknum,
|
||||
size_t blksize)
|
||||
{
|
||||
slicer->start = blknum * blksize;
|
||||
slicer->end = slicer->start + blksize;
|
||||
slicer->cur = 0;
|
||||
}
|
||||
|
||||
void coap_block2_init(coap_pkt_t *pkt, coap_block_slicer_t *slicer)
|
||||
{
|
||||
uint32_t blknum;
|
||||
@ -896,9 +904,8 @@ void coap_block2_init(coap_pkt_t *pkt, coap_block_slicer_t *slicer)
|
||||
szx = NANOCOAP_BLOCK_SIZE_EXP_MAX - 4;
|
||||
}
|
||||
}
|
||||
slicer->start = blknum * coap_szx2size(szx);
|
||||
slicer->end = slicer->start + coap_szx2size(szx);
|
||||
slicer->cur = 0;
|
||||
|
||||
coap_block_slicer_init(slicer, blknum, coap_szx2size(szx));
|
||||
}
|
||||
|
||||
void coap_block_finish(coap_block_slicer_t *slicer, uint16_t option)
|
||||
|
Loading…
Reference in New Issue
Block a user