/* Check whether the gateway was registred or now * If not, it will create a new one otherwise updated last RSSI */ private void CheckGateway(string gatewayMac, string gatewayType) { /* Check the GW */ GatewayDao dao = new GatewayDao(); Gateway gateway = dao.GetGateway(gatewayMac); if (gateway == null) { /* There is no definition for this GW. * Create a new gateway record */ gateway = new Gateway() { GatewayType = gatewayType, MACAddress = gatewayMac, Name = "Unknown", Xaxis = "0", Yaxis = "0", }; /* save new gateway */ dao.NewGateway(gateway); } else { /* Update beacon */ gateway.LastSignalTimestamp = DateTime.Now; dao.UpdateGateway(gateway); } }
/* Updates the gateway that is provided as json */ private void UpdateGateway(string data) { /* we are triming data below, splitting it by blank chars is not a valid way. * because blank char can become in the json object as well */ string command = "update gateway "; string json = data.Substring(command.Length); Gateway gateway = JsonConvert.DeserializeObject <Gateway>(json); GatewayDao gatewayDao = new GatewayDao(); gatewayDao.UpdateGateway(gateway); ServiceClient.Send(OK); }