# SpO2 Watch Python SDK
The adi-spo2-watch provides an object-oriented interface for interacting with ADI's VSM Study Watch 4.5 platform (SpO2 Watch).
**Installation**
```python
pip install adi-spo2-watch
```
**Description**
A user application can use the SDK to receive complete packets of bytes over a physical interface (USB or BLE) and
decode it. The functionality is organized into applications, some of which own sensors, some own system-level
functionality (i.e. file system), and while others own algorithms. The hierarchy of objects within the SDK mirrors the
applications present on the device. Each application has its own object within the SDK hierarchy, which is used to
interact with that application. A brief guide on using the SDK and few examples have been added below.
**Firmware Setup**
https://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/firmware/Firmware_update_guide.pdf
**Getting started with SDK**
Import the adi-spo2-watch module into your application code
```python
from adi_spo2_watch import SDK
```
Instantiate the SDK object by passing the com port number
```python
sdk = SDK('COM28')
```
The application objects can be instantiated from the sdk object. In order to instantiate an application object, we'll
have to pass a call-back function as an input argument which can be used to retrieve the data from the application
object. Define a callback function as displayed below.
```python
def callback_data(data):
print(data)
```
Once the call-back function is defined, you can instantiate the application object as shown below.
```python
application = sdk.get_sensorhub_application()
application.set_callback(callback_data, stream=application.SH_ADXL_STREAM)
```
Each application object has various methods that can be called by referring to the application. Almost all method in
an application returns result in a dict.
**Basic Example:**
```python
import time
from datetime import datetime
from adi_spo2_watch import SDK
# Callback function to receive adxl data
def callback_data(data):
sequence_number = data["payload"]["sequence_number"]
for stream_data in data["payload"]["stream_data"]:
dt_object = datetime.fromtimestamp(stream_data['timestamp'] / 1000) # convert timestamp from ms to sec.
print(f"seq :{sequence_number} timestamp: {dt_object} x,y,z :: ({stream_data['x']}, "
f"{stream_data['y']}, {stream_data['z']})")
if __name__ == "__main__":
sdk = SDK("COM4")
application = sdk.get_sensorhub_application()
# Quickstart adxl stream
application.set_callback(callback_data, stream=application.SH_ADXL_STREAM)
application.enable_csv_logging("adxl.csv", stream=application.SH_ADXL_STREAM) # Logging adxl data to csv file
application.subscribe_stream(stream=application.SH_ADXL_STREAM)
application.set_operation_mode(application.SH_CONFIG_ADXL_MODE)
application.start_sensor()
time.sleep(10)
application.stop_sensor()
application.unsubscribe_stream(stream=application.SH_ADXL_STREAM)
application.disable_csv_logging(stream=application.SH_ADXL_STREAM)
```
# Permission Issue in Ubuntu
1 - You can run your script with admin (sudo).
2 - If you don't want to run scripts as admin follows the steps below:
- add user to `tty` and `dialout` group
```
sudo usermod -aG tty <user>
sudo usermod -aG dialout <user>
```
- create a file at `/etc/udev/rules.d/` with name `10-adi-usb.rules`:
```
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0456", ATTRS{idProduct}=="2cfe", MODE="0666", GROUP="dialout"
```
- reboot
**All streams packet structure :**
https://analogdevicesinc.github.io/spo2-watch-sdk/python/_rst/adi_spo2_watch.core.packets.html#module-adi_spo2_watch.core.packets.stream_data_packets
**Documentation :**
https://analogdevicesinc.github.io/spo2-watch-sdk/python
**Examples :**
https://github.com/analogdevicesinc/spo2-watch-sdk/tree/main/python/samples
**License :**
https://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/LICENSE
**Changelog**
https://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/python/CHANGELOG.md
Raw data
{
"_id": null,
"home_page": "https://github.com/analogdevicesinc/spo2-watch-sdk",
"name": "adi-spo2-watch",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Analog Devices, Inc.",
"author_email": "healthcare-support@analog.com",
"download_url": "https://files.pythonhosted.org/packages/c6/76/9b5ec0a901154ae3a99aae66d5f4db3ad698fabbf6b3236ce1f717b0d19d/adi_spo2_watch-6.6.0.tar.gz",
"platform": null,
"description": "# SpO2 Watch Python SDK\r\n\r\nThe adi-spo2-watch provides an object-oriented interface for interacting with ADI's VSM Study Watch 4.5 platform (SpO2 Watch).\r\n\r\n**Installation**\r\n\r\n```python\r\npip install adi-spo2-watch\r\n```\r\n**Description**\r\n\r\nA user application can use the SDK to receive complete packets of bytes over a physical interface (USB or BLE) and\r\ndecode it. The functionality is organized into applications, some of which own sensors, some own system-level\r\nfunctionality (i.e. file system), and while others own algorithms. The hierarchy of objects within the SDK mirrors the\r\napplications present on the device. Each application has its own object within the SDK hierarchy, which is used to\r\ninteract with that application. A brief guide on using the SDK and few examples have been added below.\r\n\r\n**Firmware Setup**\r\n\r\nhttps://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/firmware/Firmware_update_guide.pdf\r\n\r\n**Getting started with SDK**\r\n\r\nImport the adi-spo2-watch module into your application code\r\n```python\r\nfrom adi_spo2_watch import SDK\r\n```\r\nInstantiate the SDK object by passing the com port number\r\n```python\r\nsdk = SDK('COM28')\r\n```\r\nThe application objects can be instantiated from the sdk object. In order to instantiate an application object, we'll\r\nhave to pass a call-back function as an input argument which can be used to retrieve the data from the application\r\nobject. Define a callback function as displayed below.\r\n```python\r\ndef callback_data(data):\r\n print(data)\r\n```\r\nOnce the call-back function is defined, you can instantiate the application object as shown below.\r\n```python\r\napplication = sdk.get_sensorhub_application()\r\napplication.set_callback(callback_data, stream=application.SH_ADXL_STREAM)\r\n```\r\nEach application object has various methods that can be called by referring to the application. Almost all method in \r\nan application returns result in a dict.\r\n\r\n\r\n**Basic Example:**\r\n\r\n```python\r\nimport time\r\nfrom datetime import datetime\r\nfrom adi_spo2_watch import SDK\r\n\r\n# Callback function to receive adxl data\r\ndef callback_data(data):\r\n sequence_number = data[\"payload\"][\"sequence_number\"]\r\n for stream_data in data[\"payload\"][\"stream_data\"]:\r\n dt_object = datetime.fromtimestamp(stream_data['timestamp'] / 1000) # convert timestamp from ms to sec.\r\n print(f\"seq :{sequence_number} timestamp: {dt_object} x,y,z :: ({stream_data['x']}, \"\r\n f\"{stream_data['y']}, {stream_data['z']})\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n sdk = SDK(\"COM4\")\r\n application = sdk.get_sensorhub_application()\r\n\r\n # Quickstart adxl stream\r\n application.set_callback(callback_data, stream=application.SH_ADXL_STREAM)\r\n application.enable_csv_logging(\"adxl.csv\", stream=application.SH_ADXL_STREAM) # Logging adxl data to csv file\r\n application.subscribe_stream(stream=application.SH_ADXL_STREAM)\r\n application.set_operation_mode(application.SH_CONFIG_ADXL_MODE)\r\n application.start_sensor()\r\n time.sleep(10)\r\n application.stop_sensor()\r\n application.unsubscribe_stream(stream=application.SH_ADXL_STREAM)\r\n application.disable_csv_logging(stream=application.SH_ADXL_STREAM)\r\n```\r\n\r\n# Permission Issue in Ubuntu\r\n\r\n1 - You can run your script with admin (sudo).\r\n\r\n2 - If you don't want to run scripts as admin follows the steps below:\r\n\r\n- add user to `tty` and `dialout` group\r\n\r\n```\r\nsudo usermod -aG tty <user>\r\nsudo usermod -aG dialout <user>\r\n```\r\n- create a file at `/etc/udev/rules.d/` with name `10-adi-usb.rules`:\r\n```\r\nACTION==\"add\", SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"0456\", ATTRS{idProduct}==\"2cfe\", MODE=\"0666\", GROUP=\"dialout\"\r\n```\r\n- reboot\r\n\r\n**All streams packet structure :**\r\nhttps://analogdevicesinc.github.io/spo2-watch-sdk/python/_rst/adi_spo2_watch.core.packets.html#module-adi_spo2_watch.core.packets.stream_data_packets\r\n\r\n**Documentation :**\r\nhttps://analogdevicesinc.github.io/spo2-watch-sdk/python\r\n\r\n**Examples :**\r\nhttps://github.com/analogdevicesinc/spo2-watch-sdk/tree/main/python/samples\r\n\r\n**License :**\r\nhttps://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/LICENSE\r\n\r\n**Changelog**\r\nhttps://github.com/analogdevicesinc/spo2-watch-sdk/blob/main/python/CHANGELOG.md\r\n\r\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License",
"summary": "ADI SpO2 Watch Python SDK",
"version": "6.6.0",
"project_urls": {
"Homepage": "https://github.com/analogdevicesinc/spo2-watch-sdk"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d54e1a645367b28a8f366d730ce3da8212e88b00c947f0f2ef3cb8d3f4c5ffa4",
"md5": "a0839df8f0be314754120721ec78eed4",
"sha256": "63151aaf956103d0ca653322ccc331edfb5c0050b76b2e09f6a2abca8db6b0e8"
},
"downloads": -1,
"filename": "adi_spo2_watch-6.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a0839df8f0be314754120721ec78eed4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 240669,
"upload_time": "2024-08-28T11:14:06",
"upload_time_iso_8601": "2024-08-28T11:14:06.394429Z",
"url": "https://files.pythonhosted.org/packages/d5/4e/1a645367b28a8f366d730ce3da8212e88b00c947f0f2ef3cb8d3f4c5ffa4/adi_spo2_watch-6.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c6769b5ec0a901154ae3a99aae66d5f4db3ad698fabbf6b3236ce1f717b0d19d",
"md5": "11673a5b4293656940fce00a3e197de9",
"sha256": "a2eec518ece806fd0fed66e983c5212077d7f74bc633f317fa2566374b0ef4dc"
},
"downloads": -1,
"filename": "adi_spo2_watch-6.6.0.tar.gz",
"has_sig": false,
"md5_digest": "11673a5b4293656940fce00a3e197de9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 137309,
"upload_time": "2024-08-28T11:14:08",
"upload_time_iso_8601": "2024-08-28T11:14:08.181688Z",
"url": "https://files.pythonhosted.org/packages/c6/76/9b5ec0a901154ae3a99aae66d5f4db3ad698fabbf6b3236ce1f717b0d19d/adi_spo2_watch-6.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-28 11:14:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "analogdevicesinc",
"github_project": "spo2-watch-sdk",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "adi-spo2-watch"
}