#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
'Set Fixed IP
RunNative( "SetIP" , Null )
'Connect to AP
If wifi.Connect2("MOVISTAR_0CF9","xxxxxxxx") Then 'change to your network SSID (use Connect2 if a password is required).
Log("Connected to wireless network.")
Log("My ip: ", wifi.LocalIp)
Else
Log("Failed to connect.")
Return
End If
End Sub
#if C
void SetIP(B4R::Object* o) {
IPAddress ip(192, 168, 1, 5); // (Replace xxx with desired IP)
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip, gateway, subnet);
}
#end if