-
Notifications
You must be signed in to change notification settings - Fork 6
WIP: Add libcoap CoapUdpIpChannel
#289
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
Draft
LasseRosenow
wants to merge
24
commits into
main
Choose a base branch
from
libcoap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3056e8f
Add libcoap submodule
LasseRosenow 919c64b
Remove libcoap and use it as system library
LasseRosenow be18494
Compiles
LasseRosenow 70714c2
Add response handler => it works!
LasseRosenow 9a53187
Add working server
LasseRosenow f3c182e
WIP tests are failing :(
LasseRosenow 595c28e
Fix coap address compare port
LasseRosenow fdf705b
Tests work now, but it is a bit slow maybe?
LasseRosenow 8647c38
Cleanup useless boolean thanks to condition variables
LasseRosenow ce7154c
Migrate address parsing to use libcoap api
LasseRosenow 4af3ade
remote_address => remote_host and document coap channel constructors
LasseRosenow 50e27f1
Cleanup server initialization code
LasseRosenow 9c9fefe
Correctly set receive thread stack size
LasseRosenow 3d26961
Fix stack size and use buf size define as well
LasseRosenow ee7e10b
Add comments
LasseRosenow 7db6c86
Remove redundant remote_address field
LasseRosenow 58f3000
Remove redundant coap_context field for each channel
LasseRosenow 14d844c
Cleanup more
LasseRosenow 5564c6d
Fix send_blocking mutex
LasseRosenow c7b82b8
Remove useless define semicolon
LasseRosenow be6fcff
Document channel by session logic a little bit
LasseRosenow dec99bf
Remove old files
LasseRosenow 264735a
WIP: Add full coap integration test with full reactor_uc runtime.
LasseRosenow efcccee
Small cleanup
LasseRosenow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #ifndef REACTOR_UC_COAP_UDP_IP_CHANNEL_H | ||
| #define REACTOR_UC_COAP_UDP_IP_CHANNEL_H | ||
| #include "reactor-uc/network_channel.h" | ||
| #include "reactor-uc/environment.h" | ||
| #include <pthread.h> | ||
| #include <coap3/coap.h> | ||
|
|
||
| #define COAP_UDP_IP_CHANNEL_EXPECTED_CONNECT_DURATION MSEC(10); | ||
| #define COAP_UDP_IP_CHANNEL_BUFFERSIZE 1024 | ||
| #define COAP_UDP_IP_CHANNEL_RECV_THREAD_STACK_SIZE 2048 | ||
|
|
||
| typedef struct CoapUdpIpChannel CoapUdpIpChannel; | ||
| typedef struct FederatedConnectionBundle FederatedConnectionBundle; | ||
|
|
||
| typedef enum { | ||
| COAP_REQUEST_TYPE_NONE, | ||
| COAP_REQUEST_TYPE_CONNECT, | ||
| COAP_REQUEST_TYPE_MESSAGE, | ||
| COAP_REQUEST_TYPE_DISCONNECT | ||
| } coap_request_type_t; | ||
|
|
||
| typedef struct CoapUdpIpChannel { | ||
| NetworkChannel super; | ||
|
|
||
| // Remote address etc. | ||
| coap_session_t *session; | ||
|
|
||
| // Threading and synchronization | ||
| pthread_mutex_t state_mutex; | ||
| pthread_cond_t state_cond; | ||
| pthread_mutex_t send_mutex; | ||
| pthread_cond_t send_cond; | ||
|
|
||
| NetworkChannelState state; | ||
|
|
||
| FederateMessage output; | ||
|
|
||
| // Handle message callbacks | ||
| coap_request_type_t last_request_type; | ||
| coap_mid_t last_request_mid; | ||
|
|
||
| FederatedConnectionBundle *federated_connection; | ||
| void (*receive_callback)(FederatedConnectionBundle *conn, const FederateMessage *message); | ||
| } CoapUdpIpChannel; | ||
|
|
||
| /** | ||
| * @brief Constructor for the CoapUdpIpChannel. | ||
| * | ||
| * Initializes a CoapUdpIpChannel instance with the specified remote host and protocol family. | ||
| * | ||
| * @param self Pointer to the CoapUdpIpChannel instance. | ||
| * @param remote_host The remote host address, hostname or domain E.g. 127.0.0.1, [::1] or hostname.local. | ||
| * @param remote_protocol_family The protocol family (e.g., AF_INET for IPv4 and AF_INET6 for IPv6). | ||
| */ | ||
| void CoapUdpIpChannel_ctor(CoapUdpIpChannel *self, const char *remote_host, int remote_protocol_family); | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.