sensor-sdk 0.0.1__py3-none-any.whl → 0.0.3__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.

Potentially problematic release.


This version of sensor-sdk might be problematic. Click here for more details.

@@ -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.destroy()
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 hasDeviceCallback(self) -> bool:
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
- @hasDeviceCallback.setter
115
+ @hasDeviceFoundCallback.setter
116
116
  def onDeviceFoundCallback(self, callback: Callable[[List[sensor_profile.BLEDevice]], None]):
117
117
  """
118
118
  设置扫描设备回调。
@@ -375,8 +375,8 @@ class SensorProfileDataCtx:
375
375
  saturation = 0.0
376
376
  if sensorData.dataType == DataType.NTF_ECG:
377
377
  impedanceChannelIndex = self.sensorDatas[SensorDataType.DATA_TYPE_EEG].channelCount
378
- impedance = _impedanceData[impedanceChannelIndex]
379
- saturation = _saturationData[impedanceChannelIndex]
378
+ impedance = _impedanceData[impedanceChannelIndex]
379
+ saturation = _saturationData[impedanceChannelIndex]
380
380
  impedanceChannelIndex += 1
381
381
 
382
382
  dataItem = Sample()
sensor/sensor_profile.py CHANGED
@@ -70,9 +70,9 @@ class SensorProfile:
70
70
  反初始化 SensorProfile 类的实例。
71
71
 
72
72
  """
73
- self.destroy()
73
+ self._destroy()
74
74
 
75
- def destroy(self):
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.1
3
+ Version: 0.0.3
4
4
  Summary: Python sdk for Synchroni
5
5
  Home-page: https://github.com/oymotion/SynchroniSDKPython
6
6
  Author: Martin Ye
@@ -12,7 +12,7 @@ Requires-Dist: numpy
12
12
  Requires-Dist: setuptools
13
13
  Requires-Dist: bleak
14
14
 
15
- # synchroni_sdk_python
15
+ # sensor-sdk
16
16
 
17
17
  Synchroni sdk for Python
18
18
 
@@ -20,7 +20,6 @@ Synchroni sdk for Python
20
20
 
21
21
  Synchroni SDK is the software development kit for developers to access Synchroni products.
22
22
 
23
-
24
23
  ## Contributing
25
24
 
26
25
  See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
@@ -34,10 +33,10 @@ MIT
34
33
  ## Installation
35
34
 
36
35
  ```sh
37
- pip install synchroni_sdk_python
36
+ pip install sensor-sdk
38
37
  ```
39
38
 
40
- ## 1. Permission
39
+ ## 1. Permission
41
40
 
42
41
  Application will obtain bluetooth permission by itself.
43
42
 
@@ -47,58 +46,66 @@ Application will obtain bluetooth permission by itself.
47
46
  from sensor import *
48
47
  ```
49
48
 
50
- # SensorController methods:
49
+ ## SensorController methods
51
50
 
52
- ## 1. Initalize
51
+ ### 1. Initalize
53
52
 
54
53
  ```python
55
- sensorControllerInstance = SensorController.Instance
54
+ SensorControllerInstance = SensorController()
56
55
 
57
56
  # register scan listener
58
- if not sensorControllerInstance.hasDeviceCallback:
59
- def on_device_callback(devices):
57
+ if not SensorControllerInstance.hasDeviceFoundCallback:
58
+ def on_device_callback(deviceList: List[BLEDevice]):
60
59
  # return all devices doesn't connected
61
60
  pass
62
- sensorControllerInstance.onDeviceCallback = on_device_callback
61
+ SensorControllerInstance.onDeviceFoundCallback = on_device_callback
63
62
  ```
64
63
 
65
- ## 2. Start scan
66
- Use `async def start_scan(period_in_ms: int) -> bool` to start scan
64
+ ### 2. Start scan
65
+
66
+ Use `def startScan(period_in_ms: int) -> bool` to start scan
67
+
67
68
  ```python
68
- success = await sensorControllerInstance.startScan(6000)
69
+ success = SensorControllerInstance.startScan(6000)
69
70
  ```
71
+
70
72
  returns true if start scan success, periodInMS means onDeviceCallback will be called every periodInMS
71
73
 
72
- ## 3. Stop scan
74
+ ### 3. Stop scan
75
+
76
+ Use `def stopScan() -> None` to stop scan
73
77
 
74
- Use `async def stop_scan() -> None` to stop scan
75
78
  ```python
76
- await sensorControllerInstance.stopScan()
79
+ SensorControllerInstance.stopScan()
77
80
  ```
78
- ## 4. Check scaning
81
+
82
+ ### 4. Check scaning
79
83
 
80
84
  Use `property isScanning: bool` to check scanning status
85
+
81
86
  ```python
82
- isScanning = sensorControllerInstance.isScanning
87
+ isScanning = SensorControllerInstance.isScanning
83
88
  ```
84
89
 
85
- ## 5. Check if bluetooth is enabled
90
+ ### 5. Check if bluetooth is enabled
86
91
 
87
92
  Use `property isEnabled: bool` to check if bluetooth is enabled
93
+
88
94
  ```python
89
- isEnabled = sensorControllerInstance.isEnabled
95
+ isEnabled = SensorControllerInstance.isEnabled
90
96
  ```
91
- ## 6. Create SensorProfile
97
+
98
+ ### 6. Create SensorProfile
92
99
 
93
100
  Use `def requireSensor(device: BLEDevice) -> SensorProfile | None` to create SensorProfile.
94
101
 
95
102
  If bleDevice is invalid, result is None.
96
103
 
97
104
  ```python
98
- sensorProfile = sensorControllerInstance.requireSensor(bleDevice)
105
+ sensorProfile = SensorControllerInstance.requireSensor(bleDevice)
99
106
  ```
100
107
 
101
- ## 7. Get SensorProfile
108
+ ### 7. Get SensorProfile
102
109
 
103
110
  Use `def getSensor(device: BLEDevice) -> SensorProfile | None` to get SensorProfile.
104
111
 
@@ -108,26 +115,48 @@ If SensorProfile didn't created, result is None.
108
115
  sensorProfile = SensorControllerInstance.getSensor(bleDevice)
109
116
  ```
110
117
 
111
- ## 8. Get Connected SensorProfiles
118
+ ### 8. Get Connected SensorProfiles
112
119
 
113
120
  Use `def getConnectedSensors() -> list[SensorProfile]` to get connected SensorProfiles.
121
+
114
122
  ```python
115
123
  sensorProfiles = SensorControllerInstance.getConnectedSensors()
116
124
  ```
117
125
 
118
- ## 9. Get Connected BLE Devices
126
+ ### 9. Get Connected BLE Devices
119
127
 
120
128
  Use `def getConnectedDevices() -> list[SensorProfile]` to get connected BLE Devices.
129
+
121
130
  ```python
122
131
  bleDevices = SensorControllerInstance.getConnectedDevices()
123
132
  ```
124
133
 
125
- # SensorProfile methods:
134
+ ### 10. Terminate
135
+
136
+ Use `def terminate()` to terminate sdk
137
+
138
+ ```python
139
+
140
+ def terminate():
141
+ SensorControllerInstance.terminate()
142
+ exit()
143
+
144
+ def main():
145
+ signal.signal(signal.SIGINT, lambda signal, frame: terminate())
146
+ time.sleep(30)
147
+ SensorControllerInstance.terminate()
148
+
149
+ Please MAKE SURE to call terminate when exit main() or press Ctrl+C
150
+ ```
151
+
152
+ ## SensorProfile methods
153
+
154
+ ### 11. Initalize
126
155
 
127
- ## 1. Initalize
128
156
  Please register callbacks for SensorProfile
157
+
129
158
  ```python
130
- sensorProfile = sensorControllerInstance.requireSensor(bleDevice)
159
+ sensorProfile = SensorControllerInstance.requireSensor(bleDevice)
131
160
 
132
161
  # register callbacks
133
162
  def on_state_changed(sensor, newState):
@@ -152,26 +181,30 @@ sensorProfile.onPowerChanged = on_power_changed
152
181
  sensorProfile.onDataCallback = on_data_callback
153
182
  ```
154
183
 
155
- ## 2. Connect device
156
- Use `async def connect() -> bool` to connect.
184
+ ### 12. Connect device
185
+
186
+ Use `def connect() -> bool` to connect.
187
+
157
188
  ```python
158
- success = await sensorProfile.connect()
189
+ success = sensorProfile.connect()
159
190
  ```
160
191
 
161
- ## 3. Disconnect
162
- Use `async def disconnect() -> bool` to disconnect.
192
+ ### 13. Disconnect
193
+
194
+ Use `def disconnect() -> bool` to disconnect.
195
+
163
196
  ```python
164
- success = await sensorProfile.disconnect()
197
+ success = sensorProfile.disconnect()
165
198
  ```
166
199
 
200
+ ### 14. Get device status
167
201
 
168
- ## 4. Get device status
169
- Use `property connectionState: DeviceStateEx` to get device status.
202
+ Use `property deviceState: DeviceStateEx` to get device status.
170
203
 
171
204
  Please send command in 'Ready' state, should be after connect() return True.
172
205
 
173
206
  ```python
174
- deviceStateEx = sensorProfile.connectionState
207
+ deviceStateEx = sensorProfile.deviceState
175
208
 
176
209
  # deviceStateEx has define:
177
210
  # class DeviceStateEx(Enum):
@@ -183,21 +216,22 @@ deviceStateEx = sensorProfile.connectionState
183
216
  # Invalid = 5
184
217
  ```
185
218
 
219
+ ### 15. Get BLE device of SensorProfile
186
220
 
187
-
188
- ## 5. Get BLE device of SensorProfile
189
221
  Use `property BLEDevice: BLEDevice` to get BLE device of SensorProfile.
222
+
190
223
  ```python
191
224
  bleDevice = sensorProfile.BLEDevice
192
225
  ```
193
226
 
194
- ## 6. Get device info of SensorProfile
195
- Use `async def deviceInfo() -> dict | None` to get device info of SensorProfile.
227
+ ### 16. Get device info of SensorProfile
228
+
229
+ Use `def getDeviceInfo() -> dict | None` to get device info of SensorProfile.
196
230
 
197
231
  Please call after device in 'Ready' state, return None if it's not connected.
198
232
 
199
233
  ```python
200
- deviceInfo = await sensorProfile.deviceInfo()
234
+ deviceInfo = sensorProfile.getDeviceInfo()
201
235
 
202
236
  # deviceInfo has defines:
203
237
  # deviceInfo = {
@@ -215,31 +249,37 @@ Please call after device in 'Ready' state, return None if it's not connected.
215
249
  # }
216
250
  ```
217
251
 
252
+ ### 17. Init data transfer
218
253
 
219
- ## 7. Init data transfer
220
- Use `async def init(packageSampleCount: int, powerRefreshInterval: int) -> bool`.
254
+ Use `def init(packageSampleCount: int, powerRefreshInterval: int) -> bool`.
221
255
 
222
256
  Please call after device in 'Ready' state, return True if init succeed.
257
+
223
258
  ```python
224
- success = await sensorProfile.init(5, 60*1000)
259
+ success = sensorProfile.init(5, 60*1000)
225
260
  ```
261
+
226
262
  packageSampleCount: set sample counts of SensorData.channelSamples in onDataCallback()
227
263
  powerRefreshInterval: callback period for onPowerChanged()
228
264
 
229
- ## 8. Check if init data transfer succeed
265
+ ### 18. Check if init data transfer succeed
266
+
230
267
  Use `property hasInited: bool` to check if init data transfer succeed.
268
+
231
269
  ```python
232
270
  hasInited = sensorProfile.hasInited
233
271
  ```
234
272
 
235
- ## 9. DataNotify
236
- Use `async def startDataNotification() -> bool` to start data notification.
273
+ ### 19. DataNotify
274
+
275
+ Use `def startDataNotification() -> bool` to start data notification.
237
276
 
238
277
  Please call if hasInited return True
239
- ### 9.1 Start data transfer
278
+
279
+ #### 19.1 Start data transfer
240
280
 
241
281
  ```python
242
- success = await sensorProfile.startDataNotification()
282
+ success = sensorProfile.startDataNotification()
243
283
  ```
244
284
 
245
285
  Data type list:
@@ -276,25 +316,30 @@ def on_data_callback(sensor, data):
276
316
  sensorProfile.onDataCallback = on_data_callback
277
317
  ```
278
318
 
279
- ### 9.2 Stop data transfer
280
- Use `async def stopDataNotification() -> bool` to stop data transfer.
319
+ #### 19.2 Stop data transfer
320
+
321
+ Use `def stopDataNotification() -> bool` to stop data transfer.
322
+
281
323
  ```python
282
- success = await sensorProfile.stopDataNotification()
324
+ success = sensorProfile.stopDataNotification()
283
325
  ```
284
326
 
285
- ### 9.3 Check if it's data transfering
327
+ #### 19.3 Check if it's data transfering
328
+
286
329
  Use `property isDataTransfering: bool` to check if it's data transfering.
330
+
287
331
  ```python
288
332
  isDataTransfering = sensorProfile.isDataTransfering
289
333
  ```
290
334
 
291
- ## 10. Get battery level
292
- Use `async def batteryPower() -> int` to get battery level. Please call after device in 'Ready' state.
335
+ ### 20. Get battery level
336
+
337
+ Use `def getBatteryLevel() -> int` to get battery level. Please call after device in 'Ready' state.
293
338
 
294
339
  ```python
295
- batteryPower = await sensorProfile.batteryPower()
340
+ batteryPower = sensorProfile.getBatteryLevel()
296
341
 
297
342
  # batteryPower is battery level returned, value ranges from 0 to 100, 0 means out of battery, while 100 means full.
298
343
  ```
299
344
 
300
- Please check SimpleTest function in App
345
+ Please check console.py in examples directory
@@ -0,0 +1,14 @@
1
+ sensor/__init__.py,sha256=L1VyAP0EDEnJIMeMTzp4iXHSRUUHyHScF_GIl3iYKRI,123
2
+ sensor/gforce.py,sha256=ZVOHV6_NiwGMPAf4BXqlxEHsDrynUBr0rcgqmbJT5oc,24586
3
+ sensor/sensor_controller.py,sha256=SD4kcU9Z0IjAoCDCtpM475TpuNwymGxmuFATP4NjY9M,8078
4
+ sensor/sensor_data.py,sha256=pHHHitKPs24MWYorW0DrIe4DKOMZU9c5Oh2mGktDUGg,4449
5
+ sensor/sensor_data_context.py,sha256=yFeCydxg2gpAu9Znp_OQup2XPO1iwmJMDTxVvyNEcVY,24140
6
+ sensor/sensor_device.py,sha256=XLpYe7jlc60PmIstdcqWJ_Vr1CxR2GPVAx5ll_ofnPM,3052
7
+ sensor/sensor_profile.py,sha256=44dCvb6EDv1fT6LJfjWmKlH_BMMVfdt46PlNO_LZaJs,17096
8
+ sensor/utils.py,sha256=rrgMKIPJ3u1iVSbQqcfUhlQ5h_IatHNPtqojdUHIc9Y,741
9
+ sensor_sdk-0.0.3.dist-info/LICENSE.txt,sha256=8CSivOpub3IuXODTyqBRI91AxouJZk02YrcKuOAkWu8,1111
10
+ sensor_sdk-0.0.3.dist-info/METADATA,sha256=qgnH7Pvzl3BstfDE1zHtBL1qH48t0AaDo9fmR5O44Bs,8055
11
+ sensor_sdk-0.0.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
12
+ sensor_sdk-0.0.3.dist-info/top_level.txt,sha256=Ftq49B6bH0Ffdc7c8LkcyakHo6lsg_snlBbpEUoILSk,7
13
+ sensor_sdk-0.0.3.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
14
+ sensor_sdk-0.0.3.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- sensor/__init__.py,sha256=L1VyAP0EDEnJIMeMTzp4iXHSRUUHyHScF_GIl3iYKRI,123
2
- sensor/gforce.py,sha256=ZVOHV6_NiwGMPAf4BXqlxEHsDrynUBr0rcgqmbJT5oc,24586
3
- sensor/sensor_controller.py,sha256=w87B1zp0U6o0MSbtPPKVh6YMRNSrmAtlXiOf5XvS0Yo,8067
4
- sensor/sensor_data.py,sha256=pHHHitKPs24MWYorW0DrIe4DKOMZU9c5Oh2mGktDUGg,4449
5
- sensor/sensor_data_context.py,sha256=DIY-7vN4ziCbtM8JQC5q_Ggz1FpBCVzm2vu8gEUu4mE,24148
6
- sensor/sensor_device.py,sha256=XLpYe7jlc60PmIstdcqWJ_Vr1CxR2GPVAx5ll_ofnPM,3052
7
- sensor/sensor_profile.py,sha256=ORcGs2i8M5l_49SoamgPph1H2NmtredWgajaR3S2NEI,17094
8
- sensor/utils.py,sha256=rrgMKIPJ3u1iVSbQqcfUhlQ5h_IatHNPtqojdUHIc9Y,741
9
- sensor_sdk-0.0.1.dist-info/LICENSE.txt,sha256=8CSivOpub3IuXODTyqBRI91AxouJZk02YrcKuOAkWu8,1111
10
- sensor_sdk-0.0.1.dist-info/METADATA,sha256=Pi0yorzV2UEckJU_2Urnx9mBUrEdESD4doVhgXGZ6-k,7685
11
- sensor_sdk-0.0.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
12
- sensor_sdk-0.0.1.dist-info/top_level.txt,sha256=Ftq49B6bH0Ffdc7c8LkcyakHo6lsg_snlBbpEUoILSk,7
13
- sensor_sdk-0.0.1.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
14
- sensor_sdk-0.0.1.dist-info/RECORD,,