wirepas / wm-sdk

SDK to develop applications on the MCU running Wirepas Stack
Other
44 stars 33 forks source link

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

Open E-Heerschap opened 1 year ago

E-Heerschap commented 1 year ago

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).