Compare commits

6 Commits

6 changed files with 43 additions and 35 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
docker-compose.yml

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

5
server/.gitignore vendored
View File

@ -308,7 +308,4 @@ cython_debug/
# Built Visual Studio Code Extensions
*.vsix
config.py
#docker
docker-compose.yml
config.py

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

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,
});

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()