sensor-sdk 0.0.46__tar.gz → 0.0.48__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sensor_sdk-0.0.46/sensor_sdk.egg-info → sensor_sdk-0.0.48}/PKG-INFO +1 -1
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/bleak_process.py +23 -11
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/gforce.py +3 -3
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48/sensor_sdk.egg-info}/PKG-INFO +1 -1
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/setup.py +1 -1
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/LICENSE.txt +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/README.md +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/__init__.py +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/bleak_host.py +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/sensor_controller.py +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/sensor_data.py +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/sensor_data_context.py +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/sensor_device.py +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/sensor_profile.py +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor/sensor_utils.py +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor_sdk.egg-info/SOURCES.txt +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor_sdk.egg-info/dependency_links.txt +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor_sdk.egg-info/requires.txt +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor_sdk.egg-info/top_level.txt +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/sensor_sdk.egg-info/zip-safe +0 -0
- {sensor_sdk-0.0.46 → sensor_sdk-0.0.48}/setup.cfg +0 -0
|
@@ -163,10 +163,16 @@ class BleakProcess(multiprocessing.Process):
|
|
|
163
163
|
self._gforce_event_thread.start()
|
|
164
164
|
return self._gforce_event_loop
|
|
165
165
|
|
|
166
|
-
def
|
|
167
|
-
|
|
166
|
+
def _ensure_device_loops(self, device_mac: str):
|
|
168
167
|
from sensor import sensor_utils
|
|
169
168
|
|
|
169
|
+
event_loop = self._event_loops.get(device_mac)
|
|
170
|
+
data_event_loop = self._data_event_loops.get(device_mac)
|
|
171
|
+
if (event_loop is not None and not event_loop.is_closed() and
|
|
172
|
+
data_event_loop is not None and not data_event_loop.is_closed()):
|
|
173
|
+
self._cleanup_locks.setdefault(device_mac, asyncio.Lock())
|
|
174
|
+
return
|
|
175
|
+
|
|
170
176
|
event_loop = asyncio.new_event_loop()
|
|
171
177
|
event_thread = threading.Thread(target=sensor_utils.start_loop, args=(event_loop,))
|
|
172
178
|
event_thread.daemon = True
|
|
@@ -408,6 +414,9 @@ class BleakProcess(multiprocessing.Process):
|
|
|
408
414
|
if SERVICE_GUID in adv.service_uuids:
|
|
409
415
|
serialized = _serialize_device(device, adv)
|
|
410
416
|
if serialized is not None:
|
|
417
|
+
mac = serialized.get("mac")
|
|
418
|
+
if mac:
|
|
419
|
+
self._devices[mac] = device
|
|
411
420
|
devices.append(serialized)
|
|
412
421
|
return devices
|
|
413
422
|
|
|
@@ -428,14 +437,13 @@ class BleakProcess(multiprocessing.Process):
|
|
|
428
437
|
)
|
|
429
438
|
return
|
|
430
439
|
|
|
431
|
-
self.
|
|
440
|
+
self._ensure_device_loops(device_mac)
|
|
432
441
|
gforce_loop = self._ensure_gforce_loop()
|
|
433
442
|
|
|
434
443
|
future = asyncio.run_coroutine_threadsafe(self._do_connect_inner(cmd), gforce_loop)
|
|
435
444
|
try:
|
|
436
445
|
await asyncio.wait_for(asyncio.wrap_future(future), timeout=25)
|
|
437
446
|
except asyncio.TimeoutError:
|
|
438
|
-
self._stop_device_loops(device_mac)
|
|
439
447
|
self._publish(
|
|
440
448
|
"command_result",
|
|
441
449
|
cmd_id=cmd.get("cmd_id"),
|
|
@@ -444,7 +452,6 @@ class BleakProcess(multiprocessing.Process):
|
|
|
444
452
|
result="Connect timeout",
|
|
445
453
|
)
|
|
446
454
|
except Exception as e:
|
|
447
|
-
self._stop_device_loops(device_mac)
|
|
448
455
|
self._publish(
|
|
449
456
|
"command_result",
|
|
450
457
|
cmd_id=cmd.get("cmd_id"),
|
|
@@ -496,8 +503,17 @@ class BleakProcess(multiprocessing.Process):
|
|
|
496
503
|
)
|
|
497
504
|
return
|
|
498
505
|
|
|
499
|
-
#
|
|
500
|
-
bleak_device =
|
|
506
|
+
# Read bleak BLEDevice from scanned devices
|
|
507
|
+
bleak_device = self._devices.get(device_mac)
|
|
508
|
+
if bleak_device is None:
|
|
509
|
+
self._publish(
|
|
510
|
+
"command_result",
|
|
511
|
+
cmd_id=cmd.get("cmd_id"),
|
|
512
|
+
device_mac=device_mac,
|
|
513
|
+
success=False,
|
|
514
|
+
result="Device not found in scanned devices",
|
|
515
|
+
)
|
|
516
|
+
return
|
|
501
517
|
|
|
502
518
|
# Create raw data buffer (local to sub-process)
|
|
503
519
|
raw_buf = queue.Queue(maxsize=sensor_utils.BLEAK_RESULT_QUEUE_MAXSIZE)
|
|
@@ -541,7 +557,6 @@ class BleakProcess(multiprocessing.Process):
|
|
|
541
557
|
return
|
|
542
558
|
|
|
543
559
|
# Store state
|
|
544
|
-
self._devices[device_mac] = bleak_device
|
|
545
560
|
self._gforces[device_mac] = gforce
|
|
546
561
|
self._raw_bufs[device_mac] = raw_buf
|
|
547
562
|
self._device_states[device_mac] = "Connected"
|
|
@@ -612,11 +627,8 @@ class BleakProcess(multiprocessing.Process):
|
|
|
612
627
|
# Pop state
|
|
613
628
|
self._gforces.pop(device_mac, None)
|
|
614
629
|
self._raw_bufs.pop(device_mac, None)
|
|
615
|
-
self._devices.pop(device_mac, None)
|
|
616
630
|
self._device_states[device_mac] = "Disconnected"
|
|
617
631
|
|
|
618
|
-
# Stop event loops outside the lock to avoid deadlocks
|
|
619
|
-
self._stop_device_loops(device_mac)
|
|
620
632
|
self._publish("state_changed", device_mac=device_mac, state="Disconnected")
|
|
621
633
|
|
|
622
634
|
async def _do_disconnect(self, cmd: dict):
|
|
@@ -464,9 +464,9 @@ class GForce:
|
|
|
464
464
|
return await self._run_in_gforce_loop(self._do_connect(disconnect_cb, buf))
|
|
465
465
|
|
|
466
466
|
async def _do_connect(self, disconnect_cb, buf: queue.Queue[bytes]):
|
|
467
|
-
if platform.system() == "Darwin":
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
# if platform.system() == "Darwin":
|
|
468
|
+
# loop = asyncio.get_running_loop()
|
|
469
|
+
# asyncio.set_event_loop(loop)
|
|
470
470
|
|
|
471
471
|
client = BleakClient(self._device, disconnected_callback=disconnect_cb)
|
|
472
472
|
self.client = client
|
|
@@ -8,7 +8,7 @@ with open(os.path.join(this_directory, "README.md"), "r", encoding="utf-8") as f
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name="sensor-sdk",
|
|
11
|
-
version="0.0.
|
|
11
|
+
version="0.0.48",
|
|
12
12
|
description="Python sdk for Synchroni",
|
|
13
13
|
long_description=long_description,
|
|
14
14
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|