B4R Question Log doesn't work

Ilya G.

Active Member
Licensed User
Longtime User
Why can log doesn't work?

2017-04-20_14-02-04.png
 

Ilya G.

Active Member
Licensed User
Longtime User
B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Public WiFi As ESP8266WiFi
    Private Astream As AsyncStreams
    Private server As WiFiServerSocket
    Private bc As ByteConverter
    Private Pin14 As Pin
    Private Pin1 As Pin
End Sub

Sub AppStart
    Serial1.Initialize(115200)
    Pin14.Initialize(14, Pin14.MODE_OUTPUT) ': Pin14.DigitalWrite(True)
    Pin1.Initialize(1, Pin1.MODE_OUTPUT) ': Pin1.DigitalWrite(True)

    WiFi.Connect2("RNIC", "*****")
    Log("Connected to: ", "RNIC, IP: ", WiFi.LocalIp)
    server.Initialize(80, "server_NewConnection")
    server.Listen
End Sub

Sub Server_NewConnection (NewSocket As WiFiSocket)
    Astream.Initialize(NewSocket.Stream, "astream_NewData", "astream_Error")
End Sub

Public Sub Astream_NewData (Buffer() As Byte)
    Log(Buffer)

    If bc.IndexOf(Buffer, "/set") <> -1 Then
        Dim Result As String

        If bc.IndexOf(Buffer, "/set/1/0") <> -1 Then
            Pin1.DigitalWrite(False)
            Result = Pin1.DigitalRead
        End If
        If bc.IndexOf(Buffer, "/set/1/1") <> -1 Then
            Pin1.DigitalWrite(True)
            Result = Pin1.DigitalRead
        End If
        If bc.IndexOf(Buffer, "/set/14/0") <> -1 Then
            Pin14.DigitalWrite(False)
            Result = Pin14.DigitalRead
        End If
        If bc.IndexOf(Buffer, "/set/14/1") <> -1 Then
            Pin14.DigitalWrite(True)
            Result = Pin14.DigitalRead
        End If
       
        Astream.Write("SET:").Write(Result)
    End If
   
    If bc.IndexOf(Buffer, "/status") <> -1 Then

        Dim p1 As String = Pin1.DigitalRead
        Dim p14 As String = Pin14.DigitalRead
       
        Astream.Write("Pin 1: ").Write(p1).Write(CRLF)
        Astream.Write("Pin 14: ").Write(p14).Write(CRLF)
        Astream.Write("Temperature: ").Write(t).Write(CRLF)
        Astream.Write("Humidity: ").Write(h)
    End If
   
    CallSubPlus("CloseConnection", 200, 0)
End Sub

Sub CloseConnection(u As Byte)
    If server.Socket.Connected Then
        server.Socket.Stream.Flush
        server.Socket.Close
    End If
End Sub

Sub AStream_Error
    server.Listen
End Sub
 
Upvote 0

Ilya G.

Active Member
Licensed User
Longtime User
If I add Log(CRLF, "App started"), I see only

2017-04-20_15-41-43.png


But Log("Connected to: ", "RNIC, IP: ", WiFi.LocalIp) and Log(Buffer) doesn't work :(
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Usually, if you lower the serial baud, the logs become clearer... I had that issue with my esp8266
 
Upvote 0
Top