B4R Question MQTT - Connect & Reconnect in B4R

Discussion in 'B4R Questions' started by Andrej Meszaros, Nov 13, 2017.

Similar threads

B4A Tutorial [B4X] MQTT - Connect & Reconnect
B4R Tutorial MQTT
B4R Library RDC based on MQTT
B4A Tutorial [B4X] MQTT Chat Room
B4R Tutorial ESP Configurator based on B4RSerializator
  1. Andrej Meszaros

    Andrej Meszaros Member Licensed User

    Hi,

    Erel has a great solution for mqtt connection testing in B4A, B4i and B4J.
    But how is it in B4R ?

    Has anybody idea ?

    Thanks

    Andrej
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    This code is from one of the examples:
    Code:
    Sub Connect(unused As Byte)
       
    If mqtt.Connect = False Then
         
    Log("trying to connect again")
         CallSubPlus(
    "Connect"10000)
         
    Return
       
    End If
       
    Log("Connected to broker")
       mqtt.Subscribe(
    "arduino"0)
       mqtt.Publish2(
    "pc"Array As Byte(123), True)
    End Sub

    Sub Mqtt_Disconnected
       
    Log("Disconnected")
       mqtt.Close
       Connect(
    0)
    End Sub

    Sub Mqtt_MessageArrived (Topic As String, Payload() As Byte)
       
    Log("Message arrived. Topic=", Topic, " payload: ", Payload)
    End Sub
     
  3. Andrej Meszaros

    Andrej Meszaros Member Licensed User

    Thank You Erel.
     
Loading...