add example daemon read/write programs

This commit is contained in:
Kavish Devar
2024-09-27 16:18:59 +05:30
parent d5f62751d6
commit f6334f0b9b
4 changed files with 145 additions and 29 deletions

View File

@@ -10,6 +10,12 @@ sudo apt install python3 python3-pip
pip3 install pybluez
```
If you want to run it as a daemon (Refer to the [Daemonizing](#Daemonizing) section), you will need to install the `python-daemon` package.
```bash
pip3 install python-daemon
```
## 2. Clone the repository
```bash
@@ -36,3 +42,28 @@ python3 main.py
```bash
python3 standalone.py
```
## Daemonizing
If you want to run this as a deamon, you can use the `airpods_daemon.py` script. This creates a standard UNIX socket at `/tmp/airpods_daemon.sock` and listens for commands (and sends battery/in-ear info, soon!).
You can run it as follows:
```bash
python3 airpods_daemon.py
```
### Sending data to the daemon
You can send data to the daemon using the `send_data.py` script. Since it's a standard UNIX socket, you can send data to it using any programming language that supports UNIX sockets.
This package includes a demo script that sends a command to turn off the ANC. You can run it as follows:
```bash
python3 example_daemon_send.py
```
### Reading data from the daemon
Youhcan listen to the daemon's output by running the `example_daemon_read.py` script. This script listens to the UNIX socket and prints the data it receives. Currenty, it only prints the battery percentage and the in-ear status.
```bash
python3 example_daemon_read.py
```