sensor-sdk 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl
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/sensor_controller.py +3 -3
- sensor/sensor_profile.py +2 -2
- {sensor_sdk-0.0.1.dist-info → sensor_sdk-0.0.2.dist-info}/METADATA +46 -29
- {sensor_sdk-0.0.1.dist-info → sensor_sdk-0.0.2.dist-info}/RECORD +8 -8
- {sensor_sdk-0.0.1.dist-info → sensor_sdk-0.0.2.dist-info}/LICENSE.txt +0 -0
- {sensor_sdk-0.0.1.dist-info → sensor_sdk-0.0.2.dist-info}/WHEEL +0 -0
- {sensor_sdk-0.0.1.dist-info → sensor_sdk-0.0.2.dist-info}/top_level.txt +0 -0
- {sensor_sdk-0.0.1.dist-info → sensor_sdk-0.0.2.dist-info}/zip-safe +0 -0
sensor/sensor_controller.py
CHANGED
|
@@ -61,7 +61,7 @@ class SensorController:
|
|
|
61
61
|
def terminate(self):
|
|
62
62
|
for sensor in self._sensor_profiles.values():
|
|
63
63
|
if sensor.deviceState == DeviceStateEx.Connected or sensor.deviceState == DeviceStateEx.Ready:
|
|
64
|
-
sensor.
|
|
64
|
+
sensor._destroy()
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
def _match_device(self, _device: bleak.BLEDevice, adv: AdvertisementData):
|
|
@@ -104,7 +104,7 @@ class SensorController:
|
|
|
104
104
|
self._enable_callback = callback
|
|
105
105
|
|
|
106
106
|
@property
|
|
107
|
-
def
|
|
107
|
+
def hasDeviceFoundCallback(self) -> bool:
|
|
108
108
|
"""
|
|
109
109
|
检查是否有扫描设备回调。
|
|
110
110
|
|
|
@@ -112,7 +112,7 @@ class SensorController:
|
|
|
112
112
|
"""
|
|
113
113
|
return self._device_callback != None
|
|
114
114
|
|
|
115
|
-
@
|
|
115
|
+
@hasDeviceFoundCallback.setter
|
|
116
116
|
def onDeviceFoundCallback(self, callback: Callable[[List[sensor_profile.BLEDevice]], None]):
|
|
117
117
|
"""
|
|
118
118
|
设置扫描设备回调。
|
sensor/sensor_profile.py
CHANGED
|
@@ -70,9 +70,9 @@ class SensorProfile:
|
|
|
70
70
|
反初始化 SensorProfile 类的实例。
|
|
71
71
|
|
|
72
72
|
"""
|
|
73
|
-
self.
|
|
73
|
+
self._destroy()
|
|
74
74
|
|
|
75
|
-
def
|
|
75
|
+
def _destroy(self):
|
|
76
76
|
if self._device_state == DeviceStateEx.Connected or self._device_state == DeviceStateEx.Ready:
|
|
77
77
|
self.disconnect()
|
|
78
78
|
if (self._data_event_loop != None):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sensor-sdk
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Python sdk for Synchroni
|
|
5
5
|
Home-page: https://github.com/oymotion/SynchroniSDKPython
|
|
6
6
|
Author: Martin Ye
|
|
@@ -34,7 +34,7 @@ MIT
|
|
|
34
34
|
## Installation
|
|
35
35
|
|
|
36
36
|
```sh
|
|
37
|
-
pip install
|
|
37
|
+
pip install sensor-sdk
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## 1. Permission
|
|
@@ -52,41 +52,41 @@ from sensor import *
|
|
|
52
52
|
## 1. Initalize
|
|
53
53
|
|
|
54
54
|
```python
|
|
55
|
-
|
|
55
|
+
SensorControllerInstance = SensorController()
|
|
56
56
|
|
|
57
57
|
# register scan listener
|
|
58
|
-
if not
|
|
59
|
-
def on_device_callback(
|
|
58
|
+
if not SensorControllerInstance.hasDeviceFoundCallback:
|
|
59
|
+
def on_device_callback(deviceList: List[BLEDevice]):
|
|
60
60
|
# return all devices doesn't connected
|
|
61
61
|
pass
|
|
62
|
-
|
|
62
|
+
SensorControllerInstance.onDeviceFoundCallback = on_device_callback
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
## 2. Start scan
|
|
66
|
-
Use `
|
|
66
|
+
Use `def start_scan(period_in_ms: int) -> bool` to start scan
|
|
67
67
|
```python
|
|
68
|
-
success =
|
|
68
|
+
success = SensorControllerInstance.startScan(6000)
|
|
69
69
|
```
|
|
70
70
|
returns true if start scan success, periodInMS means onDeviceCallback will be called every periodInMS
|
|
71
71
|
|
|
72
72
|
## 3. Stop scan
|
|
73
73
|
|
|
74
|
-
Use `
|
|
74
|
+
Use `def stop_scan() -> None` to stop scan
|
|
75
75
|
```python
|
|
76
|
-
|
|
76
|
+
SensorControllerInstance.stopScan()
|
|
77
77
|
```
|
|
78
78
|
## 4. Check scaning
|
|
79
79
|
|
|
80
80
|
Use `property isScanning: bool` to check scanning status
|
|
81
81
|
```python
|
|
82
|
-
isScanning =
|
|
82
|
+
isScanning = SensorControllerInstance.isScanning
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
## 5. Check if bluetooth is enabled
|
|
86
86
|
|
|
87
87
|
Use `property isEnabled: bool` to check if bluetooth is enabled
|
|
88
88
|
```python
|
|
89
|
-
isEnabled =
|
|
89
|
+
isEnabled = SensorControllerInstance.isEnabled
|
|
90
90
|
```
|
|
91
91
|
## 6. Create SensorProfile
|
|
92
92
|
|
|
@@ -95,7 +95,7 @@ Use `def requireSensor(device: BLEDevice) -> SensorProfile | None` to create Sen
|
|
|
95
95
|
If bleDevice is invalid, result is None.
|
|
96
96
|
|
|
97
97
|
```python
|
|
98
|
-
sensorProfile =
|
|
98
|
+
sensorProfile = SensorControllerInstance.requireSensor(bleDevice)
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
## 7. Get SensorProfile
|
|
@@ -122,12 +122,29 @@ Use `def getConnectedDevices() -> list[SensorProfile]` to get connected BLE Devi
|
|
|
122
122
|
bleDevices = SensorControllerInstance.getConnectedDevices()
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
+
## 10. Terminate
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
SensorControllerInstance.terminate()
|
|
129
|
+
|
|
130
|
+
def terminate():
|
|
131
|
+
SensorControllerInstance.terminate()
|
|
132
|
+
exit()
|
|
133
|
+
|
|
134
|
+
def main():
|
|
135
|
+
signal.signal(signal.SIGINT, lambda signal, frame: terminate())
|
|
136
|
+
time.sleep(30)
|
|
137
|
+
SensorControllerInstance.terminate()
|
|
138
|
+
|
|
139
|
+
Please call terminate when exit main() or press Ctrl+C
|
|
140
|
+
```
|
|
141
|
+
|
|
125
142
|
# SensorProfile methods:
|
|
126
143
|
|
|
127
144
|
## 1. Initalize
|
|
128
145
|
Please register callbacks for SensorProfile
|
|
129
146
|
```python
|
|
130
|
-
sensorProfile =
|
|
147
|
+
sensorProfile = SensorControllerInstance.requireSensor(bleDevice)
|
|
131
148
|
|
|
132
149
|
# register callbacks
|
|
133
150
|
def on_state_changed(sensor, newState):
|
|
@@ -153,15 +170,15 @@ sensorProfile.onDataCallback = on_data_callback
|
|
|
153
170
|
```
|
|
154
171
|
|
|
155
172
|
## 2. Connect device
|
|
156
|
-
Use `
|
|
173
|
+
Use `def connect() -> bool` to connect.
|
|
157
174
|
```python
|
|
158
|
-
success =
|
|
175
|
+
success = sensorProfile.connect()
|
|
159
176
|
```
|
|
160
177
|
|
|
161
178
|
## 3. Disconnect
|
|
162
|
-
Use `
|
|
179
|
+
Use `def disconnect() -> bool` to disconnect.
|
|
163
180
|
```python
|
|
164
|
-
success =
|
|
181
|
+
success = sensorProfile.disconnect()
|
|
165
182
|
```
|
|
166
183
|
|
|
167
184
|
|
|
@@ -192,12 +209,12 @@ bleDevice = sensorProfile.BLEDevice
|
|
|
192
209
|
```
|
|
193
210
|
|
|
194
211
|
## 6. Get device info of SensorProfile
|
|
195
|
-
Use `
|
|
212
|
+
Use `def getDeviceInfo() -> dict | None` to get device info of SensorProfile.
|
|
196
213
|
|
|
197
214
|
Please call after device in 'Ready' state, return None if it's not connected.
|
|
198
215
|
|
|
199
216
|
```python
|
|
200
|
-
deviceInfo =
|
|
217
|
+
deviceInfo = sensorProfile.getDeviceInfo()
|
|
201
218
|
|
|
202
219
|
# deviceInfo has defines:
|
|
203
220
|
# deviceInfo = {
|
|
@@ -217,11 +234,11 @@ Please call after device in 'Ready' state, return None if it's not connected.
|
|
|
217
234
|
|
|
218
235
|
|
|
219
236
|
## 7. Init data transfer
|
|
220
|
-
Use `
|
|
237
|
+
Use `def init(packageSampleCount: int, powerRefreshInterval: int) -> bool`.
|
|
221
238
|
|
|
222
239
|
Please call after device in 'Ready' state, return True if init succeed.
|
|
223
240
|
```python
|
|
224
|
-
success =
|
|
241
|
+
success = sensorProfile.init(5, 60*1000)
|
|
225
242
|
```
|
|
226
243
|
packageSampleCount: set sample counts of SensorData.channelSamples in onDataCallback()
|
|
227
244
|
powerRefreshInterval: callback period for onPowerChanged()
|
|
@@ -233,13 +250,13 @@ hasInited = sensorProfile.hasInited
|
|
|
233
250
|
```
|
|
234
251
|
|
|
235
252
|
## 9. DataNotify
|
|
236
|
-
Use `
|
|
253
|
+
Use `def startDataNotification() -> bool` to start data notification.
|
|
237
254
|
|
|
238
255
|
Please call if hasInited return True
|
|
239
256
|
### 9.1 Start data transfer
|
|
240
257
|
|
|
241
258
|
```python
|
|
242
|
-
success =
|
|
259
|
+
success = sensorProfile.startDataNotification()
|
|
243
260
|
```
|
|
244
261
|
|
|
245
262
|
Data type list:
|
|
@@ -277,9 +294,9 @@ sensorProfile.onDataCallback = on_data_callback
|
|
|
277
294
|
```
|
|
278
295
|
|
|
279
296
|
### 9.2 Stop data transfer
|
|
280
|
-
Use `
|
|
297
|
+
Use `def stopDataNotification() -> bool` to stop data transfer.
|
|
281
298
|
```python
|
|
282
|
-
success =
|
|
299
|
+
success = sensorProfile.stopDataNotification()
|
|
283
300
|
```
|
|
284
301
|
|
|
285
302
|
### 9.3 Check if it's data transfering
|
|
@@ -289,12 +306,12 @@ isDataTransfering = sensorProfile.isDataTransfering
|
|
|
289
306
|
```
|
|
290
307
|
|
|
291
308
|
## 10. Get battery level
|
|
292
|
-
Use `
|
|
309
|
+
Use `def getBatteryLevel() -> int` to get battery level. Please call after device in 'Ready' state.
|
|
293
310
|
|
|
294
311
|
```python
|
|
295
|
-
batteryPower =
|
|
312
|
+
batteryPower = sensorProfile.getBatteryLevel()
|
|
296
313
|
|
|
297
314
|
# batteryPower is battery level returned, value ranges from 0 to 100, 0 means out of battery, while 100 means full.
|
|
298
315
|
```
|
|
299
316
|
|
|
300
|
-
Please check
|
|
317
|
+
Please check console.py in examples directory
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
sensor/__init__.py,sha256=L1VyAP0EDEnJIMeMTzp4iXHSRUUHyHScF_GIl3iYKRI,123
|
|
2
2
|
sensor/gforce.py,sha256=ZVOHV6_NiwGMPAf4BXqlxEHsDrynUBr0rcgqmbJT5oc,24586
|
|
3
|
-
sensor/sensor_controller.py,sha256=
|
|
3
|
+
sensor/sensor_controller.py,sha256=SD4kcU9Z0IjAoCDCtpM475TpuNwymGxmuFATP4NjY9M,8078
|
|
4
4
|
sensor/sensor_data.py,sha256=pHHHitKPs24MWYorW0DrIe4DKOMZU9c5Oh2mGktDUGg,4449
|
|
5
5
|
sensor/sensor_data_context.py,sha256=DIY-7vN4ziCbtM8JQC5q_Ggz1FpBCVzm2vu8gEUu4mE,24148
|
|
6
6
|
sensor/sensor_device.py,sha256=XLpYe7jlc60PmIstdcqWJ_Vr1CxR2GPVAx5ll_ofnPM,3052
|
|
7
|
-
sensor/sensor_profile.py,sha256=
|
|
7
|
+
sensor/sensor_profile.py,sha256=44dCvb6EDv1fT6LJfjWmKlH_BMMVfdt46PlNO_LZaJs,17096
|
|
8
8
|
sensor/utils.py,sha256=rrgMKIPJ3u1iVSbQqcfUhlQ5h_IatHNPtqojdUHIc9Y,741
|
|
9
|
-
sensor_sdk-0.0.
|
|
10
|
-
sensor_sdk-0.0.
|
|
11
|
-
sensor_sdk-0.0.
|
|
12
|
-
sensor_sdk-0.0.
|
|
13
|
-
sensor_sdk-0.0.
|
|
14
|
-
sensor_sdk-0.0.
|
|
9
|
+
sensor_sdk-0.0.2.dist-info/LICENSE.txt,sha256=8CSivOpub3IuXODTyqBRI91AxouJZk02YrcKuOAkWu8,1111
|
|
10
|
+
sensor_sdk-0.0.2.dist-info/METADATA,sha256=N1iLvtzUQTtxd9dIytAd61DYqcqZcUaP-TaVs5-FtXw,7970
|
|
11
|
+
sensor_sdk-0.0.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
12
|
+
sensor_sdk-0.0.2.dist-info/top_level.txt,sha256=Ftq49B6bH0Ffdc7c8LkcyakHo6lsg_snlBbpEUoILSk,7
|
|
13
|
+
sensor_sdk-0.0.2.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
14
|
+
sensor_sdk-0.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|