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: early token generation #668

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

Commits on Nov 5, 2024

  1. zephyr_coap_req: remove unimplemented golioth_coap_req_sync()

    Remove prototype for function that is never defined.
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    e792791 View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2024

  1. coap_client: define coap token length

    Use a compile-time constant for the length of the CoAP token (in bytes).
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 7, 2024
    Configuration menu
    Copy the full SHA
    a958861 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2024

  1. coap_client: add CoAP token generator golioth_coap_next_token()

    Add golioth_coap_next_token() to randomly generate the first token and
    increment a stored value for all future tokens.
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    5c6eb02 View commit details
    Browse the repository at this point in the history
  2. coap_client: add token generation to coap get requests

    Squash before merging
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    06e97cf View commit details
    Browse the repository at this point in the history
  3. coap get: update get calls to assign coap token

    Squash before merging
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    fbc75f0 View commit details
    Browse the repository at this point in the history
  4. coap_get_block: update blockwise download to assign coap tokens

    Squash before merge
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    9586e08 View commit details
    Browse the repository at this point in the history
  5. coap_client: add token generation to coap set requests

    Squash before merging
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    cd3b9de View commit details
    Browse the repository at this point in the history
  6. coap set: update set calls to assign coap token

    TODO: unit tests for RPC
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    1933111 View commit details
    Browse the repository at this point in the history
  7. coap_set_block: update blockwise upload to assign coap tokens

    Squash before merge
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    4d81dcf View commit details
    Browse the repository at this point in the history
  8. coap: observe/rpc: create token when making request

    Squash before merge.
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    3f29df2 View commit details
    Browse the repository at this point in the history
  9. coap: unit tests: add token param to fakes

    Squash before merge
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    fecfbbc View commit details
    Browse the repository at this point in the history
  10. coap: zephyr: use token param when creating CoAP requests

    Squah before merging
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    51e22b0 View commit details
    Browse the repository at this point in the history
  11. coap: zephyr: remove token overwrite for blockwise operations

    Tokens are now generated by the calling function. The same token will
    automatically be used for each subsequent block because of the
    blockwise_transfer context struct.
    
    The workaround that overwrite the initial token for these requests is no
    longer necessary and has been removed.
    
    Squash before merging
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    bf5671d View commit details
    Browse the repository at this point in the history
  12. coap: libcoap: use request_msg token and remove block_token

    Directly use the token stored in the request message instead of creating a
    new one. Remove the block_token storage from the client struct.
    
    Squash before merging
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    5cc43f1 View commit details
    Browse the repository at this point in the history
  13. coap: libcoap: remove srand call and add comments about CoAP tokens

    CoAP tokens are now generated by the Golioth SDK outside of the libcoap
    library. The call to golioth_sys_srand() in the libcoap client is no longer
    crucial as it will be called by Golioth's token generation function.
    
    However, the random seed initialization for libcoap's token generation
    should still be called just to ensure token generation is ready in the rare
    (and currently unanticipated) case where libcoap internally fetches a new
    token. One place that this is likely to occur is when libcoap uses etags.
    We are not currently using etags in our implementation.
    
    Use dynamically allocated memory to seed the token. This value will be
    stored in the libcoap coap_session_t struct and the seed array will no
    longer be needed.
    
    Note, both Golioth and libcoap token generation uses a simple increment
    after generating the initial random token. Avoid collision by getting a
    token from Golioth and incrementing it by half its max value before seeding
    libcoap.
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    8f8d7b1 View commit details
    Browse the repository at this point in the history
  14. coap: remove token_len from golioth_coap_request_msg struct

    This value is now available as a compile-time constant.
    
    Squash before merge
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    b7af162 View commit details
    Browse the repository at this point in the history
  15. coap: observations: remove token_len and normalize param order

    Remove the token_len parameter as the compile-time define is now used
    throughout the SDK.
    
    Change the appearance and type of the token param to match what is used
    with other functions that create coap requests.
    
    Signed-off-by: Mike Szczys <[email protected]>
    szczys committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    78973cc View commit details
    Browse the repository at this point in the history