Harden HID, Wi-Fi, and web server handling
This commit is contained in:
@@ -47,6 +47,7 @@ CONFIG_DESCRIPTOR = bytes((
|
||||
STRINGS = [None, "PolterHID", "Awareness trainer", "PHID-001"]
|
||||
_GET_DESCRIPTOR = 0x06
|
||||
_DESCRIPTOR_TYPE_REPORT = 0x22
|
||||
_MAX_PENDING_REPORTS = 8
|
||||
_INSTANCE = None
|
||||
|
||||
|
||||
@@ -117,6 +118,16 @@ class HID:
|
||||
self._busy = False
|
||||
|
||||
def _send(self, report):
|
||||
if not self._ready:
|
||||
return
|
||||
report_id = report[0]
|
||||
for index, pending in enumerate(self._pending):
|
||||
if pending[0] == report_id:
|
||||
self._pending[index] = report
|
||||
self._flush()
|
||||
return
|
||||
if len(self._pending) >= _MAX_PENDING_REPORTS:
|
||||
self._pending.pop(0)
|
||||
self._pending.append(report)
|
||||
self._flush()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user