Skip to content

Commit

Permalink
Add RSSI to V2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
hhvrc committed Nov 14, 2024
1 parent da7a7bc commit 8a0bd4b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion API/Controller/Admin/GetOnlineDevices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public async Task<IActionResult> GetOnlineDevices()
Name = dbItem.Name,
ConnectedAt = x.ConnectedAt,
UserAgent = x.UserAgent,
Uptime = x.Uptime,
Latency = x.Latency,
Uptime = x.Uptime
Rssi = x.Rssi,
};
})
);
Expand All @@ -76,5 +77,6 @@ public sealed class AdminOnlineDeviceResponse
public required TimeSpan? Uptime { get; init; }
[JsonConverter(typeof(TimeSpanToMillisecondsConverter))]
public required TimeSpan? Latency { get; init; }
public required int Rssi { get; init; }
}
}
2 changes: 1 addition & 1 deletion Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10"/>
<PackageReference Include="NRedisStack" Version="0.13.0" />
<PackageReference Include="OpenShock.Serialization.Flatbuffers" Version="2.0.0-preview.4" />
<PackageReference Include="OpenShock.Serialization.Flatbuffers" Version="2.0.0-preview.5" />
<PackageReference Include="Redis.OM" Version="0.7.6" />
<PackageReference Include="Semver" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="8.3.0"/>
Expand Down
1 change: 1 addition & 0 deletions Common/Redis/DeviceOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public sealed class DeviceOnline
public TimeSpan? Uptime { get; set; }
[JsonConverter(typeof(TimeSpanToMillisecondsConverter))]
public TimeSpan? Latency { get; set; }
public int Rssi { get; set; }
}
3 changes: 2 additions & 1 deletion LiveControlGateway/Controllers/DeviceControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected override async Task UnregisterConnection()
/// <summary>
/// Keep the device online
/// </summary>
protected async Task SelfOnline(TimeSpan uptime, TimeSpan? latency = null)
protected async Task SelfOnline(TimeSpan uptime, TimeSpan? latency = null, int Rssi = -70) // -70dBm = OK connection
{
Logger.LogDebug("Received keep alive from device [{DeviceId}]", CurrentDevice.Id);

Expand Down Expand Up @@ -178,6 +178,7 @@ await deviceOnline.InsertAsync(new DeviceOnline
// as we dont want to send a device online status every time, we will do it here
online.Uptime = uptime;
online.Latency = latency;
online.Rssi = Rssi;

var sendOnlineStatusUpdate = false;

Expand Down

0 comments on commit 8a0bd4b

Please sign in to comment.