Bokka
Member
Hello!
I'm trying to write a very, very simple and basic program to connect an ESP8266 wifi module to an a MQTT server.
I have wrote that code:
The board connect without problems to the wifi network, but in the line 32 of the code, I receive this error message:
"
Main - 32: Impossibile convertire il tipo: {Type=StringLiteral,Rank=0, RemoteObject=True} in: {Type=Stream,Rank=0, RemoteObject=True}
Main - 32: I tipi non corrispondono (warning #22)
Main - 31: Routine ConnectMQTT non utilizzata. (warning #12)
"
The line is:
" client.Initialize("client", "tcp://your_iport_here", "prova")"
Where I'm wrong?
Thanks a lot in advance!
I'm trying to write a very, very simple and basic program to connect an ESP8266 wifi module to an a MQTT server.
I have wrote that code:
B4X:
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Public client As MqttClient
Public connected As Boolean
Public client As MqttClient
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
'example of connecting to a local network
If wifi.Connect2("wifi-net", "pwd") Then
Log("Connected to network")
Else
Log("Failed to connect to network")
End If
End Sub
Sub ConnectMQTT
client.Initialize("client", "tcp://your_ip:port_here", "prova")
Dim options As MqttConnectOptions
options.Initialize("user", "password")
client.Connect2(options)
End Sub
Sub client_Connected (Success As Boolean)
connected = Success
If Success Then
Log("CONNESSO")
Else
Log("NON CONNESSO")
End If
End Sub
Sub client_Disconnected
connected = False
Log("Disconnesso mqtt")
'CallSub(Main, "SetState")
End Sub
Sub client_MessageArrived (Topic As String, Payload() As Byte)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Service_Destroy
End Sub
The board connect without problems to the wifi network, but in the line 32 of the code, I receive this error message:
"
Main - 32: Impossibile convertire il tipo: {Type=StringLiteral,Rank=0, RemoteObject=True} in: {Type=Stream,Rank=0, RemoteObject=True}
Main - 32: I tipi non corrispondono (warning #22)
Main - 31: Routine ConnectMQTT non utilizzata. (warning #12)
"
The line is:
" client.Initialize("client", "tcp://your_iport_here", "prova")"
Where I'm wrong?
Thanks a lot in advance!