Scan available Wi-Fi networks on your BlackBerry

Is there an RIM API available that will help get a list of available network services or just Wi-Fi networks for a device and set up a selected network access point for any network communications?

Is it possible for my application to disable mobile networks such as GPRS, WAP, etc.?

Example:
When the application starts, it should scan Wi-Fi connections, even if the device does not have previous Wi-Fi access points and a list of available Wi-Fi connections. Then the user will select the appropriate Wi-Fi connection to connect for any network connection. Outside the application, any Internet connection, such as a browser or any other application, must be made through the same selected Wi-Fi connection. Scanning for Wi-Fi and setting up a connection are almost identical to the settings of Wi-Fi BlackBerry.

I want to do this for BlackBerry OS 4.5, 4.7 and 5.0.

Update

The fact is that I'm looking for scanning via Wi-Fi through the application. As through the application, I can scan available access points or Wi-Fi access points and install one of the access points by selecting it on the device, then connect to it for communication.

Basically, how do we establish a Wi-Fi connection in the "Manage connetion" of a BlackBerry? I have to do something similar with the application.

From some BlackBerry forums, I found out that there is a package in OS v5.0, i.e. package net.rim.device.api.wlan.hotspot to get Wi-Fi hotspots, But after a long search I did not find a single example of the example or many explanations. Since I am trying to implement by studying its API documentation, but I have not succeeded.

If you have an idea related to this or any sample code, this will be very helpful.

+3
1

, NetworkDiagnostic tool RIM.

BlackBerry,

/**
 * Determines what connection type to use and returns the necessary string to use it.
 * @return A string with the connection info
 */
private static String getConnectionString()
{
    // This code is based on the connection code developed by Mike Nelson of AccelGolf.
    // http://blog.accelgolf.com/2009/05/22/blackberry-cross-carrier-and-cross-network-http-connection
    String connectionString = null;

    // Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR variable.
    if (DeviceInfo.isSimulator())
    {
            if (UploaderThread.USE_MDS_IN_SIMULATOR)
            {
                    logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is true");
                    connectionString = ";deviceside=false";
            }
            else
            {
                    logMessage("Device is a simulator and USE_MDS_IN_SIMULATOR is false");
                    connectionString = ";deviceside=true";
            }
    }

    // Wi-Fi is the preferred transmission method.
    else if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
    {
        logMessage("Device is connected via Wifi.");
        connectionString = ";interface=wifi";
    }

    // Is the carrier network the only way to connect?
    else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT)
    {
        logMessage("Carrier coverage.");

        String carrierUid = getCarrierBIBSUid();
        if (carrierUid == null)
        {
            // Has carrier coverage, but not BIBS.  So use the carrier TCP network
            logMessage("No Uid");
            connectionString = ";deviceside=true";
        }
        else
        {
            // otherwise, use the Uid to construct a valid carrier BIBS request
            logMessage("uid is: " + carrierUid);
            connectionString = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public";
        }
    }

    // Check for an MDS connection instead (BlackBerry Enterprise Server).
    else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
    {
        logMessage("MDS coverage found");
        connectionString = ";deviceside=false";
    }

    // If there is no connection available abort to avoid bugging the user unnecssarily.
    else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
    {
        logMessage("There is no available connection.");
    }

    // In theory, all bases are covered so this shouldn't be reachable.
    else
    {
        logMessage("no other options found, assuming device.");
        connectionString = ";deviceside=true";
    }

    return connectionString;
}

/**
 * Looks through the phone service book for a carrier provided BIBS network
 * @return The uid used to connect to that network.
 */
private static String getCarrierBIBSUid()
{
    ServiceRecord[] records = ServiceBook.getSB().getRecords();
    int currentRecord;

    for (currentRecord = 0; currentRecord < records.length; currentRecord++)
    {
        if (records[currentRecord].getCid().toLowerCase().equals("ippp"))
        {
            if (records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0)
            {
                return records[currentRecord].getUid();
            }
        }
    }
    return null;
}
+5

Source: https://habr.com/ru/post/1748901/


All Articles