sensor-sdk 0.0.1__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.

@@ -0,0 +1,300 @@
1
+ Metadata-Version: 2.1
2
+ Name: sensor-sdk
3
+ Version: 0.0.1
4
+ Summary: Python sdk for Synchroni
5
+ Home-page: https://github.com/oymotion/SynchroniSDKPython
6
+ Author: Martin Ye
7
+ Author-email: yecq_82@hotmail.com
8
+ Requires-Python: >=3.8.0
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE.txt
11
+ Requires-Dist: numpy
12
+ Requires-Dist: setuptools
13
+ Requires-Dist: bleak
14
+
15
+ # synchroni_sdk_python
16
+
17
+ Synchroni sdk for Python
18
+
19
+ ## Brief
20
+
21
+ Synchroni SDK is the software development kit for developers to access Synchroni products.
22
+
23
+
24
+ ## Contributing
25
+
26
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
27
+
28
+ ## License
29
+
30
+ MIT
31
+
32
+ ---
33
+
34
+ ## Installation
35
+
36
+ ```sh
37
+ pip install synchroni_sdk_python
38
+ ```
39
+
40
+ ## 1. Permission
41
+
42
+ Application will obtain bluetooth permission by itself.
43
+
44
+ ## 2. Import SDK
45
+
46
+ ```python
47
+ from sensor import *
48
+ ```
49
+
50
+ # SensorController methods:
51
+
52
+ ## 1. Initalize
53
+
54
+ ```python
55
+ sensorControllerInstance = SensorController.Instance
56
+
57
+ # register scan listener
58
+ if not sensorControllerInstance.hasDeviceCallback:
59
+ def on_device_callback(devices):
60
+ # return all devices doesn't connected
61
+ pass
62
+ sensorControllerInstance.onDeviceCallback = on_device_callback
63
+ ```
64
+
65
+ ## 2. Start scan
66
+ Use `async def start_scan(period_in_ms: int) -> bool` to start scan
67
+ ```python
68
+ success = await sensorControllerInstance.startScan(6000)
69
+ ```
70
+ returns true if start scan success, periodInMS means onDeviceCallback will be called every periodInMS
71
+
72
+ ## 3. Stop scan
73
+
74
+ Use `async def stop_scan() -> None` to stop scan
75
+ ```python
76
+ await sensorControllerInstance.stopScan()
77
+ ```
78
+ ## 4. Check scaning
79
+
80
+ Use `property isScanning: bool` to check scanning status
81
+ ```python
82
+ isScanning = sensorControllerInstance.isScanning
83
+ ```
84
+
85
+ ## 5. Check if bluetooth is enabled
86
+
87
+ Use `property isEnabled: bool` to check if bluetooth is enabled
88
+ ```python
89
+ isEnabled = sensorControllerInstance.isEnabled
90
+ ```
91
+ ## 6. Create SensorProfile
92
+
93
+ Use `def requireSensor(device: BLEDevice) -> SensorProfile | None` to create SensorProfile.
94
+
95
+ If bleDevice is invalid, result is None.
96
+
97
+ ```python
98
+ sensorProfile = sensorControllerInstance.requireSensor(bleDevice)
99
+ ```
100
+
101
+ ## 7. Get SensorProfile
102
+
103
+ Use `def getSensor(device: BLEDevice) -> SensorProfile | None` to get SensorProfile.
104
+
105
+ If SensorProfile didn't created, result is None.
106
+
107
+ ```python
108
+ sensorProfile = SensorControllerInstance.getSensor(bleDevice)
109
+ ```
110
+
111
+ ## 8. Get Connected SensorProfiles
112
+
113
+ Use `def getConnectedSensors() -> list[SensorProfile]` to get connected SensorProfiles.
114
+ ```python
115
+ sensorProfiles = SensorControllerInstance.getConnectedSensors()
116
+ ```
117
+
118
+ ## 9. Get Connected BLE Devices
119
+
120
+ Use `def getConnectedDevices() -> list[SensorProfile]` to get connected BLE Devices.
121
+ ```python
122
+ bleDevices = SensorControllerInstance.getConnectedDevices()
123
+ ```
124
+
125
+ # SensorProfile methods:
126
+
127
+ ## 1. Initalize
128
+ Please register callbacks for SensorProfile
129
+ ```python
130
+ sensorProfile = sensorControllerInstance.requireSensor(bleDevice)
131
+
132
+ # register callbacks
133
+ def on_state_changed(sensor, newState):
134
+ # please do logic when device disconnected unexpected
135
+ pass
136
+
137
+ def on_error_callback(sensor, reason):
138
+ # called when error occurs
139
+ pass
140
+
141
+ def on_power_changed(sensor, power):
142
+ # callback for get battery level of device, power from 0 - 100, -1 is invalid
143
+ pass
144
+
145
+ def on_data_callback(sensor, data):
146
+ # called after start data transfer
147
+ pass
148
+
149
+ sensorProfile.onStateChanged = on_state_changed
150
+ sensorProfile.onErrorCallback = on_error_callback
151
+ sensorProfile.onPowerChanged = on_power_changed
152
+ sensorProfile.onDataCallback = on_data_callback
153
+ ```
154
+
155
+ ## 2. Connect device
156
+ Use `async def connect() -> bool` to connect.
157
+ ```python
158
+ success = await sensorProfile.connect()
159
+ ```
160
+
161
+ ## 3. Disconnect
162
+ Use `async def disconnect() -> bool` to disconnect.
163
+ ```python
164
+ success = await sensorProfile.disconnect()
165
+ ```
166
+
167
+
168
+ ## 4. Get device status
169
+ Use `property connectionState: DeviceStateEx` to get device status.
170
+
171
+ Please send command in 'Ready' state, should be after connect() return True.
172
+
173
+ ```python
174
+ deviceStateEx = sensorProfile.connectionState
175
+
176
+ # deviceStateEx has define:
177
+ # class DeviceStateEx(Enum):
178
+ # Disconnected = 0
179
+ # Connecting = 1
180
+ # Connected = 2
181
+ # Ready = 3
182
+ # Disconnecting = 4
183
+ # Invalid = 5
184
+ ```
185
+
186
+
187
+
188
+ ## 5. Get BLE device of SensorProfile
189
+ Use `property BLEDevice: BLEDevice` to get BLE device of SensorProfile.
190
+ ```python
191
+ bleDevice = sensorProfile.BLEDevice
192
+ ```
193
+
194
+ ## 6. Get device info of SensorProfile
195
+ Use `async def deviceInfo() -> dict | None` to get device info of SensorProfile.
196
+
197
+ Please call after device in 'Ready' state, return None if it's not connected.
198
+
199
+ ```python
200
+ deviceInfo = await sensorProfile.deviceInfo()
201
+
202
+ # deviceInfo has defines:
203
+ # deviceInfo = {
204
+ # "deviceName": str,
205
+ # "modelName": str,
206
+ # "hardwareVersion": str,
207
+ # "firmwareVersion": str,
208
+ # "emgChannelCount": int,
209
+ # "eegChannelCount": int,
210
+ # "ecgChannelCount": int,
211
+ # "accChannelCount": int,
212
+ # "gyroChannelCount": int,
213
+ # "brthChannelCount": int,
214
+ # "mtuSize": int
215
+ # }
216
+ ```
217
+
218
+
219
+ ## 7. Init data transfer
220
+ Use `async def init(packageSampleCount: int, powerRefreshInterval: int) -> bool`.
221
+
222
+ Please call after device in 'Ready' state, return True if init succeed.
223
+ ```python
224
+ success = await sensorProfile.init(5, 60*1000)
225
+ ```
226
+ packageSampleCount: set sample counts of SensorData.channelSamples in onDataCallback()
227
+ powerRefreshInterval: callback period for onPowerChanged()
228
+
229
+ ## 8. Check if init data transfer succeed
230
+ Use `property hasInited: bool` to check if init data transfer succeed.
231
+ ```python
232
+ hasInited = sensorProfile.hasInited
233
+ ```
234
+
235
+ ## 9. DataNotify
236
+ Use `async def startDataNotification() -> bool` to start data notification.
237
+
238
+ Please call if hasInited return True
239
+ ### 9.1 Start data transfer
240
+
241
+ ```python
242
+ success = await sensorProfile.startDataNotification()
243
+ ```
244
+
245
+ Data type list:
246
+
247
+ ```python
248
+ class DataType(Enum):
249
+ NTF_ACC = 0x1 # unit is g
250
+ NTF_GYRO = 0x2 # unit is degree/s
251
+ NTF_EEG = 0x10 # unit is uV
252
+ NTF_ECG = 0x11 # unit is uV
253
+ NTF_BRTH = 0x15 # unit is uV
254
+ ```
255
+
256
+ Process data in onDataCallback.
257
+
258
+ ```python
259
+ def on_data_callback(sensor, data):
260
+ if data.dataType == DataType.NTF_EEG:
261
+ pass
262
+ elif data.dataType == DataType.NTF_ECG:
263
+ pass
264
+
265
+ # process data as you wish
266
+ for oneChannelSamples in data.channelSamples:
267
+ for sample in oneChannelSamples:
268
+ if sample.isLost:
269
+ # do some logic
270
+ pass
271
+ else:
272
+ # draw with sample.data & sample.channelIndex
273
+ # print(f"{sample.channelIndex} | {sample.sampleIndex} | {sample.data} | {sample.impedance}")
274
+ pass
275
+
276
+ sensorProfile.onDataCallback = on_data_callback
277
+ ```
278
+
279
+ ### 9.2 Stop data transfer
280
+ Use `async def stopDataNotification() -> bool` to stop data transfer.
281
+ ```python
282
+ success = await sensorProfile.stopDataNotification()
283
+ ```
284
+
285
+ ### 9.3 Check if it's data transfering
286
+ Use `property isDataTransfering: bool` to check if it's data transfering.
287
+ ```python
288
+ isDataTransfering = sensorProfile.isDataTransfering
289
+ ```
290
+
291
+ ## 10. Get battery level
292
+ Use `async def batteryPower() -> int` to get battery level. Please call after device in 'Ready' state.
293
+
294
+ ```python
295
+ batteryPower = await sensorProfile.batteryPower()
296
+
297
+ # batteryPower is battery level returned, value ranges from 0 to 100, 0 means out of battery, while 100 means full.
298
+ ```
299
+
300
+ Please check SimpleTest function in App
@@ -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=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,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.42.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ sensor
@@ -0,0 +1 @@
1
+