With IDE 1.8, B4R 1.80 I'm running this code to set a fixed IP address (code Snippet https://www.b4x.com/android/forum/threads/set-ip-address-static-fixed-for-esp8266.75798/#content)
I get this error:
It works in 'DHCP' mode (without setting the IP address); any idea about this error? Is there an alternative way to set a fixed IP address on ESP8266/NodeMCU ?
B4X:
#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
B4X:
B4R version: 1.80
Parsing code. (0.00s)
Compiling code. (0.02s)
Building project (0.03s)
Compiling & deploying Ino project (NodeMCU 1.0 (ESP-12E Module) - COM3) Error
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
WARNING: Category '' in library Wire is not valid. Setting to 'Uncategorized'
b4r_main.cpp:15: error: stray '\342' in program
WiFi.config(ip, gateway, subnet);​
^
b4r_main.cpp:15: error: stray '\200' in program
b4r_main.cpp:15: error: stray '\213' in program
exit status 1
It works in 'DHCP' mode (without setting the IP address); any idea about this error? Is there an alternative way to set a fixed IP address on ESP8266/NodeMCU ?