Skip to content

Commit

Permalink
Added RSSI and SNR
Browse files Browse the repository at this point in the history
- updated README
- code cleanup
  • Loading branch information
rhenium2 committed Jun 28, 2022
1 parent 9362dd0 commit c7af593
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
13 changes: 8 additions & 5 deletions HeliumCat/Commands/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,22 @@ public static async Task Witnessed(WitnessedOptions options)

var myHotspot = await GetHotspotByIdentifier(options.Identifier);
Console.Write("Fetching witnessed ... ");
var witnessed = await HotspotService.GetWitnessedTransactions(myHotspot.Address, minDateTime);
Console.WriteLine($"{witnessed.Count}");
var transactions = await HotspotService.GetWitnessedTransactions(myHotspot.Address, minDateTime);
Console.WriteLine($"{transactions.Count}");

var witnessedDistances = new List<double>();
var witnessedHeights = new List<int>();
foreach (var transaction in witnessed)
foreach (var transaction in transactions)
{
var hotspot = await HotspotService.GetHotspot(transaction.Path[0].Challengee);
var hotspotId = transaction.Path[0].Challengee;
var witnessed = transaction.Path[0].Witnesses.Single(x => x.Gateway.Equals(myHotspot.Address));
var hotspot = await HotspotService.GetHotspot(hotspotId);

witnessedDistances.Add(Extensions.CalculateDistance(myHotspot, hotspot));
witnessedHeights.Add(hotspot.Elevation);

Console.WriteLine(
$"- {hotspot.ToString()} {Extensions.GetDirectionString(myHotspot, hotspot)} - {Extensions.GetRelativeTimeString(transaction.Time)}");
$"- {hotspot.ToString()} {Extensions.GetDirectionString(myHotspot, hotspot)} (rssi: {witnessed.Signal}dBm, snr: {witnessed.Snr.ToString("F")}dB, freq: {witnessed.Frequency.ToString("F2")}) - {Extensions.GetRelativeTimeString(transaction.Time)}");
}

if (witnessedDistances.Any())
Expand Down
5 changes: 5 additions & 0 deletions HeliumCat/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public static double CalculateDistance(Hotspot first, Hotspot second)

public static string ToDistanceText(double distance)
{
if (distance >= 1000)
{
return $"{distance / 1000:F1}km";
}

return $"{distance:F1}m";
}

Expand Down
2 changes: 0 additions & 2 deletions HeliumCat/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ await parserResult.WithParsedAsync<FrontOptions>(async options =>
await parserResult.WithParsedAsync<RadiusOptions>(async options => await Commands.RadiusBeaconStats(options));
await parserResult.WithParsedAsync<BoxOptions>(async options => await Commands.BoxBeaconStats(options));
await parserResult.WithParsedAsync<DirectionOptions>(async options => await Commands.Direction(options));
// [Obsolete]
//await parserResult.WithParsedAsync<DistanceOptions>(async options => await Commands.Distance(options));
await parserResult.WithParsedAsync<WitnessedOptions>(async options => await Commands.Witnessed(options));

Console.WriteLine("Done");
2 changes: 1 addition & 1 deletion HeliumCat/Responses/Transactions/PocReceiptsTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class Receipt

public class Witness
{
public object Timestamp { get; set; }
public long Timestamp { get; set; }
public double Snr { get; set; }
public int Signal { get; set; }
public string PacketHash { get; set; }
Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Current functions:
* [radius](#radius): beacons in the 360° radius around the hotspot
* [box](#box): beacons in the witnessed box around the hotspot (the most bottom left and the most top right hotspots) in the last 5 days
* [direction](#direction): calculates the direction between two hotspots
* [distance](#distance): distance statistics for the witnessed hotspots in the last 5 days
* [witnessed](#witnessed): shows witnessed stats of hotspot
* [witnessed](#witnessed): shows witnessed stats of hotspot with their distance and height analysis

## Usage

Expand Down Expand Up @@ -53,12 +52,6 @@ calculates the direction between two hotspots
dotnet HeliumCat.dll direction <hotspot1 name or address> <hotspot2 name or address>
```

### distance
distance stats of hotspot witnessed in the last 5 days
```
dotnet HeliumCat.dll distance <hotspot name or address>
```

### witnessed
shows witnessed stats of hotspot
```
Expand Down

0 comments on commit c7af593

Please sign in to comment.