diff --git a/IoTGateway.Model/SystemConfig.cs b/IoTGateway.Model/SystemConfig.cs index 6a1e22b..1fdfe7b 100644 --- a/IoTGateway.Model/SystemConfig.cs +++ b/IoTGateway.Model/SystemConfig.cs @@ -37,6 +37,8 @@ namespace IoTGateway.Model [Display(Name = "ThingsCloud")] ThingsCloud = 6, [Display(Name = "华为云")] - HuaWei = 7 + HuaWei = 7, + [Display(Name = "IoTGateway")] + IoTGateway = 8 } } \ No newline at end of file diff --git a/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml b/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml index 8c62079..738114d 100644 --- a/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml +++ b/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml @@ -15,7 +15,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. net6.0 68abbdf2-1485-4756-9a94-6afa874d69a3 - true - win-x64 + false \ No newline at end of file diff --git a/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml.user b/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml.user index 18471ff..7b6b1c9 100644 --- a/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/IoTGateway/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>D:\000000-IIoTGateway\00000-iotgateway\IoTGateway\bin\Release\net6.0\publish\ - True|2023-02-27T03:39:28.6812515Z;True|2023-02-20T16:42:44.7526644+08:00;True|2023-02-20T16:12:12.9091659+08:00;True|2023-02-20T09:51:20.5504880+08:00;True|2023-02-20T09:35:31.1757073+08:00;True|2023-01-13T15:48:56.7869969+08:00;True|2022-11-21T15:59:03.8927175+08:00;True|2022-11-21T15:58:06.9464735+08:00;True|2022-11-21T15:57:24.8426888+08:00;True|2022-11-21T15:55:06.1675530+08:00;True|2022-10-20T22:40:01.3534004+08:00;True|2022-08-30T20:02:03.8144013+08:00;True|2022-08-30T19:59:49.6042620+08:00;True|2022-08-30T19:52:02.8823029+08:00;True|2022-08-30T19:36:54.3646619+08:00;True|2022-07-15T22:49:16.0563176+08:00;True|2022-07-15T22:48:07.3189129+08:00;True|2022-07-15T22:44:35.7670375+08:00;True|2022-07-15T22:40:17.0184184+08:00;True|2022-06-09T15:43:47.6180879+08:00;True|2022-06-09T15:42:06.6021355+08:00;False|2022-06-09T15:41:10.3444145+08:00;False|2022-06-09T15:39:22.0048230+08:00;False|2022-06-09T15:37:35.5049088+08:00;True|2022-06-09T15:34:27.8095097+08:00;True|2022-06-09T15:33:30.9577399+08:00;False|2022-06-09T15:29:58.9432537+08:00;False|2022-06-09T15:29:15.9735490+08:00;True|2022-06-09T15:27:02.3333134+08:00;True|2022-06-09T15:18:02.0623963+08:00;True|2022-01-24T23:31:28.3620602+08:00;True|2022-01-24T23:30:03.8991942+08:00;True|2022-01-24T23:23:16.4288882+08:00;True|2021-12-24T19:18:19.0736393+08:00;True|2021-12-24T16:46:49.1192015+08:00;True|2021-12-24T16:23:28.9214784+08:00;True|2021-12-24T15:20:08.6401847+08:00;True|2021-12-17T19:11:07.1655146+08:00;True|2021-12-12T14:11:08.8380502+08:00; + True|2023-05-06T08:43:37.2780869Z;True|2023-05-06T16:16:53.5825444+08:00;True|2023-05-06T15:23:48.5579380+08:00;True|2023-02-27T11:39:28.6812515+08:00;True|2023-02-20T16:42:44.7526644+08:00;True|2023-02-20T16:12:12.9091659+08:00;True|2023-02-20T09:51:20.5504880+08:00;True|2023-02-20T09:35:31.1757073+08:00;True|2023-01-13T15:48:56.7869969+08:00;True|2022-11-21T15:59:03.8927175+08:00;True|2022-11-21T15:58:06.9464735+08:00;True|2022-11-21T15:57:24.8426888+08:00;True|2022-11-21T15:55:06.1675530+08:00;True|2022-10-20T22:40:01.3534004+08:00;True|2022-08-30T20:02:03.8144013+08:00;True|2022-08-30T19:59:49.6042620+08:00;True|2022-08-30T19:52:02.8823029+08:00;True|2022-08-30T19:36:54.3646619+08:00;True|2022-07-15T22:49:16.0563176+08:00;True|2022-07-15T22:48:07.3189129+08:00;True|2022-07-15T22:44:35.7670375+08:00;True|2022-07-15T22:40:17.0184184+08:00;True|2022-06-09T15:43:47.6180879+08:00;True|2022-06-09T15:42:06.6021355+08:00;False|2022-06-09T15:41:10.3444145+08:00;False|2022-06-09T15:39:22.0048230+08:00;False|2022-06-09T15:37:35.5049088+08:00;True|2022-06-09T15:34:27.8095097+08:00;True|2022-06-09T15:33:30.9577399+08:00;False|2022-06-09T15:29:58.9432537+08:00;False|2022-06-09T15:29:15.9735490+08:00;True|2022-06-09T15:27:02.3333134+08:00;True|2022-06-09T15:18:02.0623963+08:00;True|2022-01-24T23:31:28.3620602+08:00;True|2022-01-24T23:30:03.8991942+08:00;True|2022-01-24T23:23:16.4288882+08:00;True|2021-12-24T19:18:19.0736393+08:00;True|2021-12-24T16:46:49.1192015+08:00;True|2021-12-24T16:23:28.9214784+08:00;True|2021-12-24T15:20:08.6401847+08:00;True|2021-12-17T19:11:07.1655146+08:00;True|2021-12-12T14:11:08.8380502+08:00; \ No newline at end of file diff --git a/Plugins/Plugin/MyMqttClient.cs b/Plugins/Plugin/MyMqttClient.cs index f1e063b..45c0776 100644 --- a/Plugins/Plugin/MyMqttClient.cs +++ b/Plugins/Plugin/MyMqttClient.cs @@ -91,6 +91,7 @@ namespace Plugin await Client.SubscribeAsync("v1/gateway/attributes", MqttQualityOfServiceLevel.ExactlyOnce); break; case IoTPlatformType.IoTSharp: + case IoTPlatformType.IoTGateway: await Client.SubscribeAsync("devices/+/rpc/request/+/+", MqttQualityOfServiceLevel.ExactlyOnce); await Client.SubscribeAsync("devices/+/attributes/update", MqttQualityOfServiceLevel.ExactlyOnce); //Message: {"device": "Device A", "data": {"attribute1": "value1", "attribute2": 42}} @@ -382,6 +383,7 @@ namespace Plugin await ResponseTbRpcAsync(tRpcResponse); break; case IoTPlatformType.IoTSharp: + case IoTPlatformType.IoTGateway: await ResponseIsRpcAsync(new ISRpcResponse { DeviceId = rpcResponse.DeviceName, @@ -432,6 +434,7 @@ namespace Plugin .WithPayload(JsonConvert.SerializeObject(tbRequestData)).WithQualityOfServiceLevel(MqttQualityOfServiceLevel.ExactlyOnce).Build()); break; case IoTPlatformType.IoTSharp: + case IoTPlatformType.IoTGateway: string topic = $"devices/{deviceName}/attributes/request/{id}"; Dictionary keys = new Dictionary(); keys.Add(anySide ? "anySide" : "server", string.Join(",", args)); @@ -509,7 +512,7 @@ namespace Plugin { try { - if (CanPubTelemetry(deviceName ,device, sendModel)) + if (CanPubTelemetry(deviceName, device, sendModel)) { switch (_systemConfig.IoTPlatformType) { @@ -519,11 +522,13 @@ namespace Plugin .WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtMostOnce).Build()); break; case IoTPlatformType.IoTSharp: + case IoTPlatformType.IoTGateway: foreach (var payload in sendModel[deviceName]) { if (payload.Values != null) { - payload.Values["_ts_"] = (long)(DateTime.UtcNow - _tsStartDt).TotalMilliseconds; + if (_systemConfig.IoTPlatformType == IoTPlatformType.IoTGateway) + payload.Values["_ts_"] = (long)(DateTime.UtcNow - _tsStartDt).TotalMilliseconds; await UploadIsTelemetryDataAsync(deviceName, payload.Values); } } @@ -574,7 +579,7 @@ namespace Plugin private readonly DateTime _tsStartDt = new(1970, 1, 1); - public async Task DeviceConnected(string DeviceName ,Device device) + public async Task DeviceConnected(string DeviceName, Device device) { try { @@ -582,6 +587,7 @@ namespace Plugin { case IoTPlatformType.ThingsBoard: case IoTPlatformType.IoTSharp: + case IoTPlatformType.IoTGateway: await Client.PublishAsync(new MqttApplicationMessageBuilder().WithTopic("v1/gateway/connect") .WithPayload(JsonConvert.SerializeObject(new Dictionary { { "device", DeviceName } })) @@ -636,6 +642,7 @@ namespace Plugin { case IoTPlatformType.ThingsBoard: case IoTPlatformType.IoTSharp: + case IoTPlatformType.IoTGateway: await Client.PublishAsync(new MqttApplicationMessageBuilder().WithTopic($"v1/gateway/disconnect") .WithPayload(JsonConvert.SerializeObject(new Dictionary { { "device", DeviceName } }))