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

fix: send_ack_packet no longer causes unexpected behaviour if shared data lib fails to send #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

E-Heerschap
Copy link

Hi,

This is a pull request to fix a bug contained in the provisioning library which can cause the provisioning library to exit early and enter an invalid state.

Bug

When a failure occurs while sending an ack packet to the provisioning server using the shared data library the failure is handled by returning APP_SCHEDULER_SCHEDULE_ASAP. This causes the state machine to exit early and the library to be "stuck" in the state. Consequently, the initiator's end of provisioning callback is never called so it may stall the behaviour of their system awaiting this call.

Furthermore, the code explicitly states in a comment that the ACK is optional and in the event of a failure the provisioning process should move to the next state; which it does not in this case.

Proposed fix

The fix proposed in this pull request instead handles this as an "immediate timeout". This causes a timeout event to occur and the system to proceed as usual.

An alternative fix could be to explicitly set m_events.timeout = 1 instead of starting the timeout task (which does this).

behaviour if the Shared_Data_sendData function fails.
Copy link
Contributor

@GwendalRaoul GwendalRaoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your Pull Request.

If you are fine with my comment, I'll make the change in our internal repo and it will be part of our next release.

@@ -228,23 +228,25 @@ static uint32_t send_ack_packet(void)
res = Shared_Data_sendData(&data_to_send, packet_sent_cb);
if (res != APP_LIB_DATA_SEND_RES_SUCCESS)
{
LOG(LVL_WARNING, "State WAIT_DATA : Error sending ACK (res:%d).", res);
return APP_SCHEDULER_SCHEDULE_ASAP;
LOG(LVL_WARNING, "State WAIT_DATA : Error sending ACK (res:%u).", res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think setting "m_events.timeout = 1;" here instead would be cleaner.
It should have exactly same behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants