CZI_presence_detector/README.md

61 lines
2 KiB
Markdown
Raw Normal View History

# CZI presence detector
2023-08-17 21:46:32 +02:00
Tool to detect and publish the presence of defined devices by their WiFi MAC addresses.
2023-08-13 22:12:47 +02:00
## How scanning works
2023-08-17 21:01:43 +02:00
Sets the wifi adapter into monitor mode, then listens to surrounding packets listing all detected devices into `wifi_map.yaml`.
Then, periodically filters the results by the mac addresses that opted in on the website from `identities.json` and sends all matched identities to the website via a signed webhook. This website stores the presence information locally and displays it with `website/index.php` with a timestamp of the last update.
2023-08-13 22:12:47 +02:00
## What the website is capable of
2023-08-17 21:46:32 +02:00
Shows the last update of the `uploader.py` routine. It also allows to add identities by their name and mac and to delete identities by their mac. The mac addresses are hashed server-side and then stored into the world-accessible `identities.json`.
## Set-up
Dependencies:
2023-08-17 21:46:32 +02:00
- Scanner/Uploader: Python3, trackerjacker (pip3)
- Website: php
Configs to change:
2023-08-17 21:46:32 +02:00
- `scanner/scanner.sh`:
- WiFi adapter name
2023-08-17 21:01:43 +02:00
- Possibly some more system-specific changes
2023-08-17 21:46:32 +02:00
- `scanner/uploader.py`:
- base URL for webhook and identities
- webhook secret
- `public/update.php`:
- webhook secret
2023-08-17 21:46:32 +02:00
Put `scanner` onto the scanning device (e.g. Raspberry Pi). Let `scanner.sh` and `uploader.pu` running in the background, e.g. by the Systemd services below.
2023-08-17 18:21:57 +02:00
Put `website` onto a php-capable webserver and point your domain to it.
## Systemd services
Service for scanning packets in the background
```systemd
[Unit]
Description=CZI Presence Detector - Scanner
After=network.target
[Service]
User=root
Group=root
Restart=always
WorkingDirectory=/path/to/scanner
2023-08-17 22:14:45 +02:00
ExecStart=/path/to/scanner.sh
2023-08-17 18:21:57 +02:00
[Install]
WantedBy=multi-user.target
```
Service for uploading every $n seconds
```systemd
[Unit]
Description=CZI Presence Detector - Uploader
After=network.target
[Service]
User=pi
Group=pi
Restart=always
WorkingDirectory=/path/to/scanner
2023-08-17 22:14:45 +02:00
ExecStart=/path/to/uploader.py
2023-08-17 18:21:57 +02:00
[Install]
WantedBy=multi-user.target
```