public void CheckForCodeValidMessages(PublishArrivedArgs e) { if (e.Topic.Equals(Topic + "codevalid")) { if (e.Payload.ToString().Equals("true")) { _invalidCodeFlashLEDTimer.Change(Timeout.Infinite, Timeout.Infinite); _invalidCodeLED.Write(false); } else if (e.Payload.ToString().Equals("false")) { // Since the code was invalid we need to flash the LED on/off twice _currentFlashCount = 4; _invalidCodeFlashLEDTimer.Change(0, 1000); } } }
public void CheckForDoorbellMessages(PublishArrivedArgs e) { if (e.Topic.Equals("/" + _houseCode + _frontDoorbellTopic)) { // Set the doorbell indicator on for 3 seconds _doorbellFrontOutput.Write(true); _doorbellFrontTimer.Change(3000, 3000); } if (e.Topic.Equals("/" + _houseCode + _backDoorbellTopic)) { // Set the doorbell indicator on for 3 seconds _doorbellBackOutput.Write(true); _doorbellBackTimer.Change(3000, 3000); } if (e.Topic.Equals("/" + _houseCode + _sideDoorbellTopic)) { // Set the doorbell indicator on for 3 seconds _doorbellSideOutput.Write(true); _doorbellSideTimer.Change(3000, 3000); } }
private static bool MqttPublishArrived(object sender, PublishArrivedArgs e) { try { String commandLine = e.Payload.ToString(); String[] commandsLineDetails = commandLine.Split(';'); CommandKind commandKind = (CommandKind)Int32.Parse(commandsLineDetails[0]); ICommand command = CommandFactory.Create(commandKind); command.Execute(commandLine); command = null; commandsLineDetails = null; commandLine = null; } catch (Exception ex) { Restart("Fail to process a command", ex); } return true; }
private bool PublishArrived(object sender, PublishArrivedArgs e) { _logger.Info("Msg Recvd: " + e.Topic + " " + e.Payload.ToString()); if (e.Topic.Equals(Topic + "pingresp")) { _pingResponseOutput.Write(true); _pingResponseTimer.Change(3000, 3000); return true; } CheckForDoorbellMessages(e); return true; }
private bool PublishArrived(object sender, PublishArrivedArgs e) { _logger.Info("Msg Recvd: " + e.Topic + " " + e.Payload.ToString()); return true; }
public void CheckForBurglarMessages(PublishArrivedArgs e) { if (e.Topic.Equals("/" + _houseCode + _masterBedroomBurglarTopic)) { _masterBedroomBurglarAlarmOn = ParseBurglarMessageValue(e.Payload); SetBurglarAlarmOutput(); } if (e.Topic.Equals("/" + _houseCode + _bedroom1BurglarTopic)) { _bedroom1BurglarAlarmOn = ParseBurglarMessageValue(e.Payload); SetBurglarAlarmOutput(); } if (e.Topic.Equals("/" + _houseCode + _bedroom2BurglarTopic)) { _bedroom2BurglarAlarmOn = ParseBurglarMessageValue(e.Payload); SetBurglarAlarmOutput(); } if (e.Topic.Equals("/" + _houseCode + _firstFloorBurglarTopic)) { _firsFloorBurglarAlarmOn = ParseBurglarMessageValue(e.Payload); SetBurglarAlarmOutput(); } }
public void CheckForWindowMessages(PublishArrivedArgs e) { if (e.Topic.Equals("/" + _houseCode + _masterBedroomWindowTopic)) { _masterBedroomWindowOutput.Write(ParseSensorMessageValue(e.Payload)); } if (e.Topic.Equals("/" + _houseCode + _bedroom1WindowTopic)) { _bedroom1WindowOutput.Write(ParseSensorMessageValue(e.Payload)); } if (e.Topic.Equals("/" + _houseCode + _bedroom2WindowTopic)) { _bedroom2WindowOutput.Write(ParseSensorMessageValue(e.Payload)); } if (e.Topic.Equals("/" + _houseCode + _firstFloorWindowTopic)) { _firstFloorWindowOutput.Write(ParseSensorMessageValue(e.Payload)); } }
public void CheckForMotionMessages(PublishArrivedArgs e) { if (e.Topic.Equals("/" + _houseCode + _firstFloorMotionTopic)) { _firstFloorMotionOutput.Write(ParseSensorMessageValue(e.Payload)); } }
public void CheckForDoorMessages(PublishArrivedArgs e) { if (e.Topic.Equals("/" + _houseCode + _frontDoorTopic)) { _frontDoorOutput.Write(ParseSensorMessageValue(e.Payload)); } if (e.Topic.Equals("/" + _houseCode + _backDoorTopic)) { _backDoorOutput.Write(ParseSensorMessageValue(e.Payload)); } if (e.Topic.Equals("/" + _houseCode + _sideDoorTopic)) { _sideDoorOutput.Write(ParseSensorMessageValue(e.Payload)); } }
protected void OnPublishArrived(MqttPublishMessage m) { bool accepted = false; if (PublishArrived != null) { PublishArrivedArgs e = new PublishArrivedArgs(m.Topic, m.Payload, m.Retained, m.QualityOfService); try { accepted |= PublishArrived(this, e); } catch (Exception ex) { _logger.Error("Uncaught exception from user delegate: " + ex.ToString()); } } }
public void CheckForAlarmStateMessages(PublishArrivedArgs e) { if (e.Topic.Equals(Topic + "setalarmstate")) { if (e.Payload.ToString().Equals("away")) { _sleepModeLED.Write(false); _awayModeLED.Write(true); } else if (e.Payload.ToString().Equals("sleep")) { _sleepModeLED.Write(true); _awayModeLED.Write(false); } else if (e.Payload.ToString().Equals("off")) { _sleepModeLED.Write(false); _awayModeLED.Write(false); } } }
public void CheckForLockUnlockMessages(PublishArrivedArgs e) { if (e.Topic.Equals(Topic + "setlock")) { if (e.Payload.ToString().Equals("lock")) { _doorLockedLED.Write(true); _mqttService.Publish(new MqttParcel(Topic + "lock", "locked", QoS.BestEfforts, false)); } else if (e.Payload.ToString().Equals("unlock")) { _doorLockedLED.Write(false); _mqttService.Publish(new MqttParcel(Topic + "lock", "unlocked", QoS.BestEfforts, false)); } } }