Android Question jMQTT question... publish problem...

Mr Mo

Member
Licensed User
Hi all,
I am just a one week newbie. My first try is working with jMQTT.
My application dialog with an Arduino broker via Wifi. The Arduino is connected by Nrf24L01 to 3 sensors.
I have no problem with subcribed message.
If I try to publish... it seem not working.
The topic is MyMQTT/21/1/V_LIGHT and the payload must be "0" or "1".
For information I have other application working with this Arduino broker.
Here is the code for publishing.
Any help welcome.
B4X:
Sub tbnLight_CheckedChange(Checked As Boolean)
    Dim msg(1) As Byte
    Select tbnLight.Checked
        Case True
            msg(0) = 0x31
        Case False
            msg(0) = 0x30
    End Select
    Log("Sent Payload: " & BytesToString(msg, 0, msg.Length, "utf8"))
    Try
        mqtt.Publish("MyMQTT/21/1/V_LIGHT",msg)
    Catch
        Log(LastException)
        If mqtt.Connected = False Then
            mqtt.Connect
        End If
    End Try
End Sub
 

Mr Mo

Member
Licensed User
Hi all,
I am just a one week newbie. My first try is working with jMQTT.
My application dialog with an Arduino broker via Wifi. The Arduino is connected by Nrf24L01 to 3 sensors.
I have no problem with subcribed message.
If I try to publish... it seem not working.
The topic is MyMQTT/21/1/V_LIGHT and the payload must be "0" or "1".
For information I have other application working with this Arduino broker.
Here is the code for publishing.
Any help welcome.
B4X:
Sub tbnLight_CheckedChange(Checked As Boolean)
    Dim msg(1) As Byte
    Select tbnLight.Checked
        Case True
            msg(0) = 0x31
        Case False
            msg(0) = 0x30
    End Select
    Log("Sent Payload: " & BytesToString(msg, 0, msg.Length, "utf8"))
    Try
        mqtt.Publish("MyMQTT/21/1/V_LIGHT",msg)
    Catch
        Log(LastException)
        If mqtt.Connected = False Then
            mqtt.Connect
        End If
    End Try
End Sub

After some additional tests I have changed the publish method like:
B4X:
Try
        'mqtt.Publish("MyMQTT/21/1/V_LIGHT",msg)
        mqtt.Publish2("MyMQTT/21/1/V_LIGHT", msg, mqtt.QOS_0_MOST_ONCE, False)
    Catch

Now publishing is ok!

May I knew if somewhere there are a description of the default values for the jMQQT library?
By the way, thanks to the development team. Let me tell you it was a pleasure for me to use B4a for the first time.
Just bought my license after few hours of use.
 
Upvote 0
Top