B4R Question [SOLVED] Fixed IP on NodeMCU 1.0

inakigarm

Well-Known Member
Licensed User
Longtime User
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)

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
I get this error:

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 ?
 

inakigarm

Well-Known Member
Licensed User
Longtime User
It looks like there are three invalid characters at the end of that line. Try to remove them.
Thanks, it worked.
Seems strange, I've copied from the code snippet and pasted it directly on B4R IDE (I've tried again and the same error arise)

(From hex editor)
upload_2017-3-5_18-10-22.png


Is it a problem from the original post or something with Xenforo-Chrome browser ? (Windows 8.1 64 bits here)
 
Upvote 0

atiaust

Active Member
Licensed User
Longtime User
Hi inakigram

I experienced the same problem today when I copied some code to the clip board and pasted it into my app.

I deleted the code and retyped it from scratch and the error disappeared.

There was an issue with Win 10 copy and paste but I thought it was resolved.
 
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
Thankms for the info; maybe the hidden characters are in the original Post-code snippet (note that I use Win 8.1)
 
Upvote 0
Top