0
Beantwoord

IR.GetCurrentLocalIPInfo in i3 pro

Mike Slattery 8 jaar geleden in Applications / i3 Pro bijgewerkt 8 jaar geleden 8

Looks like this recently stopped working in the latest iridium_pro_setup_1.1.1.474 for Windows PC, Not server. The LAN port used to return it IP and now returns 169.254.254.95

[10-03-2017 10:40:25.580] INFO SCRIPT WiFi Name = Wi-Fi
[10-03-2017 10:40:25.589] INFO SCRIPT IP = 169.254.103.3
[10-03-2017 10:40:25.591] INFO SCRIPT Mask = 0.0.0.0
[10-03-2017 10:40:25.592] INFO SCRIPT MAC = B0-C0-90-8F-0A-31
[10-03-2017 10:40:25.592] INFO SCRIPT Lan Name = Local Area Connection* 11
[10-03-2017 10:40:25.593] INFO SCRIPT IP = 169.254.254.95
[10-03-2017 10:40:25.594] INFO SCRIPT Mask = 0.0.0.0
[10-03-2017 10:40:25.594] INFO SCRIPT MAC = 12-C0-90-8F-0A-31


Code

if (typeof IR.GetCurrentLocalIPInfo == "function") {
// [0] = WiFi [1] = LAN
iPInfo = IR.GetCurrentLocalIPInfo();
IR.Log("WiFi Name = " + iPInfo[0].Name);
IR.Log("IP = " + iPInfo[0].IP);
IR.Log("Mask = " + iPInfo[0].Mask);
IR.Log("MAC = " + iPInfo[0].MAC);
if (iPInfo[1] != null) {
IR.Log("Lan Name = " + iPInfo[1].Name);
IR.Log("IP = " + iPInfo[1].IP);
IR.Log("Mask = " + iPInfo[1].Mask);
IR.Log("MAC = " + iPInfo[1].MAC);
}
}
else IR.Log("No IP Info.");


Antwoord

Antwoord
Beantwoord

Hello


We recommend to use this script:


IR.AddListener(IR.EVENT_START,0,function()
{
var local = IR.GetCurrentLocalIPInfo();
IR.Log ("Size: " + local.length); for (var i = 0; i <local.length; i++)
{ IR.Log("Name = " + local[i].Name); IR.Log("IP = " + local[i].IP); IR.Log("Mask = " + local[i].Mask); IR.Log("MAC = " + local[i].MAC); } });


Hello


What real local IP do you have?

It should report 192.168.10.3.

MAC: F4:8E:38:78:89:33

This used to work without any issue.

Hello!


Try installing a more recent version of Iridium. Currently version 1.1.2 available for download.

I did try the latest 1.1.2 and still get a 169. address returned.

I changed the code to the following. I was getting an Error by not testing for null.

 

    if (typeof IR.GetCurrentLocalIPInfo == "function") {

        // [0] = WiFi  [1] = LAN

        var iPInfo = IR.GetCurrentLocalIPInfo();

        if (iPInfo[0] != null) {

            IR.Log("WiFi Name = " + iPInfo[0].Name);

            IR.Log("IP = " + iPInfo[0].IP);

            IR.Log("Mask = " + iPInfo[0].Mask);

            IR.Log("MAC = " + iPInfo[0].MAC);

        }

        if (iPInfo[1] != null) {

            IR.Log("Lan Name = " + iPInfo[1].Name);

            IR.Log("IP = " + iPInfo[1].IP);

            IR.Log("Mask = " + iPInfo[1].Mask);

            IR.Log("MAC = " + iPInfo[1].MAC);

        }

    }

    else IR.Log("No IP Info.");

 

    if (iPInfo[0].IP != null) {

        var myIp = iPInfo[0].IP;

        if (myIp.search("0.0.0.0") < 0 && myIp.search("169.") < 0) {    // returns the position of the match.

            myIp = iPInfo[0].IP // WiFi connected    // WiFi is used if address searched is found

        }

    }

    else if (myIp != null && iPInfo[1].IP != null) {

        myIp = iPInfo[1].IP // Use Lan

    } else myIp = "0.0.0.0";

I changed to this and found that the index was 2.

 

    var myIp;

    var myIpFound = false;

 

    if (typeof IR.GetCurrentLocalIPInfo == "function") {

        // [0] = WiFi  [1] = LAN

        var iPInfo = IR.GetCurrentLocalIPInfo();

 

        for (var index = 0; index < iPInfo.length; index++) {

            if (iPInfo[index] != null) {

                IR.Log("index = " + index);

                IR.Log("Name = " + iPInfo[index].Name);

                IR.Log("IP = " + iPInfo[index].IP);

                IR.Log("Mask = " + iPInfo[index].Mask);

                IR.Log("MAC = " + iPInfo[index].MAC);

                myIp = iPInfo[index].IP;

                if (myIp.search("0.0.0.0") < 0 && myIp.search("169.") < 0) {    // returns the position of the match.

                    myIp = iPInfo[0].IP // WiFi connected    // WiFi is used if address searched is found

                    myIpFound = true;

                    break;

                }

            }

        }

        if (!myIpFound) {

            myIp = "0.0.0.0";

        }

    }

    else IR.Log("No IP Info.");

Antwoord
Beantwoord

Hello


We recommend to use this script:


IR.AddListener(IR.EVENT_START,0,function()
{
var local = IR.GetCurrentLocalIPInfo();
IR.Log ("Size: " + local.length); for (var i = 0; i <local.length; i++)
{ IR.Log("Name = " + local[i].Name); IR.Log("IP = " + local[i].IP); IR.Log("Mask = " + local[i].Mask); IR.Log("MAC = " + local[i].MAC); } });


So I put the timer above it and added a test for the IP address and finally got it to work. Thanks  

 

IR.SetInterval(1000, oneSecTimer);

 

    // ***********

    //////////////

 

    var iPInfo = IR.GetCurrentLocalIPInfo();

    if (iPInfo != null) {

        IR.GetItem("PP_Settings").GetItem("MyIpAddressTxt").Text = "TCX9 IP: 0.0.0.0";

 

        for (var index = 0; index < iPInfo.length; index++) {

            if (iPInfo[index].IP != null) {

                IR.Log("index = " + index);

                IR.Log("Name = " + iPInfo[index].Name);

                IR.Log("IP = " + iPInfo[index].IP);

                IR.Log("Mask = " + iPInfo[index].Mask);

                IR.Log("MAC = " + iPInfo[index].MAC);

                var myIp = iPInfo[index].IP;

                if (myIp.search("0.0.0.0") < 0 && myIp.search("169.") < 0) {    // returns the position of the match.

                    IR.GetItem("PP_Settings").GetItem("MyIpAddressTxt").Text = "My IP: " + myIp;

                    IR.GetItem("PP_Settings").GetItem("MyMacAddressTxt").Text = "MAC: " + iPInfo[index].MAC;

                    break;

                }

            }

        }

    }

 

Mike