-
Notifications
You must be signed in to change notification settings - Fork 2k
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
gcoap/fileserver: add event callbacks #18414
Conversation
Just to get the architectural review side out -- making sure more generally useful alternatives have been considered:
On use cases, note that CoAP GET is supposed to be side effect free; now we don't, can't and won't generally enforce this in RIOT, but reacting to a GET event in any other facility than logging (at which point I'd go back whether this might not be just for logging generic CoAP requests or file system access) sounds like an invitation to do side effects, and might need a warning. |
My use case is: I have multiple sensors that I want to update, since communication happens over a bus I want to update one sensor at a time to avoid contention. (The sensor network might also only be turned on for the updates when it's otherwise in an OFF state. So I want to know when all sensors have received the update to return to the original state again) Updates are sometimes unreliable, especially with the old firmware revision. So I want to know: Was the manifest accepted ( You are right that it would probably be better to use a second channel to communicate those events (e.g. the sensors would send them explicitly). But that won't help with sensors already deployed that don't send those yet to be implemented status messages - so server side events were an easy solution to this problem. If more context information is required for other use cases, |
The first thing I asked myself, was whether |
I realized that I want to unsubscribe from those events, so I'll go with the mutex. |
c33c486
to
b6e0372
Compare
b6e0372
to
75ccf8c
Compare
b2c53a9
to
fd87b0f
Compare
fd87b0f
to
f917d85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well with files.
2022-11-13 11:36:44,921 # gcoap fileserver: Upload started: /nvm0/send/ta/ca_anchor.der
2022-11-13 11:36:50,935 # gcoap fileserver: Upload finished: /nvm0/send/ta/ca_anchor.der
2022-11-13 11:36:50,977 # gcoap fileserver: Upload started: /nvm0/send/cp/self.der
2022-11-13 11:36:56,006 # gcoap fileserver: Upload finished: /nvm0/send/cp/self.der
2022-11-13 11:36:56,064 # gcoap fileserver: Upload started: /nvm0/send/key/pubkey.der
2022-11-13 11:36:57,292 # gcoap fileserver: Upload finished: /nvm0/send/key/pubkey.der
2022-11-13 11:36:57,348 # gcoap fileserver: Upload started: /nvm0/send/key/key.der
2022-11-13 11:36:58,986 # gcoap fileserver: Upload finished: /nvm0/send/key/key.der
2022-11-13 11:56:30,376 # gcoap fileserver: Download started: /nvm0/send/key/key.der
2022-11-13 11:56:30,476 # gcoap fileserver: Download finished: /nvm0/send/key/key.der
2022-11-13 11:57:14,149 # gcoap fileserver: Delete /nvm0/send/key/key.der
2022-11-13 11:59:07,298 # gcoap fileserver: Upload started: /nvm0/send/ta/ca_anchor.der
2022-11-13 11:59:13,227 # gcoap fileserver: Upload finished: /nvm0/send/ta/ca_anchor.der
2022-11-13 11:59:13,271 # gcoap fileserver: Upload started: /nvm0/send/cp/self.der
2022-11-13 11:59:18,292 # gcoap fileserver: Upload finished: /nvm0/send/cp/self.der
2022-11-13 11:59:18,348 # gcoap fileserver: Upload started: /nvm0/send/key/pubkey.der
2022-11-13 11:59:19,186 # gcoap fileserver: Upload finished: /nvm0/send/key/pubkey.der
2022-11-13 11:59:19,238 # gcoap fileserver: Upload started: /nvm0/send/key/.key.der
2022-11-13 11:59:20,934 # gcoap fileserver: Upload finished: /nvm0/send/key/.key.der
Someone might be wondering why it is only implemented for files?
I didn't see the need for it yet - should I add it anyway? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no need for directory callbacks right now, I´d say keep it like that.
To reflect that and for extensibility, you could maybe rename some fields, if you agree.
And maybe adapt some comments here and there.
The |
This could be implemented on top, but I'd like to avoid IPC if not necessary. |
Ok please squash. |
292edce
to
65a8b71
Compare
bors merge |
Build succeeded: |
Thank you for the review! |
Contribution description
When serving updates via GCoAP fileserver it turned out to be useful to know if a node started downloading the update and when it finished doing so.
But there are probably more use cases where some action might be taken or logged based on the events on the GCoAP fileserver.
This adds 5 event types:
GCOAP_FILESERVER_GET_START
: file download started (block 0 requested)GCOAP_FILESERVER_GET_END
: file download finished (last block requested)GCOAP_FILESERVER_PUT_START
:file upload started (block 0 uploaded)GCOAP_FILESERVER_PUT_END
: file upload finished (last block uploaded)GCOAP_FILESERVER_DELETE
:file deletion requestedTesting procedure
To be a able to test this, the new callback module is enabled for
examples/gcoap_fileserver
to log file events:Issues/PRs references