diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..76edfa6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1 @@ +{"image":"mcr.microsoft.com/devcontainers/universal:2"} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8f8e9d9..4135575 100644 --- a/.gitignore +++ b/.gitignore @@ -1,207 +1,207 @@ -# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,python,venv -# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,python,venv - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -### Python Patch ### -# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration -poetry.toml - -# ruff -.ruff_cache/ - -# LSP config files -pyrightconfig.json - -### venv ### -# Virtualenv -# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ -[Bb]in -[Ii]nclude -[Ll]ib -[Ll]ib64 -[Ll]ocal -[Ss]cripts -pyvenv.cfg -pip-selfcheck.json - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -!.vscode/*.code-snippets - -# Local History for Visual Studio Code -.history/ - -# Built Visual Studio Code Extensions -*.vsix - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history -.ionide - -# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python,venv +# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,python,venv +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,python,venv + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +### venv ### +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +pip-selfcheck.json + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python,venv diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..89a8106 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger: Current File", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "justMyCode": "false" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 7ec9cfc..2d87b3b 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -## Create virtual python environment -```python -m venv .env``` - -## Run the virtual environment -```source ./.env/bin/activate``` - -## Install dependencies -```pip install -r requirements.txt``` - -## Control the docker container -```docker exec -it raspi-container /bin/bash``` - -## Enable bleak logging on Linux -Insert this command into the same console where you want to start the bleak script after to set the BLEAK_LOGGING environment variable. -```export BLEAK_LOGGING=1``` - -## Notes -The script write_height.py in the archive folder does not work right now. More reverse Engineering to write on the Elite Rizer is required. +## Create virtual python environment +```python -m venv .env``` + +## Run the virtual environment +```source ./.env/bin/activate``` + +## Install dependencies +```pip install -r requirements.txt``` + +## Control the docker container +```docker exec -it raspi-container /bin/bash``` + +## Enable bleak logging on Linux +Insert this command into the same console where you want to start the bleak script after to set the BLEAK_LOGGING environment variable. +```export BLEAK_LOGGING=1``` + +## Notes +The script write_height.py in the archive folder does not work right now. More reverse Engineering to write on the Elite Rizer is required. diff --git a/collector_scripts/run.py b/archive/automized_run_scripts/run.py similarity index 95% rename from collector_scripts/run.py rename to archive/automized_run_scripts/run.py index 939189f..05496c5 100644 --- a/collector_scripts/run.py +++ b/archive/automized_run_scripts/run.py @@ -1,42 +1,42 @@ -import subprocess -import time -from p110_connect import connect_and_start_p100 - -python_scripts = ["direto_xr.py", "elite_rizer.py", "master_collector.py"] # , "headwind.py" -print("starting scripts...") -subprocesses = [] - -p100 = connect_and_start_p100() -# p100 = True -if p100: - # Loop through the other scripts and start them - for script in python_scripts: - process = subprocess.Popen(["python", script]) - subprocesses.append(process) - print(f"Started {script}") - time.sleep(15) - -try: - # Keep the script running until interrupted by the user - while True: - pass -except KeyboardInterrupt: - # Handle KeyboardInterrupt (Ctrl+C) to terminate subprocesses - print("\nTerminating subprocesses...") - for process in subprocesses: - process.terminate() - print("All scripts terminated.") - - - - - - - - - - - - -# Additional cleanup or logging if needed -print("All scripts completed.") +import subprocess +import time +from p110_connect import connect_and_start_p100 + +python_scripts = ["direto_xr.py", "elite_rizer.py", "master_collector.py"] # , "headwind.py" +print("starting scripts...") +subprocesses = [] + +p100 = connect_and_start_p100() +# p100 = True +if p100: + # Loop through the other scripts and start them + for script in python_scripts: + process = subprocess.Popen(["python", script]) + subprocesses.append(process) + print(f"Started {script}") + time.sleep(15) + +try: + # Keep the script running until interrupted by the user + while True: + pass +except KeyboardInterrupt: + # Handle KeyboardInterrupt (Ctrl+C) to terminate subprocesses + print("\nTerminating subprocesses...") + for process in subprocesses: + process.terminate() + print("All scripts terminated.") + + + + + + + + + + + + +# Additional cleanup or logging if needed +print("All scripts completed.") diff --git a/archive/automized_run_scripts/run_scripts.bat b/archive/automized_run_scripts/run_scripts.bat index 43f4645..b48f45b 100644 --- a/archive/automized_run_scripts/run_scripts.bat +++ b/archive/automized_run_scripts/run_scripts.bat @@ -1,30 +1,30 @@ -@echo off - -REM Set the Python script to be executed 5 seconds before others -set pre_execution_script="p110_connect.py" - -REM Set the list of Python scripts to start -set python_scripts=("direto_xr.py", "elite_rizer.py", "headwind.py", "master_collector.py") -REM set python_scripts=("master_collector.py") - -REM Start the pre-execution script -start "" python %pre_execution_script% - -REM Wait for the pre-execution script to complete -:wait_for_pre_execution -ping 127.0.0.1 -n 6 > nul -tasklist | find "python.exe" | findstr "%pre_execution_script%" > nul -if errorlevel 1 goto pre_execution_completed -goto wait_for_pre_execution - -:pre_execution_completed -REM Wait for an additional 5 seconds -timeout 5 >NUL - -REM Loop through the other scripts and start them -for %%i in %python_scripts% do ( - start "" python %%i - echo Started %%i -) - +@echo off + +REM Set the Python script to be executed 5 seconds before others +set pre_execution_script="p110_connect.py" + +REM Set the list of Python scripts to start +set python_scripts=("direto_xr.py", "elite_rizer.py", "headwind.py", "master_collector.py") +REM set python_scripts=("master_collector.py") + +REM Start the pre-execution script +start "" python %pre_execution_script% + +REM Wait for the pre-execution script to complete +:wait_for_pre_execution +ping 127.0.0.1 -n 6 > nul +tasklist | find "python.exe" | findstr "%pre_execution_script%" > nul +if errorlevel 1 goto pre_execution_completed +goto wait_for_pre_execution + +:pre_execution_completed +REM Wait for an additional 5 seconds +timeout 5 >NUL + +REM Loop through the other scripts and start them +for %%i in %python_scripts% do ( + start "" python %%i + echo Started %%i +) + echo All scripts started successfully. \ No newline at end of file diff --git a/archive/automized_run_scripts/run_scripts.py b/archive/automized_run_scripts/run_scripts.py index 70984c3..ddf4a10 100644 --- a/archive/automized_run_scripts/run_scripts.py +++ b/archive/automized_run_scripts/run_scripts.py @@ -1,50 +1,50 @@ -import subprocess -from p110_connect import connect_and_start_p100 -from direto_xr import scan_and_connect_direto -from elite_rizer import scan_and_connect_rizer -from headwind import scan_and_connect_headwind -# from master_collector import handle_data -import asyncio -import time - -async def headwind(): - await scan_and_connect_headwind() - -async def direto(): - await asyncio.sleep(10) - await scan_and_connect_direto() - -async def rizer(): - await asyncio.sleep(15) - await scan_and_connect_rizer() - -# async def master_collector(): - # await asyncio.sleep(20) - # await handle_data() - # subprocess.run(["python", "master_collector.py"]) - - -async def main(): - - headwind_task = asyncio.create_task(headwind()) - direto_task = asyncio.create_task(direto()) - rizer_task = asyncio.create_task(rizer()) - # collector_task = asyncio.create_task(master_collector()) - - # Wait for all tasks to complete - await asyncio.gather(headwind_task, direto_task, rizer_task) # , collector_task - -# python_scripts = ["direto_xr.py", "elite_rizer.py", "headwind.py", "master_collector.py"] -print("starting...") -p100 = connect_and_start_p100() -if(p100 == True): - if __name__ == "__main__": - asyncio.run(main()) - -print("All scripts started successfully.") - - - - - - +import subprocess +from p110_connect import connect_and_start_p100 +from direto_xr import scan_and_connect_direto +from elite_rizer import scan_and_connect_rizer +from headwind import scan_and_connect_headwind +# from master_collector import handle_data +import asyncio +import time + +async def headwind(): + await scan_and_connect_headwind() + +async def direto(): + await asyncio.sleep(10) + await scan_and_connect_direto() + +async def rizer(): + await asyncio.sleep(15) + await scan_and_connect_rizer() + +# async def master_collector(): + # await asyncio.sleep(20) + # await handle_data() + # subprocess.run(["python", "master_collector.py"]) + + +async def main(): + + headwind_task = asyncio.create_task(headwind()) + direto_task = asyncio.create_task(direto()) + rizer_task = asyncio.create_task(rizer()) + # collector_task = asyncio.create_task(master_collector()) + + # Wait for all tasks to complete + await asyncio.gather(headwind_task, direto_task, rizer_task) # , collector_task + +# python_scripts = ["direto_xr.py", "elite_rizer.py", "headwind.py", "master_collector.py"] +print("starting...") +p100 = connect_and_start_p100() +if(p100 == True): + if __name__ == "__main__": + asyncio.run(main()) + +print("All scripts started successfully.") + + + + + + diff --git a/archive/automized_run_scripts/run_scripts.sh b/archive/automized_run_scripts/run_scripts.sh index 7445304..7795a94 100755 --- a/archive/automized_run_scripts/run_scripts.sh +++ b/archive/automized_run_scripts/run_scripts.sh @@ -1,27 +1,27 @@ -#!/bin/bash - -# Set the Python script to be executed 5 seconds before others -pre_execution_script="p110_connect.py" - -# Set the list of Python scripts to start -python_scripts=("direto_xr.py" "elite_rizer.py" "headwind.py" "master_collector.py") -# python_scripts=("master_collector.py") - -# Start the pre-execution script -python "$pre_execution_script" & - -# Wait for the pre-execution script to complete -while ps | grep -v grep | grep -q "python $pre_execution_script"; do - sleep 15 -done - -# Wait for an additional 5 seconds -sleep 10 - -# Loop through the other scripts and start them -for script in "${python_scripts[@]}"; do - python "$script" & - echo "Started $script" -done - -echo "All scripts started successfully." +#!/bin/bash + +# Set the Python script to be executed 5 seconds before others +pre_execution_script="p110_connect.py" + +# Set the list of Python scripts to start +python_scripts=("direto_xr.py" "elite_rizer.py" "headwind.py" "master_collector.py") +# python_scripts=("master_collector.py") + +# Start the pre-execution script +python "$pre_execution_script" & + +# Wait for the pre-execution script to complete +while ps | grep -v grep | grep -q "python $pre_execution_script"; do + sleep 15 +done + +# Wait for an additional 5 seconds +sleep 10 + +# Loop through the other scripts and start them +for script in "${python_scripts[@]}"; do + python "$script" & + echo "Started $script" +done + +echo "All scripts started successfully." diff --git a/archive/bno/read_bno.py b/archive/bno/read_bno.py index 0c3184e..a744fe5 100644 --- a/archive/bno/read_bno.py +++ b/archive/bno/read_bno.py @@ -1,25 +1,25 @@ -import socket -import json - -UDP_IP = "192.168.9.185" # Listen to all incoming UDP packets -UDP_PORT = 8888 # Same port as used in the ESP32 script - -udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -udp_socket.bind((UDP_IP, UDP_PORT)) - -print(f"Listening for UDP packets on {UDP_IP}:{UDP_PORT}...") - -while True: - data, addr = udp_socket.recvfrom(1024) # Buffer size is 1024 bytes - received_data = data.decode() - - try: - # Attempt to parse the received JSON data - json_data = json.loads(received_data) - print("Received JSON data:") - print(json.dumps(json_data, indent=4)) # Print the JSON data nicely formatted - except json.JSONDecodeError as e: - print("Received data is not in JSON format.") - print(f"Received data: {received_data}") - +import socket +import json + +UDP_IP = "192.168.9.185" # Listen to all incoming UDP packets +UDP_PORT = 8888 # Same port as used in the ESP32 script + +udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +udp_socket.bind((UDP_IP, UDP_PORT)) + +print(f"Listening for UDP packets on {UDP_IP}:{UDP_PORT}...") + +while True: + data, addr = udp_socket.recvfrom(1024) # Buffer size is 1024 bytes + received_data = data.decode() + + try: + # Attempt to parse the received JSON data + json_data = json.loads(received_data) + print("Received JSON data:") + print(json.dumps(json_data, indent=4)) # Print the JSON data nicely formatted + except json.JSONDecodeError as e: + print("Received data is not in JSON format.") + print(f"Received data: {received_data}") + print(f"Received data from {addr}") \ No newline at end of file diff --git a/archive/brake/read_brake.py b/archive/brake/read_brake.py index b20fa1d..2f21aa9 100644 --- a/archive/brake/read_brake.py +++ b/archive/brake/read_brake.py @@ -1,25 +1,25 @@ -import socket -import json - -UDP_IP = "192.168.9.185" # Listen to all incoming UDP packets -UDP_PORT = 7777 # Same port as used in the Arduino script - -udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -udp_socket.bind((UDP_IP, UDP_PORT)) - -print(f"Listening for UDP packets on {UDP_IP}:{UDP_PORT}...") - -while True: - data, addr = udp_socket.recvfrom(1024) # Buffer size is 1024 bytes - received_data = data.decode() - - try: - # Attempt to parse the received JSON data - json_data = json.loads(received_data) - print("Received JSON data:") - print(json.dumps(json_data, indent=4)) # Print the JSON data nicely formatted - except json.JSONDecodeError as e: - print("Received data is not in JSON format.") - print(f"Received data: {received_data}") - - print(f"Received data from {addr}") +import socket +import json + +UDP_IP = "192.168.9.185" # Listen to all incoming UDP packets +UDP_PORT = 7777 # Same port as used in the Arduino script + +udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +udp_socket.bind((UDP_IP, UDP_PORT)) + +print(f"Listening for UDP packets on {UDP_IP}:{UDP_PORT}...") + +while True: + data, addr = udp_socket.recvfrom(1024) # Buffer size is 1024 bytes + received_data = data.decode() + + try: + # Attempt to parse the received JSON data + json_data = json.loads(received_data) + print("Received JSON data:") + print(json.dumps(json_data, indent=4)) # Print the JSON data nicely formatted + except json.JSONDecodeError as e: + print("Received data is not in JSON format.") + print(f"Received data: {received_data}") + + print(f"Received data from {addr}") diff --git a/archive/collector_scripts/data_collector.py b/archive/collector_scripts/data_collector.py index 66a4182..e64039a 100644 --- a/archive/collector_scripts/data_collector.py +++ b/archive/collector_scripts/data_collector.py @@ -1,18 +1,18 @@ -class DataCollector: - def __init__(self): - self.speed_value = 0 - self.steering_value = 0 - self.brake_value = 0 - self.bno_value = 0 - - def collect_speed(self, speed): - self.speed_value = speed - - def collect_steering(self, steering): - self.steering_value = steering - - def collect_brake(self, brake): - self.brake_value = brake - - def collect_bno(self, bno): +class DataCollector: + def __init__(self): + self.speed_value = 0 + self.steering_value = 0 + self.brake_value = 0 + self.bno_value = 0 + + def collect_speed(self, speed): + self.speed_value = speed + + def collect_steering(self, steering): + self.steering_value = steering + + def collect_brake(self, brake): + self.brake_value = brake + + def collect_bno(self, bno): self.bno_value = bno \ No newline at end of file diff --git a/archive/direto/read_speed.py b/archive/direto/read_speed.py index f90019b..da56d8d 100644 --- a/archive/direto/read_speed.py +++ b/archive/direto/read_speed.py @@ -1,154 +1,154 @@ -import asyncio -from bleak import BleakScanner, BleakClient -import struct - -class BluetoothCallback: - def __init__(self): - self.received_data = 0 # Initialize with None or any default value - - async def notify_speed_callback(self, sender, data): - # Assuming data is received from the Bluetooth device - if struct.pack("@h", 1) == struct.pack("h", data, 2)[0] - output = result * 0.01 - normalized_output = normalize_speed_value(output, 0.0, 3.5) - - if output < 0: - output = abs(output) - print(normalized_output) - - self.received_data = normalized_output - - -device_name = "DIRETO XR" -DEVICEID = "" - -service_uuid = "00001826-0000-1000-8000-00805f9b34fb" # Direto - Fitness Machine Service -SERVICE = "" - -characteristic_uuid = "00002ad2-0000-1000-8000-00805f9b34fb" # Direto -CHARACTERISTIC = "" - -value_to_write = "" -old_value = "" - -def normalize_speed_value(value, min_val, max_val): - range_val = max_val - min_val - normalized_value = (value - min_val) / range_val - return normalized_value - -''' -async def on_notification(sender, data): - # collection = db["sensor_values"] # Sammlungsname // outsourcen zur api - # data = data[0] - # value = data.decode('utf-8') - - # Daten in die MongoDB schreiben - # entry = {"value": value} - # integer_value = int.from_bytes(data, byteorder='big') - #collection.insert_one(entry) - # print(f"Data written to MongoDB: {entry}") - # print(f"Data written to MongoDB: {data}") - if struct.pack("@h", 1) == struct.pack("h", data, 2)[0] - output = result * 0.01 - normalized_output = normalize_speed_value(output, 0.0, 3.5) - - if output < 0: - output = abs(output) - print(normalized_output) -''' -''' - if (value[6] != value_to_write): - value_to_write = value[6] - if(entry_id == None): - write_in_db(value_to_write) - entry_id = await get_id() - #print("Entry ID: "+entry_id) - #message = value_to_write - print("Test", value_to_write) - # is_first_entry = False - else: - #message = value_to_write - print(value_to_write) - # await update_in_db(entry_id, value_to_write) - write_in_db(value_to_write) - logger.info("Updateing for id: %r ....With Value %r", entry_id, value_to_write) - #print("Updateing for id: ", entry_id, "....With Value ", value_to_write) - # print("old value: ", old_value) - - - old_value = value_to_write - logger.info( - " [Characteristic] %s (%s), Value: %r", - characteristic, - ",".join(characteristic.properties) , - # value[0], - ) -''' - -async def scan_and_connect(): - global device_name - - global service_uuid - global SERVICE - - global characteristic_uuid - global CHARACTERISTIC - - global value_to_write - global old_value - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - print(device) - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - await stop_event.wait() - - if(DEVICEID != ""): - # Connecting to BLE Device - async with BleakClient(DEVICEID, timeout=120) as client: - # logger.info("Device ID ", device_id) - for service in client.services: - # print("service: ", service.properties) - - if (service.uuid == service_uuid): - SERVICE = service - print("[service uuid] ", SERVICE.uuid) - - if (SERVICE != ""): - # print("SERVICE", SERVICE) - for characteristic in SERVICE.characteristics: - # if ("notify" in characteristic.properties): - print("[Characteristic] %s", characteristic, characteristic.properties) - - if(characteristic.uuid == characteristic_uuid): - CHARACTERISTIC = characteristic - print("CHARACTERISTIC: ", characteristic, characteristic.properties) - if ("notify" in characteristic.properties): - bluetooth_callback = BluetoothCallback() - - while True: - try: - await client.start_notify(characteristic.uuid, bluetooth_callback.notify_speed_callback) - await asyncio.sleep(10) # keeps the connection open for 10 seconds - await client.stop_notify(characteristic.uuid) - - except Exception as e: - print("Error: ", e) -asyncio.run(scan_and_connect()) - - - +import asyncio +from bleak import BleakScanner, BleakClient +import struct + +class BluetoothCallback: + def __init__(self): + self.received_data = 0 # Initialize with None or any default value + + async def notify_speed_callback(self, sender, data): + # Assuming data is received from the Bluetooth device + if struct.pack("@h", 1) == struct.pack("h", data, 2)[0] + output = result * 0.01 + normalized_output = normalize_speed_value(output, 0.0, 3.5) + + if output < 0: + output = abs(output) + print(normalized_output) + + self.received_data = normalized_output + + +device_name = "DIRETO XR" +DEVICEID = "" + +service_uuid = "00001826-0000-1000-8000-00805f9b34fb" # Direto - Fitness Machine Service +SERVICE = "" + +characteristic_uuid = "00002ad2-0000-1000-8000-00805f9b34fb" # Direto +CHARACTERISTIC = "" + +value_to_write = "" +old_value = "" + +def normalize_speed_value(value, min_val, max_val): + range_val = max_val - min_val + normalized_value = (value - min_val) / range_val + return normalized_value + +''' +async def on_notification(sender, data): + # collection = db["sensor_values"] # Sammlungsname // outsourcen zur api + # data = data[0] + # value = data.decode('utf-8') + + # Daten in die MongoDB schreiben + # entry = {"value": value} + # integer_value = int.from_bytes(data, byteorder='big') + #collection.insert_one(entry) + # print(f"Data written to MongoDB: {entry}") + # print(f"Data written to MongoDB: {data}") + if struct.pack("@h", 1) == struct.pack("h", data, 2)[0] + output = result * 0.01 + normalized_output = normalize_speed_value(output, 0.0, 3.5) + + if output < 0: + output = abs(output) + print(normalized_output) +''' +''' + if (value[6] != value_to_write): + value_to_write = value[6] + if(entry_id == None): + write_in_db(value_to_write) + entry_id = await get_id() + #print("Entry ID: "+entry_id) + #message = value_to_write + print("Test", value_to_write) + # is_first_entry = False + else: + #message = value_to_write + print(value_to_write) + # await update_in_db(entry_id, value_to_write) + write_in_db(value_to_write) + logger.info("Updateing for id: %r ....With Value %r", entry_id, value_to_write) + #print("Updateing for id: ", entry_id, "....With Value ", value_to_write) + # print("old value: ", old_value) + + + old_value = value_to_write + logger.info( + " [Characteristic] %s (%s), Value: %r", + characteristic, + ",".join(characteristic.properties) , + # value[0], + ) +''' + +async def scan_and_connect(): + global device_name + + global service_uuid + global SERVICE + + global characteristic_uuid + global CHARACTERISTIC + + global value_to_write + global old_value + + stop_event = asyncio.Event() + + # Scanning and printing for BLE devices + def callback(device, advertising_data): + global DEVICEID + print(device) + if(device.name == device_name): + DEVICEID = device + stop_event.set() + + # Stops the scanning event + async with BleakScanner(callback) as scanner: + await stop_event.wait() + + if(DEVICEID != ""): + # Connecting to BLE Device + async with BleakClient(DEVICEID, timeout=120) as client: + # logger.info("Device ID ", device_id) + for service in client.services: + # print("service: ", service.properties) + + if (service.uuid == service_uuid): + SERVICE = service + print("[service uuid] ", SERVICE.uuid) + + if (SERVICE != ""): + # print("SERVICE", SERVICE) + for characteristic in SERVICE.characteristics: + # if ("notify" in characteristic.properties): + print("[Characteristic] %s", characteristic, characteristic.properties) + + if(characteristic.uuid == characteristic_uuid): + CHARACTERISTIC = characteristic + print("CHARACTERISTIC: ", characteristic, characteristic.properties) + if ("notify" in characteristic.properties): + bluetooth_callback = BluetoothCallback() + + while True: + try: + await client.start_notify(characteristic.uuid, bluetooth_callback.notify_speed_callback) + await asyncio.sleep(10) # keeps the connection open for 10 seconds + await client.stop_notify(characteristic.uuid) + + except Exception as e: + print("Error: ", e) +asyncio.run(scan_and_connect()) + + + diff --git a/archive/direto/write_resistance.py b/archive/direto/write_resistance.py index 9bb88f0..b4cce53 100644 --- a/archive/direto/write_resistance.py +++ b/archive/direto/write_resistance.py @@ -1,78 +1,78 @@ -import asyncio -from bleak import BleakScanner, BleakClient - -class BluetoothCallback: - def __init__(self): - self.received_data = 0 # Initialize with None or any default value - - async def notify_callback(self, sender, data): - # Assuming data is received from the Bluetooth device - print(data) - - -device_name = "DIRETO XR" # Replace with the name of your desired BLE device -DEVICE = "" - -service_uuid = "00001826-0000-1000-8000-00805f9b34fb" # Direto XR -SERVICE = "" - -characteristic_uuid = "00002ad9-0000-1000-8000-00805f9b34fb" # Direto XR -CHARACTERISTIC = "" - -async def scan_and_connect(): - global device_name - - global service_uuid - global SERVICE - - global characteristic_uuid - global CHARACTERISTIC - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - print(device) - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - await stop_event.wait() - - if(DEVICEID != ""): - # Connecting to BLE Device - async with BleakClient(DEVICEID, timeout=60) as client: - print("Device ID ", DEVICEID) - for service in client.services: - - if (service.uuid == service_uuid): - SERVICE = service - - if (SERVICE != ""): - for characteristic in SERVICE.characteristics: - - if(characteristic.uuid == characteristic_uuid): - CHARACTERISTIC = characteristic - - bluetooth_callback = BluetoothCallback() - while True: - try: - await client.start_notify(CHARACTERISTIC, bluetooth_callback.notify_callback) # characteristic.uuid - except Exception as e: - print("Error: ", e) - resistance_input = input("Enter a value between 1-100 to set the resistance level. (or 'x' to exit): ") - resistance_value = int(resistance_input) - try: - if 1 <= resistance_value <= 100: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, resistance_value])) - elif resistance_input.lower() == 'x': - await client.stop_notify(CHARACTERISTIC) # characteristic.uuid - await asyncio.sleep(1) - break - except ValueError: - print("Invalid input. Please enter a number between 1 and 100.") - +import asyncio +from bleak import BleakScanner, BleakClient + +class BluetoothCallback: + def __init__(self): + self.received_data = 0 # Initialize with None or any default value + + async def notify_callback(self, sender, data): + # Assuming data is received from the Bluetooth device + print(data) + + +device_name = "DIRETO XR" # Replace with the name of your desired BLE device +DEVICE = "" + +service_uuid = "00001826-0000-1000-8000-00805f9b34fb" # Direto XR +SERVICE = "" + +characteristic_uuid = "00002ad9-0000-1000-8000-00805f9b34fb" # Direto XR +CHARACTERISTIC = "" + +async def scan_and_connect(): + global device_name + + global service_uuid + global SERVICE + + global characteristic_uuid + global CHARACTERISTIC + + stop_event = asyncio.Event() + + # Scanning and printing for BLE devices + def callback(device, advertising_data): + global DEVICEID + print(device) + if(device.name == device_name): + DEVICEID = device + stop_event.set() + + # Stops the scanning event + async with BleakScanner(callback) as scanner: + await stop_event.wait() + + if(DEVICEID != ""): + # Connecting to BLE Device + async with BleakClient(DEVICEID, timeout=60) as client: + print("Device ID ", DEVICEID) + for service in client.services: + + if (service.uuid == service_uuid): + SERVICE = service + + if (SERVICE != ""): + for characteristic in SERVICE.characteristics: + + if(characteristic.uuid == characteristic_uuid): + CHARACTERISTIC = characteristic + + bluetooth_callback = BluetoothCallback() + while True: + try: + await client.start_notify(CHARACTERISTIC, bluetooth_callback.notify_callback) # characteristic.uuid + except Exception as e: + print("Error: ", e) + resistance_input = input("Enter a value between 1-100 to set the resistance level. (or 'x' to exit): ") + resistance_value = int(resistance_input) + try: + if 1 <= resistance_value <= 100: + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, resistance_value])) + elif resistance_input.lower() == 'x': + await client.stop_notify(CHARACTERISTIC) # characteristic.uuid + await asyncio.sleep(1) + break + except ValueError: + print("Invalid input. Please enter a number between 1 and 100.") + asyncio.run(scan_and_connect()) \ No newline at end of file diff --git a/archive/docker/Dockerfile b/archive/docker/Dockerfile index 5e0a781..345de4c 100644 --- a/archive/docker/Dockerfile +++ b/archive/docker/Dockerfile @@ -1,40 +1,40 @@ -# Use the latest Ubuntu LTS release as the base image -FROM ubuntu:20.04 - -# Set the timezone environment variable -ENV TZ=Europe/Berlin - -# Create the /etc/timezone file with the timezone data and link /etc/localtime to the correct timezone -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -# Update package lists and install essential packages -RUN apt-get update -y && \ - apt-get install -y \ - python3 \ - python3-pip \ - libglib2.0-dev \ - dbus \ - bluez \ - bluetooth \ - openssh-server && \ - mkdir /var/run/sshd \ - && apt-get clean - -# Set the working directory in the container -WORKDIR /python_scripts - -# COPY entrypoint.sh . - -# Copy the rest of the application code to the container -COPY ./scripts/ /python_scripts/ - -# Install the API dependencies -RUN pip3 install -r requirements.txt - -# Expose the port the container will run on -EXPOSE 22 - -CMD ["./entrypoint.sh"] - -# Command to start the ssh +# Use the latest Ubuntu LTS release as the base image +FROM ubuntu:20.04 + +# Set the timezone environment variable +ENV TZ=Europe/Berlin + +# Create the /etc/timezone file with the timezone data and link /etc/localtime to the correct timezone +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Update package lists and install essential packages +RUN apt-get update -y && \ + apt-get install -y \ + python3 \ + python3-pip \ + libglib2.0-dev \ + dbus \ + bluez \ + bluetooth \ + openssh-server && \ + mkdir /var/run/sshd \ + && apt-get clean + +# Set the working directory in the container +WORKDIR /python_scripts + +# COPY entrypoint.sh . + +# Copy the rest of the application code to the container +COPY ./scripts/ /python_scripts/ + +# Install the API dependencies +RUN pip3 install -r requirements.txt + +# Expose the port the container will run on +EXPOSE 22 + +CMD ["./entrypoint.sh"] + +# Command to start the ssh # CMD ["/usr/sbin/sshd", "-D"] \ No newline at end of file diff --git a/archive/docker/docker-compose.yml b/archive/docker/docker-compose.yml index 804ad0e..1b1c092 100644 --- a/archive/docker/docker-compose.yml +++ b/archive/docker/docker-compose.yml @@ -1,10 +1,10 @@ -version: '3' -services: - raspi-container: - build: . - container_name: raspi-container - network_mode: host - privileged: true - tty: true # Need to be used as long there are no scripts or other services running in the container - # ports: +version: '3' +services: + raspi-container: + build: . + container_name: raspi-container + network_mode: host + privileged: true + tty: true # Need to be used as long there are no scripts or other services running in the container + # ports: # - "2222:22" \ No newline at end of file diff --git a/archive/docker/entrypoint.sh b/archive/docker/entrypoint.sh index 2ac7c80..b2bacaa 100644 --- a/archive/docker/entrypoint.sh +++ b/archive/docker/entrypoint.sh @@ -1,8 +1,8 @@ -#!/bin/bash - -# start services -service dbus start -service bluetooth start - -# Start sshd service +#!/bin/bash + +# start services +service dbus start +service bluetooth start + +# Start sshd service # /usr/sbin/sshd -D \ No newline at end of file diff --git a/archive/headwind/archive_old_write_headwind.py b/archive/headwind/archive_old_write_headwind.py index 5ab71ae..879c869 100644 --- a/archive/headwind/archive_old_write_headwind.py +++ b/archive/headwind/archive_old_write_headwind.py @@ -1,223 +1,223 @@ -import asyncio -from bleak import BleakScanner, BleakClient -import struct - - -class BluetoothCallback: - def __init__(self): - self.received_data = 0 # Initialize with None or any default value - - async def notify_callback(self, sender, data): - # Assuming data is received from the Bluetooth device - print(data) - - ''' - if struct.pack("@h", 1) == struct.pack("h", data, 2)[0] - output = result * 0.01 - - if output < 0: - output = abs(output) - print(output) - - self.received_data = output - ''' - - -device_name = "HEADWIND BC55" # Replace with the name of your desired BLE device -DEVICE = "" - -service_uuid = "a026ee0c-0a7d-4ab3-97fa-f1500f9feb8b" -SERVICE = "" - -characteristic_uuid = "a026e038-0a7d-4ab3-97fa-f1500f9feb8b" -CHARACTERISTIC = "" - -async def scan_and_connect(): - global device_name - - global service_uuid - global SERVICE - - global characteristic_uuid - global CHARACTERISTIC - - global value_to_write - global old_value - - global is_first_entry - global run_read_loop - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - print(device) - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - await stop_event.wait() - - if(DEVICEID != ""): - # Connecting to BLE Device - # print("DEVICEID: ",DEVICEID.address) - async with BleakClient(DEVICEID, timeout=60) as client: - print("Device ID ", DEVICEID) - for service in client.services: - # print("service: ", service) - - if (service.uuid == service_uuid): - SERVICE = service - # print("[service uuid] ", SERVICE.uuid) - - if (SERVICE != ""): - # print("SERVICE", SERVICE) - for characteristic in SERVICE.characteristics: - # if ("notify" in characteristic.properties): - # print("[Characteristic] %s", characteristic, characteristic.properties) - - if(characteristic.uuid == characteristic_uuid): - CHARACTERISTIC = characteristic - # print("CHARACTERISTIC: ", characteristic, characteristic.properties) - - if ("write-without-response" in characteristic.properties): - # while True: - print("Type CHARACTERISTIC: ", type(CHARACTERISTIC)) - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) - print("client connection: ", client.is_connected) - # await client.disconnect() - # print("client connection: ", client.is_connected) - # await asyncio.sleep(10) # keeps the connection open for 10 seconds - # print("TIMER") - # await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, 100])) - ''' - if ("notify" in characteristic.properties): - - bluetooth_callback = BluetoothCallback() - while True: - try: - - # value = await client.read_gatt_char(characteristic.uuid) - # print("Die CHARARARA iSt: ", CHARACTERISTIC, CHARACTERISTIC.properties) - # await client.start_notify(characteristic.uuid, on_notification) - await client.start_notify(characteristic.uuid, bluetooth_callback.notify_callback) - print("client connection: ", client.is_connected) - await asyncio.sleep(10) # keeps the connection open for 10 seconds - await client.stop_notify(characteristic.uuid) - - except Exception as e: - print("Error: ", e) - # run_read_loop = False - - ''' - - # await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, 50])) # working if the fan is turned on and the script starting again - while True: - print("client connection: ", client.is_connected) - await client.disconnect() - print("client connection: ", client.is_connected) - speed_input = input("Enter a value between 1-100 to set the fan speed. Enter 0 to turn off the fan (or 'x' to exit): ") - if speed_input.lower() == 'x': - break - try: - speed_value = int(speed_input) - if 1 <= speed_value <= 100: - # Convert speed value to byte and write to characteristic - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, speed_value])) - print(f"Fan speed set to {speed_value}") - elif speed_value == 0: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) - else: - print("Speed value should be between 1 and 100.") - except ValueError: - print("Invalid input. Please enter a number between 1 and 100.") - # bluetooth_callback = BluetoothCallback() - - - - - -asyncio.run(scan_and_connect()) - - -async def connect_to_device(DEVICEID, SERVICE): - if(DEVICEID != ""): - # Connecting to BLE Device - # print("DEVICEID: ",DEVICEID.address) - async with BleakClient(DEVICEID, timeout=60) as client: - print("Device ID ", DEVICEID) - for service in client.services: - # print("service: ", service) - - if (service.uuid == service_uuid): - SERVICE = service - # print("[service uuid] ", SERVICE.uuid) - - if (SERVICE != ""): - # print("SERVICE", SERVICE) - for characteristic in SERVICE.characteristics: - # if ("notify" in characteristic.properties): - # print("[Characteristic] %s", characteristic, characteristic.properties) - - if(characteristic.uuid == characteristic_uuid): - CHARACTERISTIC = characteristic - # print("CHARACTERISTIC: ", characteristic, characteristic.properties) - - if ("write-without-response" in characteristic.properties): - # while True: - print("Type CHARACTERISTIC: ", type(CHARACTERISTIC)) - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) - print("client connection: ", client.is_connected) - # await client.disconnect() - # print("client connection: ", client.is_connected) - # await asyncio.sleep(10) # keeps the connection open for 10 seconds - # print("TIMER") - # await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, 100])) - ''' - if ("notify" in characteristic.properties): - - bluetooth_callback = BluetoothCallback() - while True: - try: - - # value = await client.read_gatt_char(characteristic.uuid) - # print("Die CHARARARA iSt: ", CHARACTERISTIC, CHARACTERISTIC.properties) - # await client.start_notify(characteristic.uuid, on_notification) - await client.start_notify(characteristic.uuid, bluetooth_callback.notify_callback) - print("client connection: ", client.is_connected) - await asyncio.sleep(10) # keeps the connection open for 10 seconds - await client.stop_notify(characteristic.uuid) - - except Exception as e: - print("Error: ", e) - # run_read_loop = False - - ''' - - # await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, 50])) # working if the fan is turned on and the script starting again - while True: - print("client connection: ", client.is_connected) - await client.disconnect() - print("client connection: ", client.is_connected) - speed_input = input("Enter a value between 1-100 to set the fan speed. Enter 0 to turn off the fan (or 'x' to exit): ") - if speed_input.lower() == 'x': - break - try: - speed_value = int(speed_input) - if 1 <= speed_value <= 100: - # Convert speed value to byte and write to characteristic - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, speed_value])) - print(f"Fan speed set to {speed_value}") - elif speed_value == 0: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) - else: - print("Speed value should be between 1 and 100.") - except ValueError: - print("Invalid input. Please enter a number between 1 and 100.") - # bluetooth_callback = BluetoothCallback() +import asyncio +from bleak import BleakScanner, BleakClient +import struct + + +class BluetoothCallback: + def __init__(self): + self.received_data = 0 # Initialize with None or any default value + + async def notify_callback(self, sender, data): + # Assuming data is received from the Bluetooth device + print(data) + + ''' + if struct.pack("@h", 1) == struct.pack("h", data, 2)[0] + output = result * 0.01 + + if output < 0: + output = abs(output) + print(output) + + self.received_data = output + ''' + + +device_name = "HEADWIND BC55" # Replace with the name of your desired BLE device +DEVICE = "" + +service_uuid = "a026ee0c-0a7d-4ab3-97fa-f1500f9feb8b" +SERVICE = "" + +characteristic_uuid = "a026e038-0a7d-4ab3-97fa-f1500f9feb8b" +CHARACTERISTIC = "" + +async def scan_and_connect(): + global device_name + + global service_uuid + global SERVICE + + global characteristic_uuid + global CHARACTERISTIC + + global value_to_write + global old_value + + global is_first_entry + global run_read_loop + + stop_event = asyncio.Event() + + # Scanning and printing for BLE devices + def callback(device, advertising_data): + global DEVICEID + print(device) + if(device.name == device_name): + DEVICEID = device + stop_event.set() + + # Stops the scanning event + async with BleakScanner(callback) as scanner: + await stop_event.wait() + + if(DEVICEID != ""): + # Connecting to BLE Device + # print("DEVICEID: ",DEVICEID.address) + async with BleakClient(DEVICEID, timeout=60) as client: + print("Device ID ", DEVICEID) + for service in client.services: + # print("service: ", service) + + if (service.uuid == service_uuid): + SERVICE = service + # print("[service uuid] ", SERVICE.uuid) + + if (SERVICE != ""): + # print("SERVICE", SERVICE) + for characteristic in SERVICE.characteristics: + # if ("notify" in characteristic.properties): + # print("[Characteristic] %s", characteristic, characteristic.properties) + + if(characteristic.uuid == characteristic_uuid): + CHARACTERISTIC = characteristic + # print("CHARACTERISTIC: ", characteristic, characteristic.properties) + + if ("write-without-response" in characteristic.properties): + # while True: + print("Type CHARACTERISTIC: ", type(CHARACTERISTIC)) + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) + print("client connection: ", client.is_connected) + # await client.disconnect() + # print("client connection: ", client.is_connected) + # await asyncio.sleep(10) # keeps the connection open for 10 seconds + # print("TIMER") + # await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, 100])) + ''' + if ("notify" in characteristic.properties): + + bluetooth_callback = BluetoothCallback() + while True: + try: + + # value = await client.read_gatt_char(characteristic.uuid) + # print("Die CHARARARA iSt: ", CHARACTERISTIC, CHARACTERISTIC.properties) + # await client.start_notify(characteristic.uuid, on_notification) + await client.start_notify(characteristic.uuid, bluetooth_callback.notify_callback) + print("client connection: ", client.is_connected) + await asyncio.sleep(10) # keeps the connection open for 10 seconds + await client.stop_notify(characteristic.uuid) + + except Exception as e: + print("Error: ", e) + # run_read_loop = False + + ''' + + # await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, 50])) # working if the fan is turned on and the script starting again + while True: + print("client connection: ", client.is_connected) + await client.disconnect() + print("client connection: ", client.is_connected) + speed_input = input("Enter a value between 1-100 to set the fan speed. Enter 0 to turn off the fan (or 'x' to exit): ") + if speed_input.lower() == 'x': + break + try: + speed_value = int(speed_input) + if 1 <= speed_value <= 100: + # Convert speed value to byte and write to characteristic + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, speed_value])) + print(f"Fan speed set to {speed_value}") + elif speed_value == 0: + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) + else: + print("Speed value should be between 1 and 100.") + except ValueError: + print("Invalid input. Please enter a number between 1 and 100.") + # bluetooth_callback = BluetoothCallback() + + + + + +asyncio.run(scan_and_connect()) + + +async def connect_to_device(DEVICEID, SERVICE): + if(DEVICEID != ""): + # Connecting to BLE Device + # print("DEVICEID: ",DEVICEID.address) + async with BleakClient(DEVICEID, timeout=60) as client: + print("Device ID ", DEVICEID) + for service in client.services: + # print("service: ", service) + + if (service.uuid == service_uuid): + SERVICE = service + # print("[service uuid] ", SERVICE.uuid) + + if (SERVICE != ""): + # print("SERVICE", SERVICE) + for characteristic in SERVICE.characteristics: + # if ("notify" in characteristic.properties): + # print("[Characteristic] %s", characteristic, characteristic.properties) + + if(characteristic.uuid == characteristic_uuid): + CHARACTERISTIC = characteristic + # print("CHARACTERISTIC: ", characteristic, characteristic.properties) + + if ("write-without-response" in characteristic.properties): + # while True: + print("Type CHARACTERISTIC: ", type(CHARACTERISTIC)) + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) + print("client connection: ", client.is_connected) + # await client.disconnect() + # print("client connection: ", client.is_connected) + # await asyncio.sleep(10) # keeps the connection open for 10 seconds + # print("TIMER") + # await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, 100])) + ''' + if ("notify" in characteristic.properties): + + bluetooth_callback = BluetoothCallback() + while True: + try: + + # value = await client.read_gatt_char(characteristic.uuid) + # print("Die CHARARARA iSt: ", CHARACTERISTIC, CHARACTERISTIC.properties) + # await client.start_notify(characteristic.uuid, on_notification) + await client.start_notify(characteristic.uuid, bluetooth_callback.notify_callback) + print("client connection: ", client.is_connected) + await asyncio.sleep(10) # keeps the connection open for 10 seconds + await client.stop_notify(characteristic.uuid) + + except Exception as e: + print("Error: ", e) + # run_read_loop = False + + ''' + + # await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, 50])) # working if the fan is turned on and the script starting again + while True: + print("client connection: ", client.is_connected) + await client.disconnect() + print("client connection: ", client.is_connected) + speed_input = input("Enter a value between 1-100 to set the fan speed. Enter 0 to turn off the fan (or 'x' to exit): ") + if speed_input.lower() == 'x': + break + try: + speed_value = int(speed_input) + if 1 <= speed_value <= 100: + # Convert speed value to byte and write to characteristic + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, speed_value])) + print(f"Fan speed set to {speed_value}") + elif speed_value == 0: + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) + else: + print("Speed value should be between 1 and 100.") + except ValueError: + print("Invalid input. Please enter a number between 1 and 100.") + # bluetooth_callback = BluetoothCallback() diff --git a/archive/headwind/archive_write_headwind_with_methods.py b/archive/headwind/archive_write_headwind_with_methods.py index c364ee6..2ec7ba5 100644 --- a/archive/headwind/archive_write_headwind_with_methods.py +++ b/archive/headwind/archive_write_headwind_with_methods.py @@ -1,95 +1,95 @@ -import asyncio -from bleak import BleakScanner, BleakClient -import struct - -device_name = "HEADWIND BC55" # Replace with the name of your desired BLE device -DEVICE = "" - -service_uuid = "a026ee0c-0a7d-4ab3-97fa-f1500f9feb8b" -# SERVICE = "" - -characteristic_uuid = "a026e038-0a7d-4ab3-97fa-f1500f9feb8b" -# CHARACTERISTIC = "" - -async def scan_and_connect(): - global device_name - - global service_uuid - # global SERVICE - - global characteristic_uuid - # global CHARACTERISTIC - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - print(device) - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - await stop_event.wait() - - if(DEVICEID != ""): - while True: - speed_input = input("Enter a value between 2-100 to set the fan speed. Enter 1 to turn on the fan. Enter 0 to turn off the fan (or 'x' to exit): ") - if speed_input.lower() == 'x': - break - try: - speed_value = int(speed_input) - if 0 <= speed_value <= 100: - # Convert speed value to byte and write to characteristic - await connect_to_device(DEVICEID, service_uuid, characteristic_uuid, speed_value) - else: - print("Speed value should be between 0 and 100.") - except ValueError: - print("Invalid input. Please enter a number between 0 and 100.") - -async def connect_to_device(DEVICEID, service_uuid, characteristic_uuid, fan_speed): # fan_speed is an integer between 0-100, 0 is off, 1 is on, and every other value adjust the fan_speed - SERVICE = "" - CHARACTERISTIC = "" - - try: - async with BleakClient(DEVICEID, timeout=60) as client: - print("Device ID ", DEVICEID) - for service in client.services: - # print("service: ", service) - - if (service.uuid == service_uuid): - SERVICE = service - # print("[service uuid] ", SERVICE.uuid) - - if (SERVICE != ""): - # print("SERVICE", SERVICE) - for characteristic in SERVICE.characteristics: - # if ("notify" in characteristic.properties): - # print("[Characteristic] %s", characteristic, characteristic.properties) - - if(characteristic.uuid == characteristic_uuid): - CHARACTERISTIC = characteristic - - - # if ("write-without-response" in characteristic.properties): - try: - if(fan_speed == 1): - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) - # print("client connection: ", client.is_connected) - elif(fan_speed == 0): - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) - - elif(2 <= fan_speed <= 100 ): - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, fan_speed])) - else: - print("Speed value should be between 1 and 100.") - except ValueError: - print("Invalid input. Please enter a number between 1 and 100.") - except: - print("Client connection status: ",client.is_connected(),". Device connection failed, reconnecting...") - - +import asyncio +from bleak import BleakScanner, BleakClient +import struct + +device_name = "HEADWIND BC55" # Replace with the name of your desired BLE device +DEVICE = "" + +service_uuid = "a026ee0c-0a7d-4ab3-97fa-f1500f9feb8b" +# SERVICE = "" + +characteristic_uuid = "a026e038-0a7d-4ab3-97fa-f1500f9feb8b" +# CHARACTERISTIC = "" + +async def scan_and_connect(): + global device_name + + global service_uuid + # global SERVICE + + global characteristic_uuid + # global CHARACTERISTIC + + stop_event = asyncio.Event() + + # Scanning and printing for BLE devices + def callback(device, advertising_data): + global DEVICEID + print(device) + if(device.name == device_name): + DEVICEID = device + stop_event.set() + + + # Stops the scanning event + async with BleakScanner(callback) as scanner: + await stop_event.wait() + + if(DEVICEID != ""): + while True: + speed_input = input("Enter a value between 2-100 to set the fan speed. Enter 1 to turn on the fan. Enter 0 to turn off the fan (or 'x' to exit): ") + if speed_input.lower() == 'x': + break + try: + speed_value = int(speed_input) + if 0 <= speed_value <= 100: + # Convert speed value to byte and write to characteristic + await connect_to_device(DEVICEID, service_uuid, characteristic_uuid, speed_value) + else: + print("Speed value should be between 0 and 100.") + except ValueError: + print("Invalid input. Please enter a number between 0 and 100.") + +async def connect_to_device(DEVICEID, service_uuid, characteristic_uuid, fan_speed): # fan_speed is an integer between 0-100, 0 is off, 1 is on, and every other value adjust the fan_speed + SERVICE = "" + CHARACTERISTIC = "" + + try: + async with BleakClient(DEVICEID, timeout=60) as client: + print("Device ID ", DEVICEID) + for service in client.services: + # print("service: ", service) + + if (service.uuid == service_uuid): + SERVICE = service + # print("[service uuid] ", SERVICE.uuid) + + if (SERVICE != ""): + # print("SERVICE", SERVICE) + for characteristic in SERVICE.characteristics: + # if ("notify" in characteristic.properties): + # print("[Characteristic] %s", characteristic, characteristic.properties) + + if(characteristic.uuid == characteristic_uuid): + CHARACTERISTIC = characteristic + + + # if ("write-without-response" in characteristic.properties): + try: + if(fan_speed == 1): + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) + # print("client connection: ", client.is_connected) + elif(fan_speed == 0): + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) + + elif(2 <= fan_speed <= 100 ): + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, fan_speed])) + else: + print("Speed value should be between 1 and 100.") + except ValueError: + print("Invalid input. Please enter a number between 1 and 100.") + except: + print("Client connection status: ",client.is_connected(),". Device connection failed, reconnecting...") + + asyncio.run(scan_and_connect()) \ No newline at end of file diff --git a/archive/p100/starting_p100.py b/archive/p100/starting_p100.py index 07d8175..c8be7fd 100644 --- a/archive/p100/starting_p100.py +++ b/archive/p100/starting_p100.py @@ -1,12 +1,12 @@ -from PyP100 import PyP100 -import time - -''' -Restarting the tapo p100 plug via python to start the bicycle simulator -''' -p100 = PyP100.P100("192.168.9.173", "unitylab.hhn3@gmail.com", "Unitylab") -# p100.handshake() # deprecated -# p100.login() # deprecated -p100.turnOff() -time.sleep(5) -p100.turnOn() +from PyP100 import PyP100 +import time + +''' +Restarting the tapo p100 plug via python to start the bicycle simulator +''' +p100 = PyP100.P100("192.168.9.173", "unitylab.hhn3@gmail.com", "Unitylab") +# p100.handshake() # deprecated +# p100.login() # deprecated +p100.turnOff() +time.sleep(5) +p100.turnOn() diff --git a/archive/rizer/read_steering.py b/archive/rizer/read_steering.py index 94aec88..1517925 100644 --- a/archive/rizer/read_steering.py +++ b/archive/rizer/read_steering.py @@ -1,95 +1,95 @@ -import asyncio -from bleak import BleakScanner, BleakClient - -class BluetoothCallback: - def __init__(self): - self.received_data = 0 # Initialize with None or any default value - - async def notify_callback(self, sender, data): - data = bytearray(data) - steering = 0.0 - - if data[3] == 65: - steering = 1.0 - elif data[3] == 193: - steering = -1.0 - - self.received_data = steering - print(steering) - - -device_name = "RIZER" -DEVICEID = "" - -service_uuid = "347b0001-7635-408b-8918-8ff3949ce592" # Rizer - read steering -SERVICE = "" - -characteristic_uuid = "347b0030-7635-408b-8918-8ff3949ce592" # Rizer - read steering -CHARACTERISTIC = "" - -value_to_write = "" -old_value = "" - -async def scan_and_connect(): - global device_name - - global service_uuid - global SERVICE - - global characteristic_uuid - global CHARACTERISTIC - - global value_to_write - global old_value - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - print(device) - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - await stop_event.wait() - - if(DEVICEID != ""): - # Connecting to BLE Device - async with BleakClient(DEVICEID, timeout=120) as client: - # logger.info("Device ID ", device_id) - for service in client.services: - # print("service: ", service.properties) - - if (service.uuid == service_uuid): - SERVICE = service - print("[service uuid] ", SERVICE.uuid) - - if (SERVICE != ""): - # print("SERVICE", SERVICE) - for characteristic in SERVICE.characteristics: - # if ("notify" in characteristic.properties): - print("[Characteristic] %s", characteristic, characteristic.properties) - - if(characteristic.uuid == characteristic_uuid): - CHARACTERISTIC = characteristic - print("CHARACTERISTIC: ", characteristic, characteristic.properties) - if ("notify" in characteristic.properties): - bluetooth_callback = BluetoothCallback() - - while True: - try: - await client.start_notify(characteristic.uuid, bluetooth_callback.notify_callback) - await asyncio.sleep(10) # keeps the connection open for 10 seconds - await client.stop_notify(characteristic.uuid) - - except Exception as e: - print("Error: ", e) - - -asyncio.run(scan_and_connect()) - - - +import asyncio +from bleak import BleakScanner, BleakClient + +class BluetoothCallback: + def __init__(self): + self.received_data = 0 # Initialize with None or any default value + + async def notify_callback(self, sender, data): + data = bytearray(data) + steering = 0.0 + + if data[3] == 65: + steering = 1.0 + elif data[3] == 193: + steering = -1.0 + + self.received_data = steering + print(steering) + + +device_name = "RIZER" +DEVICEID = "" + +service_uuid = "347b0001-7635-408b-8918-8ff3949ce592" # Rizer - read steering +SERVICE = "" + +characteristic_uuid = "347b0030-7635-408b-8918-8ff3949ce592" # Rizer - read steering +CHARACTERISTIC = "" + +value_to_write = "" +old_value = "" + +async def scan_and_connect(): + global device_name + + global service_uuid + global SERVICE + + global characteristic_uuid + global CHARACTERISTIC + + global value_to_write + global old_value + + stop_event = asyncio.Event() + + # Scanning and printing for BLE devices + def callback(device, advertising_data): + global DEVICEID + print(device) + if(device.name == device_name): + DEVICEID = device + stop_event.set() + + # Stops the scanning event + async with BleakScanner(callback) as scanner: + await stop_event.wait() + + if(DEVICEID != ""): + # Connecting to BLE Device + async with BleakClient(DEVICEID, timeout=120) as client: + # logger.info("Device ID ", device_id) + for service in client.services: + # print("service: ", service.properties) + + if (service.uuid == service_uuid): + SERVICE = service + print("[service uuid] ", SERVICE.uuid) + + if (SERVICE != ""): + # print("SERVICE", SERVICE) + for characteristic in SERVICE.characteristics: + # if ("notify" in characteristic.properties): + print("[Characteristic] %s", characteristic, characteristic.properties) + + if(characteristic.uuid == characteristic_uuid): + CHARACTERISTIC = characteristic + print("CHARACTERISTIC: ", characteristic, characteristic.properties) + if ("notify" in characteristic.properties): + bluetooth_callback = BluetoothCallback() + + while True: + try: + await client.start_notify(characteristic.uuid, bluetooth_callback.notify_callback) + await asyncio.sleep(10) # keeps the connection open for 10 seconds + await client.stop_notify(characteristic.uuid) + + except Exception as e: + print("Error: ", e) + + +asyncio.run(scan_and_connect()) + + + diff --git a/archive/rizer/write_height.py b/archive/rizer/write_height.py index 94eb503..7e64f47 100644 --- a/archive/rizer/write_height.py +++ b/archive/rizer/write_height.py @@ -1,98 +1,98 @@ -import asyncio -from bleak import BleakScanner, BleakClient - -class BluetoothCallback: - def __init__(self): - self.received_data = 0 # Initialize with None or any default value - - async def notify_callback(self, sender, data): - # Assuming data is received from the Bluetooth device - print(data) - - -device_name = "RIZER" # Replace with the name of your desired BLE device -DEVICE = "" - -service_uuid = "00001800-0000-1000-8000-00805f9b34fb" -SERVICE = "" - -characteristic_uuid = "00002a04-0000-1000-8000-00805f9b34fb" -CHARACTERISTIC = "" - -async def scan_and_connect(): - global device_name - - global service_uuid - global SERVICE - - global characteristic_uuid - global CHARACTERISTIC - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - print(device) - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - await stop_event.wait() - - if(DEVICEID != ""): - # Connecting to BLE Device - async with BleakClient(DEVICEID, timeout=60) as client: - # print("Device ID ", DEVICEID) - - for service in client.services: - print("service: ", service) - for characteristic in service.characteristics: - print("Characteristics: ",characteristic) - - #### To edit - currently cant write to the characteristic - ''' - for service in client.services: - # print("service: ", service) - if (service.uuid == service_uuid): - SERVICE = service - - if (SERVICE != ""): - for characteristic in SERVICE.characteristics: - print(characteristic) - - ### - if(characteristic.uuid == characteristic_uuid): - CHARACTERISTIC = characteristic - - bluetooth_callback = BluetoothCallback() - while True: - try: - await client.start_notify(CHARACTERISTIC, bluetooth_callback.notify_callback) # characteristic.uuid - except Exception as e: - print("Error: ", e) - - speed_input = input("Enter a value between 2-100 to set the fan speed. Enter 1 to turn on the fan. Enter 0 to turn off the fan (or 'x' to exit): ") - speed_value = int(speed_input) - if speed_input.lower() == 'x': - await client.stop_notify(CHARACTERISTIC) # characteristic.uuid - await asyncio.sleep(1) - break - try: - if 2 <= speed_value <= 100: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, speed_value])) - print(f"Fan speed set to {speed_value}") - elif speed_value == 1: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) - elif speed_value == 0: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) - else: - print("Speed value should be between 1 and 100.") - except ValueError: - print("Invalid input. Please enter a number between 1 and 100.") - ''' - - +import asyncio +from bleak import BleakScanner, BleakClient + +class BluetoothCallback: + def __init__(self): + self.received_data = 0 # Initialize with None or any default value + + async def notify_callback(self, sender, data): + # Assuming data is received from the Bluetooth device + print(data) + + +device_name = "RIZER" # Replace with the name of your desired BLE device +DEVICE = "" + +service_uuid = "00001800-0000-1000-8000-00805f9b34fb" +SERVICE = "" + +characteristic_uuid = "00002a04-0000-1000-8000-00805f9b34fb" +CHARACTERISTIC = "" + +async def scan_and_connect(): + global device_name + + global service_uuid + global SERVICE + + global characteristic_uuid + global CHARACTERISTIC + + stop_event = asyncio.Event() + + # Scanning and printing for BLE devices + def callback(device, advertising_data): + global DEVICEID + print(device) + if(device.name == device_name): + DEVICEID = device + stop_event.set() + + # Stops the scanning event + async with BleakScanner(callback) as scanner: + await stop_event.wait() + + if(DEVICEID != ""): + # Connecting to BLE Device + async with BleakClient(DEVICEID, timeout=60) as client: + # print("Device ID ", DEVICEID) + + for service in client.services: + print("service: ", service) + for characteristic in service.characteristics: + print("Characteristics: ",characteristic) + + #### To edit - currently cant write to the characteristic + ''' + for service in client.services: + # print("service: ", service) + if (service.uuid == service_uuid): + SERVICE = service + + if (SERVICE != ""): + for characteristic in SERVICE.characteristics: + print(characteristic) + + ### + if(characteristic.uuid == characteristic_uuid): + CHARACTERISTIC = characteristic + + bluetooth_callback = BluetoothCallback() + while True: + try: + await client.start_notify(CHARACTERISTIC, bluetooth_callback.notify_callback) # characteristic.uuid + except Exception as e: + print("Error: ", e) + + speed_input = input("Enter a value between 2-100 to set the fan speed. Enter 1 to turn on the fan. Enter 0 to turn off the fan (or 'x' to exit): ") + speed_value = int(speed_input) + if speed_input.lower() == 'x': + await client.stop_notify(CHARACTERISTIC) # characteristic.uuid + await asyncio.sleep(1) + break + try: + if 2 <= speed_value <= 100: + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, speed_value])) + print(f"Fan speed set to {speed_value}") + elif speed_value == 1: + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) + elif speed_value == 0: + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) + else: + print("Speed value should be between 1 and 100.") + except ValueError: + print("Invalid input. Please enter a number between 1 and 100.") + ''' + + asyncio.run(scan_and_connect()) \ No newline at end of file diff --git a/collector_scripts/UDP_tester.py b/collector_scripts/UDP_tester.py new file mode 100644 index 0000000..ba889a9 --- /dev/null +++ b/collector_scripts/UDP_tester.py @@ -0,0 +1,37 @@ +import socket +import json + +def send_udp_data(ip, port, data): + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Konvertiere die Ganzzahl in Bytes + data_bytes = str(data).encode() + udp_socket.sendto(data_bytes, (ip, port)) + print(f"Gesendete Nachricht: {data} an {ip}:{port}") + +def send_udp_json_data(ip, port, data): + + json_data = { + "fanSpeed": float(data), + } + print(json_data) + # Convert dictionary to JSON string + json_data = json.dumps(json_data) + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Konvertiere die Ganzzahl in Bytes + data_bytes = str(json_data).encode() + udp_socket.sendto(data_bytes, (ip, port)) + print(f"Gesendete Nachricht: {data} an {ip}:{port}") + + +# Beispiel für die Nutzung der Funktion +if __name__ == "__main__": + # Eingaben vom Benutzer einholen + if input("rizer? ") == ("y"): + incline = int(input("incline ")) + send_udp_data("127.0.0.3", 2223, incline) + else: + ip = input("Geben Sie die IP-Adresse des Empfängers ein: ") + port = int(input("Geben Sie den Port des Empfängers ein: ")) + data = int(input("Geben Sie die zu sendende Ganzzahl ein: ")) + # UDP-Daten senden + send_udp_json_data(ip, port, data) \ No newline at end of file diff --git a/collector_scripts/direto_xr.py b/collector_scripts/direto_xr.py index 4a06e82..516abb6 100644 --- a/collector_scripts/direto_xr.py +++ b/collector_scripts/direto_xr.py @@ -1,171 +1,184 @@ -import asyncio -from bleak import BleakScanner, BleakClient, exc -import struct -import sys -import socket - - -device_name = "DIRETO XR" # Replace with the name of your desired BLE device -DEVICE = "" - -service_uuid = "00001826-0000-1000-8000-00805f9b34fb" # Direto XR -SERVICE = "" - -characteristic_resistance_uuid = "00002ad9-0000-1000-8000-00805f9b34fb" # Write Resistance -characteristic_speed_uuid = "00002ad2-0000-1000-8000-00805f9b34fb" # Read Speed - - -CHARACTERISTIC_RESISTANCE = "" -CHARACTERISTIC_SPEED = "" - - -class BluetoothCallback: - def __init__(self): - self.received_speed_data = 0 # Initialize with None or any default value - self.udp_ip = "127.0.0.1" # Send the direto data to the master_collector.py script via UDP over localhost - # self.udp_ip = "10.30.77.221" # Ip of the Bicycle Simulator Desktop PC - # self.udp_ip = "192.168.9.184" # IP of the Raspberry Pi - self.udp_port = 1111 - - async def notify_resistance_callback(self, sender, data): - # Assuming data is received from the Bluetooth device - # print(data) - test = "123" - - - async def notify_speed_callback(self, sender, data): - # Assuming data is received from the Bluetooth device - if struct.pack("@h", 1) == struct.pack("h", data, 2)[0] - output = result * 0.01 - normalized_output = normalize_speed_value(output, 0.0, 2.5) # changed from 3.5 to 2.5 for a better scaling. change it back if the value range is too small - - if output < 0: - output = abs(output) - - print("Normalized Direto Speed: ", normalized_output) - self.received_speed_data = normalized_output - self.send_speed_data_udp(self.received_speed_data) - - - def send_speed_data_udp(self, speed_data): - # Create a UDP socket - with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: - # Send speed_data - udp_socket.sendto(str(speed_data).encode(), (self.udp_ip, self.udp_port)) - - -def normalize_speed_value(value, min_val, max_val): - range_val = max_val - min_val - normalized_value = (value - min_val) / range_val - return normalized_value - - -async def write_resistance(client, characteristic): - bluetooth_callback = BluetoothCallback() - try: - await client.start_notify(characteristic, bluetooth_callback.notify_resistance_callback) # characteristic.uuid - except Exception as e: - print("Error: ", e) - # resistance_input = input("Enter a value between 1-100 to set the resistance level. (or 'x' to exit): ") - resistance_input = 60 - resistance_value = int(resistance_input) - try: - if 1 <= resistance_value <= 100: - await client.write_gatt_char(characteristic, bytearray([0x04, resistance_value])) - elif resistance_input.lower() == 'x': - await client.stop_notify(characteristic) # characteristic.uuid - await asyncio.sleep(1) - sys.exit() - except ValueError: - print("Invalid input. Please enter a number between 1 and 100.") - # print("Test resistance") - - -async def read_speed(client, characteristic): - bluetooth_callback = BluetoothCallback() - try: - # await asyncio.sleep(0.5) - await client.start_notify(characteristic, bluetooth_callback.notify_speed_callback) - await asyncio.sleep(10) # keeps the connection open for 10 seconds - await client.stop_notify(characteristic.uuid) - # print("Test speed") - - except Exception as e: - print("Error: ", e) - - - -async def scan_and_connect_direto(): - global device_name - - global service_uuid - global SERVICE - - global characteristic_resistance_uuid - global characteristic_speed_uuid - - global CHARACTERISTIC_RESISTANCE - global CHARACTERISTIC_SPEED - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - # print(device) - # print("Test direto") - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - # new - ''' - try: - await stop_event.wait() - except KeyboardInterrupt: - print("Scanning stopped by user.") - scanner.stop() - # new end - ''' - await stop_event.wait() - - if(DEVICEID != ""): - client_is_connected = False - while(client_is_connected == False): - - try: - async with BleakClient(DEVICEID, timeout=90) as client: - client_is_connected = True - print("Client connected to ", DEVICEID.name) - # print("Device ID ", DEVICEID) - for service in client.services: - - if (service.uuid == service_uuid): - SERVICE = service - - if (SERVICE != ""): - for characteristic in SERVICE.characteristics: - if("write" in characteristic.properties and characteristic.uuid == characteristic_resistance_uuid): - CHARACTERISTIC_RESISTANCE = characteristic - # print("Characteristic resistance: ",CHARACTERISTIC_RESISTANCE) - - if("notify" in characteristic.properties and characteristic.uuid == characteristic_speed_uuid): - CHARACTERISTIC_SPEED = characteristic - # print("Characteristic speed: ",CHARACTERISTIC_SPEED) - - while True: - await write_resistance(client, CHARACTERISTIC_RESISTANCE) - await read_speed(client, CHARACTERISTIC_SPEED) - except exc.BleakError as e: - print(f"Failed to connect/discover services of {DEVICEID.name}: {e}") - # Add additional error handling or logging as needed - # raise - - - +import asyncio +from bleak import BleakScanner, BleakClient, exc +import struct +import sys +import socket +import json +import time + +device_name = "DIRETO XR" # Replace with the name of your desired BLE device +DEVICE = "" + +service_uuid = "00001826-0000-1000-8000-00805f9b34fb" # Direto XR +SERVICE = "" + +characteristic_resistance_uuid = "00002ad9-0000-1000-8000-00805f9b34fb" # Write Resistance +characteristic_speed_uuid = "00002ad2-0000-1000-8000-00805f9b34fb" # Read Speed + +CHARACTERISTIC_RESISTANCE = "" +CHARACTERISTIC_SPEED = "" + +UDP_IP_FROM_MASTER_COLLECTOR = "127.0.0.3" +RECEIVE_FROM_MASTER_COLLECTOR_PORT = 2225 + + +class BluetoothCallback: + def __init__(self): + self.received_speed_data = 0 # Initialize with None or any default value + self.udp_ip = "127.0.0.1" # Send the direto data to the master_collector.py script via UDP over localhost + # self.udp_ip = "10.30.77.221" # Ip of the Bicycle Simulator Desktop PC + # self.udp_ip = "192.168.9.184" # IP of the Raspberry Pi + self.udp_port = 1111 + + async def notify_resistance_callback(self, sender, data): + # Assuming data is received from the Bluetooth device + # print(data) + test = "123" + + + async def notify_speed_callback(self, sender, data): + # Assuming data is received from the Bluetooth device + if struct.pack("@h", 1) == struct.pack("h", data, 2)[0] + output = result * 0.01 + normalized_output = normalize_speed_value(output, 0.0, 2.5) # changed from 3.5 to 2.5 for a better scaling. change it back if the value range is too small + + if output < 0: + output = abs(output) + + print("Normalized Direto Speed: ", normalized_output) + self.received_speed_data = normalized_output + self.send_speed_data_udp(self.received_speed_data) + + + def send_speed_data_udp(self, speed_data): + # Create a UDP socket + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Send speed_data + udp_socket.sendto(str(speed_data).encode(), (self.udp_ip, self.udp_port)) + + +def normalize_speed_value(value, min_val, max_val): + range_val = max_val - min_val + normalized_value = (value - min_val) / range_val + return normalized_value + + +async def write_resistance(client, characteristic, resistance_value): + bluetooth_callback = BluetoothCallback() + try: + await client.start_notify(characteristic, bluetooth_callback.notify_resistance_callback) # characteristic.uuid + except Exception as e: + print("Error: ", e) + # resistance_input = input("Enter a value between 1-100 to set the resistance level. (or 'x' to exit): ") + resistance_value = int(resistance_value) + try: + #if 1 <= resistance_value <= 100: + resistance_value = min(resistance_value, 100) + resistance_value = max(resistance_value, 0) + print("write Resistance: ", resistance_value) + await client.write_gatt_char(characteristic, bytearray([0x04, resistance_value])) + # elif resistance_value.lower() == 'x': + # await client.stop_notify(characteristic) # characteristic.uuid + # await asyncio.sleep(1) + # sys.exit() + except ValueError: + print("Invalid input. Please enter a number between 1 and 100.") + # print("Test resistance") + + +async def read_speed(client, characteristic): + bluetooth_callback = BluetoothCallback() + try: + # await asyncio.sleep(0.5) + await client.start_notify(characteristic, bluetooth_callback.notify_speed_callback) + await asyncio.sleep(10) # keeps the connection open for 10 seconds + await client.stop_notify(characteristic.uuid) + # print("Test speed") + + except Exception as e: + print("Error: ", e) + + + +async def scan_and_connect_direto(): + global device_name + + global service_uuid + global SERVICE + + global characteristic_resistance_uuid + global characteristic_speed_uuid + + global CHARACTERISTIC_RESISTANCE + global CHARACTERISTIC_SPEED + + resistance_value = 0 + + stop_event = asyncio.Event() + + # Scanning and printing for BLE devices + def callback(device, advertising_data): + global DEVICEID + # print(device) + # print("Test direto") + if(device.name == device_name): + DEVICEID = device + stop_event.set() + + # Stops the scanning event + async with BleakScanner(callback) as scanner: + await stop_event.wait() + + if(DEVICEID != ""): + client_is_connected = False + while(client_is_connected == False): + + try: + async with BleakClient(DEVICEID, timeout=90) as client: + client_is_connected = True + print("Client connected to ", DEVICEID.name) + # print("Device ID ", DEVICEID) + for service in client.services: + + if (service.uuid == service_uuid): + SERVICE = service + + if (SERVICE != ""): + for characteristic in SERVICE.characteristics: + if("write" in characteristic.properties and characteristic.uuid == characteristic_resistance_uuid): + CHARACTERISTIC_RESISTANCE = characteristic + # print("Characteristic resistance: ",CHARACTERISTIC_RESISTANCE) + + if("notify" in characteristic.properties and characteristic.uuid == characteristic_speed_uuid): + CHARACTERISTIC_SPEED = characteristic + # print("Characteristic speed: ",CHARACTERISTIC_SPEED) + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + udp_socket.bind((UDP_IP_FROM_MASTER_COLLECTOR, RECEIVE_FROM_MASTER_COLLECTOR_PORT)) + udp_socket.setblocking(False) + while True: + try: + while True: + try: + resistance_data, addr = udp_socket.recvfrom(47) + sender_ip, sender_port = addr + print(f"Received message: {resistance_data.decode()} from {sender_ip}:{sender_port}") + resistance_data = json.loads(resistance_data.decode()) + resistance_value = int(resistance_data["diretoResistance"]) # Extract the sender's IP and port from addr + except BlockingIOError: + break + + except BlockingIOError: + time.sleep(0.01) # Small sleep to prevent busy-waiting + await write_resistance(client, CHARACTERISTIC_RESISTANCE, resistance_value) + await read_speed(client, CHARACTERISTIC_SPEED) + except exc.BleakError as e: + print(f"Failed to connect/discover services of {DEVICEID.name}: {e}") + # Add additional error handling or logging as needed + # raise + + + asyncio.run(scan_and_connect_direto()) \ No newline at end of file diff --git a/collector_scripts/elite_rizer.py b/collector_scripts/elite_rizer.py index 8855b64..20a92fd 100644 --- a/collector_scripts/elite_rizer.py +++ b/collector_scripts/elite_rizer.py @@ -1,126 +1,228 @@ -import asyncio -from bleak import BleakScanner, BleakClient, exc -import socket - -device_name = "RIZER" -DEVICEID = "" - -service_uuid = "347b0001-7635-408b-8918-8ff3949ce592" # Rizer - read steering -SERVICE = "" - -characteristic_steering_uuid = "347b0030-7635-408b-8918-8ff3949ce592" # Rizer - read steering -CHARACTERISTIC_STEERING = "" - - -class BluetoothCallback: - def __init__(self): - self.received_steering_data = 0 # Initialize with None or any default value - self.udp_ip = "127.0.0.1" # Send the rizer data to the master_collector.py script via UDP over localhost - # self.udp_ip = "10.30.77.221" # Ip of the Bicycle Simulator Desktop PC - # self.udp_ip = "192.168.9.184" # IP of the Raspberry Pi - self.udp_port = 2222 - - - async def notify_steering_callback(self, sender, data): - data = bytearray(data) - steering = 0.0 - - if data[3] == 65: - steering = 1.0 - elif data[3] == 193: - steering = -1.0 - - self.received_steering_data = steering - print(self.received_steering_data) - - self.send_steering_data_udp(self.received_steering_data) - - - def send_steering_data_udp(self, steering_data): - # Create a UDP socket - # print(steering_data) - with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: - # Send speed_data - udp_socket.sendto(str(steering_data).encode(), (self.udp_ip, self.udp_port)) - -async def read_steering(client, characteristic): - bluetooth_callback = BluetoothCallback() - try: - await client.start_notify(characteristic, bluetooth_callback.notify_steering_callback) - await asyncio.sleep(10) # keeps the connection open for 10 seconds - await client.stop_notify(characteristic.uuid) - # print("Test steering") - except Exception as e: - print("Error: ", e) - - - -async def scan_and_connect_rizer(): - global device_name - - global service_uuid - global SERVICE - - global characteristic_steering_uuid - global CHARACTERISTIC_STEERING - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - # print(device) - # print("Test rizer") - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - ''' - try: - await stop_event.wait() - except KeyboardInterrupt: - print("Scanning stopped by user.") - scanner.stop() - ''' - await stop_event.wait() - - if(DEVICEID != ""): - # Connecting to BLE Device - client_is_connected = False - while(client_is_connected == False): - try: - async with BleakClient(DEVICEID, timeout=90) as client: - client_is_connected = True - print("Client connected to ", DEVICEID.name) - # return True - # logger.info("Device ID ", device_id) - for service in client.services: - # print("service: ", service) - - if (service.uuid == service_uuid): - SERVICE = service - # print("[service uuid] ", SERVICE.uuid) - - if (SERVICE != ""): - # print("SERVICE", SERVICE) - for characteristic in SERVICE.characteristics: - - if("notify" in characteristic.properties and characteristic.uuid == characteristic_steering_uuid): - CHARACTERISTIC_STEERING = characteristic - # print("CHARACTERISTIC: ", CHARACTERISTIC_STEERING, characteristic.properties) - - - while True: - await read_steering(client, CHARACTERISTIC_STEERING) - except exc.BleakError as e: - print(f"Failed to connect/discover services of {DEVICEID.name}: {e}") - # Add additional error handling or logging as needed - # raise - -asyncio.run(scan_and_connect_rizer()) - - - - +import asyncio +from bleak import BleakClient, exc +import socket +import time +import json + +class Rizer: + #BLE constant + DEVICE_NAME = "RIZER" + DEVICE_UUID = "fc:12:65:28:cb:44" + + SERVICE_STEERING_UUID = "347b0001-7635-408b-8918-8ff3949ce592" # Rizer - read steering + SERVICE_INCLINE_UUID = "347b0001-7635-408b-8918-8ff3949ce592" + + INCREASE_INCLINE_HEX = "060102" + DECREASE_INCLINE_HEX = "060402" + + CHARACTERISTICS_STEERING_UUID = "347b0030-7635-408b-8918-8ff3949ce592" # Rizer - read steering + CHARACTERISTIC_INCLINE_UUID = "347b0020-7635-408b-8918-8ff3949ce592" # write tilt + + #UDP constant + UDP_IP_TO_MASTER_COLLECTOR = "127.0.0.1" # Send the rizer data to the master_collector.py script via UDP over localhost + UDP_IP_FROM_MASTER_COLLECTOR = "127.0.0.3" + udp_port = 2222 + RECEIVE_FROM_MASTER_COLLECTOR_PORT = 2223 + + _incline_value = 0 + incline_rate = 1 + incline_timer = 0 + + + + def __init__(self) -> None: + # UDP initialization + self.received_steering_data = 0 # Initialize with None or any default value + self.client_is_connected = False + + + self.current_incline_on_rizer = int(0) + self.udp_ip = "127.0.0.1" # Send the rizer data to the master_collector.py script via UDP over localhost + # self.udp_ip = "10.30.77.221" # Ip of the Bicycle Simulator Desktop PC + # self.udp_ip = "192.168.9.184" # IP of the Raspberry Pi + self.udp_port = 2222 + print("init") + + async def main(self): + print("main") + incline_value = 0 + + # create UDP socket to receive data from master collector + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + udp_socket.bind((self.UDP_IP_FROM_MASTER_COLLECTOR, self.RECEIVE_FROM_MASTER_COLLECTOR_PORT)) + udp_socket.setblocking(False) # Set the socket to non-blocking mode | without this flag it waits until it gets data + await self.connect_rizer() #connect to the Rizer + while(True): + # Receive data from the socket + try: + udp_incline_data = 0 + while True: + try: + udp_incline_data, addr = udp_socket.recvfrom(47) + sender_ip, sender_port = addr + print(f"Received message: {udp_incline_data.decode()} from {sender_ip}:{sender_port}") + incline_value = json.loads(udp_incline_data.decode()) + incline_value = int(incline_value["rizerIncline"]) # Extract the sender's IP and port from addr + except BlockingIOError: + break + + + except BlockingIOError: + time.sleep(0.01) # Small sleep to prevent busy-waiting + + + await self.write_incline() #write the new incline value to the Rizer + + self.set_incline_value(incline_value) + if self.check_new_incline(incline_value): #check if the incline value has changed + await self.write_incline() #write the new incline value to the Rizer + + await self.read_steering() #read steering over BLE ONLY WORKING with master_collector script!!! + + +#---------------------------UDP functions-------------------------------- + #send steering data over udp + def send_steering_data_udp(self, steering_data): + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Send steering_data + udp_socket.sendto(str(steering_data).encode(), (self.UDP_IP_TO_MASTER_COLLECTOR, self.udp_port)) + + #receive incline data over udp + async def receive_incline_data_udp(self): + udp_incline_data = 0 + # Set up the UDP socket + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Bind the socket to the IP and port + udp_socket.bind((self.UDP_IP_TO_MASTER_COLLECTOR, self.RECEIVE_FROM_MASTER_COLLECTOR_PORT)) + print("Hello: ", udp_incline_data) + self.incline_value = udp_incline_data + + + +#---------------------------BLE functions-------------------------------- + #function to initialize the BLE connection with the Rizer + async def connect_rizer(self): + print("start async init") + while not self.client_is_connected: + try: + self.client = BleakClient(self.DEVICE_UUID, timeout=90) + print("try to connect") + await self.client.connect() + self.client_is_connected = True + print("Client connected to ", self.DEVICE_UUID) + for service in self.client.services: + if (service.uuid == self.SERVICE_STEERING_UUID): + self.steering_service = service + print("[service uuid] ", self.steering_service.uuid) + + if (self.steering_service != ""): + # print("SERVICE", SERVICE) + for characteristic in self.steering_service.characteristics: + + if("notify" in characteristic.properties and characteristic.uuid == self.CHARACTERISTICS_STEERING_UUID): + self.steering_characteristics = characteristic + # print("CHARACTERISTIC: ", CHARACTERISTIC_STEERING, characteristic.properties) + + #print("steering ready", self.steering_ready) + self.steering_ready = 1 + + if (service.uuid == self.SERVICE_INCLINE_UUID): + self.incline_service = service + print("[service uuid] ", self.incline_service.uuid) + + if (self.incline_service != ""): + for characteristic in self.incline_service.characteristics: + + print("characteristics UUID: ", characteristic.uuid) + if("notify" in characteristic.properties and characteristic.uuid == self.CHARACTERISTIC_INCLINE_UUID): + self.incline_characteristics = characteristic + self.incline_ready = 1 + + if (self.steering_ready == 1 and self.incline_ready == 1): + print("all ready!") + self.init_ack = True + + except exc.BleakError as e: + print(f"Failed to connect/discover services of {self.DEVICE_UUID}: {e}") + # Add additional error handling or logging as needed + # raise + + #write incline to rizer over ble and store the value of his state + async def write_incline(self): + incline = self.get_incline_value() + incline = int(incline) + #print("current incline: ", int(self.current_incline_on_rizer), " Incline: ", int(incline) ) + #incline_different_temp = int(incline) - int(self.current_incline_on_rizer) #absolute difference of old and new incline value + #incline_different = abs(incline_different_temp) + #print("incline_difference: ", incline_different) + # print("Incline: ", incline, " current Incline: ", current_incline_on_rizer) + + if((int(incline) - int(self.current_incline_on_rizer)) > 0): + #for x in range (incline_different): + try: + await self.client.write_gatt_char(self.CHARACTERISTIC_INCLINE_UUID, bytes.fromhex(self.INCREASE_INCLINE_HEX), response=True) + self.current_incline_on_rizer += 1 + #self.incline_received = 0 + #print("incline written, x ", x) + except Exception as e: + print("Error: ", e) + else: + #for x in range (incline_different): + try: + await self.client.write_gatt_char(self.CHARACTERISTIC_INCLINE_UUID, bytes.fromhex(self.DECREASE_INCLINE_HEX), response=True) + self.current_incline_on_rizer += -1 + #self.incline_received = 0 + #print("incline written, x -", x) + except Exception as e: + print("Error: ", e) + + #read steering from the Rizer + async def read_steering(self): + data = bytearray(8) + sender = 0 + try: + await self.client.start_notify(self.steering_characteristics, self.notify_steering_callback) + # Access the notification data using data argument + # print(f"Steering data: {sender}") + # print(f"Steering data: {data}") + await asyncio.sleep(0.1) # keeps the connection open for 10 seconds + await self.client.stop_notify(self.steering_characteristics.uuid) + except Exception as e: + print("Error: ", e) + + + +#---------------------------Utility functions-------------------------------- + def set_incline_value(self, incline): + incline = min(int(incline), 40) + incline = max(int(incline), -20) + self._incline_value = incline + + def get_incline_value(self): + return self._incline_value + + async def notify_steering_callback(self, sender, data): + data = bytearray(data) + steering = 0.0 + + #we get this random values who stands for -1; 0 or 1 + if data[3] == 65: + steering = 1.0 + elif data[3] == 193: + steering = -1.0 + + self.received_steering_data = steering + print(self.received_steering_data) + + self.send_steering_data_udp(self.received_steering_data) + + #check if rizer alredy arrived position + def check_new_incline(self, new_inline_udp): + if self.current_incline_on_rizer != new_inline_udp: + print("incline value write BLE: ", self.get_incline_value()) + return True + else: + return False + +rizer = Rizer() +asyncio.run(rizer.main()) \ No newline at end of file diff --git a/collector_scripts/headwind.py b/collector_scripts/headwind.py index 6c4244e..da906bb 100644 --- a/collector_scripts/headwind.py +++ b/collector_scripts/headwind.py @@ -1,121 +1,153 @@ -import asyncio -from bleak import BleakScanner, BleakClient, exc -from master_collector import DataReceiver - -class BluetoothCallback: - def __init__(self): - self.received_data = 0 # Initialize with None or any default value - - async def notify_callback(self, sender, data): - # Assuming data is received from the Bluetooth device - # print(data) - test = "123" - - -device_name = "HEADWIND BC55" # Replace with the name of your desired BLE device -DEVICE = "" - -service_uuid = "a026ee0c-0a7d-4ab3-97fa-f1500f9feb8b" -SERVICE = "" - -characteristic_uuid = "a026e038-0a7d-4ab3-97fa-f1500f9feb8b" -CHARACTERISTIC = "" - -async def scan_and_connect_headwind(): - global device_name - - global service_uuid - global SERVICE - - global characteristic_uuid - global CHARACTERISTIC - - global value_to_write - global old_value - - global is_first_entry - global run_read_loop - - stop_event = asyncio.Event() - - # Scanning and printing for BLE devices - def callback(device, advertising_data): - global DEVICEID - print(device) - if(device.name == device_name): - DEVICEID = device - stop_event.set() - - # Stops the scanning event - async with BleakScanner(callback) as scanner: - # new - try: - await stop_event.wait() - except KeyboardInterrupt: - print("Scanning stopped by user.") - scanner.stop() - # new end - # old############ - await stop_event.wait() - # old############ - - if(DEVICEID != ""): - client_is_connected = False - while(client_is_connected == False): - try: - async with BleakClient(DEVICEID, timeout=90) as client: - client_is_connected = True - print("Client connected to ", DEVICEID.name) - # print("Device ID ", DEVICEID) - for service in client.services: - - if (service.uuid == service_uuid): - SERVICE = service - - if (SERVICE != ""): - for characteristic in SERVICE.characteristics: - - if(characteristic.uuid == characteristic_uuid): - CHARACTERISTIC = characteristic - - receiver = DataReceiver() - bluetooth_callback = BluetoothCallback() - receiver.open_udp_socket() - while True: - - try: - receiver.start_udp_listener() - # print("FAN SPEED: ", receiver.get_fan_speed()) - speed_value = receiver.get_fan_speed() - except Exception as e: - print("Error: ", e) - try: - await client.start_notify(CHARACTERISTIC, bluetooth_callback.notify_callback) # characteristic.uuid - except Exception as e: - print("Error: ", e) - - ''' Test - receiver.start_udp_listener() - try: - receiver.listen_for_udp_data() - except KeyboardInterrupt: - receiver.stop_udp_listener() - ''' - try: - if 2 <= speed_value <= 100: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, speed_value])) - print(f"Fan speed set to {speed_value}") - elif speed_value == 1: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) - elif speed_value == 0: - await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) - else: - print("Speed value should be between 1 and 100.") - except ValueError: - print("Invalid input. Please enter a number between 1 and 100.") - except exc.BleakError as e: - print(f"Failed to connect/discover services of {DEVICEID.name}: {e}") - # Add additional error handling or logging as needed - # raise - -asyncio.run(scan_and_connect_headwind()) \ No newline at end of file +import asyncio +from bleak import BleakScanner, BleakClient, exc +from master_collector import DataReceiver +import socket +import json +import select +import time + +class BluetoothCallback(): + def __init__(self): + self.received_data = 0 # Initialize with None or any default value + + async def notify_callback(self, sender, data): + # Assuming data is received from the Bluetooth device + # print(data) + test = "123" + + +device_name = "HEADWIND BC55" # Replace with the name of your desired BLE device +DEVICE = "" + +service_uuid = "a026ee0c-0a7d-4ab3-97fa-f1500f9feb8b" +SERVICE = "" + +characteristic_uuid = "a026e038-0a7d-4ab3-97fa-f1500f9feb8b" +CHARACTERISTIC = "" + +UDP_IP_FROM_MASTER_COLLECTOR = "127.0.0.3" +RECEIVE_FROM_MASTER_COLLECTOR_PORT = 2224 + +async def scan_and_connect_headwind(): + global device_name + + global service_uuid + global SERVICE + + global characteristic_uuid + global CHARACTERISTIC + + global value_to_write + global old_value + + global is_first_entry + global run_read_loop + + speed_value = 0 + + stop_event = asyncio.Event() + + # Scanning and printing for BLE devices + def callback(device, advertising_data): + global DEVICEID + + print(device) + if(device.name == device_name): + DEVICEID = device + stop_event.set() + + # Stops the scanning event + async with BleakScanner(callback) as scanner: + # new + try: + await stop_event.wait() + except KeyboardInterrupt: + print("Scanning stopped by user.") + scanner.stop() + # new end + # old############ + await stop_event.wait() + # old############ + + if(DEVICEID != ""): + client_is_connected = False + while(client_is_connected == False): + try: + async with BleakClient(DEVICEID, timeout=90) as client: + client_is_connected = True + print("Client connected to ", DEVICEID.name) + # print("Device ID ", DEVICEID) + for service in client.services: + + if (service.uuid == service_uuid): + SERVICE = service + + if (SERVICE != ""): + for characteristic in SERVICE.characteristics: + + if(characteristic.uuid == characteristic_uuid): + CHARACTERISTIC = characteristic + + #receiver = DataReceiver() + #print("rizer id: ", id(receiver)) + + bluetooth_callback = BluetoothCallback() + #receiver.open_udp_socket() + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + udp_socket.bind((UDP_IP_FROM_MASTER_COLLECTOR, RECEIVE_FROM_MASTER_COLLECTOR_PORT)) + udp_socket.setblocking(False) #without this flag it waits until it gets data + while True: + try: + while True: + try: + ble_fan_data, addr = udp_socket.recvfrom(47) + sender_ip, sender_port = addr + print(f"Received message: {ble_fan_data.decode()} from {sender_ip}:{sender_port}") # Extract the sender's IP and port from addr + print("ble fan data: ", ble_fan_data) + ble_fan_value = json.loads(ble_fan_data.decode()) + print("decoded fan value ", ble_fan_value) + speed_value = int(ble_fan_value["fanSpeed"]) + + print("ble_fan_value: ", ble_fan_value) + print("value: ", speed_value) + except BlockingIOError: + break + + except BlockingIOError: + time.sleep(0.01) # Small sleep to prevent busy-waiting + except Exception as e: + print("Error: ", e) + try: + await client.start_notify(CHARACTERISTIC, bluetooth_callback.notify_callback) # characteristic.uuid + except Exception as e: + print("Error: ", e) + + try: + if 2 <= speed_value <= 100: #TODO we have to write 1 before we can write some other values + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x02, speed_value])) + print(f"Fan speed set to {speed_value}") + elif speed_value == 1: + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x04])) # Turns fan on -> bytearray([0x04, 0x04]), Turns fan off -> bytearray([0x04, 0x01]), Adjust fan Speed -> bytearray([0x02, ]) + elif speed_value == 0: + await client.write_gatt_char(CHARACTERISTIC, bytearray([0x04, 0x01])) + else: + print("Speed value should be between 1 and 100.") + except ValueError: + print("Invalid input. Please enter a number between 1 and 100.") + + except exc.BleakError as e: + print(f"Failed to connect/discover services of {DEVICEID.name}: {e}") + # Add additional error handling or logging as needed + # raise + +try: + asyncio.run(scan_and_connect_headwind()) +except BaseException: + import sys + print(sys.exc_info()[0]) + import traceback + print(traceback.format_exc()) +finally: + print("Press Enter to continue ...") + input() + diff --git a/collector_scripts/master_collector.py b/collector_scripts/master_collector.py index 5d97867..2754336 100644 --- a/collector_scripts/master_collector.py +++ b/collector_scripts/master_collector.py @@ -1,184 +1,209 @@ -import asyncio -import socket -import select -import json - -class DataSender: - def __init__(self): - self.speed_value = 0 - self.steering_value = 0 - self.brake_value = 0 - self.bno_value = 0 - self.roll_value = 0 - self.udp_unity_send_ip = "127.0.0.2" # IP of the computer running Unity (just the localhost ip if the script is running on the same computer than the simulation) - # self.udp_unity_send_ip = "10.30.77.221" # IP of the computer running Unity - self.udp_unity_send_port = 1337 - - def collect_speed(self, speed): - self.speed_value = speed - - def collect_steering(self, steering): - self.steering_value = steering - - def collect_brake(self, brake): - self.brake_value = brake - - def collect_bno(self, bno): - self.bno_value = bno - - def collect_roll(self, roll): - self.roll_value = roll - - def send_unity_data_udp(self, speed_data, steering_data, brake_data, bno_data, roll_data): - - - # Create a dictionary with the required parameters - data = { - "diretoSpeed": float(speed_data), - "rizerSteering": float(steering_data), - "espBno": float(bno_data), - "espBrake": float(brake_data), - "espRoll": float(roll_data) - } - print(data) - # Convert dictionary to JSON string - json_data = json.dumps(data) - - # Create a UDP socket - with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: - # Send JSON data - udp_socket.sendto(json_data.encode(), (self.udp_unity_send_ip, self.udp_unity_send_port)) - - -# This class might be to be located in the headwind script -class DataReceiver: - def __init__(self): - # self.udp_unity_receive_ip = "127.0.0.1" - # self.udp_unity_receive_port = 12345 - self.udp_unity_receive_socket = None - self.ble_fan_speed = 0 - - - def get_fan_speed(self): - print("Self ble fan speed: ", self.ble_fan_speed) - return self.ble_fan_speed - - def open_udp_socket(self): - # Create a UDP socket - udp_unity_receive_ip = "127.0.0.1" - udp_unity_receive_port = 12345 - - self.udp_unity_receive_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.udp_unity_receive_socket.bind((udp_unity_receive_ip, udp_unity_receive_port)) - - print("Listening for UDP data...") - - def start_udp_listener(self): - # Infinite loop to continuously receive data - try: - data, addr = self.udp_unity_receive_socket.recvfrom(1024) # Buffer size is 1024 bytes - - json_data = data.decode('utf-8') # Decode bytes to string - # value = json.loads(data.decode()) - unity_values = json.loads(json_data) - ble_fan_value = unity_values["bleFan"] - # print("ble fan from unity: ", ble_fan_value) - self.ble_fan_speed = ble_fan_value - except Exception as e: - print(f"Error while receiving UDP data: {e}") - - def stop_udp_listener(self): - if self.udp_unity_receive_socket: - self.udp_unity_receive_socket.close() - print("UDP listener stopped.") - - - -if __name__ == "__main__": - ''' - try: - data_receiver.start_udp_listener() - except KeyboardInterrupt: - print("\nKeyboardInterrupt received. Stopping the loop.") - finally: - pass - # udp_unity_receive_socket.close() - ''' - data_sender = DataSender() - - print("Master Collector script started...") - # IP adresses to receive data from actuators and sensors - UDP_IP = "127.0.0.1" # IP to receive data from elite_rizer.py as well as from direto_xr.py scripts via UDP - # UDP_IP_UNITY_RECEIVE = "127.0.0.1" # Receives Data from unity such as the ble fan data - UDP_ESP_IP = "10.30.77.221" # External IP of the computer running this script to receive data from ESP32 -> Bicycle Simulator Desktop PC - # UDP_ESP_IP = "192.168.9.184" # Raspberry Pi 3 - # UDP_ESP_IP = "192.168.9.198" # Raspberry Pi 5 - - # ports to receive data from actuators and sensors - UDP_PORT_DIRETO = 1111 - UDP_PORT_RIZER = 2222 - UDP_PORT_ROLL = 6666 - UDP_PORT_BRAKE = 7777 - UDP_PORT_BNO = 8888 - # UDP_PORT_UNITY_RECEIVE = 12345 # Port to receive data from unity such as the ble fan data - - - udp_rizer_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - udp_rizer_socket.bind((UDP_IP, UDP_PORT_RIZER)) - - udp_direto_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - udp_direto_socket.bind((UDP_IP, UDP_PORT_DIRETO)) - - udp_brake_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - udp_brake_socket.bind((UDP_ESP_IP, UDP_PORT_BRAKE)) - - udp_bno_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - udp_bno_socket.bind((UDP_ESP_IP, UDP_PORT_BNO)) - - udp_roll_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - udp_roll_socket.bind((UDP_ESP_IP, UDP_PORT_ROLL)) - - # udp_unity_receive_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - # udp_unity_receive_socket.bind((UDP_IP_UNITY_RECEIVE, UDP_PORT_UNITY_RECEIVE)) - - - - while True: - # print("udp_direto_socket: ", udp_direto_socket) - data_sender.send_unity_data_udp(data_sender.speed_value, data_sender.steering_value, data_sender.brake_value, data_sender.bno_value, data_sender.roll_value) - readable, _, _ = select.select([udp_rizer_socket, udp_direto_socket, udp_brake_socket, udp_bno_socket, udp_roll_socket], [], []) - - for sock in readable: - data, addr = sock.recvfrom(1024) - if sock is udp_rizer_socket: - steering_value = data.decode() - # print("steering: ", steering_value) - data_sender.collect_steering(steering_value) - elif sock is udp_direto_socket: - speed_value = data.decode() - # print("SPEED: ", speed_value) - data_sender.collect_speed(speed_value) - elif sock is udp_brake_socket: - brake_value = json.loads(data.decode()) - brake_value = brake_value["sensor_value"] - # print("Brake_value: ", brake_value) - data_sender.collect_brake(brake_value) - elif sock is udp_bno_socket: - bno_value = json.loads(data.decode()) - bno_value = bno_value["euler_r"] - # print("BNO_Value: ", bno_value) - data_sender.collect_bno(bno_value) - elif sock is udp_roll_socket: - roll_value = json.loads(data.decode()) - # print("Roll_Value: ", roll_value) - roll_value = roll_value["sensor_value"] - data_sender.collect_roll(roll_value) - ''' - elif sock is udp_unity_receive_socket: - json_data = data.decode('utf-8') # Decode bytes to string - # value = json.loads(data.decode()) - unity_values = json.loads(json_data) - ble_fan_value = unity_values["bleFan"] - print("ble fan from unity: ", ble_fan_value) - ''' - +import asyncio +import socket +import select +import json +import time + +class DataSender: + def __init__(self): + self.speed_value = 0 + self.steering_value = 0 + self.brake_value = 0 + self.bno_value = 0 + self.roll_value = 0 + self.usingOldVersion = 0 + self.udp_unity_send_ip = "127.0.0.2" # IP of the computer running Unity (just the localhost ip if the script is running on the same computer than the simulation) + # self.udp_unity_send_ip = "10.30.77.221" # IP of the computer running Unity + self.udp_unity_send_port = 1337 + + def collect_speed(self, speed): + self.speed_value = speed + + def collect_steering(self, steering): + self.steering_value = steering + + def collect_brake(self, brake): + self.brake_value = brake + + def collect_bno(self, bno): + self.bno_value = bno + + def collect_roll(self, roll): + self.roll_value = roll + + def send_unity_data_udp(self, speed_data, steering_data, brake_data, bno_data, roll_data, usingOldVesion): + + + # Create a dictionary with the required parameters + data = { + "diretoSpeed": float(speed_data), + "rizerSteering": float(steering_data), + "espBno": float(bno_data), + "espBrake": float(brake_data), + "espRoll": float(roll_data), + "usingOldVersion": int(usingOldVesion) + } + print(data) + # Convert dictionary to JSON string + json_data = json.dumps(data) + + # Create a UDP socket + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Send JSON data + udp_socket.sendto(json_data.encode(), (self.udp_unity_send_ip, self.udp_unity_send_port)) + + +# This class might be to be located in the headwind script +class DataReceiver: + def __init__(self): + self.ble_fan_speed = 0 + self.ble_incline = 40 + self.ble_resistance = 0 + self.ble_resistance = 0 + self.send_to_actuator_ip = "127.0.0.3" + self.send_to_rizer_port = 2223 + self.send_to_headwind_port = 2224 + self.send_to_direto_port = 2225 + + def set_ble_fan_speed(self, fan_speed): + self.ble_fan_speed = fan_speed + + def set_ble_incline(self, incline_data): + self.ble_incline = incline_data + print("Self incline data: ", self.ble_incline) + + def get_fan_speed(self): + #global ble_fan_speed + print("Self ble fan speed: ", self.ble_fan_speed) + return self.ble_fan_speed + + def get_incline(self): + print("Self ble incline: ", self.ble_incline) + return self.ble_incline + + def get_resistance(self): + #global ble_resistance + print("Self ble resistance: ", self.ble_resistance) + return self.ble_resistance + + def send_udp_data_to_rizer(self, incline_data): + # Create a dictionary with the required parameters + data = { + "rizerIncline": float(incline_data), + } + print(data) + # Convert dictionary to JSON string + json_data = json.dumps(data) + + # Create a UDP socket + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Send JSON data + udp_socket.sendto(json_data.encode(), (self.send_to_actuator_ip, self.send_to_rizer_port)) + + + def send_udp_data_to_headwind(self, fan_speed): + # Create a dictionary with the required parameters + data = { + "fanSpeed": float(fan_speed), + } + print(data) + # Convert dictionary to JSON string + json_data = json.dumps(data) + + # Create a UDP socket + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Send JSON data + udp_socket.sendto(json_data.encode(), (self.send_to_actuator_ip, self.send_to_headwind_port)) + + def send_udp_data_to_direto(self, resistance_data): + # Create a dictionary with the required parameters + data = { + "diretoResistance": float(resistance_data), + } + print(data) + # Convert dictionary to JSON string + json_data = json.dumps(data) + + # Create a UDP socket + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp_socket: + # Send JSON data + udp_socket.sendto(json_data.encode(), (self.send_to_actuator_ip, self.send_to_direto_port)) + + + def stop_udp_listener(self): + if self.udp_unity_receive_socket: + self.udp_unity_receive_socket.close() + print("UDP listener stopped.") + + + +if __name__ == "__main__": + data_sender = DataSender() + + print("Master Collector script started...") + # IP adresses to receive data from actuators and sensors + UDP_IP = "127.0.0.1" # IP to receive data from elite_rizer.py as well as from direto_xr.py scripts via UDP + # UDP_IP_UNITY_RECEIVE = "127.0.0.1" # Receives Data from unity such as the ble fan data + UDP_ESP_IP = "192.168.0.101" # IP of the computer running this script to receive data from ESP32 -> Bicycle Simulator Desktop PC + # UDP_ESP_IP = "192.168.9.184" # Raspberry Pi 3 + # UDP_ESP_IP = "192.168.9.198" # Raspberry Pi 5 + + # ports to receive data from actuators and sensors + UDP_PORT_DIRETO = 1111 + UDP_PORT_RIZER = 2222 + UDP_PORT_ROLL = 6666 + UDP_PORT_BRAKE = 7777 + UDP_PORT_BNO = 8888 + # UDP_PORT_UNITY_RECEIVE = 12345 # Port to receive data from unity such as the ble fan data + + + udp_rizer_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + udp_rizer_socket.bind((UDP_IP, UDP_PORT_RIZER)) + + udp_direto_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + udp_direto_socket.bind((UDP_IP, UDP_PORT_DIRETO)) + + udp_brake_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + udp_brake_socket.bind((UDP_ESP_IP, UDP_PORT_BRAKE)) + + udp_bno_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + udp_bno_socket.bind((UDP_ESP_IP, UDP_PORT_BNO)) + + udp_roll_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + udp_roll_socket.bind((UDP_ESP_IP, UDP_PORT_ROLL)) + + # udp_unity_receive_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + # udp_unity_receive_socket.bind((UDP_IP_UNITY_RECEIVE, UDP_PORT_UNITY_RECEIVE)) + + + + while True: + # print("udp_direto_socket: ", udp_direto_socket) + data_sender.send_unity_data_udp(data_sender.speed_value, data_sender.steering_value, data_sender.brake_value, data_sender.bno_value, data_sender.roll_value, usingOldVesion = 1) + readable, _, _ = select.select([udp_rizer_socket, udp_direto_socket, udp_brake_socket, udp_bno_socket, udp_roll_socket], [], []) + + for sock in readable: + data, addr = sock.recvfrom(1024) + if sock is udp_rizer_socket: + steering_value = data.decode() + # print("steering: ", steering_value) + data_sender.collect_steering(steering_value) + elif sock is udp_direto_socket: + speed_value = data.decode() + # print("SPEED: ", speed_value) + data_sender.collect_speed(speed_value) + elif sock is udp_brake_socket: + brake_value = json.loads(data.decode()) + brake_value = brake_value["sensor_value"] + # print("Brake_value: ", brake_value) + data_sender.collect_brake(brake_value) + elif sock is udp_bno_socket: + bno_value = json.loads(data.decode()) + # print("BNO_Value: ", bno_value) + bno_value = bno_value["euler_r"] + data_sender.collect_bno(bno_value) + elif sock is udp_roll_socket: + roll_value = json.loads(data.decode()) + # print("Roll_Value: ", roll_value) + roll_value = roll_value["sensor_value"] + data_sender.collect_roll(roll_value) \ No newline at end of file diff --git a/collector_scripts/master_receiver.py b/collector_scripts/master_receiver.py new file mode 100644 index 0000000..d67c7ef --- /dev/null +++ b/collector_scripts/master_receiver.py @@ -0,0 +1,39 @@ +from master_collector import DataReceiver +import json +import socket +import select + + +if __name__ == "__main__": + print("Master Receiver started...") + data_receiver = DataReceiver() + + # Create a UDP socket + udp_unity_receive_ip = "127.0.0.1" + udp_unity_receive_port = 12345 + + udp_unity_receive_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + udp_unity_receive_socket.bind((udp_unity_receive_ip, udp_unity_receive_port)) + + while True: + print("Listening for UDP data...") + readable, _, _ = select.select([udp_unity_receive_socket], [], []) + for sock in readable: + try: + data, addr = sock.recvfrom(1024) + if sock is udp_unity_receive_socket: + data = json.loads(data.decode()) + unity_ble_fan_speed = data["bleFan"] + unity_ble_incline = data["bleIncline"] + unity_ble_resistance = data["bleResistance"] + print(unity_ble_incline, unity_ble_fan_speed) + data_receiver.send_udp_data_to_rizer(unity_ble_incline) + data_receiver.send_udp_data_to_headwind(unity_ble_fan_speed) + data_receiver.send_udp_data_to_direto(unity_ble_resistance) + + except Exception as e: + print(f"Error while receiving UDP data: {e}") + + + + diff --git a/collector_scripts/p110_connect.py b/collector_scripts/p110_connect.py index cd56a34..e3af1f5 100644 --- a/collector_scripts/p110_connect.py +++ b/collector_scripts/p110_connect.py @@ -1,35 +1,35 @@ -from PyP100 import PyP100 -import time - - -def connect_and_start_p100(): - p100 = PyP100.P100("10.30.77.220", "unitylab.hhn3@gmail.com", "Unitylab") #Creates a P100 plug object - # p100.handshake() #Creates the cookies required for further methods - # p100.login() - print("Restarting P100 Power Outlet") - try: - if(p100.get_status() == False): - print("P100 already off") - - - if(p100.get_status() == True): - try: - time.sleep(1) - print("Waiting for devices to turn off...") - p100.turnOff() - time.sleep(5) - # print("Turning on the devices...") - # p100.turnOn() - except Exception: - pass - time.sleep(5) - print("Turn P100 on...") - p100.turnOn() - time.sleep(10) - except Exception: - pass - print("done") - return True - -connect_and_start_p100() # uncomment this if the bicycle simulator getting started by a batch or a shell script and comment it if the bicycle simulator is getting started by run.py python script - +from PyP100 import PyP100 +import time + + +def connect_and_start_p100(): + p100 = PyP100.P100("192.168.0.110", "unitylab.hhn3@gmail.com", "Unitylab") #Creates a P100 plug object + # p100.handshake() #Creates the cookies required for further methods + # p100.login() + print("Restarting P100 Power Outlet") + try: + if(p100.get_status() == False): + print("P100 already off") + + + if(p100.get_status() == True): + try: + time.sleep(1) + print("Waiting for devices to turn off...") + p100.turnOff() + time.sleep(5) + # print("Turning on the devices...") + # p100.turnOn() + except Exception: + pass + time.sleep(5) + print("Turn P100 on...") + p100.turnOn() + time.sleep(10) + except Exception: + pass + print("done") + return True + +connect_and_start_p100() # uncomment this if the bicycle simulator getting started by a batch or a shell script and comment it if the bicycle simulator is getting started by run.py python script + diff --git a/collector_scripts/run_scripts.bat b/collector_scripts/run_scripts.bat index 0dc60a0..13c8ea9 100644 --- a/collector_scripts/run_scripts.bat +++ b/collector_scripts/run_scripts.bat @@ -1,30 +1,33 @@ -@echo off - -REM Set the Python script to be executed 5 seconds before others -set pre_execution_script="p110_connect.py" - -REM Set the list of Python scripts to start -set python_scripts=("direto_xr.py", "elite_rizer.py", "headwind.py", "master_collector.py") - -REM Start the pre-execution script -start "" python %pre_execution_script% - -REM Wait for the pre-execution script to complete -:wait_for_pre_execution -echo Pre execution script started -ping 127.0.0.1 -n 6 > nul -tasklist | find "python.exe" | findstr "%pre_execution_script%" > nul -if errorlevel 1 goto pre_execution_completed -goto wait_for_pre_execution - -:pre_execution_completed -REM Wait for an additional 5 seconds -timeout 5 >NUL - -REM Loop through the other scripts and start them -for %%i in %python_scripts% do ( - start "" python %%i - echo Started %%i -) - +@echo off + +REM Set the Python script to be executed 5 seconds before others +set pre_execution_script="p110_connect.py" + +ping 127.0.0.1 -n 50 > nul REM pings to delay the script5 + +REM Set the list of Python scripts to start +set python_scripts=("direto_xr.py", "headwind.py", "elite_rizer.py", "master_collector.py", "master_receiver.py") +REM "direto_xr.py", "headwind.py", + +REM Start the pre-execution script +start "" python %pre_execution_script% + +REM Wait for the pre-execution script to complete +:wait_for_pre_execution +echo Pre execution script started +ping 127.0.0.1 -n 6 > nul +tasklist | find "python.exe" | findstr "%pre_execution_script%" > nul +if errorlevel 1 goto pre_execution_completed +goto wait_for_pre_execution + +:pre_execution_completed +REM Wait for an additional 5 seconds +timeout 5 >NUL + +REM Loop through the other scripts and start them +for %%i in %python_scripts% do ( + start "" python %%i + echo Started %%i +) + echo All scripts started successfully. \ No newline at end of file diff --git a/collector_scripts/sensor_scripts/Arduino_Files/ESP32-AS5600-Roll/ESP32-AS5600-Roll.ino b/collector_scripts/sensor_scripts/Arduino_Files/ESP32-AS5600-Roll/ESP32-AS5600-Roll.ino new file mode 100644 index 0000000..22e1a78 --- /dev/null +++ b/collector_scripts/sensor_scripts/Arduino_Files/ESP32-AS5600-Roll/ESP32-AS5600-Roll.ino @@ -0,0 +1,302 @@ +#include +#include +#include +#include +#include + +const int HALL_PIN = 32; + +//const char* ssid = "raspi-webgui"; +//const char* password = "bikingismylife"; +const char *ssid = "Bicycle_Simulator_Network"; +const char *password = "17701266"; +unsigned int localUdpPort = 6666; +const unsigned long udpSendInterval = 500; // Interval for sending UDP packets in milliseconds +unsigned long lastUdpSendTime = 0; // Variable to store the last time UDP packet was sent + +WiFiUDP udp; + +using namespace std; // Use the std namespace for ArduinoSTL + +// General control settings and flags +const int debugging = 0; +const int printResult = 1; +const int directionalMode = 1; + +// Control timings in ms +const int loopTime = 60; // time between value calculation and printing in average angle reading +const int iterationCount = 20; // how many angle readings to average in one loop +const int iterationPadding = 0; // time between individual value readings + +// Control settings for turn direction reading +const float turnSensitivityActivation = 6; // default: 22 - for turn direction +const float turnSensitivityDeactivation = 31; + +// AS5600 device specifics +const int deviceAddress = 0x36; +const int registerAddressHigh = 0x0E; // Register for high 4 bits +const int registerAddressLow = 0x0F; // Register for low 8 bits +const int maxSensorValue = 4095; +const int maxDegrees = 360; +const int SDA_PIN = 18; +const int SCL_PIN = 19; + +//reused variables +unsigned long loopStartTime; +unsigned long loopEndTime; +unsigned long executionTime; +float lastReadAngle = 0; +int directionBufferIndex = 0; +int directionBufferSize = 0; +uint64_t directionBuffer = 0; +int turnDirection = 0; +int lastTurnDirection = 0; +int nextBit = 0; +int angleTolerance = 0; + + +int readValues = 0; + +void AddToBuffer(int val) { + directionBuffer = (directionBuffer << 1) | (val & 1); +} + +int countOnes(uint64_t n) +{ + unsigned int c; // the total bits set in n + for (c = 0; n; n = n & (n-1)) + { + c++; + } + return c; +} + +void printBufferBits() { + int i; + // The number of bits in a uint64_t is 64 + for (i = 63; i >= 0; i--) { + // Check the i-th bit using bitwise AND + uint64_t bit = (directionBuffer >> i) & 1; + Serial.print((int)bit); + } + Serial.println(); // Print a new line after all bits +} + +void setup() { + Wire.begin(SDA_PIN, SCL_PIN); + Serial.begin(115200); + + WiFi.hostname("Roll_ESP"); + WiFi.begin(ssid, password); + + while (WiFi.status() != WL_CONNECTED) + { + delay(1000); + Serial.print("Connecting with WiFi with ssid: "); + Serial.print(ssid); + Serial.print(" and password: "); + Serial.println(password); + Serial.println(WiFi.status()); + } + + Serial.println("Connection with WiFi successful"); + udp.begin(localUdpPort); + + loopStartTime = millis(); +} + +void loop() { + if (directionalMode) { + getRotation(); + } else { + averageAngle(); + } + + // Check if it's time to send the UDP packet + unsigned long currentTime = millis(); + if (currentTime - lastUdpSendTime >= udpSendInterval) { + StaticJsonDocument<500> doc; + + String jsonStr; + doc["sensor"] = "AS5600"; + doc["sensor_value"] = turnDirection; + + serializeJson(doc, jsonStr); + + // Read UDP messages + int packetSize = udp.parsePacket(); + if (packetSize) { + char packetBuffer[255]; + udp.read(packetBuffer, packetSize); + + Serial.print("Received message: "); + Serial.println(packetBuffer); + } + + udp.beginPacket("192.168.0.101", 6666); + udp.print(jsonStr); + udp.endPacket(); + + // Update the last send time + lastUdpSendTime = currentTime; + } +} + +void averageAngle() { + loopStartTime = millis(); + float angleReadings[iterationCount]; + + for (int it = 0; it < iterationCount; ++it) { + float angle = readAngle(); + + // Check if readAngle encountered an error + if (isnan(angle)) { + Serial.print(" !Reading Error! "); + continue; // Skip the rest of the loop if there's an error + } + angleReadings[it] = angle; + if(iterationPadding > 0)delay(iterationPadding); + } + + int readValuesSize = sizeof(angleReadings) / sizeof(angleReadings[0]); + // Calculate the mean angle using the array of readings + float averagedAngle = meanAngle(angleReadings, readValuesSize); + + if(debugging){ + Serial.println(""); + Serial.print("Raw values: "); + Serial.println(readValuesSize); + printArray(angleReadings, readValuesSize); + } + if(printResult) { + Serial.print("Angle: "); + Serial.println(averagedAngle, 3); // Print with 3 decimal places + } + loopEndTime = millis(); + executionTime = loopEndTime - loopStartTime; + + if(debugging) { + Serial.print("execution time: "); + Serial.println(executionTime); + } + if(executionTime <= loopTime) { + delay((float)(loopTime - executionTime)); + } else { + if(debugging) { + Serial.println("Cant keep up! Execution time of " + (String)executionTime + "ms is " + (String) (executionTime - loopTime) + "ms over the budget!"); + } else { + Serial.println(" Device Slowdown!"); + } + } +} + +float readAngle() { + // Request the high byte from the specified register of the device + Wire.beginTransmission(deviceAddress); + Wire.write(registerAddressHigh); + int transmissionStatusHigh = Wire.endTransmission(); + + if (transmissionStatusHigh != 0) { + Serial.print("Error in I2C transmission (high byte). Status: "); + Serial.println(transmissionStatusHigh); + return NAN; // Skip the rest of the loop if there's an error + } + + Wire.requestFrom(deviceAddress, 1); + + while (Wire.available() < 1); + + byte highByte = Wire.read(); + + // Request the low byte from the specified register of the device + Wire.beginTransmission(deviceAddress); + Wire.write(registerAddressLow); + int transmissionStatusLow = Wire.endTransmission(); + + if (transmissionStatusLow != 0) { + Serial.print("Error in I2C transmission (low byte). Status: "); + Serial.println(transmissionStatusLow); + return NAN; // Skip the rest of the loop if there's an error + } + + Wire.requestFrom(deviceAddress, 1); + + while (Wire.available() < 1); + + byte lowByte = Wire.read(); + + // Combine the high and low bytes to form a 12-bit value + int sensorValue = (highByte << 8) | lowByte; + + // Map the sensor value to degrees + float degrees = (float(sensorValue) / maxSensorValue) * maxDegrees; + + // Check if the angle is exactly 360.0, and if so, set it to 0.0 + if (degrees == 360.0) { + degrees = 0.0; + } + readValues++; + return degrees; +} + +// Calculate the mean angle from -180 to 180 degrees +double meanAngle(const float angles[], int size) { + double x = 0.0; + double y = 0.0; + + for (int i = 0; i < size; ++i) { + x += cos(angles[i] * PI / 180); + y += sin(angles[i] * PI / 180); + } + + return (atan2(y, x) * 180 / PI) + 180; +} + +void printArray(const float arr[], int size) { + Serial.print("["); + for (int i = 0; i < size; ++i) { + Serial.print(arr[i], 3); // Print each element with 3 decimal places + if (i < size - 1) { + Serial.print(", "); + } + } + Serial.println("]"); +} + +void getRotation() { + float newAngle = readAngle(); + if(newAngle > lastReadAngle + angleTolerance) { + AddToBuffer(1); + } else if(newAngle < lastReadAngle - angleTolerance) { + AddToBuffer(0); + } else { + nextBit = (nextBit + 1) % 2; //Add 1 and 0 in equal amounts + AddToBuffer(nextBit); + } + + lastReadAngle = newAngle; + + int ones = countOnes(directionBuffer); + int zeroes = 64 - ones; + if(debugging) { + Serial.println("Zeroes count: " + (String)zeroes + ", Ones count: " + (String)ones + "."); + } + int sensitivity = (lastTurnDirection == -1 || lastTurnDirection == 1) ? turnSensitivityDeactivation : turnSensitivityActivation; + if(ones > 64 - sensitivity) turnDirection = 1; + else if(ones <= sensitivity) turnDirection = -1; + else turnDirection = 0; + + if(printResult && lastTurnDirection != turnDirection) { + lastTurnDirection = turnDirection; + if(turnDirection == 1) Serial.println("Turning clockwise..."); + else if(turnDirection == -1) Serial.println("Turning counter-clockwise..."); + else if(turnDirection == 0) Serial.println("Not turning..."); + } + if(millis() - loopStartTime > 10000){ + Serial.println("Rate of "+(String)(readValues / 10)+" values per second."); + loopStartTime = millis(); + readValues = 0; + } +} + + diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/.gitignore b/collector_scripts/sensor_scripts/Brake_Sensor/.gitignore new file mode 100644 index 0000000..16539a7 --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/.travis.yml b/collector_scripts/sensor_scripts/Brake_Sensor/.travis.yml new file mode 100644 index 0000000..a8bbc57 --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/c_cpp_properties.json b/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..3afbab7 --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/c_cpp_properties.json @@ -0,0 +1,501 @@ +// +// !!! WARNING !!! AUTO-GENERATED FILE! +// PLEASE DO NOT MODIFY IT AND USE "platformio.ini": +// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags +// +{ + "configurations": [ + { + "name": "PlatformIO", + "includePath": [ + "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/include", + "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src", + "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/.pio/libdeps/esp32dev/ArduinoJson/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/newlib/platform_include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/include/esp_additions/freertos", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/port/xtensa/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/include/esp_additions", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/include/soc", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/port/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/heap/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/log/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/include/apps", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/include/apps/sntp", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/lwip/src/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/port/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/port/esp32/include/arch", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/soc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/soc/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/soc/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/hal/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/hal/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/hal/platform_port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_rom/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_rom/include/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_rom/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_system/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_system/port/soc", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_system/port/public_compat", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/xtensa/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/xtensa/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/driver/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/driver/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_pm/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_ringbuf/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/efuse/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/efuse/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/vfs/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_wifi/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_event/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_netif/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_eth/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/tcpip_adapter/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_phy/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_phy/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_ipc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/app_trace/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_timer/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mbedtls/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mbedtls/mbedtls/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mbedtls/esp_crt_bundle/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/app_update/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/spi_flash/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bootloader_support/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/nvs_flash/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/pthread/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_gdbstub/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_gdbstub/xtensa", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_gdbstub/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espcoredump/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espcoredump/include/port/xtensa", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wpa_supplicant/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wpa_supplicant/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/ieee802154/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/console", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/asio/asio/asio/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/asio/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/common/osi/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/include/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/common/api/include/api", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/common/btc/profile/esp/blufi/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/common/btc/profile/esp/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/storage", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/api", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/cbor/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/unity/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/unity/unity/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/cmock/CMock/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/coap/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/coap/libcoap/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/nghttp/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/nghttp/nghttp2/lib/includes", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-tls", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-tls/esp-tls-crypto", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_adc_cal/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hid/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/tcp_transport/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_http_client/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_http_server/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_https_ota/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_https_server/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_lcd/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_lcd/interface", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/protobuf-c/protobuf-c", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/protocomm/include/common", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/protocomm/include/security", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/protocomm/include/transports", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mdns/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_local_ctrl/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/sdmmc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_serial_slave_link/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_websocket_client/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/expat/expat/expat/lib", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/expat/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wear_levelling/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/fatfs/diskio", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/fatfs/vfs", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/fatfs/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freemodbus/freemodbus/common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/idf_test/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/idf_test/include/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/jsmn/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/json/cJSON", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/libsodium/libsodium/src/libsodium/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/libsodium/port_include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mqtt/esp-mqtt/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/openssl/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/perfmon/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/spiffs/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/ulp/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wifi_provisioning/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/rmaker_common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_diagnostics/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/rtc_store/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_insights/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/json_parser/upstream/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/json_parser/upstream", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/json_generator/upstream", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_schedule/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp_secure_cert_mgr/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_rainmaker/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/gpio_button/button/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/qrcode/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/ws2812_led", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_littlefs/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/tool", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/typedef", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/image", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/math", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/nn", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/layer", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/detect", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/model_zoo", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp32-camera/driver/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp32-camera/conversions/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/dotprod/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/support/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/support/mem/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/hann/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/blackman/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/blackman_harris/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/blackman_nuttall/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/nuttall/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/flat_top/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/iir/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/fir/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/add/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/sub/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/mul/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/addc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/mulc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/sqrt/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/matrix/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/fft/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/dct/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/conv/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/kalman/ekf/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/kalman/ekf_imu13states/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/fb_gfx/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/dio_qspi/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/cores/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/variants/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Ethernet/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/FS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdateServer/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/I2S/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Insights/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/LittleFS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/NetBIOS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Preferences/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/RainMaker/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SD/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SPIFFS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/USB/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Update/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src", + "" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "path": [ + "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/include", + "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src", + "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/.pio/libdeps/esp32dev/ArduinoJson/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/newlib/platform_include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/include/esp_additions/freertos", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/port/xtensa/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freertos/include/esp_additions", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/include/soc", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/include/soc/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/port/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hw_support/port/esp32/private_include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/heap/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/log/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/include/apps", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/include/apps/sntp", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/lwip/src/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/port/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/port/esp32/include/arch", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/soc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/soc/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/soc/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/hal/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/hal/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/hal/platform_port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_rom/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_rom/include/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_rom/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_system/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_system/port/soc", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_system/port/public_compat", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/xtensa/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/xtensa/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/driver/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/driver/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_pm/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_ringbuf/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/efuse/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/efuse/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/vfs/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_wifi/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_event/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_netif/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_eth/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/tcpip_adapter/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_phy/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_phy/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_ipc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/app_trace/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_timer/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mbedtls/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mbedtls/mbedtls/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mbedtls/esp_crt_bundle/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/app_update/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/spi_flash/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bootloader_support/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/nvs_flash/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/pthread/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_gdbstub/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_gdbstub/xtensa", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_gdbstub/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espcoredump/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espcoredump/include/port/xtensa", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wpa_supplicant/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wpa_supplicant/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wpa_supplicant/esp_supplicant/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/ieee802154/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/console", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/asio/asio/asio/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/asio/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/common/osi/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/include/esp32/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/common/api/include/api", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/common/btc/profile/esp/blufi/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/common/btc/profile/esp/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/storage", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/bt/esp_ble_mesh/api", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/cbor/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/unity/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/unity/unity/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/cmock/CMock/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/coap/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/coap/libcoap/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/nghttp/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/nghttp/nghttp2/lib/includes", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-tls", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-tls/esp-tls-crypto", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_adc_cal/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_hid/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/tcp_transport/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_http_client/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_http_server/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_https_ota/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_https_server/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_lcd/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_lcd/interface", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/protobuf-c/protobuf-c", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/protocomm/include/common", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/protocomm/include/security", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/protocomm/include/transports", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mdns/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_local_ctrl/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/sdmmc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_serial_slave_link/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_websocket_client/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/expat/expat/expat/lib", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/expat/port/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wear_levelling/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/fatfs/diskio", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/fatfs/vfs", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/fatfs/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/freemodbus/freemodbus/common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/idf_test/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/idf_test/include/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/jsmn/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/json/cJSON", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/libsodium/libsodium/src/libsodium/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/libsodium/port_include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mqtt/esp-mqtt/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/openssl/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/perfmon/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/spiffs/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/ulp/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/wifi_provisioning/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/rmaker_common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_diagnostics/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/rtc_store/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_insights/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/json_parser/upstream/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/json_parser/upstream", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/json_generator/upstream", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_schedule/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp_secure_cert_mgr/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_rainmaker/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/gpio_button/button/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/qrcode/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/ws2812_led", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_littlefs/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/tool", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/typedef", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/image", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/math", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/nn", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/layer", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/detect", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp-dl/include/model_zoo", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp32-camera/driver/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp32-camera/conversions/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/dotprod/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/support/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/support/mem/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/hann/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/blackman/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/blackman_harris/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/blackman_nuttall/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/nuttall/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/windows/flat_top/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/iir/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/fir/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/add/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/sub/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/mul/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/addc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/mulc/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/math/sqrt/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/matrix/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/fft/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/dct/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/conv/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/common/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/kalman/ekf/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/espressif__esp-dsp/modules/kalman/ekf_imu13states/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/fb_gfx/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/dio_qspi/include", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/cores/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/variants/esp32", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/ArduinoOTA/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/BluetoothSerial/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/DNSServer/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/EEPROM/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/ESP32/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/ESPmDNS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Ethernet/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/FFat/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/FS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdate/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/HTTPUpdateServer/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/I2S/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Insights/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/LittleFS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/NetBIOS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Preferences/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/RainMaker/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SD/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SD_MMC/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SPI/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SPIFFS/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/SimpleBLE/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Ticker/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/USB/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Update/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src", + "C:/Users/unity/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src", + "" + ] + }, + "defines": [ + "PLATFORMIO=60114", + "ARDUINO_ESP32_DEV", + "HAVE_CONFIG_H", + "MBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"", + "UNITY_INCLUDE_CONFIG_H", + "WITH_POSIX", + "_GNU_SOURCE", + "IDF_VER=\"v4.4.6-dirty\"", + "ESP_PLATFORM", + "_POSIX_READER_WRITER_LOCKS", + "ARDUINO_ARCH_ESP32", + "ESP32", + "F_CPU=240000000L", + "ARDUINO=10812", + "ARDUINO_VARIANT=\"esp32\"", + "ARDUINO_BOARD=\"Espressif ESP32 Dev Module\"", + "ARDUINO_PARTITION_default", + "" + ], + "cStandard": "gnu99", + "cppStandard": "gnu++11", + "compilerPath": "C:/Users/unity/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc.exe", + "compilerArgs": [ + "-mlongcalls", + "" + ] + } + ], + "version": 4 +} diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/extensions.json b/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/extensions.json new file mode 100644 index 0000000..0678aa0 --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/launch.json b/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/launch.json new file mode 100644 index 0000000..6213b90 --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/.vscode/launch.json @@ -0,0 +1,44 @@ +// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY +// +// PlatformIO Debugging Solution +// +// Documentation: https://docs.platformio.org/en/latest/plus/debugging.html +// Configuration: https://docs.platformio.org/en/latest/projectconf/sections/env/options/debug/index.html + +{ + "version": "0.2.0", + "configurations": [ + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug", + "executable": "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/.pio/build/esp32dev/firmware.elf", + "projectEnvName": "esp32dev", + "toolchainBinDir": "C:/Users/unity/.platformio/packages/toolchain-xtensa-esp32/bin", + "internalConsoleOptions": "openOnSessionStart", + "preLaunchTask": { + "type": "PlatformIO", + "task": "Pre-Debug" + } + }, + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug (skip Pre-Debug)", + "executable": "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/.pio/build/esp32dev/firmware.elf", + "projectEnvName": "esp32dev", + "toolchainBinDir": "C:/Users/unity/.platformio/packages/toolchain-xtensa-esp32/bin", + "internalConsoleOptions": "openOnSessionStart" + }, + { + "type": "platformio-debug", + "request": "launch", + "name": "PIO Debug (without uploading)", + "executable": "c:/Users/unity/Desktop/BicycleSimulator/Brake_Sensor/.pio/build/esp32dev/firmware.elf", + "projectEnvName": "esp32dev", + "toolchainBinDir": "C:/Users/unity/.platformio/packages/toolchain-xtensa-esp32/bin", + "internalConsoleOptions": "openOnSessionStart", + "loadMode": "manual" + } + ] +} diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/README.rst b/collector_scripts/sensor_scripts/Brake_Sensor/README.rst new file mode 100644 index 0000000..90d2137 --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-espressif32/examples/arduino-wifiscan + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e quantum + + # Upload firmware for the specific environment + > platformio run -e quantum --target upload + + # Clean build files + > platformio run --target clean diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/platformio.ini b/collector_scripts/sensor_scripts/Brake_Sensor/platformio.ini new file mode 100644 index 0000000..16189e5 --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/platformio.ini @@ -0,0 +1,17 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = arduino +monitor_speed = 115200 +lib_deps = + bblanchon/ArduinoJson@^6.21.2 diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/src/main.cpp b/collector_scripts/sensor_scripts/Brake_Sensor/src/main.cpp new file mode 100644 index 0000000..e0305c7 --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/src/main.cpp @@ -0,0 +1,63 @@ +#include +#include +#include +#include + +const int HALL_PIN = 32; + +const char *ssid = "Bicycle_Simulator_Network"; +const char *password = "17701266"; +unsigned int localUdpPort = 8888; + +WiFiUDP udp; + +void setup() +{ + + pinMode(HALL_PIN, INPUT_PULLUP); + delay(1000); + + WiFi.hostname("Brake_ESP"); + + Serial.begin(115200); + WiFi.begin(ssid, password); + + while (WiFi.status() != WL_CONNECTED) + { + delay(1000); + Serial.println("Connecting with WiFi"); + } + + Serial.println("Connection with WiFi successful"); + udp.begin(localUdpPort); +} + +void loop() +{ + + int sensorValue = analogRead(HALL_PIN); // read Sensor value + StaticJsonDocument<500> doc; + + String jsonStr; + doc["sensor"] = "Brake"; + doc["sensor_value"] = sensorValue; + + serializeJson(doc, jsonStr); + + // Read UDP messages + int packetSize = udp.parsePacket(); + if (packetSize) + { + char packetBuffer[255]; + udp.read(packetBuffer, packetSize); + + Serial.print("Received message: "); + Serial.println(packetBuffer); + } + + udp.beginPacket("192.168.0.101", 7777); + udp.print(jsonStr); + udp.endPacket(); + + delay(1000); +} diff --git a/collector_scripts/sensor_scripts/Brake_Sensor/src/test/README b/collector_scripts/sensor_scripts/Brake_Sensor/src/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/collector_scripts/sensor_scripts/Brake_Sensor/src/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/collector_scripts/sensor_scripts/Gyro_Sensor/.gitignore b/collector_scripts/sensor_scripts/Gyro_Sensor/.gitignore new file mode 100644 index 0000000..5762142 --- /dev/null +++ b/collector_scripts/sensor_scripts/Gyro_Sensor/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/collector_scripts/sensor_scripts/Gyro_Sensor/.vscode/extensions.json b/collector_scripts/sensor_scripts/Gyro_Sensor/.vscode/extensions.json new file mode 100644 index 0000000..0678aa0 --- /dev/null +++ b/collector_scripts/sensor_scripts/Gyro_Sensor/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/collector_scripts/sensor_scripts/Gyro_Sensor/platformio.ini b/collector_scripts/sensor_scripts/Gyro_Sensor/platformio.ini new file mode 100644 index 0000000..b25c41d --- /dev/null +++ b/collector_scripts/sensor_scripts/Gyro_Sensor/platformio.ini @@ -0,0 +1,18 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:upesy_wroom] +platform = espressif32 +board = upesy_wroom +framework = arduino +monitor_speed = 115200 +lib_deps = + bblanchon/ArduinoJson@^6.21.2 + arduino-libraries/BNO055@^1.2.1 diff --git a/collector_scripts/sensor_scripts/Gyro_Sensor/src/main.cpp b/collector_scripts/sensor_scripts/Gyro_Sensor/src/main.cpp new file mode 100644 index 0000000..a80bd35 --- /dev/null +++ b/collector_scripts/sensor_scripts/Gyro_Sensor/src/main.cpp @@ -0,0 +1,84 @@ +#include + +#include +#include + +#include "BNO055_support.h" +#include + +#include + +const char *ssid = "Bicycle_Simulator_Network"; +const char *password = "17701266"; +unsigned int localUdpPort = 8888; + +WiFiUDP udp; + +struct bno055_t myBNO; +struct bno055_euler myEulerData; // Structure to hold the Euler data +struct bno055_gyro myGyroData; // Structure to hold the Gyro data + +unsigned long lastTime = 0; + +void setup() +{ + // Initialize I2C communication + Wire.begin(); + + // Create a static buffer for framing BME280 sensor data with ESP32 chip ID. + + // Initialization of the BNO055 + BNO_Init(&myBNO); // Assigning the structure to hold information about the device + + // Configuration to NDoF mode + bno055_set_operation_mode(OPERATION_MODE_NDOF); + + delay(1); + + Serial.begin(115200); + WiFi.hostname("Gyro_ESP"); + WiFi.begin(ssid, password); + + while (WiFi.status() != WL_CONNECTED) + { + delay(1000); // setting sending rate + Serial.println("Connecting with WiFi"); + } + + Serial.println("Connection with WiFi successful"); + + udp.begin(localUdpPort); +} + +void loop() +{ + bno055_read_euler_hrp(&myEulerData); // Update Euler data into the structure + StaticJsonDocument<500> doc; + + int packetSize = udp.parsePacket(); + + // Method for receiving data + if (packetSize) + { + char packetBuffer[255]; + udp.read(packetBuffer, packetSize); + + Serial.print("Received message: "); + Serial.println(packetBuffer); + } + + // Creating JSON for sensor data + String jsonStr; + doc["sensor"] = "BNO055"; + doc["euler_h"] = ((myEulerData.h) / 16.00); + doc["euler_r"] = ((myEulerData.r) / 16.00); + doc["euler_p"] = ((myEulerData.p) / 16.00); + + serializeJson(doc, jsonStr); + + udp.beginPacket("192.168.0.101", 8888); + udp.print(jsonStr); + udp.endPacket(); + + delay(10); +} diff --git a/collector_scripts/sensor_scripts/Gyro_Sensor/test/README b/collector_scripts/sensor_scripts/Gyro_Sensor/test/README new file mode 100644 index 0000000..b0416ad --- /dev/null +++ b/collector_scripts/sensor_scripts/Gyro_Sensor/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/collector_scripts/sensor_scripts/Roll_Sensor/.gitignore b/collector_scripts/sensor_scripts/Roll_Sensor/.gitignore new file mode 100644 index 0000000..5762142 --- /dev/null +++ b/collector_scripts/sensor_scripts/Roll_Sensor/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/collector_scripts/sensor_scripts/Roll_Sensor/.vscode/extensions.json b/collector_scripts/sensor_scripts/Roll_Sensor/.vscode/extensions.json new file mode 100644 index 0000000..0678aa0 --- /dev/null +++ b/collector_scripts/sensor_scripts/Roll_Sensor/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/collector_scripts/sensor_scripts/Roll_Sensor/README.md b/collector_scripts/sensor_scripts/Roll_Sensor/README.md new file mode 100644 index 0000000..e69de29 diff --git a/collector_scripts/sensor_scripts/Roll_Sensor/platformio.ini b/collector_scripts/sensor_scripts/Roll_Sensor/platformio.ini new file mode 100644 index 0000000..5408a38 --- /dev/null +++ b/collector_scripts/sensor_scripts/Roll_Sensor/platformio.ini @@ -0,0 +1,15 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = arduino +lib_deps = bblanchon/ArduinoJson@^7.0.3 diff --git a/collector_scripts/sensor_scripts/Roll_Sensor/src/main.cpp b/collector_scripts/sensor_scripts/Roll_Sensor/src/main.cpp new file mode 100644 index 0000000..e8e088a --- /dev/null +++ b/collector_scripts/sensor_scripts/Roll_Sensor/src/main.cpp @@ -0,0 +1,300 @@ +#include +#include +#include +#include +#include + +const int HALL_PIN = 32; + +//const char* ssid = "raspi-webgui"; +//const char* password = "bikingismylife"; +const char *ssid = "Bicycle_Simulator_Network"; +const char *password = "17701266"; +unsigned int localUdpPort = 6666; +const unsigned long udpSendInterval = 500; // Interval for sending UDP packets in milliseconds +unsigned long lastUdpSendTime = 0; // Variable to store the last time UDP packet was sent + +WiFiUDP udp; + +using namespace std; // Use the std namespace for ArduinoSTL + +// General control settings and flags +const int debugging = 0; +const int printResult = 1; +const int directionalMode = 1; + +// Control timings in ms +const int loopTime = 60; // time between value calculation and printing in average angle reading +const int iterationCount = 20; // how many angle readings to average in one loop +const int iterationPadding = 0; // time between individual value readings + +// Control settings for turn direction reading +const float turnSensitivityActivation = 6; // default: 22 - for turn direction +const float turnSensitivityDeactivation = 31; + +// AS5600 device specifics +const int deviceAddress = 0x36; +const int registerAddressHigh = 0x0E; // Register for high 4 bits +const int registerAddressLow = 0x0F; // Register for low 8 bits +const int maxSensorValue = 4095; +const int maxDegrees = 360; +const int SDA_PIN = 18; +const int SCL_PIN = 19; + +//reused variables +unsigned long loopStartTime; +unsigned long loopEndTime; +unsigned long executionTime; +float lastReadAngle = 0; +int directionBufferIndex = 0; +int directionBufferSize = 0; +uint64_t directionBuffer = 0; +int turnDirection = 0; +int lastTurnDirection = 0; +int nextBit = 0; +int angleTolerance = 0; + + +int readValues = 0; + +void AddToBuffer(int val) { + directionBuffer = (directionBuffer << 1) | (val & 1); +} + +int countOnes(uint64_t n) +{ + unsigned int c; // the total bits set in n + for (c = 0; n; n = n & (n-1)) + { + c++; + } + return c; +} + +void printBufferBits() { + int i; + // The number of bits in a uint64_t is 64 + for (i = 63; i >= 0; i--) { + // Check the i-th bit using bitwise AND + uint64_t bit = (directionBuffer >> i) & 1; + Serial.print((int)bit); + } + Serial.println(); // Print a new line after all bits +} + +void setup() { + Wire.begin(SDA_PIN, SCL_PIN); + Serial.begin(115200); + + WiFi.hostname("Roll_ESP"); + WiFi.begin(ssid, password); + + while (WiFi.status() != WL_CONNECTED) + { + delay(1000); + Serial.print("Connecting with WiFi with ssid: "); + Serial.print(ssid); + Serial.print(" and password: "); + Serial.println(password); + Serial.println(WiFi.status()); + } + + Serial.println("Connection with WiFi successful"); + udp.begin(localUdpPort); + + loopStartTime = millis(); +} + +void loop() { + if (directionalMode) { + getRotation(); + } else { + averageAngle(); + } + + // Check if it's time to send the UDP packet + unsigned long currentTime = millis(); + if (currentTime - lastUdpSendTime >= udpSendInterval) { + StaticJsonDocument<500> doc; + + String jsonStr; + doc["sensor"] = "AS5600"; + doc["sensor_value"] = turnDirection; + + serializeJson(doc, jsonStr); + + // Read UDP messages + int packetSize = udp.parsePacket(); + if (packetSize) { + char packetBuffer[255]; + udp.read(packetBuffer, packetSize); + + Serial.print("Received message: "); + Serial.println(packetBuffer); + } + + udp.beginPacket("192.168.0.101", 6666); + udp.print(jsonStr); + udp.endPacket(); + + // Update the last send time + lastUdpSendTime = currentTime; + } +} + +void averageAngle() { + loopStartTime = millis(); + float angleReadings[iterationCount]; + + for (int it = 0; it < iterationCount; ++it) { + float angle = readAngle(); + + // Check if readAngle encountered an error + if (isnan(angle)) { + Serial.print(" !Reading Error! "); + continue; // Skip the rest of the loop if there's an error + } + angleReadings[it] = angle; + if(iterationPadding > 0)delay(iterationPadding); + } + + int readValuesSize = sizeof(angleReadings) / sizeof(angleReadings[0]); + // Calculate the mean angle using the array of readings + float averagedAngle = meanAngle(angleReadings, readValuesSize); + + if(debugging){ + Serial.println(""); + Serial.print("Raw values: "); + Serial.println(readValuesSize); + printArray(angleReadings, readValuesSize); + } + if(printResult) { + Serial.print("Angle: "); + Serial.println(averagedAngle, 3); // Print with 3 decimal places + } + loopEndTime = millis(); + executionTime = loopEndTime - loopStartTime; + + if(debugging) { + Serial.print("execution time: "); + Serial.println(executionTime); + } + if(executionTime <= loopTime) { + delay((float)(loopTime - executionTime)); + } else { + if(debugging) { + Serial.println("Cant keep up! Execution time of " + (String)executionTime + "ms is " + (String) (executionTime - loopTime) + "ms over the budget!"); + } else { + Serial.println(" Device Slowdown!"); + } + } +} + +float readAngle() { + // Request the high byte from the specified register of the device + Wire.beginTransmission(deviceAddress); + Wire.write(registerAddressHigh); + int transmissionStatusHigh = Wire.endTransmission(); + + if (transmissionStatusHigh != 0) { + Serial.print("Error in I2C transmission (high byte). Status: "); + Serial.println(transmissionStatusHigh); + return NAN; // Skip the rest of the loop if there's an error + } + + Wire.requestFrom(deviceAddress, 1); + + while (Wire.available() < 1); + + byte highByte = Wire.read(); + + // Request the low byte from the specified register of the device + Wire.beginTransmission(deviceAddress); + Wire.write(registerAddressLow); + int transmissionStatusLow = Wire.endTransmission(); + + if (transmissionStatusLow != 0) { + Serial.print("Error in I2C transmission (low byte). Status: "); + Serial.println(transmissionStatusLow); + return NAN; // Skip the rest of the loop if there's an error + } + + Wire.requestFrom(deviceAddress, 1); + + while (Wire.available() < 1); + + byte lowByte = Wire.read(); + + // Combine the high and low bytes to form a 12-bit value + int sensorValue = (highByte << 8) | lowByte; + + // Map the sensor value to degrees + float degrees = (float(sensorValue) / maxSensorValue) * maxDegrees; + + // Check if the angle is exactly 360.0, and if so, set it to 0.0 + if (degrees == 360.0) { + degrees = 0.0; + } + readValues++; + return degrees; +} + +// Calculate the mean angle from -180 to 180 degrees +double meanAngle(const float angles[], int size) { + double x = 0.0; + double y = 0.0; + + for (int i = 0; i < size; ++i) { + x += cos(angles[i] * PI / 180); + y += sin(angles[i] * PI / 180); + } + + return (atan2(y, x) * 180 / PI) + 180; +} + +void printArray(const float arr[], int size) { + Serial.print("["); + for (int i = 0; i < size; ++i) { + Serial.print(arr[i], 3); // Print each element with 3 decimal places + if (i < size - 1) { + Serial.print(", "); + } + } + Serial.println("]"); +} + +void getRotation() { + float newAngle = readAngle(); + if(newAngle > lastReadAngle + angleTolerance) { + AddToBuffer(1); + } else if(newAngle < lastReadAngle - angleTolerance) { + AddToBuffer(0); + } else { + nextBit = (nextBit + 1) % 2; //Add 1 and 0 in equal amounts + AddToBuffer(nextBit); + } + + lastReadAngle = newAngle; + + int ones = countOnes(directionBuffer); + int zeroes = 64 - ones; + if(debugging) { + Serial.println("Zeroes count: " + (String)zeroes + ", Ones count: " + (String)ones + "."); + } + int sensitivity = (lastTurnDirection == -1 || lastTurnDirection == 1) ? turnSensitivityDeactivation : turnSensitivityActivation; + if(ones > 64 - sensitivity) turnDirection = 1; + else if(ones <= sensitivity) turnDirection = -1; + else turnDirection = 0; + + if(printResult && lastTurnDirection != turnDirection) { + lastTurnDirection = turnDirection; + if(turnDirection == 1) Serial.println("Turning clockwise..."); + else if(turnDirection == -1) Serial.println("Turning counter-clockwise..."); + else if(turnDirection == 0) Serial.println("Not turning..."); + } + if(millis() - loopStartTime > 10000){ + Serial.println("Rate of "+(String)(readValues / 10)+" values per second."); + loopStartTime = millis(); + readValues = 0; + } +} \ No newline at end of file diff --git a/collector_scripts/sensor_scripts/Roll_Sensor/test/README b/collector_scripts/sensor_scripts/Roll_Sensor/test/README new file mode 100644 index 0000000..b0416ad --- /dev/null +++ b/collector_scripts/sensor_scripts/Roll_Sensor/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/develop/Figure_1.png b/develop/Figure_1.png new file mode 100644 index 0000000..d125f71 Binary files /dev/null and b/develop/Figure_1.png differ diff --git a/develop/ble_device_data.json b/develop/ble_device_data.json new file mode 100644 index 0000000..f902479 --- /dev/null +++ b/develop/ble_device_data.json @@ -0,0 +1,410 @@ +{ + "00001800-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a00-0000-1000-8000-00805f9b34fb", + "properties": [ + "read", + "write" + ], + "data": [ + [ + 82, + 73, + 90, + 69, + 82 + ] + ] + }, + { + "uuid": "00002a01-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 0 + ] + ] + }, + { + "uuid": "00002a04-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 24, + 0, + 48, + 0, + 0, + 0, + 144, + 1 + ] + ] + }, + { + "uuid": "00002aa6-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 1 + ] + ] + } + ], + "00001801-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a05-0000-1000-8000-00805f9b34fb", + "properties": [ + "indicate" + ], + "data": [], + "error": "Could not read characteristic handle 11: Protocol Error 0x02: Read Not Permitted" + } + ], + "0000180a-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a29-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 69, + 108, + 105, + 116, + 101 + ] + ] + }, + { + "uuid": "00002a25-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 56, + 48, + 57 + ] + ] + }, + { + "uuid": "00002a27-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 51 + ] + ] + }, + { + "uuid": "00002a26-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 50, + 52 + ] + ] + }, + { + "uuid": "00002a28-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 50, + 52 + ] + ] + } + ], + "0000fe59-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "8ec90003-f315-4f60-9fb8-838830daea50", + "properties": [ + "write", + "indicate" + ], + "data": [ + [] + ] + } + ], + "347b0001-7635-408b-8918-8ff3949ce592": [ + { + "uuid": "347b0012-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 30: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0013-7635-408b-8918-8ff3949ce592", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + ] + }, + { + "uuid": "347b0014-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0 + ] + ] + }, + { + "uuid": "347b0016-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 37: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0017-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0 + ] + ] + }, + { + "uuid": "347b0019-7635-408b-8918-8ff3949ce592", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 228, + 1, + 0, + 0 + ] + ] + }, + { + "uuid": "347b0030-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 168, + 166, + 39, + 193 + ] + ] + }, + { + "uuid": "347b0031-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 47: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0032-7635-408b-8918-8ff3949ce592", + "properties": [ + "indicate" + ], + "data": [ + [] + ] + }, + { + "uuid": "347b0022-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 255, + 100, + 129, + 60 + ] + ] + }, + { + "uuid": "347b0020-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 55: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0021-7635-408b-8918-8ff3949ce592", + "properties": [ + "indicate" + ], + "data": [ + [] + ] + } + ] +} \ No newline at end of file diff --git a/develop/compare_json.py b/develop/compare_json.py new file mode 100644 index 0000000..19f7ed8 --- /dev/null +++ b/develop/compare_json.py @@ -0,0 +1,34 @@ +import json + +def compare_data_lists(file1, file2): + with open(file1, 'r') as f1, open(file2, 'r') as f2: + data1 = json.load(f1) + data2 = json.load(f2) + + differences = [] + + for service_uuid, subdata in data1.items(): + + for charac in subdata: + + if (charac["data"] != get_dict_by_uuid(data2[service_uuid], charac["uuid"])["data"]): + + print("Change in JSON found:") + print("Characterisic: ",charac["uuid"]) + print("Steering left:",charac["data"]) + print("Steering middle:", get_dict_by_uuid(data2[service_uuid], charac["uuid"])["data"]) + +def get_dict_by_uuid(characteristics, target_uuid): + return next((char for char in characteristics if char['uuid'] == target_uuid), None) + +# Usage +file1 = "left_ble_device_data.json" +file2 = "middle_ble_device_data.json" + +differences = compare_data_lists(file1, file2) +#print_differences(differences) + + + + + diff --git a/develop/left_ble_device_data.json b/develop/left_ble_device_data.json new file mode 100644 index 0000000..dad3b2e --- /dev/null +++ b/develop/left_ble_device_data.json @@ -0,0 +1,410 @@ +{ + "00001800-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a00-0000-1000-8000-00805f9b34fb", + "properties": [ + "read", + "write" + ], + "data": [ + [ + 82, + 73, + 90, + 69, + 82 + ] + ] + }, + { + "uuid": "00002a01-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 0 + ] + ] + }, + { + "uuid": "00002a04-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 24, + 0, + 48, + 0, + 0, + 0, + 144, + 1 + ] + ] + }, + { + "uuid": "00002aa6-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 1 + ] + ] + } + ], + "00001801-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a05-0000-1000-8000-00805f9b34fb", + "properties": [ + "indicate" + ], + "data": [], + "error": "Could not read characteristic handle 11: Protocol Error 0x02: Read Not Permitted" + } + ], + "0000180a-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a29-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 69, + 108, + 105, + 116, + 101 + ] + ] + }, + { + "uuid": "00002a25-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 56, + 48, + 57 + ] + ] + }, + { + "uuid": "00002a27-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 51 + ] + ] + }, + { + "uuid": "00002a26-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 50, + 52 + ] + ] + }, + { + "uuid": "00002a28-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 50, + 52 + ] + ] + } + ], + "0000fe59-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "8ec90003-f315-4f60-9fb8-838830daea50", + "properties": [ + "write", + "indicate" + ], + "data": [ + [] + ] + } + ], + "347b0001-7635-408b-8918-8ff3949ce592": [ + { + "uuid": "347b0012-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 30: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0013-7635-408b-8918-8ff3949ce592", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + ] + }, + { + "uuid": "347b0014-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0 + ] + ] + }, + { + "uuid": "347b0016-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 37: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0017-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0 + ] + ] + }, + { + "uuid": "347b0019-7635-408b-8918-8ff3949ce592", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 228, + 1, + 0, + 0 + ] + ] + }, + { + "uuid": "347b0030-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 32, + 9, + 155, + 193 + ] + ] + }, + { + "uuid": "347b0031-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 47: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0032-7635-408b-8918-8ff3949ce592", + "properties": [ + "indicate" + ], + "data": [ + [] + ] + }, + { + "uuid": "347b0022-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0, + 100, + 129, + 60 + ] + ] + }, + { + "uuid": "347b0020-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 55: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0021-7635-408b-8918-8ff3949ce592", + "properties": [ + "indicate" + ], + "data": [ + [] + ] + } + ] +} \ No newline at end of file diff --git a/develop/middle_ble_device_data.json b/develop/middle_ble_device_data.json new file mode 100644 index 0000000..1e882f6 --- /dev/null +++ b/develop/middle_ble_device_data.json @@ -0,0 +1,410 @@ +{ + "00001800-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a00-0000-1000-8000-00805f9b34fb", + "properties": [ + "read", + "write" + ], + "data": [ + [ + 82, + 73, + 90, + 69, + 82 + ] + ] + }, + { + "uuid": "00002a01-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 0 + ] + ] + }, + { + "uuid": "00002a04-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 24, + 0, + 48, + 0, + 0, + 0, + 144, + 1 + ] + ] + }, + { + "uuid": "00002aa6-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 1 + ] + ] + } + ], + "00001801-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a05-0000-1000-8000-00805f9b34fb", + "properties": [ + "indicate" + ], + "data": [], + "error": "Could not read characteristic handle 11: Protocol Error 0x02: Read Not Permitted" + } + ], + "0000180a-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a29-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 69, + 108, + 105, + 116, + 101 + ] + ] + }, + { + "uuid": "00002a25-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 56, + 48, + 57 + ] + ] + }, + { + "uuid": "00002a27-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 51 + ] + ] + }, + { + "uuid": "00002a26-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 50, + 52 + ] + ] + }, + { + "uuid": "00002a28-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 50, + 52 + ] + ] + } + ], + "0000fe59-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "8ec90003-f315-4f60-9fb8-838830daea50", + "properties": [ + "write", + "indicate" + ], + "data": [ + [] + ] + } + ], + "347b0001-7635-408b-8918-8ff3949ce592": [ + { + "uuid": "347b0012-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 30: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0013-7635-408b-8918-8ff3949ce592", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + ] + }, + { + "uuid": "347b0014-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0 + ] + ] + }, + { + "uuid": "347b0016-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 37: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0017-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0 + ] + ] + }, + { + "uuid": "347b0019-7635-408b-8918-8ff3949ce592", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 228, + 1, + 0, + 0 + ] + ] + }, + { + "uuid": "347b0030-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 224, + 231, + 167, + 192 + ] + ] + }, + { + "uuid": "347b0031-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 47: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0032-7635-408b-8918-8ff3949ce592", + "properties": [ + "indicate" + ], + "data": [ + [] + ] + }, + { + "uuid": "347b0022-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0, + 100, + 129, + 60 + ] + ] + }, + { + "uuid": "347b0020-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 55: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0021-7635-408b-8918-8ff3949ce592", + "properties": [ + "indicate" + ], + "data": [ + [] + ] + } + ] +} \ No newline at end of file diff --git a/develop/plot_json.py b/develop/plot_json.py new file mode 100644 index 0000000..d214322 --- /dev/null +++ b/develop/plot_json.py @@ -0,0 +1,53 @@ +import json +import matplotlib.pyplot as plt +import numpy as np + +def load_and_plot(): + # Load the JSON data + with open('rizer_data.json', 'r') as f: + data = json.load(f) + + # Extract the first element from each inner list for all four categories + single_y_values_1 = [inner_list[0] for inner_list in data] + single_y_values_2 = [inner_list[1] for inner_list in data] + single_y_values_3 = [inner_list[2] for inner_list in data] + single_y_values_4 = [inner_list[3] for inner_list in data] + + # Create a 2x2 grid of subplots + fig, axs = plt.subplots(2, 2, figsize=(15, 12)) + + # Plot Category 1 + axs[0, 0].plot(range(len(data)), single_y_values_1, color='blue', label='First Value') + axs[0, 0].set_title('Category 1') + axs[0, 0].set_xlabel('Index') + axs[0, 0].set_ylabel('Value') + axs[0, 0].legend() + + # Plot Category 2 + axs[0, 1].plot(range(len(data)), single_y_values_2, color='green', label='Second Value') + axs[0, 1].set_title('Category 2') + axs[0, 1].set_xlabel('Index') + axs[0, 1].set_ylabel('Value') + axs[0, 1].legend() + + # Plot Category 3 + axs[1, 0].plot(range(len(data)), single_y_values_3, color='red', label='Third Value') + axs[1, 0].plot(range(len(data)), single_y_values_4, color='purple', label='Fourth Value') + axs[1, 0].set_title('Category 3') + axs[1, 0].set_xlabel('Index') + axs[1, 0].set_ylabel('Value') + axs[1, 0].legend() + + # Plot Category 4 + axs[1, 1].plot(range(len(data)), single_y_values_4, color='purple', label='Fourth Value') + axs[1, 1].set_title('Category 4') + axs[1, 1].set_xlabel('Index') + axs[1, 1].set_ylabel('Value') + axs[1, 1].legend() + + # Adjust layout + plt.tight_layout() + plt.show() + +if __name__ == "__main__": + load_and_plot() diff --git a/develop/read_all_rizer.py b/develop/read_all_rizer.py new file mode 100644 index 0000000..02d7cbd --- /dev/null +++ b/develop/read_all_rizer.py @@ -0,0 +1,147 @@ +import asyncio +from bleak import BleakClient, exc, BleakScanner +import socket +import time +import json + +class TestRizer: + + #BLE constant + DEVICE_NAME = "RIZER" + DEVICE_UUID = "fc:12:65:28:cb:44" + + SERVICE_STEERING_UUID = "347b0001-7635-408b-8918-8ff3949ce592" + CHARACTERISTICS_STEERING_UUID = "347b0030-7635-408b-8918-8ff3949ce592" + + client_is_connected = False + listCharacteristic = [] + + listen_data = {} + + data_list = [] + + +#---------------------------BLE functions-------------------------------- + #function to initialize the BLE connection with the Rizer + async def start_notification(self, characteristic): + print("characteristic: ", characteristic) + if self.client_is_connected: + try: + #for characteristic in self.listCharacteristic: + await self.client.start_notify( + characteristic, + self.on_steering_changed + ) + print("Started notification for steering characteristic") + except Exception as e: + print(f"Failed to start notification: {e}") + else: + print("Not connected to the device") + + async def stop_notification(self): + if self.client_is_connected: + try: + await self.client.stop_notify() + print("Stopped notification for steering characteristic") + except Exception as e: + print(f"Failed to stop notification: {e}") + + + async def on_steering_changed(self, sender, data): + data = bytearray(data) + self.data_list.append([byte for byte in data]) + print(f"Sender {sender}: \n Steering changed: {data}") + print(f"Sender {sender}: \n Steering changed: {[byte for byte in data]}") + + + def save_to_json(self, filename="ble_device_data.json"): + with open(filename, 'w') as f: + json.dump(self.data, f, indent=2) + print(f"Data saved to {filename}") + + async def connect_rizer(self): + print("Start async init") + while not self.client_is_connected: + try: + self.client = BleakClient(self.DEVICE_UUID, timeout=90) + print("Trying to connect") + await self.client.connect() + self.client_is_connected = True + print(f"Client connected to {self.DEVICE_UUID}") + + # Initialize data structure + self.data = {} + + for service in self.client.services: + service_uuid = str(service.uuid) + self.data[service_uuid] = [] + + for characteristic in service.characteristics: + if (characteristic.uuid == self.CHARACTERISTICS_STEERING_UUID): + self.listCharacteristic.append(characteristic) + + char_uuid = str(characteristic.uuid) + char_data = { + "uuid": char_uuid, + "properties": characteristic.properties, + "data": [] + } + self.data[service_uuid].append(char_data) + + + print(f"=== Trying to read Data for {char_uuid}:") + + try: + value = await self.client.read_gatt_char(characteristic.uuid) + data = bytearray(value) + print(f"=== Data: {[byte for byte in data]}") + + # Store the data + char_data["data"].append([byte for byte in data]) + except exc.BleakError as e: + print(f"=== Failed to read Data!") + char_data["error"] = str(e) + + print("\n") + + except exc.BleakError as e: + print(f"Failed to connect/discover services of {self.DEVICE_UUID}: {e}") + + return self.data + + + + +rizer = TestRizer() + +async def main(): + + #config = "middle" + await rizer.connect_rizer() + + #rizer.save_to_json(filename= config +"_ble_device_data.json") + + + + + for charc in rizer.listCharacteristic: + + await rizer.start_notification(characteristic = charc) + + # Keep the connection alive for a while + await asyncio.sleep(60) + + await rizer.stop_notification() + + print(rizer.data_list) + # Specify the file path and name + file_path = 'rizer_data.json' + + # Open the file in write mode + with open(file_path, 'w') as f: + # Use json.dump() to serialize the data to JSON format + json.dump(rizer.data_list, f, indent=4) + + print(f"Data saved to {file_path}") + +asyncio.run(main()) diff --git a/develop/right_ble_device_data.json b/develop/right_ble_device_data.json new file mode 100644 index 0000000..f902479 --- /dev/null +++ b/develop/right_ble_device_data.json @@ -0,0 +1,410 @@ +{ + "00001800-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a00-0000-1000-8000-00805f9b34fb", + "properties": [ + "read", + "write" + ], + "data": [ + [ + 82, + 73, + 90, + 69, + 82 + ] + ] + }, + { + "uuid": "00002a01-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 0 + ] + ] + }, + { + "uuid": "00002a04-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 24, + 0, + 48, + 0, + 0, + 0, + 144, + 1 + ] + ] + }, + { + "uuid": "00002aa6-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 1 + ] + ] + } + ], + "00001801-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a05-0000-1000-8000-00805f9b34fb", + "properties": [ + "indicate" + ], + "data": [], + "error": "Could not read characteristic handle 11: Protocol Error 0x02: Read Not Permitted" + } + ], + "0000180a-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "00002a29-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 69, + 108, + 105, + 116, + 101 + ] + ] + }, + { + "uuid": "00002a25-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 56, + 48, + 57 + ] + ] + }, + { + "uuid": "00002a27-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 51 + ] + ] + }, + { + "uuid": "00002a26-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 50, + 52 + ] + ] + }, + { + "uuid": "00002a28-0000-1000-8000-00805f9b34fb", + "properties": [ + "read" + ], + "data": [ + [ + 50, + 52 + ] + ] + } + ], + "0000fe59-0000-1000-8000-00805f9b34fb": [ + { + "uuid": "8ec90003-f315-4f60-9fb8-838830daea50", + "properties": [ + "write", + "indicate" + ], + "data": [ + [] + ] + } + ], + "347b0001-7635-408b-8918-8ff3949ce592": [ + { + "uuid": "347b0012-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 30: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0013-7635-408b-8918-8ff3949ce592", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + ] + }, + { + "uuid": "347b0014-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0 + ] + ] + }, + { + "uuid": "347b0016-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 37: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0017-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 0 + ] + ] + }, + { + "uuid": "347b0019-7635-408b-8918-8ff3949ce592", + "properties": [ + "read" + ], + "data": [ + [ + 0, + 228, + 1, + 0, + 0 + ] + ] + }, + { + "uuid": "347b0030-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 168, + 166, + 39, + 193 + ] + ] + }, + { + "uuid": "347b0031-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 47: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0032-7635-408b-8918-8ff3949ce592", + "properties": [ + "indicate" + ], + "data": [ + [] + ] + }, + { + "uuid": "347b0022-7635-408b-8918-8ff3949ce592", + "properties": [ + "notify" + ], + "data": [ + [ + 255, + 100, + 129, + 60 + ] + ] + }, + { + "uuid": "347b0020-7635-408b-8918-8ff3949ce592", + "properties": [ + "write" + ], + "data": [], + "error": "Could not read characteristic handle 55: Protocol Error 0x02: Read Not Permitted" + }, + { + "uuid": "347b0021-7635-408b-8918-8ff3949ce592", + "properties": [ + "indicate" + ], + "data": [ + [] + ] + } + ] +} \ No newline at end of file diff --git a/develop/rizer_data.json b/develop/rizer_data.json new file mode 100644 index 0000000..5becd8a --- /dev/null +++ b/develop/rizer_data.json @@ -0,0 +1,3638 @@ +[ + [ + 0, + 161, + 4, + 192 + ], + [ + 224, + 246, + 2, + 192 + ], + [ + 64, + 131, + 253, + 191 + ], + [ + 160, + 100, + 11, + 192 + ], + [ + 192, + 67, + 17, + 192 + ], + [ + 224, + 32, + 23, + 192 + ], + [ + 0, + 124, + 21, + 192 + ], + [ + 0, + 245, + 13, + 192 + ], + [ + 192, + 67, + 17, + 192 + ], + [ + 64, + 214, + 8, + 192 + ], + [ + 128, + 179, + 14, + 192 + ], + [ + 224, + 246, + 2, + 192 + ], + [ + 128, + 53, + 8, + 191 + ], + [ + 64, + 99, + 180, + 63 + ], + [ + 49, + 38, + 124, + 64 + ], + [ + 207, + 176, + 217, + 64 + ], + [ + 216, + 240, + 30, + 65 + ], + [ + 108, + 167, + 69, + 65 + ], + [ + 164, + 250, + 102, + 65 + ], + [ + 172, + 173, + 103, + 65 + ], + [ + 79, + 177, + 100, + 65 + ], + [ + 164, + 250, + 102, + 65 + ], + [ + 79, + 41, + 106, + 65 + ], + [ + 40, + 249, + 105, + 65 + ], + [ + 88, + 69, + 105, + 65 + ], + [ + 88, + 69, + 105, + 65 + ], + [ + 12, + 97, + 104, + 65 + ], + [ + 12, + 97, + 104, + 65 + ], + [ + 4, + 48, + 104, + 65 + ], + [ + 4, + 48, + 104, + 65 + ], + [ + 4, + 48, + 104, + 65 + ], + [ + 40, + 249, + 105, + 65 + ], + [ + 4, + 228, + 104, + 65 + ], + [ + 12, + 97, + 104, + 65 + ], + [ + 12, + 97, + 104, + 65 + ], + [ + 212, + 254, + 103, + 65 + ], + [ + 216, + 200, + 105, + 65 + ], + [ + 4, + 228, + 104, + 65 + ], + [ + 120, + 101, + 102, + 65 + ], + [ + 76, + 25, + 103, + 65 + ], + [ + 212, + 254, + 103, + 65 + ], + [ + 76, + 25, + 103, + 65 + ], + [ + 228, + 254, + 100, + 65 + ], + [ + 152, + 102, + 99, + 65 + ], + [ + 24, + 61, + 93, + 65 + ], + [ + 52, + 3, + 81, + 65 + ], + [ + 40, + 71, + 65, + 65 + ], + [ + 184, + 38, + 43, + 65 + ], + [ + 60, + 88, + 25, + 65 + ], + [ + 120, + 79, + 10, + 65 + ], + [ + 15, + 178, + 243, + 64 + ], + [ + 136, + 124, + 205, + 64 + ], + [ + 232, + 80, + 175, + 64 + ], + [ + 248, + 68, + 154, + 64 + ], + [ + 241, + 225, + 117, + 64 + ], + [ + 160, + 3, + 15, + 64 + ], + [ + 128, + 43, + 41, + 63 + ], + [ + 128, + 162, + 43, + 191 + ], + [ + 0, + 196, + 204, + 191 + ], + [ + 32, + 74, + 6, + 192 + ], + [ + 192, + 22, + 2, + 192 + ], + [ + 0, + 201, + 251, + 191 + ], + [ + 224, + 55, + 1, + 192 + ], + [ + 64, + 26, + 245, + 191 + ], + [ + 0, + 161, + 4, + 192 + ], + [ + 192, + 114, + 248, + 191 + ], + [ + 192, + 22, + 2, + 192 + ], + [ + 192, + 22, + 2, + 192 + ], + [ + 192, + 22, + 2, + 192 + ], + [ + 0, + 161, + 4, + 192 + ], + [ + 224, + 251, + 28, + 192 + ], + [ + 128, + 136, + 93, + 192 + ], + [ + 128, + 157, + 163, + 192 + ], + [ + 32, + 72, + 210, + 192 + ], + [ + 80, + 61, + 2, + 193 + ], + [ + 112, + 124, + 29, + 193 + ], + [ + 136, + 15, + 54, + 193 + ], + [ + 40, + 118, + 82, + 193 + ], + [ + 96, + 132, + 117, + 193 + ], + [ + 216, + 196, + 145, + 193 + ], + [ + 72, + 138, + 148, + 193 + ], + [ + 188, + 246, + 147, + 193 + ], + [ + 28, + 69, + 150, + 193 + ], + [ + 104, + 204, + 150, + 193 + ], + [ + 88, + 31, + 150, + 193 + ], + [ + 216, + 71, + 151, + 193 + ], + [ + 216, + 71, + 151, + 193 + ], + [ + 148, + 179, + 150, + 193 + ], + [ + 28, + 167, + 150, + 193 + ], + [ + 4, + 192, + 150, + 193 + ], + [ + 148, + 179, + 150, + 193 + ], + [ + 140, + 56, + 150, + 193 + ], + [ + 140, + 56, + 150, + 193 + ], + [ + 88, + 31, + 150, + 193 + ], + [ + 184, + 164, + 149, + 193 + ], + [ + 40, + 139, + 149, + 193 + ], + [ + 248, + 3, + 149, + 193 + ], + [ + 148, + 43, + 148, + 193 + ], + [ + 240, + 63, + 145, + 193 + ], + [ + 232, + 140, + 129, + 193 + ], + [ + 79, + 171, + 65, + 193 + ], + [ + 224, + 37, + 246, + 192 + ], + [ + 177, + 73, + 197, + 192 + ], + [ + 143, + 250, + 238, + 192 + ], + [ + 48, + 1, + 11, + 193 + ], + [ + 56, + 167, + 28, + 193 + ], + [ + 176, + 70, + 27, + 193 + ], + [ + 160, + 208, + 19, + 193 + ], + [ + 224, + 254, + 18, + 193 + ], + [ + 24, + 25, + 20, + 193 + ], + [ + 96, + 97, + 20, + 193 + ], + [ + 96, + 97, + 20, + 193 + ], + [ + 88, + 235, + 20, + 193 + ], + [ + 128, + 129, + 16, + 193 + ], + [ + 200, + 250, + 15, + 193 + ], + [ + 64, + 106, + 7, + 193 + ], + [ + 64, + 197, + 246, + 192 + ], + [ + 49, + 66, + 200, + 192 + ], + [ + 240, + 101, + 146, + 192 + ], + [ + 96, + 239, + 29, + 192 + ], + [ + 0, + 62, + 215, + 190 + ], + [ + 192, + 89, + 208, + 63 + ], + [ + 192, + 110, + 126, + 64 + ], + [ + 56, + 97, + 199, + 64 + ], + [ + 76, + 20, + 1, + 65 + ], + [ + 143, + 6, + 41, + 65 + ], + [ + 160, + 210, + 77, + 65 + ], + [ + 68, + 25, + 100, + 65 + ], + [ + 4, + 178, + 101, + 65 + ], + [ + 120, + 101, + 102, + 65 + ], + [ + 177, + 103, + 105, + 65 + ], + [ + 172, + 127, + 101, + 65 + ], + [ + 4, + 178, + 101, + 65 + ], + [ + 120, + 101, + 102, + 65 + ], + [ + 172, + 127, + 101, + 65 + ], + [ + 96, + 151, + 102, + 65 + ], + [ + 44, + 77, + 101, + 65 + ], + [ + 172, + 127, + 101, + 65 + ], + [ + 172, + 127, + 101, + 65 + ], + [ + 104, + 51, + 102, + 65 + ], + [ + 236, + 74, + 103, + 65 + ], + [ + 120, + 205, + 103, + 65 + ], + [ + 120, + 205, + 103, + 65 + ], + [ + 4, + 179, + 99, + 65 + ], + [ + 212, + 255, + 98, + 65 + ], + [ + 168, + 135, + 78, + 65 + ], + [ + 136, + 201, + 43, + 65 + ], + [ + 113, + 59, + 252, + 64 + ], + [ + 160, + 170, + 89, + 64 + ], + [ + 0, + 192, + 241, + 191 + ], + [ + 192, + 204, + 170, + 192 + ], + [ + 177, + 55, + 190, + 192 + ], + [ + 0, + 196, + 139, + 192 + ], + [ + 128, + 96, + 55, + 192 + ], + [ + 224, + 32, + 23, + 192 + ], + [ + 32, + 204, + 35, + 192 + ], + [ + 64, + 196, + 78, + 192 + ], + [ + 0, + 47, + 77, + 192 + ], + [ + 128, + 4, + 83, + 192 + ], + [ + 32, + 191, + 69, + 192 + ], + [ + 160, + 32, + 51, + 192 + ], + [ + 128, + 90, + 54, + 192 + ], + [ + 0, + 175, + 68, + 192 + ], + [ + 192, + 178, + 85, + 192 + ], + [ + 160, + 144, + 57, + 192 + ], + [ + 64, + 87, + 71, + 192 + ], + [ + 96, + 198, + 97, + 192 + ], + [ + 80, + 65, + 144, + 192 + ], + [ + 128, + 190, + 188, + 192 + ], + [ + 192, + 220, + 224, + 192 + ], + [ + 248, + 183, + 5, + 193 + ], + [ + 80, + 82, + 30, + 193 + ], + [ + 8, + 103, + 63, + 193 + ], + [ + 168, + 193, + 86, + 193 + ], + [ + 113, + 75, + 107, + 193 + ], + [ + 79, + 210, + 124, + 193 + ], + [ + 84, + 177, + 141, + 193 + ], + [ + 56, + 99, + 147, + 193 + ], + [ + 148, + 43, + 148, + 193 + ], + [ + 112, + 233, + 147, + 193 + ], + [ + 132, + 248, + 146, + 193 + ], + [ + 20, + 126, + 147, + 193 + ], + [ + 56, + 17, + 148, + 193 + ], + [ + 172, + 112, + 147, + 193 + ], + [ + 132, + 248, + 146, + 193 + ], + [ + 228, + 87, + 146, + 193 + ], + [ + 100, + 164, + 148, + 193 + ], + [ + 248, + 234, + 146, + 193 + ], + [ + 104, + 177, + 148, + 193 + ], + [ + 132, + 248, + 146, + 193 + ], + [ + 180, + 35, + 145, + 193 + ], + [ + 248, + 234, + 146, + 193 + ], + [ + 132, + 248, + 146, + 193 + ], + [ + 160, + 101, + 146, + 193 + ], + [ + 44, + 100, + 130, + 193 + ], + [ + 120, + 220, + 61, + 193 + ], + [ + 96, + 151, + 221, + 192 + ], + [ + 96, + 200, + 170, + 192 + ], + [ + 64, + 115, + 204, + 192 + ], + [ + 192, + 83, + 1, + 193 + ], + [ + 72, + 195, + 21, + 193 + ], + [ + 184, + 149, + 22, + 193 + ], + [ + 168, + 77, + 14, + 193 + ], + [ + 88, + 126, + 13, + 193 + ], + [ + 144, + 200, + 13, + 193 + ], + [ + 144, + 200, + 13, + 193 + ], + [ + 168, + 77, + 14, + 193 + ], + [ + 104, + 3, + 14, + 193 + ], + [ + 184, + 158, + 12, + 193 + ], + [ + 160, + 158, + 4, + 193 + ], + [ + 143, + 250, + 238, + 192 + ], + [ + 177, + 241, + 205, + 192 + ], + [ + 79, + 51, + 167, + 192 + ], + [ + 16, + 14, + 132, + 192 + ], + [ + 32, + 26, + 76, + 192 + ], + [ + 0, + 192, + 241, + 191 + ], + [ + 0, + 146, + 86, + 191 + ], + [ + 0, + 16, + 170, + 62 + ], + [ + 64, + 99, + 180, + 63 + ], + [ + 160, + 73, + 53, + 64 + ], + [ + 240, + 98, + 143, + 64 + ], + [ + 15, + 112, + 213, + 64 + ], + [ + 24, + 239, + 7, + 65 + ], + [ + 88, + 154, + 42, + 65 + ], + [ + 108, + 206, + 82, + 65 + ], + [ + 236, + 74, + 103, + 65 + ], + [ + 4, + 178, + 101, + 65 + ], + [ + 104, + 51, + 102, + 65 + ], + [ + 104, + 51, + 102, + 65 + ], + [ + 44, + 77, + 101, + 65 + ], + [ + 44, + 77, + 101, + 65 + ], + [ + 148, + 102, + 100, + 65 + ], + [ + 136, + 153, + 100, + 65 + ], + [ + 76, + 25, + 103, + 65 + ], + [ + 120, + 101, + 102, + 65 + ], + [ + 124, + 231, + 102, + 65 + ], + [ + 136, + 153, + 100, + 65 + ], + [ + 136, + 153, + 100, + 65 + ], + [ + 116, + 51, + 100, + 65 + ], + [ + 60, + 230, + 99, + 65 + ], + [ + 84, + 232, + 96, + 65 + ], + [ + 136, + 159, + 77, + 65 + ], + [ + 60, + 11, + 60, + 65 + ], + [ + 244, + 150, + 31, + 65 + ], + [ + 184, + 33, + 249, + 64 + ], + [ + 208, + 5, + 135, + 64 + ], + [ + 0, + 50, + 236, + 62 + ], + [ + 224, + 43, + 103, + 192 + ], + [ + 32, + 91, + 169, + 192 + ], + [ + 32, + 147, + 145, + 192 + ], + [ + 192, + 178, + 85, + 192 + ], + [ + 128, + 42, + 34, + 192 + ], + [ + 160, + 29, + 50, + 192 + ], + [ + 192, + 235, + 81, + 192 + ], + [ + 96, + 112, + 64, + 192 + ], + [ + 224, + 54, + 69, + 192 + ], + [ + 224, + 100, + 63, + 192 + ], + [ + 224, + 8, + 66, + 192 + ], + [ + 64, + 186, + 51, + 192 + ], + [ + 32, + 56, + 96, + 192 + ], + [ + 208, + 4, + 160, + 192 + ], + [ + 15, + 199, + 203, + 192 + ], + [ + 143, + 69, + 254, + 192 + ], + [ + 56, + 171, + 28, + 193 + ], + [ + 8, + 145, + 55, + 193 + ], + [ + 56, + 55, + 80, + 193 + ], + [ + 152, + 1, + 112, + 193 + ], + [ + 128, + 116, + 135, + 193 + ], + [ + 56, + 99, + 147, + 193 + ], + [ + 56, + 99, + 147, + 193 + ], + [ + 104, + 177, + 148, + 193 + ], + [ + 72, + 138, + 148, + 193 + ], + [ + 156, + 55, + 149, + 193 + ], + [ + 20, + 126, + 147, + 193 + ], + [ + 56, + 17, + 148, + 193 + ], + [ + 24, + 166, + 147, + 193 + ], + [ + 188, + 246, + 147, + 193 + ], + [ + 12, + 6, + 147, + 193 + ], + [ + 216, + 196, + 145, + 193 + ], + [ + 92, + 3, + 139, + 193 + ], + [ + 40, + 100, + 111, + 193 + ], + [ + 56, + 55, + 80, + 193 + ], + [ + 88, + 213, + 40, + 193 + ], + [ + 32, + 32, + 4, + 193 + ], + [ + 160, + 104, + 197, + 192 + ], + [ + 176, + 242, + 134, + 192 + ], + [ + 64, + 214, + 8, + 192 + ], + [ + 0, + 160, + 83, + 190 + ], + [ + 64, + 141, + 216, + 63 + ], + [ + 15, + 192, + 89, + 64 + ], + [ + 136, + 226, + 185, + 64 + ], + [ + 44, + 42, + 5, + 65 + ], + [ + 104, + 99, + 40, + 65 + ], + [ + 0, + 59, + 66, + 65 + ], + [ + 15, + 25, + 98, + 65 + ], + [ + 212, + 254, + 103, + 65 + ], + [ + 96, + 151, + 102, + 65 + ], + [ + 172, + 127, + 101, + 65 + ], + [ + 236, + 74, + 103, + 65 + ], + [ + 76, + 25, + 103, + 65 + ], + [ + 60, + 230, + 99, + 65 + ], + [ + 76, + 25, + 103, + 65 + ], + [ + 148, + 102, + 100, + 65 + ], + [ + 120, + 96, + 89, + 65 + ], + [ + 236, + 211, + 68, + 65 + ], + [ + 208, + 200, + 28, + 65 + ], + [ + 56, + 222, + 227, + 64 + ], + [ + 72, + 45, + 155, + 64 + ], + [ + 177, + 151, + 83, + 64 + ], + [ + 128, + 69, + 185, + 63 + ], + [ + 0, + 100, + 215, + 189 + ], + [ + 64, + 131, + 253, + 191 + ], + [ + 64, + 187, + 87, + 192 + ], + [ + 240, + 183, + 155, + 192 + ], + [ + 96, + 157, + 209, + 192 + ], + [ + 192, + 83, + 1, + 193 + ], + [ + 240, + 87, + 25, + 193 + ], + [ + 120, + 147, + 53, + 193 + ], + [ + 207, + 217, + 76, + 193 + ], + [ + 152, + 35, + 90, + 193 + ], + [ + 49, + 148, + 102, + 193 + ], + [ + 184, + 161, + 126, + 193 + ], + [ + 76, + 215, + 142, + 193 + ], + [ + 104, + 204, + 150, + 193 + ], + [ + 120, + 177, + 149, + 193 + ], + [ + 184, + 164, + 149, + 193 + ], + [ + 56, + 244, + 151, + 193 + ], + [ + 160, + 81, + 150, + 193 + ], + [ + 140, + 56, + 150, + 193 + ], + [ + 140, + 56, + 150, + 193 + ], + [ + 116, + 139, + 147, + 193 + ], + [ + 104, + 177, + 148, + 193 + ], + [ + 100, + 164, + 148, + 193 + ], + [ + 40, + 173, + 144, + 193 + ], + [ + 216, + 186, + 136, + 193 + ], + [ + 96, + 30, + 120, + 193 + ], + [ + 177, + 151, + 92, + 193 + ], + [ + 200, + 145, + 68, + 193 + ], + [ + 248, + 88, + 51, + 193 + ], + [ + 48, + 155, + 33, + 193 + ], + [ + 56, + 221, + 22, + 193 + ], + [ + 96, + 81, + 6, + 193 + ], + [ + 224, + 251, + 223, + 192 + ], + [ + 241, + 51, + 172, + 192 + ], + [ + 48, + 214, + 137, + 192 + ], + [ + 160, + 69, + 43, + 192 + ], + [ + 64, + 120, + 159, + 191 + ], + [ + 0, + 80, + 50, + 62 + ], + [ + 128, + 57, + 184, + 63 + ], + [ + 79, + 56, + 47, + 64 + ], + [ + 96, + 29, + 116, + 64 + ], + [ + 15, + 185, + 168, + 64 + ], + [ + 15, + 112, + 213, + 64 + ], + [ + 224, + 163, + 2, + 65 + ], + [ + 240, + 251, + 24, + 65 + ], + [ + 116, + 185, + 40, + 65 + ], + [ + 136, + 190, + 61, + 65 + ], + [ + 228, + 88, + 77, + 65 + ], + [ + 92, + 100, + 92, + 65 + ], + [ + 60, + 230, + 99, + 65 + ], + [ + 4, + 178, + 101, + 65 + ], + [ + 76, + 51, + 99, + 65 + ], + [ + 76, + 25, + 103, + 65 + ], + [ + 252, + 129, + 104, + 65 + ], + [ + 76, + 25, + 103, + 65 + ], + [ + 177, + 103, + 105, + 65 + ], + [ + 104, + 51, + 102, + 65 + ], + [ + 44, + 77, + 101, + 65 + ], + [ + 236, + 155, + 103, + 65 + ], + [ + 36, + 156, + 101, + 65 + ], + [ + 84, + 152, + 98, + 65 + ], + [ + 24, + 61, + 93, + 65 + ], + [ + 24, + 229, + 74, + 65 + ], + [ + 164, + 195, + 53, + 65 + ], + [ + 248, + 36, + 28, + 65 + ], + [ + 56, + 169, + 10, + 65 + ], + [ + 136, + 245, + 230, + 64 + ], + [ + 232, + 162, + 192, + 64 + ], + [ + 168, + 88, + 155, + 64 + ], + [ + 96, + 33, + 129, + 64 + ], + [ + 113, + 98, + 61, + 64 + ], + [ + 0, + 120, + 241, + 63 + ], + [ + 0, + 112, + 221, + 62 + ], + [ + 128, + 204, + 55, + 191 + ], + [ + 192, + 63, + 255, + 191 + ], + [ + 128, + 90, + 54, + 192 + ], + [ + 0, + 158, + 101, + 192 + ], + [ + 16, + 22, + 137, + 192 + ], + [ + 32, + 172, + 173, + 192 + ], + [ + 207, + 229, + 198, + 192 + ], + [ + 241, + 224, + 229, + 192 + ], + [ + 32, + 103, + 247, + 192 + ], + [ + 48, + 137, + 14, + 193 + ], + [ + 32, + 241, + 28, + 193 + ], + [ + 88, + 213, + 40, + 193 + ], + [ + 8, + 26, + 51, + 193 + ], + [ + 15, + 101, + 61, + 193 + ], + [ + 192, + 44, + 74, + 193 + ], + [ + 8, + 54, + 89, + 193 + ], + [ + 49, + 251, + 105, + 193 + ], + [ + 116, + 136, + 128, + 193 + ], + [ + 48, + 108, + 140, + 193 + ], + [ + 192, + 85, + 147, + 193 + ], + [ + 188, + 246, + 147, + 193 + ], + [ + 100, + 164, + 148, + 193 + ], + [ + 156, + 55, + 149, + 193 + ], + [ + 220, + 29, + 149, + 193 + ], + [ + 248, + 3, + 149, + 193 + ], + [ + 140, + 56, + 150, + 193 + ], + [ + 144, + 59, + 151, + 193 + ], + [ + 156, + 154, + 150, + 193 + ], + [ + 244, + 151, + 149, + 193 + ], + [ + 244, + 151, + 149, + 193 + ], + [ + 248, + 43, + 150, + 193 + ], + [ + 96, + 190, + 148, + 193 + ], + [ + 56, + 17, + 148, + 193 + ], + [ + 40, + 173, + 144, + 193 + ], + [ + 232, + 76, + 137, + 193 + ], + [ + 40, + 245, + 125, + 193 + ], + [ + 88, + 76, + 97, + 193 + ], + [ + 88, + 238, + 71, + 193 + ], + [ + 0, + 123, + 50, + 193 + ], + [ + 176, + 165, + 33, + 193 + ], + [ + 144, + 29, + 15, + 193 + ], + [ + 79, + 135, + 240, + 192 + ], + [ + 192, + 32, + 195, + 192 + ], + [ + 240, + 121, + 146, + 192 + ], + [ + 0, + 246, + 55, + 192 + ], + [ + 64, + 186, + 177, + 191 + ], + [ + 0, + 200, + 54, + 190 + ], + [ + 0, + 82, + 120, + 63 + ], + [ + 160, + 234, + 22, + 64 + ], + [ + 160, + 243, + 101, + 64 + ], + [ + 72, + 132, + 155, + 64 + ], + [ + 248, + 78, + 194, + 64 + ], + [ + 40, + 43, + 237, + 64 + ], + [ + 164, + 31, + 12, + 65 + ], + [ + 216, + 200, + 33, + 65 + ], + [ + 152, + 103, + 46, + 65 + ], + [ + 28, + 185, + 63, + 65 + ], + [ + 49, + 21, + 75, + 65 + ], + [ + 15, + 209, + 87, + 65 + ], + [ + 120, + 154, + 97, + 65 + ], + [ + 68, + 25, + 100, + 65 + ], + [ + 172, + 127, + 101, + 65 + ], + [ + 152, + 102, + 99, + 65 + ], + [ + 248, + 76, + 98, + 65 + ], + [ + 60, + 230, + 99, + 65 + ], + [ + 236, + 74, + 103, + 65 + ], + [ + 76, + 204, + 100, + 65 + ], + [ + 76, + 204, + 100, + 65 + ], + [ + 120, + 101, + 102, + 65 + ], + [ + 136, + 153, + 100, + 65 + ], + [ + 60, + 230, + 99, + 65 + ], + [ + 192, + 206, + 101, + 65 + ], + [ + 44, + 77, + 101, + 65 + ], + [ + 148, + 102, + 100, + 65 + ], + [ + 241, + 49, + 97, + 65 + ], + [ + 177, + 191, + 90, + 65 + ], + [ + 143, + 39, + 70, + 65 + ], + [ + 177, + 108, + 44, + 65 + ], + [ + 16, + 134, + 27, + 65 + ], + [ + 56, + 169, + 10, + 65 + ], + [ + 113, + 63, + 240, + 64 + ], + [ + 15, + 182, + 202, + 64 + ], + [ + 240, + 118, + 163, + 64 + ], + [ + 128, + 248, + 123, + 64 + ], + [ + 177, + 40, + 41, + 64 + ], + [ + 0, + 134, + 30, + 63 + ], + [ + 128, + 65, + 110, + 191 + ], + [ + 64, + 7, + 40, + 192 + ], + [ + 64, + 89, + 126, + 192 + ], + [ + 224, + 163, + 168, + 192 + ], + [ + 160, + 185, + 196, + 192 + ], + [ + 241, + 177, + 227, + 192 + ], + [ + 232, + 55, + 3, + 193 + ], + [ + 248, + 237, + 10, + 193 + ], + [ + 192, + 131, + 24, + 193 + ], + [ + 168, + 125, + 34, + 193 + ], + [ + 40, + 118, + 52, + 193 + ], + [ + 216, + 251, + 64, + 193 + ], + [ + 192, + 188, + 73, + 193 + ], + [ + 113, + 169, + 91, + 193 + ], + [ + 192, + 178, + 110, + 193 + ], + [ + 143, + 158, + 127, + 193 + ], + [ + 132, + 102, + 136, + 193 + ], + [ + 48, + 130, + 144, + 193 + ], + [ + 192, + 42, + 149, + 193 + ], + [ + 92, + 151, + 148, + 193 + ], + [ + 112, + 233, + 147, + 193 + ], + [ + 44, + 125, + 148, + 193 + ], + [ + 240, + 16, + 149, + 193 + ], + [ + 120, + 177, + 149, + 193 + ], + [ + 56, + 17, + 148, + 193 + ], + [ + 188, + 246, + 147, + 193 + ], + [ + 112, + 233, + 147, + 193 + ], + [ + 188, + 246, + 147, + 193 + ], + [ + 0, + 4, + 148, + 193 + ], + [ + 56, + 17, + 148, + 193 + ], + [ + 20, + 126, + 147, + 193 + ], + [ + 28, + 74, + 146, + 193 + ], + [ + 88, + 83, + 142, + 193 + ], + [ + 176, + 133, + 135, + 193 + ], + [ + 113, + 205, + 125, + 193 + ], + [ + 168, + 45, + 112, + 193 + ], + [ + 56, + 234, + 93, + 193 + ], + [ + 192, + 44, + 74, + 193 + ], + [ + 32, + 71, + 58, + 193 + ], + [ + 192, + 79, + 43, + 193 + ], + [ + 104, + 82, + 17, + 193 + ], + [ + 177, + 88, + 233, + 192 + ], + [ + 208, + 71, + 149, + 192 + ], + [ + 64, + 204, + 61, + 192 + ], + [ + 0, + 250, + 119, + 191 + ], + [ + 0, + 103, + 111, + 63 + ], + [ + 113, + 30, + 43, + 64 + ], + [ + 224, + 45, + 114, + 64 + ], + [ + 232, + 215, + 165, + 64 + ], + [ + 15, + 112, + 213, + 64 + ], + [ + 84, + 229, + 8, + 65 + ], + [ + 0, + 128, + 27, + 65 + ], + [ + 40, + 5, + 53, + 65 + ], + [ + 44, + 6, + 78, + 65 + ], + [ + 68, + 25, + 100, + 65 + ], + [ + 96, + 151, + 102, + 65 + ], + [ + 236, + 74, + 103, + 65 + ], + [ + 120, + 101, + 102, + 65 + ], + [ + 124, + 26, + 101, + 65 + ], + [ + 120, + 101, + 102, + 65 + ], + [ + 20, + 179, + 104, + 65 + ], + [ + 4, + 228, + 104, + 65 + ], + [ + 212, + 254, + 103, + 65 + ], + [ + 252, + 129, + 104, + 65 + ], + [ + 172, + 127, + 101, + 65 + ], + [ + 148, + 102, + 100, + 65 + ], + [ + 76, + 25, + 103, + 65 + ], + [ + 124, + 231, + 102, + 65 + ], + [ + 84, + 152, + 98, + 65 + ], + [ + 172, + 127, + 101, + 65 + ], + [ + 44, + 77, + 101, + 65 + ], + [ + 160, + 127, + 99, + 65 + ], + [ + 15, + 76, + 99, + 65 + ], + [ + 76, + 102, + 97, + 65 + ], + [ + 52, + 241, + 88, + 65 + ], + [ + 92, + 80, + 73, + 65 + ], + [ + 88, + 141, + 57, + 65 + ], + [ + 248, + 22, + 39, + 65 + ], + [ + 216, + 86, + 20, + 65 + ], + [ + 40, + 245, + 247, + 64 + ], + [ + 88, + 214, + 196, + 64 + ], + [ + 88, + 31, + 152, + 64 + ], + [ + 128, + 237, + 107, + 64 + ], + [ + 64, + 219, + 8, + 64 + ], + [ + 128, + 3, + 47, + 63 + ], + [ + 0, + 68, + 60, + 191 + ], + [ + 64, + 131, + 253, + 191 + ], + [ + 128, + 250, + 108, + 192 + ], + [ + 64, + 213, + 175, + 192 + ], + [ + 192, + 220, + 224, + 192 + ], + [ + 143, + 204, + 251, + 192 + ], + [ + 32, + 31, + 10, + 193 + ], + [ + 32, + 246, + 18, + 193 + ], + [ + 56, + 97, + 33, + 193 + ], + [ + 49, + 7, + 45, + 193 + ], + [ + 120, + 54, + 65, + 193 + ], + [ + 192, + 21, + 88, + 193 + ], + [ + 200, + 109, + 108, + 193 + ], + [ + 120, + 172, + 129, + 193 + ], + [ + 216, + 196, + 145, + 193 + ], + [ + 44, + 190, + 149, + 193 + ], + [ + 220, + 29, + 149, + 193 + ], + [ + 240, + 16, + 149, + 193 + ], + [ + 4, + 192, + 150, + 193 + ], + [ + 28, + 69, + 150, + 193 + ], + [ + 200, + 216, + 150, + 193 + ], + [ + 124, + 108, + 151, + 193 + ], + [ + 48, + 232, + 151, + 193 + ], + [ + 28, + 69, + 150, + 193 + ], + [ + 240, + 16, + 149, + 193 + ], + [ + 92, + 151, + 148, + 193 + ], + [ + 20, + 126, + 147, + 193 + ], + [ + 20, + 126, + 147, + 193 + ], + [ + 132, + 248, + 146, + 193 + ], + [ + 44, + 186, + 140, + 193 + ], + [ + 132, + 8, + 131, + 193 + ], + [ + 248, + 33, + 109, + 193 + ], + [ + 136, + 213, + 85, + 193 + ], + [ + 79, + 221, + 59, + 193 + ], + [ + 192, + 5, + 35, + 193 + ], + [ + 128, + 26, + 12, + 193 + ], + [ + 177, + 145, + 249, + 192 + ], + [ + 177, + 73, + 197, + 192 + ], + [ + 224, + 188, + 145, + 192 + ], + [ + 96, + 160, + 67, + 192 + ], + [ + 64, + 26, + 245, + 191 + ], + [ + 0, + 109, + 22, + 191 + ], + [ + 0, + 109, + 45, + 63 + ], + [ + 192, + 162, + 4, + 64 + ], + [ + 143, + 213, + 101, + 64 + ], + [ + 152, + 217, + 178, + 64 + ], + [ + 128, + 253, + 249, + 64 + ], + [ + 204, + 17, + 29, + 65 + ], + [ + 220, + 90, + 51, + 65 + ], + [ + 40, + 233, + 76, + 65 + ], + [ + 120, + 154, + 97, + 65 + ], + [ + 40, + 1, + 102, + 65 + ] +] \ No newline at end of file diff --git a/docs/ hardware_idears.md b/docs/ hardware_idears.md new file mode 100644 index 0000000..bf37691 --- /dev/null +++ b/docs/ hardware_idears.md @@ -0,0 +1,3 @@ +- Foot sensor while stand still Structure-borne sound transducer maybe with light barrier or pressure sensor +- Structure-borne sound transducer for undergound feedback and crashes (rockhorn) +- Brake feedback (maybe with pressure sensor) diff --git a/docs/rizer_classdiagram.wsd b/docs/rizer_classdiagram.wsd new file mode 100644 index 0000000..8cbddec --- /dev/null +++ b/docs/rizer_classdiagram.wsd @@ -0,0 +1,16 @@ +@startuml + +class BluetoothCallback { + notify_steering_callback + read_steering + write_tilt + scan_and_connect_rizer +} + +class UDP_Handler{ + send_steering_data_udp + listening_udp + get_new_tilt_value +} + +@enduml \ No newline at end of file diff --git a/docs/rizer_sequencediagram.wsd b/docs/rizer_sequencediagram.wsd new file mode 100644 index 0000000..12ec8c6 --- /dev/null +++ b/docs/rizer_sequencediagram.wsd @@ -0,0 +1,35 @@ +@startuml test +title "RIZER" + +participant Unity +participant Master_Collector +participant UDP_Handler +participant BluetoothCallback +participant RIZER + + +par + UDP_Handler -> UDP_Handler: listen for tilt +end + +Unity -> Master_Collector: send new tilt +Master_Collector -> UDP_Handler: send new tilt + +UDP_Handler -> BluetoothCallback: computed tilt commands + +par "tilt 0.5" + + alt + BluetoothCallback -> RIZER: send tilt + end + + BluetoothCallback -> BluetoothCallback: listen for steering + RIZER -> BluetoothCallback: send steering +end + + +BluetoothCallback -> UDP_Handler: send steering +UDP_Handler -> Master_Collector: send steering +Master_Collector -> Unity: send steering + +@enduml diff --git a/requirements.txt b/requirements.txt index f59bbe2..c9f803e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -# bluepy==1.3.0 -asyncio==3.4.3 -bleak==0.21.1 -sockets==1.0.0 -# git+https://github.com/almottier/TapoP100.git@main -# logging -# struct +# bluepy==1.3.0 +asyncio==3.4.3 +bleak==0.21.1 +sockets==1.0.0 +# git+https://github.com/almottier/TapoP100.git@main +# logging +# struct