nix-files/hosts/by-name/moby/gps.nix

45 lines
1.8 KiB
Nix
Raw Normal View History

2023-07-25 12:02:58 +00:00
# pinephone GPS happens in EG25 modem
# serial control interface to modem is /dev/ttyUSB2
# after enabling GPS, readout is /dev/ttyUSB1
#
# minimal process to enable modem and GPS:
# - `echo 1 > /sys/class/modem-power/modem-power/device/powered`
# - `screen /dev/ttyUSB2 115200`
# - `AT+QGPSCFG="nmeasrc",1`
# - `AT+QGPS=1`
#
# now, something like `gpsd` can directly read from /dev/ttyUSB1.
#
# initial GPS fix can take 15+ minutes.
# meanwhile, services like eg25-manager can speed this up by uploading assisted GPS data to the modem.
#
# geoclue somehow fits in here as a geospatial provider that leverages GPS and also other sources like radio towers
2023-08-22 07:15:14 +00:00
{ lib, ... }:
2023-07-25 12:02:58 +00:00
{
2023-08-22 07:15:14 +00:00
# test gpsd with `gpspipe -w -n 10 2> /dev/null | grep -m 1 TPV | jq '.lat, .lon' | tr '\n' ' '`
# ^ should return <lat> <long>
2023-07-25 12:02:58 +00:00
services.gpsd.enable = true;
services.gpsd.devices = [ "/dev/ttyUSB1" ];
2023-08-22 07:15:14 +00:00
# test geoclue2 by building `geoclue2-with-demo-agent`
# and running "${geoclue2-with-demo-agent}/libexec/geoclue-2/demos/where-am-i"
services.geoclue2.enable = true;
services.geoclue2.appConfig.where-am-i = {
# this is the default "agent", shipped by geoclue package: allow it to use location
isAllowed = true;
isSystem = false;
# XXX: setting users != [] might be causing `where-am-i` to time out
# users = [
# # restrict to only one set of users. empty array (default) means "allow any user to access geolocation".
# (builtins.toString config.users.users.colin.uid)
# ];
2023-08-22 07:15:14 +00:00
};
systemd.services.geoclue.after = lib.mkForce []; #< defaults to network-online, but not all my sources require network
users.users.geoclue.extraGroups = [
"dialout" # TODO: figure out if dialout is required. that's for /dev/ttyUSB1, but geoclue probably doesn't read that?
];
2023-08-22 07:15:14 +00:00
2023-08-22 04:53:40 +00:00
sane.services.eg25-control.enable = true;
2023-07-25 12:02:58 +00:00
}