get IP address

  • how to het the module IP address. I normally do this through "os.interfaces" but its not implemented.
    Is there a special fucntion call for this..... Thanks.

  • I made a typo to be clear this should read 'GET" the IP address, after tart up.


    require('lowsys').settings gives you the IP settings.

    Right know there is no way to get the IP address if you are using the DHCP client. You are right, os.interfaces will have to be implemented.

  • Oh wait, there is a way. Connect somewhere via TCP with the tcp module, then read the local socket address. That should work.

  • Hi. Yes I was wondering if it was available through tcp. as it has to be somewhere. I will try and sort it out and post the reply here. Thanks.

  • I am using udp at the moment in the first layer of my control and data aq system which I am porting from Nodes hosted on linux embedded or windowsPC. At the moment it seems. UDPserver.address() only provides the host IP adress on connected sockets. Until a connection is made it seems that the host adrress in the tcp/ip layers is not initialised. UDP.connect is also not supported at the moment (dont need it anyway) but a UDP connection will cause the local hostip to become correctly populated and server.address() will work ON my PC. Soon I will be implementing my tcp socket connections so I will come back to this problem then . As I assume tcpserver.connect is impemented and therefore this method will work. As I also have a dedicated (application) server in my system infrastructure it will be no problem in the future to obtain the IP address this way. However, for other applications using DHCP (most serious iot apps I think) it would be nice to know the IP at start up time, particularly if the module is roaming. Instead of implementing the interfaces part of the OS module I would suggest you just provide a private function call to pull this up from the underlying DHCP client. I'll be back.

Log in to reply