GeofenceMonitor

class GeofenceMonitor(packetRepository: Lazy<PacketRepository>, nodeManager: NodeManager, serviceNotifications: MeshNotificationManager, crossingStore: GeofenceCrossingStore, notificationPrefs: NotificationPrefs, scope: CoroutineScope)(source)

Raises a LOCAL notification when another mesh node's reported position crosses a waypoint's geofence. Evaluation runs against OTHER nodes' positions arriving over the mesh — never the device's own location — so this is manual point-in-region math, NOT the OS Geofencing API.

Hooked from MeshDataHandlerImpl.handlePosition; holds the active geofence-bearing waypoints in memory (refreshed from PacketRepository.getWaypoints, normalised via activeWaypointPackets so stale/expired transmissions can't fire). By default only waypoints created by THIS device are tracked — geofences are mesh-broadcast, so without that filter every receiver in range would alert on the creator's crossings — but the user can opt in to specific foreign geofences via NotificationPrefs.geofenceAlertOptIns. Crossing state lives in GeofenceCrossingStore (in-memory, baseline-on-first-sighting).

Received positions are funnelled through a single ordered worker so that two positions for the same node can never be evaluated out of order (which would corrupt the inside/outside baseline and fire a spurious or missed alert).

Constructors

Link copied to clipboard
constructor(packetRepository: Lazy<PacketRepository>, nodeManager: NodeManager, serviceNotifications: MeshNotificationManager, crossingStore: GeofenceCrossingStore, notificationPrefs: NotificationPrefs, scope: CoroutineScope)

Functions

Link copied to clipboard
fun onPositionReceived(nodeNum: Int, myNodeNum: Int, position: Position)

Evaluate a received node position against every active geofence. nodeNum is the position's sender.