Skip to content

Commit

Permalink
resolve protos
Browse files Browse the repository at this point in the history
  • Loading branch information
ridomin committed Sep 30, 2022
1 parent 23c3e95 commit 79a45af
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion samples/memmon-protobuff/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Device(ILogger<Device> logger, IConfiguration configuration, TelemetryCli

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var cs = new ConnectionSettings(_configuration.GetConnectionString("cs")) { ModelId="memmon.proto"};
var cs = new ConnectionSettings(_configuration.GetConnectionString("cs")) { ModelId = MemmonClient.ModelId };
_logger.LogWarning($"Connecting to..{cs}");
var mqtt = await BrokerClientFactory.CreateFromConnectionSettingsAsync(cs, true, stoppingToken);
connectionSettings = cs;
Expand Down
1 change: 1 addition & 0 deletions samples/memmon-protobuff/_protos/memmon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace _protos
{
internal class MemmonClient
{
internal const string ModelId = "rido.memmon";
public Properties Props = new Properties();
public IReadOnlyProperty<Properties> AllProperties { get; set; }
public IWritableProperty<Properties, ack> Property_interval { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions samples/memmon-protobuff/_protos/memmon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ option csharp_namespace = "memmon_model_protos";
import "google/protobuf/timestamp.proto";
import "google/protobuf/any.proto";

package rido.memmon;

message Telemetries {
double workingSet = 1;
}
Expand Down
3 changes: 3 additions & 0 deletions samples/mqtt-grpc-device/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,19 @@ async Task<ack> OnPropIntervalReceivedHandler(Properties desired)
{
ArgumentNullException.ThrowIfNull(connection);
ack ack = new ack();
client!.Interval.Version++;
if (desired.Interval > 0)
{
client!.Props.Interval= desired.Interval;
ack.Status = 200;
ack.Version = client.Interval.Version!.Value;
ack.Description = "property accepted";
ack.Value = Google.Protobuf.WellKnownTypes.Any.Pack(desired);
}
else
{
ack.Status = 200;
ack.Version = client.Interval.Version!.Value;
ack.Description = "negative values not accepted";
ack.Value = Google.Protobuf.WellKnownTypes.Any.Pack(client!.Props);
}
Expand Down
9 changes: 6 additions & 3 deletions samples/mqtt-grpc-device/protos/mqtt-grpc-device.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ option csharp_namespace = "mqtt_grpc_device_protos";
import "google/protobuf/timestamp.proto";
import "google/protobuf/any.proto";

package rido.mqtt_grpc_device;

// @topic: -> device/{clientId}/tel[/{telName}]
message Telemetries {
double temperature = 1;
Expand All @@ -30,9 +32,10 @@ service Commands {
}

message ack {
int32 status = 1;
string description = 2;
google.protobuf.Any value =3;
google.protobuf.Any value = 1;
int32 version = 2;
int32 status = 3;
string description = 4;
}

message echoRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace mqtt_grpc_device;

internal class mqtt_grpc_sample_device
{
internal const string ModelId = "mqtt-grpc-device.proto";
internal const string ModelId = "rido.mqtt_grpc_device";
internal IMqttClient Connection;

internal Properties Props;
Expand Down

0 comments on commit 79a45af

Please sign in to comment.