Skip to content

GPS initialization improvements, DBus refactoring - #3

Open
teal-bauer wants to merge 29 commits into
rescoot:mainfrom
librescoot:full-modem-service
Open

GPS initialization improvements, DBus refactoring#3
teal-bauer wants to merge 29 commits into
rescoot:mainfrom
librescoot:full-modem-service

Conversation

@teal-bauer

Copy link
Copy Markdown
Contributor

Configures GPS auxiliary antenna voltage like unu-modem does, as well as configuring more detailed GPS parameters.

Changes

Instead of shelling out, use proper channels:

  • Replace shell command execution (mmcli) with direct D-Bus communication
  • Add ModemManager D-Bus client wrapper with property/method access
  • Implement GPIO power control for SIM7100E modem

And improve modem configuration / recovery as per further analysis of OEM modem service:

  • Add USB recovery mechanism (unbind/bind)
  • Configure GPS via AT commands through D-Bus (antenna voltage, XTRA assistance)

Testing

Deployed and tested on device:

  • Modem state detection working correctly
  • GPS configuration succeeds on first attempt
  • GPS fix established in ~6 seconds
  • No error spam in log

teal-bauer and others added 29 commits March 13, 2025 08:07
`HGET gps state` can have the following values:

- `off` if gps is enabled
- `searching` while a fix is being established
- `fix-established` when a fix has been established
- `error` if location services could not be enabled or GPS messages from gpsd could not be parsed
Update the publishModemState function to use the status field in the internet Redis hash key for the modem connection state, as requested in issue #4.
- Implement actual internet connectivity check using ping via the modem interface.
- Update Redis 'internet' hash 'status' field based on ping result.
- Refactor modem restart logic to handle GPIO errors and fall back to 'mmcli --reset' (addresses feedback related to #3).
Adds an 'error-state' field to the 'modem' hash in Redis.
This field provides a single string indicating the primary error
condition (e.g., no-modem, sim-missing, powered-off, ok) in kebab-case
for easier consumption by other services like the DBC.
Add delays and retries when enabling the gps-unmanaged location source via mmcli. This aims to address potential timing issues on slower modems where the command might fail intermittently, especially after disabling other sources.
Now triggering modem recovery when internet connectivity check fails despite modem reporting as connected. This helps recover from situations where the modem thinks it's online but actual internet connectivity is down. Status is published as disconnected immediately before recovery attempts.
The modem-service now correctly populates the 'modem-state' key in the 'internet' Redis hash. This value is a direct reflection of the modem.State.Status field, providing values like 'connected', 'disconnected', 'off', 'no-modem', or 'UNKNOWN'.
Key changes:

1. __New GPS Filter (`internal/location/filter.go`):__

   - Includes a Kalman filter for position and velocity.
   - Implements stationary detection based on speed and small position changes.
   - Smooths the course when the scooter is moving.

2. __Redis Integration (`internal/redis/redis.go`):__
   - Added `PublishFilteredLocationState` to publish data to a new `gps:filtered` hash.

3. __Location Service Update (`internal/location/location.go`):__

   - The `LocationService` now uses the `GPSFilter`.
   - It stores the `LastRawReportedLocation` to allow publishing both raw and filtered data.

4. __Main Service Update (`internal/service/service.go`):__

   - The `monitorStatus` loop now calls `publishLocationState` with both raw (`s.Location.LastRawReportedLocation`) and filtered (`s.Location.CurrentLoc`) GPS data.
   - Raw data is published to the `gps` Redis hash.
   - Filtered data is published to the `gps:filtered` Redis hash.

The system will now provide more stable speed and course readings, especially when stationary, and the Kalman filter will help smooth the track during motion. You can compare the `gps` and `gps:filtered` hashes in Redis to observe the filter's effect.
Change PUBLISH message from 'location-update' to 'timestamp' to match
field name, triggering immediate refresh in ScootUI's SyncableCubit
- communicate with ModemManager via D-Bus instead of shell commands
- add GPIO power control for modem
- add USB recovery mechanism
- configure GPS via AT commands (antenna voltage, XTRA assistance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants