Intel Connection Web API Documentation and Examples

The Intel Connection Web API provides web developers with JavaScript access to information about the device's connection state.



When web apps have the ability to learn about the characteristics of the device's network connection they are be able to make use of that information to create a better experience for the user.

For instance, in combination with other information about the device, a web app might use connection information to request a video stream which is approprate for the device's current bandwidth capability. A web app may determine that current signal strength is not sufficient for the app to function appropriatly for the desired user experience - and may prompt the user re-orient the device or move closer to a wireless access point.

Browser and Device Compatibility

The table below lists some compatability notes for browser and operating system combinations.

If you are interested in seeing these APIs available on other device types and operating systems please let us know by leaving comments.

BrowserOperating SystemNotes
Firefox 3.5.x, 3.6.x Windows (XP, Vista, Win 7) Seems to be working well.
Chrome 4.0.x.y Windows (XP, Vista, Win 7) Seems to be working well.
Safari 4.0.x Windows (XP, Vista, Win 7) Seems to be working well.
Opera v 10.x Windows (XP, Vista, Win 7) Not currently working. It's on the debug todo list.
Internet Explorer 8.x Windows (XP, Vista, Win 7) Not supported yet. Its on the todo list though.
Firefox, Chrome, Safari Linux, MacOS Not supported yet. Linux and Mac OS porting is underway :)

A code sample to get you started

This HTML & JavaScript shows you how to embed the Intel Connection Web API into your app.

  <div id="IntelWebAPIs_sample_code_status_div" 
    style="border:1px dotted red;width:640px;height:480px;overflow:auto;"></div>
  <script type="text/javascript">

    // this outer closure just to keep the sample code from cluttering up
    // the namespace with the function names etc being used
    (function() {
      //kick off IntelWebAPIs.init() and IntelWebAPIs.require() when
      //the page is loaded
      add_onload_handler( function() {

        //called by IntelWebAPIs.init()
        function init_result_func(result) {
          if(result.success) {
            // now bring in Intel Web APIs required by your app...
            output_status("IntelWebAPIs Connector init success");
            IntelWebAPIs.require(["connection"], require_completion_func, require_progress_func);
          else {
            output_status("IntelWebAPIs Connector init error: " + result.error.msg);
            //handle error condition
            //result.error.msg contains an error message
            //result.connectorInstUrl contains the url to the Intel Web API connector installer
            output_status("you may need to download the Intel Web API connector from here: " + 
        //called by IntelWebAPIs.require()
        function require_completion_func(result) {
            //you can now use IntelWebAPIs.connection properties and functions
            output_status("IntelWebAPIs." + result.installInfo.plugins[0].name + " ready for use!");
              // send a status message to our div every second
              var connInfo = IntelWebAPIs.connection.getConnectionInfo();
              output_status("Wifi connected=" + connInfo.wifi.connected);
              output_status("Wifi signal strength=" + connInfo.wifi.signalStrength);
          else {
            //check other result properties and handle error condition
            output_status("IntelWebAPIs error: " + result.installInfo.msg);
        //called by IntelWebAPIs.require()
        function require_progress_func(statusMsg){
          //statusMsg is a string - send this wherever
          output_status("IntelWebAPIs connector status: " + statusMsg);
      /* Its recommended that you wait until the document is loaded 
         before calling IntelWebAPIs.init() and IntelWebAPIs.require() 
         This utility helps with that...*/
      function add_onload_handler(addfunc, altwindow) {
        var targwindow = window;
        if(typeof(altwindow) != 'undefined'){
          targwindow = altwindow;
        /* chain the onload functions together */
        var prevf = targwindow.onload;
        var newf  = addfunc;
        targwindow.onload = function(){
            if(typeof(prevf) == 'function'){
      /* utility that outputs status messages to a div*/
      function output_status(str) {
        var divout = document.getElementById("IntelWebAPIs_sample_code_status_div");
        divout.innerHTML += str + "<br/>";
        divout.scrollTop = divout.scrollHeight;
    })(); // end of outer closure

This is the result Object that is passed into init_result_func(result).
If the Intel Web API Connector is not yet installed on a user's device you can use the result.connectorInstUrl to prompt the user, in the context of your app, to install it.
Once the Intel Web API Connector is installed other apis are installed by the connector, with minimal user interruption, when your app calls IntelWebAPIs.require().

  result = { 
    success           : boolean,
    // these fields are valid if success != true
    connectorInstUrl  : string 
    error             : {
      msg             : string 

This is the result Object that is passed into require_completion_func(result).

  result = { 
    success       : boolean,
    installInfo   : {
      msg         : string,
      plugins     : [ { 
        name      : string,
        installed : boolean,
        details   : string

JavaScript API Details
These are the properties and functions exposed by the Connection Web API:

  IntelWebAPIs.connection = {
    'version'             : string,
    'connected'           : boolean,
    'getConnectionInfo'   : function

This is the API's version string. It is formatted as "major.minor.patch" where major and minor are numbers and patch is a string.

The IntelWebAPIs.connection.connected property indicates if the device is connected to a network or not. true for connected, false otherwise.

The IntelWebAPIs.connection.getConnectionInfo() function returns an Object with information about the current connection.
  connectionInfo =  {
    'lan'         : {
      'connected'       : boolean,
      'signalStrength'  : number,     //will be 100 if connected, 0 if not connected
      'linkSpeed'       : number      //kbps in 100bps or 0 if unknown or disconnected
    'wifi'        : {
      'connected'       : boolean
      'signalStrength'  : number,     //RSSI signal strength as a percent or -1 if unknown. 
                                      // signal strength is 0 when disconnected.
      'linkSpeed'       : number      //kbps in 100bps or 0 if unknown or disconnected

These JavaScript functions demonstrate accessing the connection information:

  function output_connected(){
    alert("connected = " + IntelWebAPIs.connection.connected);      
  function output_connection_info() {
    var conninfo = IntelWebAPIs.connection.getConnectionInfo();
    alert("lan.connected="        + conninfo['lan']['connected']);  
    alert("lan.signalStrength="   + conninfo['lan']['signalStrength']);
    alert("lan.linkSpeed="        + conninfo['lan']['linkSpeed']);

    alert("wifi.connected="       + conninfo['wifi']['connected']);  
    alert("wifi.signalStrength="  + conninfo['wifi']['signalStrength']);
    alert("wifi.linkSpeed="       + conninfo['wifi']['linkSpeed']);

See it working in this page!
Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.