Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coap: zephyr: implement server-negotiated block size during block upload #570

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Commits on Sep 16, 2024

  1. coap_client: add SZX_TO_BLOCKSIZE

    Add SZX_TO_BLOCKSIZE macro to convert from coap enum value to bytes
    
    Signed-off-by: Mike Szczys <mike@golioth.io>
    szczys committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    d4fd45a View commit details
    Browse the repository at this point in the history
  2. coap: zephyr: remove duplicate BLOCKSIZE_TO_SZX

    Remove macro that is more broadly available from coap_client.h
    
    Signed-off-by: Mike Szczys <mike@golioth.io>
    szczys committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    a9f5cff View commit details
    Browse the repository at this point in the history
  3. coap_blockwise: add negotiated_size_szx to post_block_ctx

    When performing blockwise upload, the server may negotiate a smaller
    block size than the device begins with.
    
    - Add a struct member to track this using post_block_ctx which is
      accessible both in the block upload functions as well as the coap thread
      functions. Use the _szx suffice to indicate coap block size enum value
      (as opposed to bytes).
    - When the server requests a smaller size, update the blockwise_transfer
      context so the value is used on subsequent blocks.
    - When the block_size is updated to a smaller value, the number of the next
      block needs to be recalculated because the previous transfer actually
      included more than one block of the newly negotiated size.
    
    Signed-off-by: Mike Szczys <mike@golioth.io>
    szczys committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    ab3fc72 View commit details
    Browse the repository at this point in the history
  4. coap: zephyr: update block upload size based on server response

    When the server responds to a block upload request with a smaller
    block size, store the value to inform the negotiated block size.
    
    Signed-off-by: Mike Szczys <mike@golioth.io>
    szczys committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    0392ee6 View commit details
    Browse the repository at this point in the history
  5. coap: zephyr: use negotiated block size when adding block1

    Use the negotiated block size when initializing the block1 option of the
    coap packet.
    
    This moves the use of the compiled-in
    CONFIG_GOLIOTH_BLOCKWISE_UPLOAD_MAX_BLOCK_SIZE value to the
    initialization step of the negotiated value, and allows for the negotiated
    value to be updated based on the server preference, then used for all
    subsequent coap requests in the block upload process.
    
    The Kconfig value was previously masked by a bitwise operation. This should
    not be necessary as that symbol was updated to a 'choice' in Kconfig so we
    can be confident that the value is valid coap size or it would have
    triggered a static assert.
    
    Signed-off-by: Mike Szczys <mike@golioth.io>
    szczys committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    86adf2d View commit details
    Browse the repository at this point in the history