B4R Question WifiProgram will not compile in V2.8

rodmcm

Active Member
Licensed User
Hi
This test programs compiles and runs in Ver 2.2 but not in V2.8.. Am I missing something
B4X:
'ESP32 WIFI TEST
'  Revison 1
' 29 August 2019



#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 600
    '#DefineExtra: #define SKIP_B4RNEW
#End Region

Sub Process_Globals
    'Network
    Private server As WiFiServerSocket
    Private wifi As ESP8266WiFi
    Private astream As AsyncStreams
    Private WIFIConnected As Boolean = False
    'Timers
    Public Serial1 As Serial
   
    Private UpdateTimer As Timer

    Private counter As ULong
                                                                                             'Number of ADC counts before RPM changes
End Sub


Private Sub AppStart
    Serial1.Initialize(115200)
    UpdateTimer.Initialize("UpdateTimer_Tick", 250) '1000ms = 1 second
    UpdateTimer.Enabled = True
    AddLooper("DigitalSample")

    StartWIFI
End Sub


Sub StartWIFI
    wifi.Disconnect
    RunNative( "SetIP" , Null)
     #if C
     void SetIP(B4R::Object* o)
     {
    IPAddress local_IP(192,168,4,35);
    IPAddress gateway(192,168,4,9);
    IPAddress subnet(255,255,255,0);
    WiFi.softAPConfig(local_IP, gateway, subnet);       // set gateway
    }
    #End If
    If wifi.StartAccessPoint2("ESP32WIFITEST","12345678") Then
        server.Initialize(51042, "Server_NewConnection")
        server.Listen
        Log("Waiting for connection.")
    Else
        Log("Failed to connect to Wifi.")
        WIFIConnected=True
    End If
End Sub


Sub Server_NewConnection (NewSocket As WiFiSocket)
    Log("new connection")
    Log("My ip: ", wifi.AccessPointIp)
    astream.Initialize(NewSocket.Stream,"astream_NewData", "astream_Error")
    WIFIConnected=True
End Sub


' Looper
Sub DigitalSample
    If WIFIConnected Then
        counter = counter + 1
        If counter Mod 100000 = 0 Then
            Log("Took me ", Millis, " milliseconds to count to ", counter)
            Log(counter / Millis, " loops per milliseconds")
        End If
    End If
End Sub



' Sends all of the values
Sub SendAllValues
    If WIFIConnected Then
        'Log("Sending Values")
        Dim b(0) As Byte
        b(0) = 240
        astream.Write(b)
        Delay(100)
    End If
End Sub



' Updates the information
Private Sub UpdateTimer_Tick
    SendAllValues
End Sub


' For incoming messages.. Not used
Sub aStream_NewData (Buffer() As Byte)
   
End Sub

Sub aStream_Error
    Log("error")
    server.Listen
    WIFIConnected=False
End Sub
 

Attachments

Top