6 Commits

Author SHA256 Message Date
localhorst 165c79e67b improve systemd unit file 2025-03-23 14:58:35 +01:00
Pheanox c0ac71ebba fix: edit wrong .gitignore :D 2025-03-22 10:22:19 +01:00
Pheanox 10e8e14cd6 feat: add docker compose to gitignore 2025-03-22 10:20:42 +01:00
localhorst a9c8525e6e Merge pull request 'Add timestamps of locations providers' (#18) from feat/timestamps into main
Reviewed-on: #18
Reviewed-by: Philipp Schweizer <Philipp.schw@directbox.com>
2025-02-14 21:22:57 +01:00
Pheanox 39c07fcef0 refactor: only search once for wifiMessage 2025-02-14 21:06:47 +01:00
localhorst 52d521a6ad rename var 2025-02-08 21:24:40 +01:00
6 changed files with 43 additions and 35 deletions
+1
View File
@@ -0,0 +1 @@
docker-compose.yml
+3
View File
@@ -56,6 +56,9 @@ Use `https://your.domain.tld/api/metrics` to retrieve useful insides for monitor
## Add a Location Tracker
We use the [SenseCAP T1000-B](https://www.seeedstudio.com/SenseCAP-Card-Tracker-T1000-B-p-5698.html) from seeedstudio because of the fair price and multiple location providers. However, you can use any LoRaWAN-enabled tracker that is compatible with TTN and supports the required payload fields.
## Troubleshooting
Run `journalctl -u locationhub.service -f` to see log output.
### Onboard SenseCAP T1000-B
1. Download and install the App [SenseCraft](https://play.google.com/store/apps/details?id=cc.seeed.sensecapmate)
2. Skip the user account at startup with `Skip` in the upper right corner
-3
View File
@@ -309,6 +309,3 @@ cython_debug/
*.vsix
config.py
#docker
docker-compose.yml
+18 -11
View File
@@ -1,22 +1,29 @@
[Unit]
Description=LocationHub
Description=LocationHub Service
Documentation=https://git.mosad.xyz/localhorst/LocationHub
After=network.target systemd-networkd-wait-online.service mysqld.service
[Service]
Type=simple
User=locationhub
Group=locationhub
WorkingDirectory=/home/locationhub/git/LocationHub/server/
ExecStart=/usr/bin/npm run dev
# Combine commands for build and start
ExecStart=/bin/bash -c "/usr/bin/npm run build && /usr/bin/npm run start"
# Restart policies
Restart=on-failure
StandardOutput=append:/var/log/LocationHub.log
StandardError=append:/var/log/LocationHub.log
RestartSec=5s
# Logging configuration
StandardOutput=journal
StandardError=journal
SyslogIdentifier=locationhub
# Resource control (optional but helps stability)
MemoryLimit=512M
CPUQuota=50%
[Install]
WantedBy=multi-user.target
```
Activate Systemd Job
```
systemctl daemon-reload
systemctl enable locationhub.service
systemctl start locationhub.service
systemctl status locationhub.service
+18 -18
View File
@@ -56,24 +56,24 @@ router.post(
timestamp: latitudeData?.timestamp
? new Date(latitudeData.timestamp)
: longitudeData?.timestamp
? new Date(longitudeData.timestamp)
: undefined,
? new Date(longitudeData.timestamp)
: undefined,
};
const wifiTimestamp = (() => {
const messages = message.uplink_message.decoded_payload?.messages?.[0];
const wifiScan = messages?.find((e: { type: string }) => e.type === "Wi-Fi Scan");
return wifiScan?.timestamp ? new Date(wifiScan.timestamp) : undefined;
})();
const wifiMessage =
message.uplink_message.decoded_payload?.messages[0].find(
(e) => e.type === "Wi-Fi Scan"
);
const wifiScans =
message.uplink_message.decoded_payload?.messages[0]
.find((e) => e.type === "Wi-Fi Scan")
?.measurementValue?.map((w) => ({
lp_ttn_end_device_uplinks_id,
mac: w.mac,
rssi: w.rssi,
scanned_at_timestamp: wifiTimestamp,
})) ?? [];
wifiMessage?.measurementValue?.map((w) => ({
lp_ttn_end_device_uplinks_id,
mac: w.mac,
rssi: w.rssi,
scanned_at_utc: wifiMessage?.timestamp
? new Date(wifiMessage.timestamp)
: undefined,
})) ?? [];
const ttnGatewayReceptions = message.uplink_message.rx_metadata.map(
(g) => ({
@@ -109,9 +109,9 @@ router.post(
gnss:
gnnsLocation.latitude && gnnsLocation.longitude
? {
latitude: gnnsLocation.latitude,
longitude: gnnsLocation.longitude,
}
latitude: gnnsLocation.latitude,
longitude: gnnsLocation.longitude,
}
: undefined,
gnss_timestamp: gnssTimestamp.timestamp,
});
+2 -2
View File
@@ -5,14 +5,14 @@ interface CreateWifiScanParams {
lp_ttn_end_device_uplinks_id: string;
mac: string;
rssi: number;
scanned_at_timestamp?: Date;
scanned_at_utc?: Date;
}
interface UpdateWifiScanParams {
wifi_scan_id: string;
mac?: string;
rssi?: number;
scanned_at_timestamp?: Date;
scanned_at_utc?: Date;
}
@injectable()