public Home() { InitializeComponent(); List <ConfigMqtt> itens = DatabaseManipulation.DBConfigMqtt(); mqttConnectionShutter = new MQTTConnection(); mqttConnectionAH = new MQTTConnection(); mqttConnectionH = new MQTTConnection(); mqttConnectionAzm = new MQTTConnection(); mqttConnectionSinc = new MQTTConnection(); mqttConnectionCmdExterno = new MQTTConnection(); mqttConnectioninfoTrapeira = new MQTTConnection(); mqttConnectioninfoAzmDomo = new MQTTConnection(); mqttConnectioninfoPosHome = new MQTTConnection(); mqttConnectioninfoPosPark = new MQTTConnection(); mqttConnectioninfoResolucao = new MQTTConnection(); mqttConnectioninfoSincTelescopio = new MQTTConnection(); mqttConnectioninfoPosTelescopio = new MQTTConnection(); mqttConnectioninfoVelDomo = new MQTTConnection(); brokerConfig = itens[0].valor; mqttPort = int.Parse(itens[1].valor); strCfgShutter = itens[2].valor; strCfgAH = itens[3].valor; strCfgH = itens[4].valor; strCfgAzm = itens[5].valor; strCfgSinc = itens[6].valor; strCfgCmdExterno = itens[7].valor; strCfgInfoTpr = itens[8].valor; strCfgInfoAzm = itens[9].valor; strCfgInfoHome = itens[10].valor; strCfgInfoPark = itens[11].valor; strCfgInfoResol = itens[12].valor; strCfgInfoSinc = itens[13].valor; strCfgInfoPos = itens[14].valor; strCfgInfoVelDomo = itens[15].valor; mqttConnectionShutter.StartConnection(brokerConfig, mqttPort, strCfgShutter); mqttConnectionAH.StartConnection(brokerConfig, mqttPort, strCfgAH); mqttConnectionH.StartConnection(brokerConfig, mqttPort, strCfgH); mqttConnectionAzm.StartConnection(brokerConfig, mqttPort, strCfgAzm); mqttConnectionSinc.StartConnection(brokerConfig, mqttPort, strCfgSinc); mqttConnectionCmdExterno.StartConnection(brokerConfig, mqttPort, strCfgCmdExterno); mqttConnectioninfoTrapeira.StartConnection(brokerConfig, mqttPort, strCfgInfoTpr); mqttConnectioninfoAzmDomo.StartConnection(brokerConfig, mqttPort, strCfgInfoAzm); mqttConnectioninfoPosHome.StartConnection(brokerConfig, mqttPort, strCfgInfoHome); mqttConnectioninfoPosPark.StartConnection(brokerConfig, mqttPort, strCfgInfoPark); mqttConnectioninfoResolucao.StartConnection(brokerConfig, mqttPort, strCfgInfoResol); mqttConnectioninfoSincTelescopio.StartConnection(brokerConfig, mqttPort, strCfgInfoSinc); mqttConnectioninfoPosTelescopio.StartConnection(brokerConfig, mqttPort, strCfgInfoPos); mqttConnectioninfoVelDomo.StartConnection(brokerConfig, mqttPort, strCfgInfoVelDomo); }
public void CreateMQTTConnection() { _log.Debug("Creating MQTT Connection"); if (ConnectionAddressTextBox.Text == "") { _log.Error("Connection addres was empty when trying to create the MQTT connection"); AddLineToTextBlock("Empty connection address!"); } try { if (_mqtt != null) { _log.Debug("MQTT Connection already exists, removing..."); _mqtt.RemoveConnection(); _mqtt = null; } _mqtt = new MQTTConnection(_log, ConnectionAddressTextBox.Text); _mqtt.Connect(); _mqtt.Subscribe(DefaultValues.TEAMNAMES); _mqtt.AttachMessageHandlerMethod(HandlePlayerMessage); } catch (Exception e) { _log.Error("Excpetion thrown when trying to setup MQTT connection > " + e.ToString()); AddLineToTextBlock("Exception occured! Check logging..."); } if (_mqtt != null && _mqtt.isConnected()) { _log.Info("Connection established!"); AddLineToTextBlock("Connection established!"); } else { _log.Error("Connection failed!"); AddLineToTextBlock("Connection Failed!"); } }
public MainPage() { InitializeComponent(); //Content = new HeaderView(); menuList = new List <MasterPageItem>(); //Fot Android / IOS icons var page1 = new MasterPageItem() { id = 1, Title = "Home", Icon = "Home.png" }; var page2 = new MasterPageItem() { id = 2, Title = "Devices", Icon = "About.png" }; var page3 = new MasterPageItem() { id = 3, Title = "Configuration", Icon = "Configuration.png" }; var page4 = new MasterPageItem() { id = 4, Title = "Profile", Icon = "ProfileSetting.png" }; var page5 = new MasterPageItem() { id = 5, Title = "Configuration", Icon = "Configuration.png" }; var page6 = new MasterPageItem() { id = 6, Title = "Profile Settings", Icon = "ProfileSetting.png" }; var page7 = new MasterPageItem() { id = 7, Title = "Rooms", Icon = "Home.png" }; menuList.Add(page1); menuList.Add(page2); menuList.Add(page7); menuList.Add(page3); menuList.Add(page4); menuList.Add(page5); menuList.Add(page6); navigationDrawerList.ItemsSource = menuList; // Detail = new NavigationPage((Page)Activator.CreateInstance(typeof(HomePage))); // Remove page before Edit Page // this.Navigation.RemovePage(this.Navigation.NavigationStack[this.Navigation.NavigationStack.Count ]); arduino = new Arduino(); mobileDevices = new List <MobileDevice>(); mqttConnection = new MQTTConnection("", "", "", this); // listDevices = new List<SplashyApp.Models.Device>(); Rooms = new Models.Rooms() { }; NeedLoadedRoomsAndDevices = new Dictionary <string, string>(); // MqttClient client = new MqttClient("35.158.109.193", MqttSettings.MQTT_BROKER_DEFAULT_PORT, false, null, null, MqttSslProtocols.None); //int code = client.Connect("A", "server", "ri0Xohsuozahr2aB", true, 150); Detail = new HomeTabbedPage(this); }