-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from WildernessLabs/feature/device-info
record device name and position when position data arrives
- Loading branch information
Showing
15 changed files
with
179 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Deploy: | ||
NoLink: [ Clima ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace Meadow.Devices; | ||
|
||
public abstract class ClimaAppBase : App<F7CoreComputeV2, ClimaHardwareProvider, IClimaHardware> | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,39 @@ | ||
using Meadow; | ||
using Meadow.Devices; | ||
using Meadow.Peripherals.Sensors.Location.Gnss; | ||
using System; | ||
|
||
namespace Clima_Demo; | ||
|
||
public class LocationController | ||
{ | ||
private IGnssSensor gnss; | ||
|
||
public bool LogData { get; set; } = false; | ||
|
||
public event EventHandler<GnssPositionInfo> PositionReceived; | ||
|
||
public LocationController(IClimaHardware clima) | ||
{ | ||
if (clima.Gnss is { } gnss) | ||
{ | ||
//gnss.GsaReceived += GnssGsaReceived; | ||
//gnss.GsvReceived += GnssGsvReceived; | ||
//gnss.VtgReceived += GnssVtgReceived; | ||
gnss.RmcReceived += GnssRmcReceived; | ||
gnss.GllReceived += GnssGllReceived; | ||
gnss.StartUpdating(); | ||
} | ||
|
||
} | ||
private void GnssGsaReceived(object _, ActiveSatellites e) | ||
{ | ||
if (e.SatellitesUsedForFix is { } sats) | ||
{ | ||
Resolver.Log.Info($"Number of active satellites: {sats.Length}"); | ||
} | ||
} | ||
|
||
private void GnssGsvReceived(object _, SatellitesInView e) | ||
{ | ||
Resolver.Log.Info($"Satellites in view: {e.Satellites.Length}"); | ||
} | ||
|
||
private void GnssVtgReceived(object _, CourseOverGround e) | ||
{ | ||
if (e is { } cv) | ||
{ | ||
Resolver.Log.Info($"{cv}"); | ||
}; | ||
} | ||
|
||
private void GnssRmcReceived(object _, GnssPositionInfo e) | ||
{ | ||
if (e.Position is not null) | ||
{ | ||
Resolver.Log.InfoIf(LogData, $"GNSS Position: lat: [{e.Position.Latitude}], long: [{e.Position.Longitude}]"); | ||
this.gnss = gnss; | ||
this.gnss.GnssDataReceived += OnGnssDataReceived; | ||
this.gnss.StartUpdating(); | ||
} | ||
} | ||
|
||
private void GnssGllReceived(object _, GnssPositionInfo e) | ||
private void OnGnssDataReceived(object sender, IGnssResult e) | ||
{ | ||
if (e.Position is not null) | ||
if (e is GnssPositionInfo pi) | ||
{ | ||
Resolver.Log.InfoIf(LogData, $"GNSS Position: lat: [{e.Position.Latitude}], long: [{e.Position.Longitude}]"); | ||
if (pi.IsValid && pi.Position != null) | ||
{ | ||
// we only need one position fix - weather stations don't move | ||
Resolver.Log.InfoIf(LogData, $"GNSS Position: lat: [{pi.Position.Latitude}], long: [{pi.Position.Longitude}]"); | ||
PositionReceived?.Invoke(this, pi); | ||
gnss.StopUpdating(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.