diff --git a/PlantBox.Broker/ClientManager.cs b/PlantBox.Broker/ClientManager.cs index 2373656..58e292e 100644 --- a/PlantBox.Broker/ClientManager.cs +++ b/PlantBox.Broker/ClientManager.cs @@ -79,7 +79,23 @@ namespace PlantBox.Broker protected override void InfoCommand(CommandStream commandStream, CommandPacket packet) { - throw new NotImplementedException(); + InfoRequest infoRequest = new InfoRequest().Deserialize(packet.Arguments); + ulong id = packet.ID; + PlantBox plantBox = Broker.PlantBoxesManager[id]; + + if (plantBox == null) + { + throw new InvalidOperationException($"This PlantBox (${id}) does not exist"); + } + + var response = new InfoResponse + ( + plantBox.Name, plantBox.Type, plantBox.State, + plantBox.Humidity.Min, plantBox.Humidity.Max, + plantBox.Luminosity.Min, plantBox.Luminosity.Max, + plantBox.Temperature.Min, plantBox.Temperature.Max + ); + commandStream.Send(response.ToCommandPacket(id)); } protected override void PingCommand(CommandStream commandStream, CommandPacket packet)