B4R Question ESP8266 mqtt.Publish bug ?

Andrej Meszaros

Member
Licensed User
Longtime User
Hi Erel,

can You check this ?

When i try to send data with > mqtt.publish("mytopic",mydata) it works.

But when i do it this way >
Dim fields(8) As String
fields(7) = "mytopic"

mqtt.publish ( fields( 7 ), mydata ) it doesnt works.

Thank You

Andrej
 

Andrej Meszaros

Member
Licensed User
Longtime User
Some additional info to my question.

I create an array with data necesery to connect to wifi and mqtt server.
The data are : filed(0) = ssid, field(1) = wifi password, field(2) = mqttserver ..... port, user, pasword, topic ...
Everything is working but sending data not working when the topic is used from field array.

fields(7) is defined as string
fields(7) = "mytopic"

mqtt.publish ( fields( 7 ), mydata ) > it doesnt works
mqtt.publish("mytopic",mydata) > it works.

Thank You

Andrej
 
Upvote 0

miker2069

Active Member
Licensed User
Longtime User
What happens if you first assign fields(7) to another string variable like:

B4X:
Dim topic as String = fields(7)

Log("Verify correct topic, Topic = ",topic)
mqtt.publish(topic,mydata)

Sounds somewhat similar to the issue I had returning an element of an array - See my post here. If it's similar, should be resolved in next version and in interim use the work around described above.
 
Last edited:
Upvote 0
Top