giggetto71 Active Member Licensed User Longtime User Feb 21, 2016 #1 guys, I am using jMQTT library and JMQTTBroker libraries for a small test: local networ, raspberry PI and my pc. the broker runs on the raspberry pi @ 192.168.1.5 where the broker is initialized and on client publishes a random number every 5 seconds on the topic "RandomNumbers" On the PC side I have a B4J app that connects to the raspberry PI MQTT connections and correctly receives the random numbers published by the raspberry PI on the topic "RandomNumbers". in the same b4J app I am trying to publish a start/stop command to the raspberry PI to stop or start publishing the random numbers. for some reasons that I can't understand it seems that while the messages from the raspberry PI flow nicely to the B4J app, the other way oround does not work.. In B4J app start .... Code: Dim clientId As String = Rnd(0, 999999999) & DateTime.Now mqtt.Initialize("mqtt", "tcp://192.168.1.5:51041", clientId) Dim mo As MqttConnectOptions mo.Initialize(user, password) mqtt.Connect2(mo) mqtt.Subscribe("RandomNumber", 0) .... then in Code: Private Sub mqtt_MessageArrived (Topic As String, Payload() As Byte) Dim obj As Object = serializator.ConvertBytesToObject(Payload) Dim ii As Int = obj Label1.Text = Topic & ":" & ii end sub then I have 1 button where I publish on the topic "command" to the raspberry PI the payload "stop" Code: Sub Button1_MouseClicked (EventData As MouseEvent) mqtt.Publish2("command", serializator.ConvertObjectToBytes("stop"),1,True) end sub On the Raspberry PI side, I have the broker initialized and the code which publishes a new random number every 5 seconds. unfortunately the event Code: sub mqttclient_MessageArrived does not fire when I publish the message from the B4J app. Any hint to try to understand what is wrong? thanks! Last edited: Feb 21, 2016
guys, I am using jMQTT library and JMQTTBroker libraries for a small test: local networ, raspberry PI and my pc. the broker runs on the raspberry pi @ 192.168.1.5 where the broker is initialized and on client publishes a random number every 5 seconds on the topic "RandomNumbers" On the PC side I have a B4J app that connects to the raspberry PI MQTT connections and correctly receives the random numbers published by the raspberry PI on the topic "RandomNumbers". in the same b4J app I am trying to publish a start/stop command to the raspberry PI to stop or start publishing the random numbers. for some reasons that I can't understand it seems that while the messages from the raspberry PI flow nicely to the B4J app, the other way oround does not work.. In B4J app start .... Code: Dim clientId As String = Rnd(0, 999999999) & DateTime.Now mqtt.Initialize("mqtt", "tcp://192.168.1.5:51041", clientId) Dim mo As MqttConnectOptions mo.Initialize(user, password) mqtt.Connect2(mo) mqtt.Subscribe("RandomNumber", 0) .... then in Code: Private Sub mqtt_MessageArrived (Topic As String, Payload() As Byte) Dim obj As Object = serializator.ConvertBytesToObject(Payload) Dim ii As Int = obj Label1.Text = Topic & ":" & ii end sub then I have 1 button where I publish on the topic "command" to the raspberry PI the payload "stop" Code: Sub Button1_MouseClicked (EventData As MouseEvent) mqtt.Publish2("command", serializator.ConvertObjectToBytes("stop"),1,True) end sub On the Raspberry PI side, I have the broker initialized and the code which publishes a new random number every 5 seconds. unfortunately the event Code: sub mqttclient_MessageArrived does not fire when I publish the message from the B4J app. Any hint to try to understand what is wrong? thanks!
Erel B4X founder Staff member Licensed User Longtime User Feb 21, 2016 #2 Please edit your post and add [code]code here...[/code] tags. Upvote 0
Siam Active Member Licensed User Longtime User Feb 21, 2016 #3 hello, if i understand you right, you press the button to publish "command" and on the other site nothing happens? have you on the othersite Code: mqtt.Subscribe("command",0) in your code? greetings andy Upvote 0
hello, if i understand you right, you press the button to publish "command" and on the other site nothing happens? have you on the othersite Code: mqtt.Subscribe("command",0) in your code? greetings andy
giggetto71 Active Member Licensed User Longtime User Feb 21, 2016 #4 YES!!!!!! that was the problem....Rookie mistake! THANKS Siam! Upvote 0