Android Question JMQTTBrokerExtended 2.1 Payload (Message) not decoded correctly

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone,
I'm using the library by @Informatrix have the necessity to put an MQTT Broker on an Android Tablet (panel pc).
However, I noticed that the event _Publish decodes badly the Message in B4A (in B4J it is decoded correctly).



What I send:
Screenshot 2025-06-23 alle 12.51.37.png


What I receive (in B4J it prints only "ok")

Screenshot 2025-06-23 alle 12.51.46.png



Full B4A Code:

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
   
    Private broker As MQTTBrokerExtended
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
   
    broker.Initialize(1883, broker.AUTHENTICATION_NO, False, "broker")
    broker.Start
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Private Sub broker_Publish(ClientID As String, Username As String, QOS As String, TopicName As String, Message() As Byte, IsDupFlag As Boolean, IsRetainFlag As Boolean)
    ' Someone published a message
    Log(BytesToString(Message, 0, Message.Length, "UTF-8"))
'    If SubExists(mCallBack, $"${mEventName}_NewMessage"$) Then
'        CallSubDelayed3(mCallBack, $"${mEventName}_NewMessage"$, TopicName, BytesToString(Message, 0, Message.Length, "utf8"))
'    End If
End Sub

I also attached the project.
Am I missing something?

Thanks in advance
 

Attachments

  • Mqtt Broker Example.zip
    10.1 KB · Views: 58
Top