A Common Lisp package and systemd service for logging Racebox Mini sensor data.
Many functions in the current implementation repeatedly use (dbus:with-open-bus () …) in the same call. Change it to only opens the bus once and put all calls in a single open.
(ql:quickload :racebox-tools)
;; Return a list of name/object pairs for each RaceBox Mini nearby.
(racebox-tools:list-racebox-devices)
;; By default these all use the first RaceBox Mini in the list returned
;; by (racebox-tools:list-racebox-devices), but there's an optional parameter.
;; Disconnect first so connect won't error out.
(racebox-tools:disconnect)
(racebox-tools:connect)
;; Read metadata UUIDs for manufacturer, serial, hardware/firmware versions.
(racebox-tools:read-metadata)
;; Get a racebox-mini-data-message structure holding the raw integer values
;; described in the RaceBox Mini Data Message
(let ((racebox-value (racebox-tools:read-current-value)))
(swank:inspect-in-emacs racebox-value))
(racebox-tools:disconnect)
Connect to the first seen RaceBox:
(ql:quickload :racebox-tools)
(let ((my-racebox (first ;; First name/object pair
(first ;; Get the name
(racebox-tools:list-racebox-devices)))))
(racebox-tools:connect :device-name my-racebox)
(racebox-tools:read-metadata :device-name my-racebox)
(let ((result (racebox-tools:read-current-value :device-name my-racebox)))
(swank:inspect-in-emacs result))
(racebox-tools:disconnect :device-name my-racebox))
Convert a SQLite database track into a GPX file.
(ql:quickload :racebox-tools)
(let ((db-name "/home/jeremiah/moto_rides/sept_17/racebox-2023-09-17T18:26:37.302257Z.db")
(gpx-name "/home/jeremiah/moto_rides/sept_17/gpx1.gpx"))
(rbt:db-to-gpx db-name gpx-name))
Make sure ~/lisp/ is in ~/.config/common-lisp/source-registry.conf.d/projects.conf with this code:
(:tree (:home "lisp/"))
Clone racebox-tools and dbus-tools into ~/lisp/
mkdir -p $HOME/lisp/
cd $HOME/lisp/
git clone [email protected]:jl2/racebox-tools.git
git clone [email protected]:jl2/dbus-tools.git
Edit ./racebox-recorder.service::13 and replace ‘jeremiah’ with your username.
sudo cp racebox-tools/racebox-recorder.service /etc/systemd/services/
systemctl start racebox-recorder
After a second the RaceBox LED should shine blue and a new .db file should show up in ~/lisp/racebox-tools/databases.
# Connect interactively to RaceBox device
sudo gatttool -t random -b <RaceboxAddress> -I
# Type this in to connect:
connect
# Type this to read data:
char-read-hnd f
ISC
Copyright (c) 2023 Jeremiah LaRocco <[email protected]>