void PublishMsg() { string message = "huhu"; string subTopic1 = "mySubtopic1"; MQTTBehaviour.Publish(subTopic1, message); print("Message published: " + message); }
void PublishMsg() { string message = "222"; string subTopic1 = "janfiess/anim"; MQTTBehaviour.Publish(subTopic1, message); print("Message published: " + message); }
// when the button Set ID/"ASSIGN" is pressed public void OnSetDeviceId(InputField input_deviceId) { string newDeviceId = (input_deviceId.text == "") ? input_deviceId.placeholder.GetComponent <Text>().text : input_deviceId.text; // print(mqttAddress + " | " + newDeviceId); MQTTBehaviour.Publish("hat/setId", "i" + newDeviceId); // print("hat/setId: "+ newDeviceId); }
// when the button Set ID/"Set SSID, PW, Broker IP" is pressed public void OnSetupBroker() { string ssid = (input_ssid.text == "") ? input_ssid.placeholder.GetComponent <Text>().text : input_ssid.text; string pw = (input_pw.text == "") ? input_pw.placeholder.GetComponent <Text>().text : input_pw.text; string brokerSettings = (input_brokerSettings.text == "") ? input_brokerSettings.placeholder.GetComponent <Text>().text : input_brokerSettings.text; MQTTBehaviour.Publish("hat/ssid", ssid); MQTTBehaviour.Publish("hat/pw", pw); MQTTBehaviour.Publish("hat/broker", brokerSettings); // print(mqttAddress + " | " + ssid + " | " + pw + " | " + brokerSettings); }
private void Start() { MQTTBehaviour.Connect(); if (MQTTBehaviour.Client != null) { MQTTBehaviour.Client.MqttMsgPublishReceived += OnNewMqttMessage; } // publish Invoke("PublishMsg", 2); }
public void StartMQTT() { MQTTBehaviour.Connect(); if (MQTTBehaviour.Client != null) { MQTTBehaviour.Client.MqttMsgPublishReceived += OnNewMqttMessage; } // define which topics yu want to subscribe to MQTTBehaviour.s_client.Subscribe(new string[] { "hat/msg" }, new byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE }); // subscribes to the topic janfiess/mySubtopic1 MQTTBehaviour.s_client.Subscribe(new string[] { "hat/getId" }, new byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE }); // subscribes to the topic janfiess/mySubtopic1 }
private void Awake() { mqttBehaviour = new MQTTBehaviour(); mqttBehaviour.m_brokerURL = m_brokerURL; mqttBehaviour.m_brokerPort = m_brokerPort; if (Mqtt_Client.s_instance == null) { Mqtt_Client.s_instance = this; DontDestroyOnLoad(this.gameObject); } else { Destroy(this.gameObject); } }
private void Start() { MQTTBehaviour.Connect(); if (MQTTBehaviour.Client != null) { MQTTBehaviour.Client.MqttMsgPublishReceived += OnNewMqttMessage; } // define which topics yu want to subscribe to MQTTBehaviour.s_client.Subscribe(new string[] { "janfiess/#" }, new byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE }); // subscribes to the topic janfiess/mySubtopic1 MQTTBehaviour.s_client.Subscribe(new string[] { "janfiess/static" }, new byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE }); // subscribes to the topic janfiess/mySubtopic2 // publish Invoke("PublishMsg", 2); }
private void Awake() { mqttBehaviour = new MQTTBehaviour(); // mqttBehaviour.m_brokerURL = m_brokerURL; // mqttBehaviour.m_brokerURL = (input_brokerURL.text == "") ? input_brokerURL.placeholder.GetComponent<Text>().text : input_brokerURL.text; mqttBehaviour.m_brokerPort = m_brokerPort; if (Mqtt_Client.s_instance == null) { Mqtt_Client.s_instance = this; DontDestroyOnLoad(this.gameObject); } else { Destroy(this.gameObject); } }
public static void Publish(string p_topic, string p_txt) { MQTTBehaviour.Publish(p_topic, p_txt, MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, false); }
private void Awake() { MQTTBehaviour.s_instance = this; }
/* * When the anim button "ALL HATS" is pressed */ public void OnAnim_AllHats(string msg) { MQTTBehaviour.Publish("hat/all", msg); }
// ORANGE constant solid (called via buttons) public void OnAnim_1Hat_orange(InputField input_deviceId) { string deviceId = (input_deviceId.text == "") ? input_deviceId.placeholder.GetComponent <Text>().text : input_deviceId.text; MQTTBehaviour.Publish("hat/" + deviceId, "a5", MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true); }
void Awake() { mqttBehaviour = new MQTTBehaviour(); }
private void Awake() { MQTTBehaviour.s_instance = this; m_brokerURL = (input_brokerURL.text == "") ? input_brokerURL.placeholder.GetComponent <Text>().text : input_brokerURL.text; }