订阅飞行器实时数据,更新机场配置文件

main
zhangbin 2 months ago
parent e72b868938
commit 752e89a0bb

@ -40,11 +40,11 @@ namespace OpenAuth.WebApi.Model.mqtt
{ {
$"thing/product/{gateway}/osd", $"thing/product/{gateway}/osd",
$"thing/product/{gateway}/events", $"thing/product/{gateway}/events",
$"thing/product/{gateway}/requests1", $"thing/product/{gateway}/requests",
$"thing/product/{gateway}/services_reply", $"thing/product/{gateway}/services_reply",
//$"thing/product/{gateway}/drc/up", //$"thing/product/{gateway}/drc/up",
//$"thing/product/{gateway}/drc/down", //$"thing/product/{gateway}/drc/down",
$"thing/product/{gateway}/status" $"sys/product/{gateway}/status"
}); });
} }
await _mqttCenter.ConnectAndSubscribeAsync(topics.ToArray()); await _mqttCenter.ConnectAndSubscribeAsync(topics.ToArray());

@ -183,8 +183,8 @@ namespace OpenAuth.WebApi.Model.mqtt
var topics = new List<string>(); var topics = new List<string>();
topics.AddRange(new[] topics.AddRange(new[]
{ {
$"thing/product/{dronesn}/osd", $"sys/product/{dronesn}/osd",
$"thing/product/{uavsn}/osd", $"sys/product/{uavsn}/osd",
}); });
await _mqttCenter.SubscribeAsync(topics.ToArray()); await _mqttCenter.SubscribeAsync(topics.ToArray());
var requestData = new var requestData = new

@ -22,7 +22,7 @@ namespace OpenAuth.WebApi.Model.mqtt
{ {
return topic.Contains("/status"); return topic.Contains("/status");
} }
string bid, tid, previousgateway;
public async Task HandleAsync(string topic, string payload) public async Task HandleAsync(string topic, string payload)
{ {
_logger.LogError($"[Service] Topic={topic}, Payload={payload}"); _logger.LogError($"[Service] Topic={topic}, Payload={payload}");
@ -35,8 +35,9 @@ namespace OpenAuth.WebApi.Model.mqtt
{ {
return; return;
} }
bid = root["bid"]?.ToString() ?? ""; var bid = root["bid"]?.ToString() ?? "";
tid = root["tid"]?.ToString() ?? ""; var tid = root["tid"]?.ToString() ?? "";
var timestamp = long.Parse(root["timestamp"]?.ToString() ?? "0");
var requestData = new var requestData = new
{ {
bid = bid, bid = bid,
@ -50,7 +51,7 @@ namespace OpenAuth.WebApi.Model.mqtt
}; };
string getway = topic.Split('/')[2]; string getway = topic.Split('/')[2];
string payloadreq = JsonSerializer.Serialize(requestData); string payloadreq = JsonSerializer.Serialize(requestData);
await _mqttClientManager.PublishAsync($"thing/product/{getway}/status_reply", payloadreq); await _mqttClientManager.PublishAsync($"sys/product/{getway}/status_reply", payloadreq);
} }
} }
} }

Loading…
Cancel
Save