B4R Question ESP8266 send file with MQTT

Michael1968

Active Member
Licensed User
Longtime User
Hi all,
I want to send a log file from my ESP8266 via MQTT to a Rpi3.
Sending Text massages work
I have Change Erels "File Transfer" example..but it didn't work.
how can please help me?

B4X:
If fs.OpenRead("/log.dat") Then
            Dim size As ULong = fs.CurrentFile.Size
            Log("size: ", size)
            Dim counter As ULong = 0
            Dim b(1024) As  Byte
            Do While counter < size
                Dim read As Int = fs.Stream.ReadBytes(b, 0, Min(b.Length, size - counter))
                Log(read)
                               
                If read = 0 Then
                    'success = False
                    Log("false")
                    Exit
                End If
                counter = counter + read
                'astream.Write2(b, 0, read)
            Loop
            fs.Close
            Log ("sende über MQTT")
           
            Mqtt.Publish(MqttTopic,bc.StringFromBytes(b) )
 
Top