How to get address IP WiFi BlackBerry 10

I want to get the WiFi ipv4 address in blackberry and write these codes that are referenced in others as below, it worked in my Dev Alpha C but I have no other devices to test.

However, it doesn't seem to work in the Z10 or Q10.

Is the interface of network, also called "bcm0" in the Z10 or Q10?

Is someone knows it this problem?

Thank you.

    foreach (const QNetworkInterface &interface, QNetworkInterface::allInterfaces()){

            qDebug() <<  "humanReadableName: " << interface.humanReadableName();
            //if(QString::compare(interface.humanReadableName(), "en0") == 0){
            if(QString::compare(interface.humanReadableName(), "bcm0") == 0){
                foreach (const QNetworkAddressEntry &entry, interface.addressEntries()) {
                    if (entry.prefixLength() <= 32){
                        wifiIP = entry.ip().toString();
                        qDebug() << "IPv4: " << entry.ip().toString();
                        return true;
                    }
                    else
                        qDebug() << "IPv6: " << entry.ip().toString();
                }
            }
        }
    return false;

Oddly enough, I wrote this yesterday for an extension WebWorks

Here's the skeleton code

    netstatus_interface_details_t *details;

    if(BPS_SUCCESS == netstatus_get_interface_details(NULL, &details)) {
        netstatus_ip_status_t nstatus = netstatus_interface_get_ip_status(details);
        netstatus_interface_type_t ntype = netstatus_interface_get_type(details);
        bool nisconnected = netstatus_interface_is_connected(details);
        bool nisup = netstatus_interface_is_up(details);
        const char* nname = netstatus_interface_get_name(details);

        int nipcnt = netstatus_interface_get_num_ip_addresses(details);

        for(int i=0; i

I wrote cela for retooling as an extension that it collects all data simply and then throw it all away (I just saw in the debugger)

Specifically, you need store IP addresses nipaddr gets in the loop, if nothing else

A few above who are important pieces of info

nisup - if the network device is active

nisconnected - is it connected to a network

nType - if you get a result WIFI (search netstatus_interface_type_t in dox for any possible return) you WiFi

nStatus - connection info (look to the top of netstatus_ip_status_t for more details)

There are three possible results

The first runs aground (no network at all)

The network ntype is not WIFI (also bad)

The INVESTIGATION period gets collected and you can use it

Note that you will have at least two survey periods while yu needs to work which is ipv4 and ipv6

Personally I'll just regex them

^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$

The above is easy to do in JavaScript and identifies an ip4

Oh - ipv6 that comes up is the linux full log xxxx:xxxx:xxxx:xxxx % dev

You can do a sanity check on the ssid but I ain't got that far yet (I don't need it)

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for