-
Notifications
You must be signed in to change notification settings - Fork 317
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
nrf_rpc: two-way handshake and NOWAIT group type #1335
Conversation
cc1588c
to
31f79ef
Compare
31f79ef
to
2e6aa11
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.
Have some comments, mostly to improve comments, but I like the idea overall :)
2e6aa11
to
4e84aa2
Compare
if (waiting_group_count > 0) { | ||
err = nrf_rpc_os_event_wait(&groups_init_event, CONFIG_NRF_RPC_GROUP_INIT_WAIT_TIME); | ||
if (err) { | ||
NRF_RPC_ERR("Not all groups are ready to use."); | ||
} | ||
} | ||
|
||
return err; |
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.
In case waiting_group_count
is zero, the err
value from either transport->api->init()
, nrf_rpc_os_event_init()
or group_init_send()
(in the last round of the for-loop) will be returned.
Should err
be zeroed before the waiting_group_count > 0
conditional?
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.
Yes, I think so. Thanks for catching it.
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.
Fixed
4e84aa2
to
e577715
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.
Approved with minor suggestions.
nrf_rpc/nrf_rpc.c
Outdated
bound_handler(*group); | ||
} | ||
|
||
if (first_init && wait_on_init && ++initialized_group_count == waiting_group_count) { |
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.
Do not use ++x
operator inside "if" expression (it should not have side-effects).
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.
Removed the side effect from if
.
nrf_rpc/nrf_rpc.c
Outdated
group_data = (*group)->data; | ||
first_init = group_data->dst_group_id == NRF_RPC_ID_UNKNOWN; | ||
group_data->dst_group_id = hdr->src_group_id; | ||
bool wait_on_init = (*group)->wait_on_init; |
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.
Local variable declarations should be at the beginning.
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.
Moved the declaration to the beginning.
e577715
to
216842a
Compare
I have applied @Damian-Nordic suggestion in a separate commit. Let me know if you prefer groups to have single |
5d9dc1f
to
00de5c9
Compare
00de5c9
to
aa9b85b
Compare
* to reset the local state. | ||
* @param _initiator The group is the initiator. | ||
*/ | ||
#define NRF_RPC_GROUP_DEFINE_NOWAIT(_name, _strid, _transport, _ack_handler, \ |
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.
This macro looks almost the same like NRF_RPC_GROUP_DEFINE You can consider simplification by creating, local macro and use it under these two. For example NRF_RPC_GROUP_DEFINE_INTERNAL__()
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.
Not sure, then the user could use the internal macro to create a group that is neither NOWAIT
or normal. Do we want to encourage that?
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.
I mean to keep both macros and use internal macro under them to avoid duplication in macro body
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.
I think when user use something which has internal in name then he does it on his own responsibility
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.
Done as suggested.
84b8597
to
47293c1
Compare
@peknis applied your suggestions. |
3ff8922
to
3c477d9
Compare
Implement two-way handshake nRF RPC initialization: When an initialization packet with the unknown destination group ID is received, reply to that with an initialization packet with the right destination group ID. This makes it possible to re-establish the link even if either peer has rebooted, or has booted with a delay. Also, allow to configure infinite group init timeout. Signed-off-by: Damian Krolik <[email protected]>
The NOWAIT group type does not block nrf_rpc_init until binding completion. The user can define regular and NOINIT groups simultaneously, but nrf_rpc_init will only wait for regular groups to complete the binding. The NOINIT group can be assigned a callback, which notifies that the group binding has been completed. If a remote peer resets and binds again, the callback will be executed again. When `initiator` flag is set, the nrf_rpc will initiate group binding when nrf_rpc_init is called. There must be at least one initiator on either side of the IPC channel. Both peers can be the initiator at the same time. Signed-off-by: Rafał Kuźnia <[email protected]>
3c477d9
to
0924311
Compare
This PR consists of two commits:
See descriptions for more details.