Esempio n. 1
0
        public async Task UpdateDevicesList(DiscoverDeviceRsp response, IMiCommunication communication)
        {
            var device = _devices.FirstOrDefault(x => x.Sid == response.sid);

            if (device != null)
            {
                device.UpdateDevice(response.data);
                return;
            }

            if (response.model == "gateway")
            {
                Gateway g = new Gateway(response, null, communication);
                g.UpdateDevice(response.data);
                _devices.Add(g);
                return;
            }

            if (response.model == "sensor_ht")
            {
                TemperatureSensor g = new TemperatureSensor(response, null, communication);
                g.UpdateDevice(response.data);
                _devices.Add(g);
                return;
            }
        }
Esempio n. 2
0
        private async Task UpdateDevice(DiscoverDeviceRsp response)
        {
            await _devicesKeeper.UpdateDevicesList(response, _communication);

            Interlocked.Decrement(ref _awaitedDevices);
            if (_awaitedDevices == 0)
            {
                _waitHandle.Set();
            }
        }
Esempio n. 3
0
        public ICommandResponse ParseCommand(string commandString)
        {
            if (commandString.Contains("get_id_list_ack"))
            {
                DiscoverGatewayRsp resp = JsonConvert.DeserializeObject <DiscoverGatewayRsp>(commandString);
                return(resp);
            }
            else if (commandString.Contains("read_ack") || commandString.Contains("write_ack"))
            {
                DiscoverDeviceRsp resp = JsonConvert.DeserializeObject <DiscoverDeviceRsp>(commandString);
                return(resp);
            }
            else if (commandString.Contains("heartbeat"))
            {
                HeartBeatRsp resp = JsonConvert.DeserializeObject <HeartBeatRsp>(commandString);
                return(resp);
            }

            return(null);
        }
Esempio n. 4
0
 public Gateway(DiscoverDeviceRsp response, string name, IMiCommunication communication)
     : base(response.sid, DeviceTypes.Gateway, response.short_id, name, response.model, communication)
 {
 }
Esempio n. 5
0
 public TemperatureSensor(DiscoverDeviceRsp response, string name, IMiCommunication communication)
     : base(response.sid, DeviceTypes.TemperatureHumiditySensor, response.short_id, name, response.model, communication)
 {
 }