Skip to content

Packets that are received out of order may be ignored #3

Description

@dachboden-berlin

Example:
ESP sends ButtonPressed (inq: 1)
ESP sends ButtonReleased (inq: 2)

Packets are received out of order due to network conditions

Current behavior:

  1. ButtonReleased packet is received, and ignored because button state is already unpressed
  2. ButtonPressed packet is received and tossed out because inq 1 < 2
  3. No Button Press event was handled!

Expected behavior:
Button press event is handled despite arriving out of order

Possible Fix:

  • When ButtonReleased packet is received (while button state is unpressed), quickly fire ButtonPressed and ButtonReleased events.
  • Example fix for Button class:
def release(self) -> None:
    if not self._state:
        self._fire_event("ButtonPressed", False)  # new addition
        self._fire_event("ButtonReleased", False)  # new addition
        return
    self._state = False
    self._fire_event("ButtonReleased", False)

Further TODO:
add pytest.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions