@Robin, the wifi object has a life cycle... and .getIP() can only be executed when it is (had) a connection. That's the reason why you get >Uncaught Error: Cannot read property 'cmd' of undefined at line 1 col 11 var b={};f.cmd("AT+CIFSR\r\n",... with up-arrow (accent circumflex - ^) pointing to cmd property of (minimized) f variable in Post #4. Variable/property f of/within wifi object is undefined until connection exists. (yes, it could be handled 'gracefully'... on cost of space/variables not available to the application anymore... : ).
The life cycle and the communication between the application stack and the wifi stack together with your application of them explains the error you get.
Most of the time requiring a module is only making the code object available to the application with no (or minimal) setup. The typical .connect() then returns an object that is functionally alive and a service to the application.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@Robin, the wifi object has a life cycle... and .getIP() can only be executed when it is (had) a connection. That's the reason why you get
>Uncaught Error: Cannot read property 'cmd' of undefined at line 1 col 11 var b={};f.cmd("AT+CIFSR\r\n",...
with up-arrow (accent circumflex - ^) pointing tocmd
property of (minimized) f variable in Post #4. Variable/propertyf
of/withinwifi
object isundefined
until connection exists. (yes, it could be handled 'gracefully'... on cost of space/variables not available to the application anymore... : ).The life cycle and the communication between the application stack and the wifi stack together with your application of them explains the error you get.
Most of the time requiring a module is only making the code object available to the application with no (or minimal) setup. The typical
.connect()
then returns an object that is functionally alive and a service to the application.