      1 /*
      2  * This is sound cordova_plugin (TV specific API).
      3  * Apache License (2004). See http://www.apache.org/licenses/LICENSE-2.0
      4  *
      5  * Copyright (c) 2014, LG Electronics, Inc.
      6  */
      7
      8 /**
      9  * This represents the deviceInfo API itself, and provides a global namespace for operating deviceInfo service.
     10  * @class
     11  */
     12 cordova.define('cordova/plugin/deviceInfo', function (require, exports, module) { // jshint ignore:line
     13
     14     var service;
     15     if (window.PalmSystem){ // jshint ignore:line
     16         console.log("Window.PalmSystem Available"); // jshint ignore:line
     17         service = require('cordova/plugin/webos/service');
     18     } else {
     19         service = {
     20             Request : function(uri, params) {
     21                console.log(uri + " invoked. But I am a dummy because PalmSystem is not available"); // jshint ignore:line
     22
     23                if (typeof params.onFailure === 'function') {
     24                   params.onFailure({ returnValue:false,
     25                      errorText:"PalmSystem Not Available. Cordova is not installed?"});
     26                }
     27         }};
     28     }
     29
     30     /**
     31      * deviceInfo interface
     32      */
     33     var DeviceInfo = function () {
     34     };
     35
     36     function log(msg) {
     37     //    //console.log//will be removed // jshint ignore:line
     38     }
     39
     40     function checkErrorCodeNText(result, errorCode, errorText) {
     41
     42         if (result.errorCode === undefined || result.errorCode === null ) {
     43             result.errorCode = errorCode;
     44         }
     45         if (result.errorText === undefined || result.errorText === null) {
     46             result.errorText = errorText;
     47         }
     48     }
     49
     50
     51     /**
     52      * @namespace DeviceInfo.EddystoneFrame
     53      */
     54     DeviceInfo.EddystoneFrame = {
     55     /**
     56      * UUID
     57      * @since 1.4
     58      * @constant
     59      */
     60         UUID: "uid",
     61     /**
     62      * URL
     63      * @since 1.4
     64      * @constant
     65      */
     66         URL: "url"
     67     };
     68
     69     /**
     70      * Gets network information. Network information includes IP address assigned to wireless / wired LAN, gateway address, netmask and DNS address.
     71      * @class DeviceInfo
     72      * @param {Function} successCallback success callback function.
     73      * @param {Function} errorCallback failure callback function.
     74      * @return {Object}
     75      * <div align=left>
     76      * <table class="hcap_spec" width=400>
     77      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
     78      *   <tbody>
     79      *       <tr><th>isInternetConnectionAvailable</th><th>Boolean</th><th>Internet connection true: connected, false: not connected</th></tr>
     80      *       <tr class="odd"><th>wired</th><th>Object</th><th>Wired network information object. </th></tr>
     81      *       <tr><th>wired.state</th><th>String</th><th>Wired network connection "connected": connected "disconnected": not connected</th></tr>
     82      *       <tr class="odd"><th>wired.interfaceName</th><th>String</th><th>Wired network interface name. </th></tr>
     83      *       <tr><th>wired.ipAddress</th><th>String</th><th>IP address assigned to the wired network interface. </th></tr>
     84      *       <tr class="odd"><th>wired.netmask</th><th>String</th><th>Netmask assigned to the wired network interface. </th></tr>
     85      *       <tr><th>wired.gateway</th><th>String</th><th>Gateway address assigned to the wired network interface</th></tr>
     86      *       <tr class="odd"><th>wired.onInternet</th><th>String</th><th>Internet connection to the wired network "yes": connected "no": not connected. </th></tr>
     87      *       <tr><th>wired.method</th><th>String</th><th>IP allocation "manual": fixed allocation "dhcp": dynamic allocation</th></tr>
     88      *       <tr class="odd"><th>wired.dns1</th><th>String</th><th>DNS address assigned to the wired network interface. </th></tr>
     89      *       <tr><th>wired.dns2</th><th>String</th><th>Secondary DNS address assigned to the wired network interface. </th></tr>
     90      *       <tr class="odd"><th>wifi</th><th>Object</th><th>Wireless network information object. </th></tr>
     91      *       <tr><th>wifi.state</th><th>String</th><th>Wireless network connection "connected": connected "disconnected": not connected</th></tr>
     92      *       <tr class="odd"><th>wifi.interfaceName</th><th>String</th><th>Wireless network interface name. </th></tr>
     93      *       <tr><th>wifi.ipAddress</th><th>String</th><th>IP address assigned to the wireless network interface. </th></tr>
     94      *       <tr class="odd"><th>wifi.netmask</th><th>String</th><th>Netmask assigned to the wireless network interface. </th></tr>
     95      *       <tr><th>wifi.gateway</th><th>String</th><th>Gateway address assigned to the wireless network interface</th></tr>
     96      *       <tr class="odd"><th>wifi.onInternet</th><th>String</th><th>Internet connection to the wireless network "yes": connected "no": not connected. </th></tr>
     97      *       <tr><th>wifi.method</th><th>String</th><th>IP allocation "manual": fixed allocation "dhcp": dynamic allocation</th></tr>
     98      *       <tr class="odd"><th>wifi.dns1</th><th>String</th><th>DNS address assigned to the wireless network interface. </th></tr>
     99      *       <tr><th>wifi.dns2</th><th>String</th><th>Secondary DNS address assigned to the wireless network interface. </th></tr>
    100      *   </tbody>
    101      * </table>
    102      * </div>
    103      *
    104      * @example
    105      * // Javascript code
    106      * function getNetworkInformation () {
    107      *   function successCb(cbObject) {
    108      *      console.log("cbObject : " + JSON.stringify(cbObject));
    109      *      console.log("isInternetConnectionAvailable : " + cbObject.isInternetConnectionAvailable);
    110      *      console.log("wired.state : " + cbObject.wired.state);
    111      *      console.log("wired.method : " + cbObject.wired.method);
    112      *      console.log("wired.ipAddress : " + cbObject.wired.ipAddress);
    113      *      console.log("wired.netmask : " + cbObject.wired.netmask);
    114      *      console.log("wired.dns1 : " + cbObject.wired.dns1);
    115      *      console.log("wired.dns2 : " + cbObject.wired.dns2);
    116      *      console.log("wifi.state : " + cbObject.wifi.state);
    117      *      console.log("wifi.method : " + cbObject.wifi.method);
    118      *      console.log("wifi.ipAddress : " + cbObject.wifi.ipAddress);
    119      *      console.log("wifi.netmask : " + cbObject.wifi.netmask);
    120      *      console.log("wifi.dns1 : " + cbObject.wifi.dns1);
    121      *      console.log("wifi.dns2 : " + cbObject.wifi.dns2);
    122      *   }
    123      *
    124      *   function failureCb(cbObject) {
    125      *      var errorCode = cbObject.errorCode;
    126      *      var errorText = cbObject.errorText;
    127      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    128      *   }
    129      *
    130      *   var deviceInfo = new DeviceInfo();
    131      *   deviceInfo.getNetworkInfo(successCb, failureCb);
    132      * }
    133      * @since 1.0
    134      * @see
    135      * <a href="DeviceInfo%23getNetworkMacInfo.html">DeviceInfo.getNetworkMacInfo()</a><br>,
    136      * <a href="DeviceInfo%23setNetworkInfo.html">DeviceInfo.setNetworkInfo()</a><br>
    137      */
    138     DeviceInfo.prototype.getNetworkInfo = function (successCallback, errorCallback) {
    139
    140         log("getNetworkInfo: ");
    141         service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    142             method: 'getNetworkInfo',
    143             parameters: {},
    144             onSuccess: function (result) {
    145                 if (typeof successCallback === 'function') {
    146                     delete result.returnValue;
    147                     successCallback(result);
    148                 }
    149             },
    150             onFailure: function (error) {
    151                 log("getNetworkInfo: onFailure");
    152                 if (error.errorText.indexOf('Unknown method') !== -1) {
    153                     // Call old method
    154                     service.Request('luna://com.palm.connectionmanager', {
    155                         method: 'getstatus',
    156                         parameters: {},
    157                         onSuccess: function (result) {
    158                             log("getNetworkInfo: onSuccess");
    159                             delete result.returnValue;
    160                             if (typeof successCallback === 'function') {
    161                                 successCallback(result);
    162                             }
    163                         },
    164                         onFailure: function (error) {
    165                             log("getNetworkInfo: onFailure");
    166                             delete error.returnValue;
    167                             if (typeof errorCallback === 'function') {
    168                                 errorCallback(error);
    169                             }
    170                         }
    171                     });
    172                 }
    173                 else {
    174                     delete error.returnValue;
    175                     if (typeof errorCallback === 'function') {
    176                         errorCallback(error);
    177                     }
    178                 }
    179             }
    180         });
    181     /*
    182         service.Request('luna://com.palm.connectionmanager', {
    183             method: 'getstatus',
    184             parameters: {},
    185             onSuccess: function(result) {
    186                 log("getNetworkInfo: onSuccess");
    187                 delete result.returnValue;
    188                 if (typeof successCallback === 'function') {
    189                     successCallback(result);
    190                 }
    191             },
    192             onFailure: function(error) {
    193                 log("getNetworkInfo: onFailure");
    194                 delete error.returnValue;
    195                 if (typeof errorCallback === 'function') {
    196                     errorCallback(error);
    197                 }
    198             }
    199         });
    200       */
    201         log("DeviceInfo.getNetworkInfo Done");
    202     };
    203
    204     /**
    205      * Sets network information. Network information includes IP address assigned to wireless / wired LAN, gateway address, netmask and DNS address.
    206      * @class DeviceInfo
    207      * @param {Function} successCallback success callback function.
    208      * @param {Function} errorCallback failure callback function.
    209      * @param {Object} options
    210      * <div align=left>
    211      * <table class="hcap_spec" width=400>
    212      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    213      *   <tbody>
    214      *       <tr><th>wired</th><th>Object</th><th>Wired network information object. </th><th>required</th></tr>
    215      *       <tr class="odd"><th>wired.enabled</th><th>Boolean</th><th>Wired network connection true : enabled false : disabled </th><th>required</th></tr>
    216      *       <tr><th>wired.method</th><th>String</th><th>IP allocation "manual": fixed allocation "dhcp": dynamic allocation, If DHCP is enabled then ipAddress, gateway, netmask and DNS settings are ignored.</th><th>required</th></tr>
    217      *       <tr class="odd"><th>wired.ipAddress</th><th>String</th><th>IP address assigned to the wired network interface. </th><th>required</th></tr>
    218      *       <tr><th>wired.netmask</th><th>String</th><th>Netmask assigned to the wired network interface. </th><th>required</th></tr>
    219      *       <tr class="odd"><th>wired.gateway</th><th>String</th><th>Gateway address assigned to the wired network interface</th><th>required</th></tr>
    220      *       <tr><th>wired.dns1</th><th>String</th><th>DNS address assigned to the wired network interface. </th><th>required</th></tr>
    221      *       <tr class="odd"><th>wired.dns2</th><th>String</th><th>Secondary DNS address assigned to the wired network interface. </th><th>required</th></tr>
    222      *       <tr><th>wifi</th><th>Object</th><th>Wireless network information object. </th><th>required</th></tr>
    223      *       <tr class="odd"><th>wifi.method</th><th>String</th><th>IP allocation "manual": fixed allocation "dhcp": dynamic allocation, If DHCP is enabled then ipAddress, gateway, netmask and DNS settings are ignored.</th><th>required</th></tr>
    224      *       <tr><th>wifi.enabled</th><th>Boolean</th><th>Wireless network connection true : enabled false : disabled </th><th>required</th></tr>
    225      *       <tr class="odd"><th>wifi.ipAddress</th><th>String</th><th>IP address assigned to the wireless network interface. </th><th>required</th></tr>
    226      *       <tr><th>wifi.netmask</th><th>String</th><th>Netmask assigned to the wireless network interface. </th><th>required</th></tr>
    227      *       <tr class="odd"><th>wifi.gateway</th><th>String</th><th>Gateway address assigned to the wireless network interface</th><th>required</th></tr>
    228      *       <tr><th>wifi.dns1</th><th>String</th><th>DNS address assigned to the wireless network interface. </th><th>required</th></tr>
    229      *       <tr class="odd"><th>wifi.dns2</th><th>String</th><th>Secondary DNS address assigned to the wireless network interface. </th><th>required</th></tr>
    230      *   </tbody>
    231      * </table>
    232      * </div>
    233      *
    234      * @example
    235      * // Javascript code
    236      * function setNetworkInformation () {
    237      *   function successCb() {
    238      *      console.log("successCb");
    239      *   }
    240      *
    241      *   function failureCb(cbObject) {
    242      *      var errorCode = cbObject.errorCode;
    243      *      var errorText = cbObject.errorText;
    244      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    245      *   }
    246      *
    247      *   var deviceInfo = new DeviceInfo();
    248      *   var wired = {
    249      *      enabled : true,
    250      *      method : "manual",
    251      *      ipAddress : "192.168.0.2",
    252      *      netmask : "255.255.255.0",
    253      *      gateway : "192.168.0.1",
    254      *      dns1 : "156.147.135.180",
    255      *      dns2 : "156.147.135.181"
    256      *   };
    257      *   var wifi = {
    258      *      enabled : true,
    259      *      method : "manual",
    260      *      ipAddress : "192.168.0.2",
    261      *      netmask : "255.255.255.0",
    262      *      gateway : "192.168.0.1",
    263      *      dns1 : "156.147.135.180",
    264      *      dns2 : "156.147.135.181"
    265      *   };
    266      *   var options = {
    267      *      wired : wired,
    268      *      wifi : wifi
    269      *   };
    270      *   deviceInfo.setNetworkInfo(successCb, failureCb, options);
    271      * }
    272      * @since 1.3
    273      * @see
    274      * <a href="DeviceInfo%23getNetworkInfo.html">DeviceInfo.getNetworkInfo()</a><br>
    275      */
    276     DeviceInfo.prototype.setNetworkInfo = function (successCallback, errorCallback, options) {
    277
    278         log("setNetworkInfo: ");
    279
    280         service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    281             method: 'setNetworkInfo',
    282             parameters: options,
    283             onSuccess: function(result) {
    284                 log("setNetworkInfo: onSuccess");
    285                 if (typeof successCallback === 'function') {
    286                     successCallback();
    287                 }
    288             },
    289             onFailure: function(error) {
    290                 log("setNetworkInfo: onFailure");
    291                 delete error.returnValue;
    292                 if (typeof errorCallback === 'function') {
    293                     errorCallback(error);
    294                 }
    295             }
    296         });
    297
    298         log("DeviceInfo.setNetworkInfo Done");
    299     };
    300
    301     /**
    302      * Gets beacon information.
    303      * @class DeviceInfo
    304      * @param {Function} successCallback success callback function.
    305      * @param {Function} errorCallback failure callback function.
    306      * @return {Object}
    307      * <div align=left>
    308      * <table class="hcap_spec" width=400>
    309      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    310      *   <tbody>
    311      *       <tr><th>enabled</th><th>Boolean</th><th>Beacon is enabled true: enabled, false: disabled</th><th>required</th></tr>
    312      *       <tr class="odd"><th>uuid</th><th>String</th><th>UUID of beacon, 32 hexadecimal digits. Only valid when 'enabled' is true.</th><th>required</th></tr>
    313      *       <tr><th>major</th><th>Number</th><th>Major number of beacon.(0 ~ 65535) Only valid when 'enabled' is true.</th><th>required</th></tr>
    314      *       <tr class="odd"><th>minor</th><th>Number</th><th>Minor number of beacon.(0 ~ 65535) Only valid when 'enabled' is true.</th><th>required</th></tr>
    315      *   </tbody>
    316      * </table>
    317      * </div>
    318      *
    319      * @example
    320      * // Javascript code
    321      * function getBeaconInfo () {
    322      *   function successCb(cbObject) {
    323      *      console.log("cbObject : " + JSON.stringify(cbObject));
    324      *      console.log("enabled : " + cbObject.enabled);
    325      *      console.log("uuid : " + cbObject.uuid);
    326      *      console.log("major : " + cbObject.major);
    327      *      console.log("minor : " + cbObject.minor);
    328      *   }
    329      *
    330      *   function failureCb(cbObject) {
    331      *      var errorCode = cbObject.errorCode;
    332      *      var errorText = cbObject.errorText;
    333      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    334      *   }
    335      *
    336      *   var deviceInfo = new DeviceInfo();
    337      *   deviceInfo.getBeaconInfo(successCb, failureCb);
    338      * }
    339      *
    340      * @since 1.3
    341      * @see
    342      * <a href="DeviceInfo%23setBeaconInfo.html">DeviceInfo.setBeaconInfo()</a><br>,
    343      */
    344     DeviceInfo.prototype.getBeaconInfo = function (successCallback, errorCallback) {
    345
    346         log("getBeaconInfo: ");
    347
    348         service.Request("luna://com.webos.service.commercial.signage.storageservice/network/", {
    349             method: 'getBeaconInfo',
    350             parameters: {},
    351             onSuccess: function(result) {
    352                 log("getBeaconInfo: onSuccess");
    353                 delete result.returnValue;
    354                 if (typeof successCallback === 'function') {
    355                     successCallback(result);
    356                 }
    357             },
    358             onFailure: function(error) {
    359                 log("getBeaconInfo: onFailure");
    360                 delete error.returnValue;
    361                 if (typeof errorCallback === 'function') {
    362                     errorCallback(error);
    363                 }
    364             }
    365         });
    366
    367         log("DeviceInfo.getBeaconInfo Done");
    368     };
    369
    370
    371     /**
    372      * Sets beacon information.
    373      * @class DeviceInfo
    374      * @param {Function} successCallback success callback function.
    375      * @param {Function} errorCallback failure callback function.
    376      * @param {Object} options
    377      * <div align=left>
    378      * <table class="hcap_spec" width=400>
    379      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    380      *   <tbody>
    381      *       <tr><th>enabled</th><th>Boolean</th><th>Beacon is enabled true: enabled, false: disabled</th><th>required</th></tr>
    382      *       <tr class="odd"><th>uuid</th><th>String</th><th>UUID of beacon, 32 hexadecimal digits. Only valid when 'enabled' is true.</th><th>required</th></tr>
    383      *       <tr><th>major</th><th>Number</th><th>Major number of beacon.(0 ~ 65535) Only valid when 'enabled' is true.</th><th>required</th></tr>
    384      *       <tr class="odd"><th>minor</th><th>Number</th><th>Minor number of beacon.(0 ~ 65535) Only valid when 'enabled' is true.</th><th>required</th></tr>
    385      * </table>
    386      * </div>
    387      *
    388      * @example
    389      * // Javascript code
    390      * function setBeaconInfo () {
    391      *   function successCb() {
    392      *      console.log("successCb");
    393      *   }
    394      *
    395      *   function failureCb(cbObject) {
    396      *      var errorCode = cbObject.errorCode;
    397      *      var errorText = cbObject.errorText;
    398      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    399      *   }
    400      *
    401      *   var deviceInfo = new DeviceInfo();
    402      *
    403      *   var options = {
    404      *      enabled : true,
    405      *      uuid : "1A2B3C4D5E1A2B3C4D5E1A2B3C4D5EFF",
    406      *      major :1234,
    407      *      minor :4321
    408      *   };
    409      *
    410      *   deviceInfo.setBeaconInfo(successCb, failureCb, options);
    411      * }
    412      * @since 1.3
    413      * @see
    414      * <a href="DeviceInfo%23getBeaconInfo.html">DeviceInfo.getBeaconInfo()</a><br>
    415      */
    416     DeviceInfo.prototype.setBeaconInfo = function (successCallback, errorCallback, options) {
    417
    418         log("setBeaconInfo: ");
    419
    420         var regex = function(uuid) {
    421
    422             if (typeof uuid === "undefined" || uuid === null || uuid.length != 32) {
    423                 return false;
    424             }
    425
    426             var reg = new RegExp(/^[a-fA-F0-9]*$/g);
    427             return reg.exec(uuid) !== null ? true : false;
    428
    429         };
    430
    431         if (options.enabled === true && (regex(options.uuid) === false ||
    432             isNaN(options.major) || options.major < 0 || options.major > 65535 ||
    433             isNaN(options.minor) || options.minor < 0 || options.minor > 65535) ){
    434
    435             log("setBeaconInfo: options are invalid.");
    436
    437             if (typeof errorCallback === 'function') {
    438                 var result = {};
    439                 checkErrorCodeNText(result, "DSBI", "DeviceInfo.setBeaconInfo. Invalid options.");
    440                 errorCallback(result);
    441             }
    442
    443             return;
    444         }
    445
    446         service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    447             method: 'setBeaconInfo',
    448             parameters: options,
    449             onSuccess: function(result) {
    450                 log("setBeaconInfo: onSuccess");
    451                 if (typeof successCallback === 'function') {
    452                     successCallback();
    453                 }
    454             },
    455             onFailure: function(error) {
    456                 log("setBeaconInfo: onFailure");
    457                 delete error.returnValue;
    458                 if (typeof errorCallback === 'function') {
    459                     errorCallback(error);
    460                 }
    461             }
    462         });
    463
    464         log("DeviceInfo.setBeaconInfo Done");
    465     };
    466
    467     /**
    468      * Gets Soft AP information.
    469      * @class DeviceInfo
    470      * @param {Function} successCallback success callback function.
    471      * @param {Function} errorCallback failure callback function.
    472      * @return {Object}
    473      * <div align=left>
    474      * <table class="hcap_spec" width=400>
    475      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
    476      *   <tbody>
    477      *       <tr><th>enabled</th><th>Boolean</th><th>Soft AP is enabled true: enabled, false: disabled</th></tr>
    478      *       <tr class="odd"><th>ssid</th><th>String</th><th>SSID of Soft AP (Maximum length is 32). Only valid when 'enabled' is true.</th></tr>
    479      *       <tr><th>securityKey</th><th>String</th><th>Security key(6 characters). It is automatically prefixed with "LG". Only valid when 'enabled' is true.</th></tr>
    480      *   </tbody>
    481      * </table>
    482      * </div>
    483      *
    484      * @example
    485      * // Javascript code
    486      * function getSoftApInfo () {
    487      *   function successCb(cbObject) {
    488      *      console.log("cbObject : " + JSON.stringify(cbObject));
    489      *      console.log("enabled : " + cbObject.enabled);
    490      *      console.log("ssid : " + cbObject.ssid);
    491      *      console.log("securityKey : " + cbObject.securityKey);
    492      *   }
    493      *
    494      *   function failureCb(cbObject) {
    495      *      var errorCode = cbObject.errorCode;
    496      *      var errorText = cbObject.errorText;
    497      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    498      *   }
    499      *
    500      *   var deviceInfo = new DeviceInfo();
    501      *   deviceInfo.getSoftApInfo(successCb, failureCb);
    502      * }
    503      *
    504      * @since 1.3
    505      * @see
    506      * <a href="DeviceInfo%23setSoftApInfo.html">DeviceInfo.setSoftApInfo()</a><br>,
    507      */
    508     DeviceInfo.prototype.getSoftApInfo = function (successCallback, errorCallback) {
    509
    510         log("getSoftApInfo: ");
    511
    512         service.Request("luna://com.webos.service.commercial.signage.storageservice/network/", {
    513             method: 'getSoftApInfo',
    514             parameters: {},
    515             onSuccess: function(result) {
    516                 log("getSoftApInfo: onSuccess");
    517                 delete result.returnValue;
    518                 if (typeof successCallback === 'function') {
    519                     successCallback(result);
    520                 }
    521             },
    522             onFailure: function(error) {
    523                 log("getSoftApInfo: onFailure");
    524                 delete error.returnValue;
    525                 if (typeof errorCallback === 'function') {
    526                     errorCallback(error);
    527                 }
    528             }
    529         });
    530
    531         log("DeviceInfo.getSoftApInfo Done");
    532     };
    533
    534     /**
    535      * Sets Soft AP information.
    536      * @class DeviceInfo
    537      * @param {Function} successCallback success callback function.
    538      * @param {Function} errorCallback failure callback function.
    539      * @param {Object} options
    540      * <div align=left>
    541      * <table class="hcap_spec" width=400>
    542      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    543      *   <tbody>
    544      *       <tr><th>enabled</th><th>Boolean</th><th>Soft AP is enabled true: enabled, false: disabled</th><th>required</th></tr>
    545      *       <tr class="odd"><th>ssid</th><th>String</th><th>SSID of Soft AP (Maximum length is 32). Only valid when 'enabled' is true.</th><th>required</th></tr>
    546      *       <tr><th>securityKey</th><th>String</th><th>Security key(6 characters). It is automatically prefixed with "LG". Only valid when 'enabled' is true.</th><th>required</th></tr>
    547      *   </tbody>
    548      * </table>
    549      * </div>
    550      *
    551      * @example
    552      * // Javascript code
    553      * function setSoftApInfo () {
    554      *   function successCb(cbObject) {
    555      *      console.log("cbObject : " + JSON.stringify(cbObject));
    556      *      console.log("enabled : " + cbObject.enabled);
    557      *      console.log("ssid : " + cbObject.ssid);
    558      *      console.log("securityKey : " + cbObject.securityKey);
    559      *   }
    560      *
    561      *   function failureCb(cbObject) {
    562      *      var errorCode = cbObject.errorCode;
    563      *      var errorText = cbObject.errorText;
    564      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    565      *   }
    566      *
    567      *   var deviceInfo = new DeviceInfo();
    568      *
    569      *   var options = {
    570      *      enabled : true,
    571      *      ssid : "LG SIGNAGE",
    572      *      securityKey : "404571"
    573      *   };
    574      *
    575      *   deviceInfo.setSoftApInfo(successCb, failureCb, options);
    576      * }
    577      *
    578      * @since 1.3
    579      * @see
    580      * <a href="DeviceInfo%23getSoftApInfo.html">DeviceInfo.getSoftApInfo()</a><br>,
    581      */
    582     DeviceInfo.prototype.setSoftApInfo = function (successCallback, errorCallback, options) {
    583
    584         log("setSoftApInfo: ");
    585
    586         if (options.enabled === true && ( // Add condition
    587             (options.ssid !== null && options.ssid.length > 32) ||
    588             (options.securityKey !== null && options.securityKey.length !== 6))) {
    589
    590             log("setSoftApInfo: options are invalid.");
    591
    592             if (typeof errorCallback === 'function') {
    593                 var result = {};
    594                 checkErrorCodeNText(result, "DSSI", "DeviceInfo.setSoftApInfo. Invalid options.");
    595                 errorCallback(result);
    596             }
    597
    598             return;
    599         }
    600
    601
    602         service.Request("luna://com.webos.service.commercial.signage.storageservice/network/", {
    603             method: 'setSoftApInfo',
    604             parameters: options,
    605             onSuccess: function(result) {
    606                 log("setSoftApInfo: onSuccess");
    607                 if (typeof successCallback === 'function') {
    608                     successCallback();
    609                 }
    610             },
    611             onFailure: function(error) {
    612                 log("setSoftApInfo: onFailure");
    613                 delete error.returnValue;
    614                 if (typeof errorCallback === 'function') {
    615                     errorCallback(error);
    616                 }
    617             }
    618         });
    619
    620         log("DeviceInfo.setSoftApInfo Done");
    621     };
    622
    623     /**
    624      * Gets list of detected wifi networks.
    625      * @class DeviceInfo
    626      * @param {Function} successCallback success callback function.
    627      * @param {Function} errorCallback failure callback function.
    628      * @return {Object}
    629      * <div align=left>
    630      * <table class="hcap_spec" width=400>
    631      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
    632      *   <tbody>
    633      *       <tr><th>networkInfo</th><th>Array</th><th>Array of Wifi network information objects</th></tr>
    634      *       <tr class="odd"><th>networkInfo.signalLevel</th><th>Number</th><th>Signal level (0 ~ 100)</th></tr>
    635      *       <tr><th>networkInfo.ssid</th><th>String</th><th>SSID</th></tr>
    636      *   </tbody>
    637      * </table>
    638      * </div>
    639      *
    640      * @example
    641      * // Javascript code
    642      * function getWifiList () {
    643      *   function successCb(cbObject) {
    644      *
    645      *      console.log("cbObject : " + JSON.stringify(cbObject));
    646      *
    647      *      for(var i=0; i < cbObject.networkInfo.length; i++) {
    648      *          console.log("network info : ssid " + cbObject.networkInfo[i].ssid);
    649      *          console.log("network info : signalLevel " + cbObject.networkInfo[i].signalLevel);
    650      *      }
    651      *   }
    652      *
    653      *   function failureCb(cbObject) {
    654      *      var errorCode = cbObject.errorCode;
    655      *      var errorText = cbObject.errorText;
    656      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    657      *   }
    658      *
    659      *   var deviceInfo = new DeviceInfo();
    660      *   deviceInfo.getWifiList(successCb, failureCb);
    661      * }
    662      * @since 1.3
    663      * @see
    664      * <a href="DeviceInfo%23connectWifi.html">DeviceInfo.connectWifi()</a><br>
    665      */
    666     DeviceInfo.prototype.getWifiList = function (successCallback, errorCallback) {
    667
    668         log("getWifiList: ");
    669
    670         service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    671             method: 'getWifiList',
    672             parameters: {},
    673             onSuccess: function(result) {
    674                 log("getWifiList: onSuccess");
    675                 delete result.returnValue;
    676                 if (typeof successCallback === 'function') {
    677                     successCallback(result);
    678                 }
    679             },
    680             onFailure: function(error) {
    681                 log("getWifiList: onFailure");
    682                 delete error.returnValue;
    683                 if (typeof errorCallback === 'function') {
    684                     errorCallback(error);
    685                 }
    686             }
    687         });
    688
    689         log("DeviceInfo.getWifiList Done");
    690     };
    691
    692     /**
    693      * Connects wifi network using SSID and password.
    694      * @class DeviceInfo
    695      * @param {Function} successCallback success callback function.
    696      * @param {Function} errorCallback failure callback function.
    697      * @param {Object} options
    698      * <div align=left>
    699      * <table class="hcap_spec" width=400>
    700      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    701      *   <tbody>
    702      *       <tr><th>ssid</th><th>String</th><th>SSID (Maximum length is 32)</th><th>required</th></tr>
    703      *       <tr class="odd"><th>password</th><th>String</th><th>password</th><th>required</th></tr>
    704      *       <tr><th>hidden</th><th>Boolean</th><th>true : hidden AP. false : open AP(default)</th><th>optional</th></tr>
    705      *   </tbody>
    706      * </table>
    707      * </div>
    708      *
    709      * @example
    710      * // Javascript code
    711      * function connectWifi () {
    712      *   function successCb() {
    713      *      console.log("successCb");
    714      *   }
    715      *
    716      *   function failureCb(cbObject) {
    717      *      var errorCode = cbObject.errorCode;
    718      *      var errorText = cbObject.errorText;
    719      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    720      *   }
    721      *
    722      *   var deviceInfo = new DeviceInfo();
    723      *
    724      *   var options = {
    725      *      ssid : "AP_NAME",
    726      *      password : "12341234"
    727      *   };
    728      *
    729      *   deviceInfo.connectWifi(successCb, failureCb, options);
    730      * }
    731      * @since 1.3
    732      * @see
    733      * <a href="DeviceInfo%23getWifiList.html">DeviceInfo.getWifiList()</a><br>
    734      */
    735     DeviceInfo.prototype.connectWifi = function (successCallback, errorCallback, options) {
    736
    737         log("connectWifi: ");
    738
    739         service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    740             method: 'connectWifi',
    741             parameters: options,
    742             onSuccess: function(result) {
    743                 log("connectWifi: onSuccess");
    744                 if (typeof successCallback === 'function') {
    745                     successCallback();
    746                 }
    747             },
    748             onFailure: function(error) {
    749                 log("connectWifi: onFailure");
    750                 delete error.returnValue;
    751                 if (typeof errorCallback === 'function') {
    752                     errorCallback(error);
    753                 }
    754             }
    755         });
    756
    757         log("DeviceInfo.connectWifi Done");
    758     };
    759
    760     /**
    761      * Starts WPS (Wifi Protected Setup) using PBC (Push Button Configuration) or PIN.
    762      * @class DeviceInfo
    763      * @param {Function} successCallback success callback function.
    764      * @param {Function} errorCallback failure callback function.
    765      * @param {Object} options
    766      * <div align=left>
    767      * <table class="hcap_spec" width=400>
    768      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    769      *   <tbody>
    770      *       <tr><th>method</th><th>String</th><th>PBC : Push WPS button on your wireless router after the call with this parameter.<br>PIN : Enter the PIN which is returned with the success callback in your router's setting menu.</th><th>required</th></tr>
    771      *   </tbody>
    772      * </table>
    773      * </div>
    774      * @return {Object}
    775      * <div align=left>
    776      * <table class="hcap_spec" width=400>
    777      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
    778      *   <tbody>
    779      *       <tr><th>pin</th><th>String</th><th>If PIN method is used, this is returned in success callback. </th></tr>
    780      *   </tbody>
    781      * </table>
    782      * </div>
    783      *
    784      * @example
    785      * // Javascript code
    786      * function startWpsbyPBC () {
    787      *   function successCb() {
    788      *      console.log("successCb");
    789      *   }
    790      *
    791      *   function failureCb(cbObject) {
    792      *      var errorCode = cbObject.errorCode;
    793      *      var errorText = cbObject.errorText;
    794      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    795      *   }
    796      *
    797      *   var deviceInfo = new DeviceInfo();
    798      *
    799      *   var options = {
    800      *   	method : "PBC"
    801      *   };
    802      *
    803      *   deviceInfo.startWps(successCb, failureCb, options);
    804      * }
    805      *
    806      * // Javascript code
    807      * function startWpsbyPIN () {
    808      *   function successCb(cbObject) {
    809      *      console.log("successCb PIN : " + cbObject.pin);
    810      *   }
    811      *
    812      *   function failureCb(cbObject) {
    813      *      var errorCode = cbObject.errorCode;
    814      *      var errorText = cbObject.errorText;
    815      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    816      *   }
    817      *
    818      *   var deviceInfo = new DeviceInfo();
    819      *
    820      *   var options = {
    821      *   	method : "PIN"
    822      *   };
    823      *
    824      *   deviceInfo.startWps(successCb, failureCb, options);
    825      * }
    826      * @since 1.3
    827      * @see
    828      * <a href="DeviceInfo%23stopWps.html">DeviceInfo.stopWps()</a><br>
    829      */
    830     DeviceInfo.prototype.startWps = function (successCallback, errorCallback, options) {
    831
    832         log("startWps: ");
    833
    834         service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    835             method: 'startWps',
    836             parameters: options,
    837             onSuccess: function(result) {
    838                 log("startWps: onSuccess");
    839                 delete result.returnValue;
    840                 if (typeof successCallback === 'function') {
    841                     successCallback(result);
    842                 }
    843             },
    844             onFailure: function(error) {
    845                 log("startWps: onFailure");
    846                 delete error.returnValue;
    847                 if (typeof errorCallback === 'function') {
    848                     errorCallback(error);
    849                 }
    850             }
    851         });
    852
    853         log("DeviceInfo.startWps Done");
    854     };
    855
    856     /**
    857      * Stops WPS (Wifi Protected Setup) operation.
    858      * @class DeviceInfo
    859      * @param {Function} successCallback success callback function.
    860      * @param {Function} errorCallback failure callback function.
    861      *
    862      * @example
    863      * // Javascript code
    864      * function stopWps () {
    865      *   function successCb() {
    866      *      console.log("successCb");
    867      *   }
    868      *
    869      *   function failureCb(cbObject) {
    870      *      var errorCode = cbObject.errorCode;
    871      *      var errorText = cbObject.errorText;
    872      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    873      *   }
    874      *
    875      *   var deviceInfo = new DeviceInfo();
    876      *
    877      *   deviceInfo.stopWps(successCb, failureCb);
    878      * }
    879      * @since 1.3
    880      * @see
    881      * <a href="DeviceInfo%23startWps.html">DeviceInfo.startWps()</a><br>
    882      */
    883     DeviceInfo.prototype.stopWps = function (successCallback, errorCallback) {
    884
    885         log("stopWps: ");
    886
    887         service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    888             method: 'stopWps',
    889             parameters: {},
    890             onSuccess: function(result) {
    891                 log("stopWps: onSuccess");
    892                 if (typeof successCallback === 'function') {
    893                     successCallback();
    894                 }
    895             },
    896             onFailure: function(error) {
    897                 log("stopWPS: onFailure");
    898                 delete error.returnValue;
    899                 if (typeof errorCallback === 'function') {
    900                     errorCallback(error);
    901                 }
    902             }
    903         });
    904
    905         log("DeviceInfo.stopWps Done");
    906     };
    907
    908     /**
    909      * Gets network MAC information.
    910      * @class DeviceInfo
    911      * @param {Function} successCallback success callback function.
    912      * @param {Function} errorCallback failure callback function.
    913      * @return {Object}
    914      * <div align=left>
    915      * <table class="hcap_spec" width=400>
    916      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
    917      *   <tbody>
    918      *       <tr><th>wiredInfo</th><th>Object</th><th>An object that has MAC address of the wired network interface. </th></tr>
    919      *       <tr class="odd"><th>wiredInfo.macAddress</th><th>String</th><th>MAC address of the wired network interface. </th></tr>
    920      *       <tr><th>wifiInfo</th><th>Object</th><th>An object that has MAC address of the wireless network interface. </th></tr>
    921      *       <tr class="odd"><th>wifiInfo.macAddress</th><th>String</th><th>MAC address of the wireless network interface. </th></tr>
    922      *   </tbody>
    923      * </table>
    924      * </div>
    925      *
    926      * @example
    927      * // Javascript code
    928      * function getNetworkMacInformation () {
    929      *   function successCb(cbObject) {
    930      *      console.log("cbObject : " + JSON.stringify(cbObject));
    931      *      console.log("wiredInfo.macAddress : " + cbObject.wiredInfo.macAddress);
    932      *      console.log("wifiInfo.macAddress : " + cbObject.wifiInfo.macAddress);
    933      *
    934      *      // Do something
    935      *         ...
    936      *   }
    937      *
    938      *   function failureCb(cbObject) {
    939      *      var errorCode = cbObject.errorCode;
    940      *      var errorText = cbObject.errorText;
    941      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    942      *   }
    943      *
    944      *   var deviceInfo = new DeviceInfo();
    945      *   deviceInfo.getNetworkMacInfo(successCb, failureCb);
    946      * }
    947      * @since 1.0
    948      * @see
    949      * <a href="DeviceInfo%23getNetworkInfo.html">DeviceInfo.getNetworkInfo()</a><br>
    950      */
    951     DeviceInfo.prototype.getNetworkMacInfo = function (successCallback, errorCallback) {
    952
    953         log("getNetworkMacInfo: ");
    954
    955         service.Request('luna://com.webos.service.tv.signage', {
    956             method: 'getinfo',
    957             parameters: {},
    958             onSuccess: function(result) {
    959                 log("getNetworkMacInfo: onSuccess");
    960                 delete result.returnValue;
    961                 if (typeof successCallback === 'function') {
    962                     successCallback(result);
    963                 }
    964             },
    965             onFailure: function(error) {
    966                 log("getNetworkMacInfo: onFailure");
    967                 delete error.returnValue;
    968                 if (typeof errorCallback === 'function') {
    969                     errorCallback(error);
    970                 }
    971             }
    972         });
    973
    974         log("DeviceInfo.getNetworkMacInfo Done");
    975     };
    976
    977     /**
    978      * Gets device platform information. Platform information includes manufacturer, model name, software version, hardware version and product serial number.
    979      * @class DeviceInfo
    980      * @param {Function} successCallback success callback function.
    981      * @param {Function} errorCallback failure callback function.
    982      * @return {Object}
    983      * <div align=left>
    984      * <table class="hcap_spec" width=400>
    985      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
    986      *   <tbody>
    987      *       <tr><th>hardwareVersion</th><th>String</th><th>hardware version of signage monitor. </th></tr>
    988      *       <tr class="odd"><th>manufacturer</th><th>String</th><th>manufacturer of signage monitor. </th></tr>
    989      *       <tr><th>modelName</th><th>String</th><th>signage monitor model name. </th></tr>
    990      *       <tr class="odd"><th>sdkVersion</th><th>String</th><th>SDK version of signage monitor. </th></tr>
    991      *       <tr><th>serialNumber</th><th>String</th><th>signage monitor serial number. </th></tr>
    992      *       <tr class="odd"><th>firmwareVersion</th><th>String</th><th>firmware version of signage monitor. </th></tr>
    993      *   </tbody>
    994      * </table>
    995      * </div>
    996      *
    997      * @example
    998      * // Javascript code
    999      * function getPlatformInfo () {
    1000      *   function successCb(cbObject) {
    1001      *      console.log("cbObject : " + JSON.stringify(cbObject));
    1002      *      console.log("hardwareVersion : " + cbObject.hardwareVersion);
    1003      *      console.log("modelName : " + cbObject.modelName);
    1004      *      console.log("sdkVersion : " + cbObject.sdkVersion);
    1005      *      console.log("serialNumber : " + cbObject.serialNumber);
    1006      *      console.log("firmwareVersion : " + cbObject.firmwareVersion);
    1007      *
    1008      *      // Do something
    1009      *         ...
    1010      *   }
    1011      *
    1012      *   function failureCb(cbObject) {
    1013      *      var errorCode = cbObject.errorCode;
    1014      *      var errorText = cbObject.errorText;
    1015      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    1016      *   }
    1017      *
    1018      *   var deviceInfo = new DeviceInfo();
    1019      *   deviceInfo.getPlatformInfo(successCb, failureCb);
    1020      * }
    1021      * @since 1.0
    1022      * @see
    1023      * <a href="DeviceInfo%23getNetworkMacInfo.html">DeviceInfo.getNetworkMacInfo()</a><br>
    1024      */
    1025     DeviceInfo.prototype.getPlatformInfo = function (successCallback, errorCallback) {
    1026
    1027         log("getPlatformInfo: ");
    1028
    1029         service.Request('luna://com.webos.service.tv.systemproperty', {
    1030             method: 'getSystemInfo',
    1031             parameters: {
    1032                 keys: ["modelName", "serialNumber", "firmwareVersion", "hardwareVersion", "sdkVersion"]
    1033             },
    1034             onSuccess: function(result) {
    1035                 log("getPlatformInfo: onSuccess");
    1036                 result.manufacturer = "LGE";
    1037                 result.sdkVersion = "";
    1038                 delete result.returnValue;
    1039                 if (typeof successCallback === 'function') {
    1040                     successCallback(result);
    1041                 }
    1042             },
    1043             onFailure: function(error) {
    1044                 log("getPlatformInfo: onFailure");
    1045                 delete error.returnValue;
    1046                 if (typeof errorCallback === 'function') {
    1047                     errorCallback(error);
    1048                 }
    1049             }
    1050         });
    1051
    1052         log("DeviceInfo.getPlatformInfo Done");
    1053     };
    1054
    1055     /**
    1056      * Gets device usage information. Usage information includes cpu and memory status.
    1057      * @class DeviceInfo
    1058      * @param {Function} successCallback success callback function.
    1059      * @param {Function} errorCallback failure callback function.
    1060      * @param {Object} options
    1061      * <div align=left>
    1062      * <table class="hcap_spec" width=400>
    1063      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    1064      *   <tbody>
    1065      *       <tr><th>cpus</th><th>Boolean</th><th>true to get CPU information, false otherwise.</th><th>optional</th></tr>
    1066      *       <tr class="odd"><th>memory</th><th>Boolean</th><th>true to get memory information, false otherwise.</th><th>optional</th></tr>
    1067      *   </tbody>
    1068      * </table>
    1069      * </div>
    1070      * @return {Object}
    1071      * <div align=left>
    1072      * <table class="hcap_spec" width=400>
    1073      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Available</th></tr></thead>
    1074      *   <tbody>
    1075      *       <tr><th>cpus</th><th>Array</th><th>Array of objects containing information about each CPU/core installed: model, and times <br>(an object containing the number of milliseconds the CPU/core spent in: user, nice, sys, idle, and irq).</th><th>optional</th></tr>
    1076      *       <tr class="odd"><tr><th>memory</th><th>Object</th><th>Object containing total and free member fields. <br>'total' is total amount of system memory in bytes and 'free' is amount of free memory in bytes.</th><th>optional</th></tr>
    1077      *   </tbody>
    1078      * </table>
    1079      * </div>
    1080      *
    1081      * @example
    1082      * // Javascript code
    1083      * function getSystemUsageInfo() {
    1084      *   function successCb(cbObject) {
    1085      *      console.log("cbObject : " + JSON.stringify(cbObject));
    1086      *      console.log("memory.total : " + cbObject.memory.total);
    1087      *      console.log("memory.free : " + cbObject.memory.free);
    1088      *
    1089      *      for (var i in cbObject.cpus) {
    1090      *         console.log("cpu.model " +  cbObject.cpus[i].model);
    1091      *         console.log("cpu.times.user " +  cbObject.cpus[i].times.user);
    1092      *         console.log("cpu.times.nice " +  cbObject.cpus[i].times.nice);
    1093      *         console.log("cpu.times.sys " +  cbObject.cpus[i].times.sys);
    1094      *         console.log("cpu.times.idle " +  cbObject.cpus[i].times.idle);
    1095      *         console.log("cpu.times.irq " +  cbObject.cpus[i].times.irq);
    1096      *      }
    1097      *      // Do something
    1098      *   }
    1099      *
    1100      *   function failureCb(cbObject) {
    1101      *      var errorCode = cbObject.errorCode;
    1102      *      var errorText = cbObject.errorText;
    1103      *      console.log ("Error Code [" + errorCode + "]: " + errorText);
    1104      *   }
    1105      *
    1106      *   var deviceInfo = new DeviceInfo();
    1107      *   var options = {cpus : true, memory : true};
    1108      *   deviceInfo.getSystemUsageInfo(successCb, failureCb, options);
    1109      * }
    1110      * @since 1.2
    1111      * @see
    1112      * <a href="DeviceInfo%23getPlatformInfo.html">DeviceInfo.getPlatformInfo()</a><br>
    1113      */
    1114     DeviceInfo.prototype.getSystemUsageInfo = function (successCallback, errorCallback, options) {
    1115
    1116         log("getSystemUsageInfo: ");
    1117
    1118         service.Request("luna://com.webos.service.commercial.signage.storageservice", {
    1119             method : "getSystemUsageInfo",
    1120             parameters : {
    1121                 cpus : options.cpus,
    1122                 memory : options.memory
    1123             },
    1124             onSuccess : function(result) {
    1125                 if (result.returnValue === true) {
    1126                     var ret = {};
    1127                     if (typeof result.memory !== 'undefined' ) {
    1128                     	ret.memory = result.memory;
    1129                     }
    1130                     if (typeof result.cpus !== 'undefined' ) {
    1131                         ret.cpus = result.cpus;
    1132                     }
    1133                     if (typeof successCallback === 'function') {
    1134                         successCallback(ret);
    1135                     }
    1136                 } else {
    1137                     if (typeof errorCallback === 'function') {
    1138                         errorCallback({
    1139                             errorCode:result.errorCode,
    1140                             errorText:result.errorText
    1141                         });
    1142                     }
    1143                 }
    1144             },
    1145             onFailure : function (result) {
    1146                 if (typeof errorCallback === 'function') {
    1147                     errorCallback({
    1148                         errorCode:result.errorCode,
    1149                         errorText:result.errorText
    1150                     });
    1151                 }
    1152             }
    1153         });
    1154
    1155         log("DeviceInfo.getSystemUsageInfo Done");
    1156     };
    1157
    1158     /**
    1159      * Sets Proxy Info
    1160      * @class DeviceInfo
    1161      * @param {Function} successCallback success callback function.
    1162      * @param {Function} errorCallback failure callback function.
    1163      * @param {Object} options
    1164      * <div align=left>
    1165      * <table class="hcap_spec" width=400>
    1166      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    1167      *   <tbody>
    1168      *       <tr><th>enabled</th><th>Boolean</th><th>proxy is enabled true : enabled, false : disabled</th><th>required</th></tr>
    1169      *       <tr class="odd"><th>ipAddress</th><th>String</th><th>proxy server ip (when 'enabled' is true, it is required)</th><th>optional</th></tr>
    1170      *       <tr><th>port</th><th>Number</th><th>proxy server port (0 ~ 65535) (when 'enabled' is true, it is required)</th><th>optional</th></tr>
    1171      *       <tr class="odd"><th>userName</th><th>String</th><th>proxy server username (when 'enabled' is true and authentication is used by proxy server, it is required)</th><th>optional</th></tr>
    1172      *       <tr><th>password</th><th>String</th><th>proxy server password (when 'enabled' is true and authentication is used by proxy server, it is required)</th><th>optional</th></tr>
    1173      *   </tbody>
    1174      * </table>
    1175      * </div>
    1176      * @return <p>If the method is successfully executed, success callback function is called without a parameter.</br>
    1177      * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p>
    1178      *
    1179      * @example
    1180      * // Javascript code
    1181      * function setProxyInfo () {
    1182      *  var options = {
    1183      *     enabled : true,
    1184      *     ipAddress : "163.231.22.43",
    1185      *     port : 5000,
    1186      *     userName : "example",
    1187      *     password : "35792234",
    1188 	 *  };
    1189 	 *  function successCb() {
    1190 	 *     console.log("sucess");
    1191 	 *     // Do something
    1192 	 *  }
    1193 	 *  function failureCb(cbObject) {
    1194 	 *     var errorCode = cbObject.errorCode;
    1195 	 *     var errorText = cbObject.errorText;
    1196 	 *     console.log ("Error Code [" + errorCode + "]: " + errorText);
    1197 	 *  }
    1198 	 *  var deviceinfo = new DeviceInfo();
    1199 	 *  deviceinfo.setProxyInfo(successCb, failureCb, options);
    1200 	 * }
    1201      * @since 1.4
    1202      * @see
    1203      * <a href="DeviceInfo%23getProxyInfo.html">DeviceInfo.getProxyInfo()</a><br>
    1204      */
    1205     DeviceInfo.prototype.setProxyInfo = function(successCallback, errorCallback, options) {
    1206         var proxyInfo = {};
    1207
    1208         log("setProxyInfo: " + options.enabled);
    1209
    1210         if (typeof options.enabled !== 'boolean' && typeof errorCallback === 'function') {
    1211             var result = {};
    1212             checkErrorCodeNText(result, "DSPI", "DeviceInfo.setProxyInfo returns failure. enabled is not boolean.");
    1213             errorCallback(result);
    1214             return;
    1215         } else if (typeof options.ipAddress !== 'string' && typeof errorCallback === 'function') {
    1216             var result = {};
    1217             checkErrorCodeNText(result, "DSPI", "DeviceInfo.setProxyInfo returns failure. ipAddress is not string.");
    1218             errorCallback(result);
    1219             return;
    1220         } else if (typeof options.port !== 'number' && typeof errorCallback === 'function') {
    1221             var result = {};
    1222             checkErrorCodeNText(result, "DSPI", "DeviceInfo.setProxyInfo returns failure. port is not number.");
    1223             errorCallback(result);
    1224             return;
    1225         }
    1226
    1227         if (options.enabled == false) {
    1228             proxyInfo.proxyEnable = "off";
    1229         } else {
    1230             proxyInfo.proxyEnable = "on";
    1231
    1232             if ((options.ipAddress === null || options.ipAddress === undefined || options.ipAddress === "" ||
    1233                     options.port === null || options.port === undefined || isNaN(options.port)) && typeof errorCallback === 'function') {
    1234                 var result = {};
    1235                 checkErrorCodeNText(result, "DSPI", "DeviceInfo.setProxyInfo returns failure. ipAddress and port are required.");
    1236                 errorCallback(result);
    1237                 return;
    1238             } else {
    1239                 proxyInfo.proxySingleAddress = options.ipAddress;
    1240                 proxyInfo.proxySinglePort    = options.port.toString();
    1241             }
    1242         }
    1243
    1244         if (typeof options.userName === 'string' && options.userName !== undefined && options.userName !== null &&
    1245             typeof options.password === 'string' && options.password !== undefined && options.password !== null) {
    1246             proxyInfo.proxySingleUsername = options.userName;
    1247             proxyInfo.proxySinglePassword = options.password;
    1248         }
    1249
    1250         log("proxyInfo : " + JSON.stringify(proxyInfo));
    1251
    1252         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
    1253             method: "set",
    1254             parameters: {
    1255                 category: "commercial",
    1256                 settings: proxyInfo
    1257             },
    1258             onSuccess: function(result) {
    1259                 log("setProxyInfo: On Success");
    1260
    1261                 if (result.returnValue === true) {
    1262                     if (typeof successCallback === 'function') {
    1263                         successCallback();
    1264                     }
    1265                 }
    1266             },
    1267             onFailure: function(result) {
    1268                 log("setSoundOut: On Failure");
    1269                 delete result.returnValue;
    1270                 if (typeof errorCallback === 'function') {
    1271                     checkErrorCodeNText(result, "DSPI", "DeviceInfo.setProxyInfo returns failure.");
    1272                     errorCallback(result);
    1273                 }
    1274             }
    1275         });
    1276
    1277         log("DeviceInfo.setProxyInfo Done");
    1278     };
    1279
    1280 	/**
    1281      * Gets Proxy Info
    1282      * @class DeviceInfo
    1283      * @param {Function} successCallback success callback function.
    1284      * @param {Function} errorCallback failure callback function.
    1285      * @return {Object} options
    1286      * <div align=left>
    1287      * <table class="hcap_spec" width=400>
    1288      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
    1289      *   <tbody>
    1290      *       <tr><th>enabled</th><th>Boolean</th><th>proxy is enabled true : enabled, false : disabled</th></tr>
    1291      *       <tr class="odd"><th>ipAddress</th><th>String</th><th>proxy server ip (when 'enabled' is true, it is required)</th></tr>
    1292      *       <tr><th>port</th><th>Number</th><th>proxy server port (0 ~ 65535) (when 'enabled' is true, it is required)</th></tr>
    1293      *   </tbody>
    1294      * </table>
    1295      * </div>
    1296      *
    1297 	 * @example
    1298      * // Javascript code
    1299      * function getProxyInfo () {
    1300 	 *  function successCb(cbObject) {
    1301 	 *     console.log("cbObject : " + JSON.stringify(cbObject));
    1302 	 *     console.log("enabled : " + cbObject.enabled);
    1303 	 *     console.log("ipAddress : " + cbObject.ipAddress);
    1304 	 *     console.log("port : " + cbObject.port);
    1305 	 *  }
    1306 	 *  function failureCb(cbObject) {
    1307 	 *     var errorCode = cbObject.errorCode;
    1308 	 *     var errorText = cbObject.errorText;
    1309 	 *     console.log ("Error Code [" + errorCode + "]: " + errorText);
    1310 	 *  }
    1311 	 *  var deviceinfo = new DeviceInfo();
    1312 	 *  deviceinfo.getProxyInfo(successCb, failureCb);
    1313 	 * }
    1314      * @since 1.4
    1315      * @see
    1316      * <a href="DeviceInfo%23setProxyInfo.html">DeviceInfo.setProxyInfo()</a><br>
    1317      */
    1318     DeviceInfo.prototype.getProxyInfo = function (successCallback, errorCallback) {
    1319
    1320         log("getProxyInfo: ");
    1321
    1322         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
    1323             method: "get",
    1324             parameters: {
    1325                 category: "commercial",
    1326                 keys: ["proxyEnable", "proxySingleAddress", "proxySinglePort"]
    1327             },
    1328             onSuccess: function(result) {
    1329                 log("getProxyInfo: On Success");
    1330
    1331                 if (result.returnValue === true) {
    1332                     var cbObj       = {};
    1333                     cbObj.enabled   = (result.settings.proxyEnable === "on") ? true : false;
    1334                     cbObj.ipAddress = result.settings.proxySingleAddress;
    1335                     cbObj.port      = parseInt(result.settings.proxySinglePort);
    1336
    1337                     if (typeof successCallback === 'function') {
    1338                         successCallback(cbObj);
    1339                     }
    1340                 }
    1341             },
    1342             onFailure: function(result) {
    1343                 log("getProxyInfo: On Failure");
    1344                 delete result.returnValue;
    1345                 if (typeof errorCallback === 'function') {
    1346                     checkErrorCodeNText(result, "DGPI", "DeviceInfo.getProxyInfo returns failure.");
    1347                     errorCallback(result);
    1348                 }
    1349             }
    1350         });
    1351
    1352         log("DeviceInfo.getProxyInfo Done");
    1353     };
    1354
    1355 		/**
    1356      * Sets iBeacon Info
    1357      * @class DeviceInfo
    1358      * @param {Function} successCallback success callback function.
    1359      * @param {Function} errorCallback failure callback function.
    1360      * @param {Object} options
    1361      * <div align=left>
    1362      * <table class="hcap_spec" width=400>
    1363      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    1364      *   <tbody>
    1365      *       <tr><th>enabled</th><th>Boolean</th><th>iBeacon is enabled true : enabled, false : disabled</th><th>required</th></tr>
    1366      *       <tr class="odd"><th>uuid</th><th>String</th><th>UUID of iBeacon, 32 hexadecimal digits. (when 'enabled' is true, it is required)</th><th>optional</th></tr>
    1367      *       <tr><th>major</th><th>Number</th><th>major (0 ~ 65535) (when 'enabled' is true, it is required)</th><th>optional</th></tr>
    1368      *       <tr class="odd"><th>minor</th><th>Number</th><th>minor (0 ~ 65535) (when 'enabled' is true, it is required)</th><th>optional</th></tr>
    1369      *   </tbody>
    1370      * </table>
    1371      * </div>
    1372      * @return <p>If the method is successfully executed, success callback function is called without a parameter.</br>
    1373      * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p>
    1374      *
    1375      * @example
    1376      * // Javascript code
    1377      * function setiBeaconInfo () {
    1378      *  var options = {
    1379      *     enabled : true,
    1380      *     uuid : "f7826da64fa24e988024bc5b71e0893e",
    1381 	 *     major : 5000,
    1382 	 *     minor : 3000
    1383 	 *  };
    1384 	 *  function successCb(cbObject) {
    1385 	 *     console.log("sucess");
    1386 	 *     // Do something
    1387 	 *  }
    1388 	 *  function failureCb(cbObject) {
    1389 	 *     var errorCode = cbObject.errorCode;
    1390 	 *     var errorText = cbObject.errorText;
    1391 	 *     console.log ("Error Code [" + errorCode + "]: " + errorText);
    1392 	 *  }
    1393 	 *  var deviceinfo = new DeviceInfo();
    1394 	 *  deviceinfo.setiBeaconInfo(successCb, failureCb);
    1395 	 * }
    1396      * @since 1.4
    1397      * @see
    1398      * <a href="DeviceInfo%23getiBeaconInfo.html">DeviceInfo.getiBeaconInfo()</a><br>
    1399      */
    1400     DeviceInfo.prototype.setiBeaconInfo = function(successCallback, errorCallback, options) {
    1401         var regex = function(uuid) {
    1402             if (typeof uuid === "undefined" || uuid === null || uuid.length != 32) {
    1403                 return false;
    1404             }
    1405
    1406             var reg = new RegExp(/^[a-fA-F0-9]*$/g);
    1407             return reg.exec(uuid) !== null ? true : false;
    1408         };
    1409
    1410         var iBeaconInfo = {};
    1411
    1412         if ((options.enabled === null || options.enabled === undefined || typeof options.enabled !== 'boolean') && typeof errorCallback === 'function') {
    1413             var result = {};
    1414             checkErrorCodeNText(result, "DSIB", "DeviceInfo.setiBeaconInfo returns failure. enabled is required.");
    1415             errorCallback(result);
    1416             log("DeviceInfo.setiBeaconInfo invalid ");
    1417             return;
    1418         }
    1419
    1420         if (options.enabled == false) {
    1421             iBeaconInfo.beaconMode = "off";
    1422         } else {
    1423             if ((options.uuid === null || options.uuid === undefined || regex(options.uuid) === false) && typeof errorCallback === 'function') {
    1424                 var result = {};
    1425                 checkErrorCodeNText(result, "DSIB", "DeviceInfo.setiBeaconInfo returns failure. uuid is not valid.");
    1426                 errorCallback(result);
    1427                 log("DeviceInfo.setiBeaconInfo invalid ");
    1428                 return;
    1429             }
    1430
    1431             if ((options.major === null || options.major === undefined || isNaN(options.major) || options.major < 0 || options.major > 65535 ||
    1432                     options.minor === null || options.minor === undefined || isNaN(options.minor) || options.minor < 0 || options.minor > 65535) &&
    1433                 typeof errorCallback === 'function') {
    1434                 var result = {};
    1435                 checkErrorCodeNText(result, "DSIB", "DeviceInfo.setiBeaconInfo returns failure. major and minor are not valid.");
    1436                 errorCallback(result);
    1437                 log("DeviceInfo.setiBeaconInfo invalid ");
    1438                 return;
    1439             }
    1440
    1441             iBeaconInfo.beaconMode = "on";
    1442             iBeaconInfo.beaconType = "iBeacon";
    1443             iBeaconInfo.iBeaconUuid = options.uuid;
    1444             iBeaconInfo.iBeaconMajor = options.major.toString();
    1445             iBeaconInfo.iBeaconMinor = options.minor.toString();
    1446         }
    1447
    1448         log("iBeaconInfo: " + JSON.stringify(iBeaconInfo));
    1449
    1450         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
    1451             method: "set",
    1452             parameters: {
    1453                 category: "commercial",
    1454                 settings: iBeaconInfo
    1455             },
    1456             onSuccess: function(result) {
    1457                 log("setiBeaconInfo: On Success");
    1458
    1459                 if (result.returnValue === true) {
    1460                     service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    1461                         method: 'notifyUpdatingBeaconInfo',
    1462                         parameters: {},
    1463                         onSuccess: function(result) {
    1464                             log("notifyUpdatingBeaconInfo: onSuccess");
    1465                             delete result.returnValue;
    1466                             if (typeof successCallback === 'function') {
    1467                                 successCallback(result);
    1468                             }
    1469                         },
    1470                         onFailure: function(error) {
    1471                             log("notifyUpdatingBeaconInfo: onFailure");
    1472                             delete error.returnValue;
    1473                             if (typeof errorCallback === 'function') {
    1474                                 errorCallback(error);
    1475                             }
    1476                         }
    1477                     });
    1478                 }
    1479             },
    1480             onFailure: function(result) {
    1481                 log("setiBeaconInfo: On Failure");
    1482                 delete result.returnValue;
    1483                 if (typeof errorCallback === 'function') {
    1484                     checkErrorCodeNText(result, "DSIB", "DeviceInfo.setiBeaconInfo returns failure.");
    1485                     errorCallback(result);
    1486                 }
    1487             }
    1488         });
    1489
    1490         log("DeviceInfo.setiBeaconInfo Done");
    1491     };
    1492
    1493 		/**
    1494      * Gets iBeacon Info
    1495      * @class DeviceInfo
    1496      * @param {Function} successCallback success callback function.
    1497      * @param {Function} errorCallback failure callback function.
    1498      * @return {Object} options
    1499      * <div align=left>
    1500      * <table class="hcap_spec" width=400>
    1501      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
    1502      *   <tbody>
    1503      *       <tr><th>enabled</th><th>Boolean</th><th>iBeacon is enabled true : enabled, false : disabled</th></tr>
    1504      *       <tr class="odd"><th>uuid</th><th>String</th><th>UUID of iBeacon, 32 hexadecimal digits. (when 'enabled' is true, it is required)</th></tr>
    1505      *       <tr><th>major</th><th>Number</th><th>major (0 ~ 65535) (when 'enabled' is true, it is required)</th></tr>
    1506      *       <tr class="odd"><th>minor</th><th>Number</th><th>minor (0 ~ 65535) (when 'enabled' is true, it is required)</th></tr>
    1507      *   </tbody>
    1508      * </table>
    1509      * </div>
    1510      *
    1511 	 * @example
    1512      * // Javascript code
    1513      * function getiBeaconInfo () {
    1514 	 *  function successCb(cbObject) {
    1515 	 *     console.log("cbObject : " + JSON.stringify(cbObject));
    1516 	 *     console.log("enabled : " + cbObject.enabled);
    1517 	 *     console.log("uuid : " + cbObject.uuid);
    1518 	 *     console.log("major : " + cbObject.major);
    1519 	 *     console.log("minor : " + cbObject.minor);
    1520 	 *     // Do something
    1521 	 *  }
    1522 	 *  function failureCb(cbObject) {
    1523 	 *     var errorCode = cbObject.errorCode;
    1524 	 *     var errorText = cbObject.errorText;
    1525 	 *     console.log ("Error Code [" + errorCode + "]: " + errorText);
    1526 	 *  }
    1527 	 *  var deviceinfo = new DeviceInfo();
    1528 	 *  deviceinfo.getiBeaconInfo(successCb, failureCb);
    1529 	 * }
    1530      * @since 1.4
    1531      * @see
    1532      * <a href="DeviceInfo%23setiBeaconInfo.html">DeviceInfo.setiBeaconInfo()</a><br>
    1533      */
    1534     DeviceInfo.prototype.getiBeaconInfo = function (successCallback, errorCallback) {
    1535
    1536         log("getiBeaconInfo: ");
    1537
    1538         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
    1539             method: "get",
    1540             parameters: {
    1541                 category: "commercial",
    1542                 keys: ["beaconMode", "iBeaconUuid", "iBeaconMajor", "iBeaconMinor"]
    1543             },
    1544             onSuccess: function(result) {
    1545                 log("getiBeaconInfo: On Success");
    1546
    1547                 if (result.returnValue === true) {
    1548                     var cbObj       = {};
    1549                     cbObj.enabled = (result.settings.beaconMode === "on") ? true : false;
    1550                     cbObj.uuid    = result.settings.iBeaconUuid;
    1551                     cbObj.major   = parseInt(result.settings.iBeaconMajor);
    1552                     cbObj.minor   = parseInt(result.settings.iBeaconMinor);
    1553
    1554                     if (typeof successCallback === 'function') {
    1555                         successCallback(cbObj);
    1556                     }
    1557                 }
    1558             },
    1559             onFailure: function(result) {
    1560                 log("getiBeaconInfo: On Failure");
    1561                 delete result.returnValue;
    1562                 if (typeof errorCallback === 'function') {
    1563                     checkErrorCodeNText(result, "DGIB", "DeviceInfo.getiBeaconInfo returns failure.");
    1564                     errorCallback(result);
    1565                 }
    1566             }
    1567         });
    1568
    1569         log("DeviceInfo.getiBeaconInfo Done");
    1570     };
    1571
    1572 	/**
    1573      * Sets Eddystone Info, Each <a href="DeviceInfo.EddystoneFrame.html#constructor">EddystoneFrame</a> has a set of predefined frame properties.
    1574      * @class DeviceInfo
    1575      * @param {Function} successCallback success callback function.
    1576      * @param {Function} errorCallback failure callback function.
    1577      * @param {Object} options
    1578      * <div align=left>
    1579      * <table class="hcap_spec" width=400>
    1580      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead>
    1581      *   <tbody>
    1582      *       <tr><th>enabled</th><th>Boolean</th><th>Eddystone is enabled true : enabled, false : disabled</th><th>required</th></tr>
    1583      *       <tr class="odd"><th>frame</th><th>String</th><th><a href="DeviceInfo.EddystoneFrame.html#constructor">EddystoneFrame</a></th><th>optional</th></tr>
    1584      *       <tr><th>frameData</th><th>String</th><th>UUID of beacon, 32 hexadecimal digits. Only valid when 'enabled' is true and 'frame' is DeviceInfo.EddystoneFrame.UUID<br>
    1585 	 *       URL of beacon. Only valid when 'enabled' is true and 'frame' is DeviceInfo.EddystoneFrame.URL<br>
    1586 	 *       (when 'enabled' is true, it is required)</th><th>optional</th></tr>
    1587      *   </tbody>
    1588      * </table>
    1589      * </div>
    1590      * @return <p>If the method is successfully executed, success callback function is called without a parameter.</br>
    1591      * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p>
    1592      *
    1593      * @example
    1594      * // Javascript code
    1595      * function setEddystoneInfo () {
    1596      *  var options = {
    1597      *     enabled : true,
    1598      *     frame : DeviceInfo.EddystoneFrame.URL,
    1599 	 *     frameData : "https://www.lge.com"
    1600 	 *  };
    1601 	 *  function successCb(cbObject) {
    1602 	 *     console.log("sucess");
    1603 	 *     // Do something
    1604 	 *  }
    1605 	 *  function failureCb(cbObject) {
    1606 	 *     var errorCode = cbObject.errorCode;
    1607 	 *     var errorText = cbObject.errorText;
    1608 	 *     console.log ("Error Code [" + errorCode + "]: " + errorText);
    1609 	 *  }
    1610 	 *  var deviceinfo = new DeviceInfo();
    1611 	 *  deviceinfo.setEddystoneInfo(successCb, failureCb, options);
    1612 	 * }
    1613      * @since 1.4
    1614      * @see
    1615      * <a href="DeviceInfo%23getEddystoneInfo.html">DeviceInfo.getEddystoneInfo()</a><br>
    1616      */
    1617     DeviceInfo.prototype.setEddystoneInfo = function(successCallback, errorCallback, options) {
    1618         var chkuuid = function(uuid) {
    1619             if (typeof uuid === "undefined" || uuid === null || uuid.length != 32) {
    1620                 return false;
    1621             }
    1622
    1623             var reg = new RegExp(/^[a-fA-F0-9]*$/g);
    1624             return reg.exec(uuid) !== null ? true : false;
    1625         };
    1626
    1627         var eddystoneInfo = {};
    1628
    1629         log("setEddystoneInfo: " + options.enabled);
    1630
    1631         if ((options.enabled === null || options.enabled === undefined || typeof options.enabled !== 'boolean') && typeof errorCallback === 'function')
    1632         {
    1633             var result = {};
    1634             checkErrorCodeNText(result, "DSEI", "DeviceInfo.setEddystoneInfo returns failure. enabled is required.");
    1635             errorCallback(result);
    1636             log("DeviceInfo.setEddystoneInfo invalid ");
    1637             return;
    1638         }
    1639
    1640         if (options.enabled === false)
    1641         {
    1642             eddystoneInfo.beaconMode = "off";
    1643         }
    1644         else
    1645         {
    1646             eddystoneInfo.beaconMode = "on";
    1647             eddystoneInfo.beaconType = "eddystone";
    1648
    1649             if (options.frame === DeviceInfo.EddystoneFrame.UUID)
    1650             {
    1651                 if (chkuuid(options.frameData) === false && typeof errorCallback === 'function') {
    1652                     var result = {};
    1653                     checkErrorCodeNText(result, "DSEI", "DeviceInfo.setEddystoneInfo returns failure. frameData is not valid.");
    1654                     errorCallback(result);
    1655                     log("DeviceInfo.setEddystoneInfo invalid ");
    1656                     return;
    1657                 }
    1658
    1659                 eddystoneInfo.eddyStoneFrame = options.frame;
    1660                 eddystoneInfo.eddyStoneUuid  = options.frameData;
    1661
    1662             }
    1663             else if (options.frame === DeviceInfo.EddystoneFrame.URL)
    1664             {
    1665                 if ((options.frameData === null || options.frameData === undefined || typeof options.frameData !== 'string' ||
    1666                     options.frameData.search("://") < 0 || options.frameData.substring(0, 4).toUpperCase() !== "HTTP") && typeof errorCallback === 'function')
    1667                 {
    1668                     var result = {};
    1669                     checkErrorCodeNText(result, "DSEI", "DeviceInfo.setEddystoneInfo returns failure. frameData is not valid.");
    1670                     errorCallback(result);
    1671                     log("DeviceInfo.setEddystoneInfo invalid ");
    1672                     return;
    1673                 }
    1674
    1675                 eddystoneInfo.eddyStoneFrame     = options.frame;
    1676                 eddystoneInfo.eddyStoneUrlPrefix = options.frameData.substring(0, options.frameData.search("://"));
    1677                 if (options.frameData.substring(options.frameData.search("://") + 3, 3).toUpperCase() === "WWW") {
    1678                     eddystoneInfo.eddyStoneUrlPrefix = eddystoneInfo.eddyStoneUrlPrefix + "Ex";
    1679                 }
    1680
    1681                 var lengthPrefix = 0;
    1682                 if(eddystoneInfo.eddyStoneUrlPrefix.toUpperCase() === "HTTP"){
    1683                     lengthPrefix = 7;//http://
    1684                 } else if(eddystoneInfo.eddyStoneUrlPrefix.toUpperCase() === "HTTPEX"){
    1685                     lengthPrefix = 11;//http://www.
    1686                 } else if(eddystoneInfo.eddyStoneUrlPrefix.toUpperCase() === "HTTPS"){
    1687                     lengthPrefix = 8;//https://
    1688                 } else if(eddystoneInfo.eddyStoneUrlPrefix.toUpperCase() === "HTTPSEX"){
    1689                     lengthPrefix = 12;//https://www.
    1690                 }
    1691
    1692                 if (options.frameData.length - lengthPrefix > 17)
    1693                 {
    1694                     var result = {};
    1695                     checkErrorCodeNText(result, "DSEI", "DeviceInfo.setEddystoneInfo returns failure. url size is over.");
    1696                     errorCallback(result);
    1697                     log("DeviceInfo.setEddystoneInfo invalid ");
    1698                     return;
    1699                 }
    1700
    1701                 eddystoneInfo.eddyStoneUrl       = options.frameData.substring(lengthPrefix, options.frameData.length);
    1702                 eddystoneInfo.eddyStoneUrlExCode = "noneValue";
    1703             }
    1704             else
    1705             {
    1706                 var result = {};
    1707                 checkErrorCodeNText(result, "DSEI", "DeviceInfo.setEddystoneInfo returns failure. frame is not valid.");
    1708                 errorCallback(result);
    1709                 log("DeviceInfo.setEddystoneInfo invalid ");
    1710                 return;
    1711             }
    1712         }
    1713
    1714         log("eddystoneInfo : " + JSON.stringify(eddystoneInfo));
    1715
    1716         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
    1717             method: "set",
    1718             parameters: {
    1719                 category: "commercial",
    1720                 settings: eddystoneInfo
    1721             },
    1722             onSuccess: function(result) {
    1723                 log("setEddystoneInfo: On Success");
    1724
    1725                 if (result.returnValue === true) {
    1726                     service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', {
    1727                         method: 'notifyUpdatingBeaconInfo',
    1728                         parameters: {},
    1729                         onSuccess: function(result) {
    1730                             log("notifyUpdatingBeaconInfo: onSuccess");
    1731                             delete result.returnValue;
    1732                             if (typeof successCallback === 'function') {
    1733                                 successCallback(result);
    1734                             }
    1735                         },
    1736                         onFailure: function(error) {
    1737                             log("notifyUpdatingBeaconInfo: onFailure");
    1738                             delete error.returnValue;
    1739                             if (typeof errorCallback === 'function') {
    1740                                 errorCallback(error);
    1741                             }
    1742                         }
    1743                     });
    1744                 }
    1745             },
    1746             onFailure: function(result) {
    1747                 log("setEddystoneInfo: On Failure");
    1748                 delete result.returnValue;
    1749                 if (typeof errorCallback === 'function') {
    1750                     checkErrorCodeNText(result, "DSEI", "DeviceInfo.setEddystoneInfo returns failure.");
    1751                     errorCallback(result);
    1752                 }
    1753             }
    1754         });
    1755     };
    1756
    1757     /**
    1758      * Gets Eddystone Info, Each <a href="DeviceInfo.EddystoneFrame.html#constructor">EddystoneFrame</a> has a set of predefined frame properties.
    1759      * @class DeviceInfo
    1760      * @param {Function} successCallback success callback function.
    1761      * @param {Function} errorCallback failure callback function.
    1762      * @return {Object} options
    1763      * <div align=left>
    1764      * <table class="hcap_spec" width=400>
    1765      *   <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead>
    1766      *   <tbody>
    1767      *       <tr><th>enabled</th><th>Boolean</th><th>Eddystone is enabled true : enabled, false : disabled</th></tr>
    1768      *       <tr class="odd"><th>frame</th><th>String</th><th><a href="DeviceInfo.EddystoneFrame.html#constructor">EddystoneFrame</a></th></tr>
    1769      *       <tr><th>frameData</th><th>String</th><th>UUID of beacon, 32 hexadecimal digits. Only valid when 'enabled' is true and 'frame' is DeviceInfo.EddystoneFrame.UUID<br>
    1770 	 *       URL of beacon. Only valid when 'enabled' is true and 'frame' is DeviceInfo.EddystoneFrame.URL<br>
    1771 	 *       (when 'enabled' is true, it is required)</th></tr>
    1772      *   </tbody>
    1773      * </table>
    1774      * </div>
    1775      *
    1776 	 * @example
    1777      * // Javascript code
    1778      * function getEddystoneInfo () {
    1779 	 *  function successCb(cbObject) {
    1780 	 *     console.log("cbObject : " + JSON.stringify(cbObject));
    1781 	 *     console.log("enabled : " + cbObject.enabled);
    1782 	 *     console.log("frame : " + cbObject.uuid);
    1783 	 *     console.log("frameData : " + cbObject.major);
    1784 	 *     // Do something
    1785 	 *  }
    1786 	 *  function failureCb(cbObject) {
    1787 	 *     var errorCode = cbObject.errorCode;
    1788 	 *     var errorText = cbObject.errorText;
    1789 	 *     console.log ("Error Code [" + errorCode + "]: " + errorText);
    1790 	 *  }
    1791 	 *  var deviceinfo = new DeviceInfo();
    1792 	 *  deviceinfo.getEddystoneInfo(successCb, failureCb);
    1793 	 * }
    1794      * @since 1.4
    1795      * @see
    1796      * <a href="DeviceInfo%23setEddystoneInfo.html">DeviceInfo.setEddystoneInfo()</a><br>
    1797      */
    1798     DeviceInfo.prototype.getEddystoneInfo = function (successCallback, errorCallback) {
    1799
    1800         log("getEddystoneInfo: ");
    1801
    1802         service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", {
    1803             method: "get",
    1804             parameters: {
    1805                 category: "commercial",
    1806                 keys: ["beaconMode", "eddyStoneFrame", "eddyStoneUuid", "eddyStoneUrlPrefix", "eddyStoneUrl", "eddyStoneUrlExCode"]
    1807             },
    1808             onSuccess: function(result) {
    1809                 log("getEddystoneInfo: On Success");
    1810
    1811                 if (result.returnValue === true) {
    1812                     var cbObj     = {};
    1813                     cbObj.enabled = (result.settings.beaconMode === "on") ? true : false;
    1814                     cbObj.frame   = result.settings.eddyStoneFrame;
    1815
    1816                     if (result.settings.eddyStoneFrame === DeviceInfo.EddystoneFrame.UUID) {
    1817                         cbObj.frameData = result.settings.eddyStoneUuid;
    1818                     } else {
    1819                         if(result.settings.eddyStoneUrlPrefix === "http") {
    1820                             cbObj.frameData = "http://" + result.settings.eddyStoneUrl;
    1821                         } else if (result.settings.eddyStoneUrlPrefix === "httpEx") {
    1822                             cbObj.frameData = "http://www." + result.settings.eddyStoneUrl;
    1823                         } else if (result.settings.eddyStoneUrlPrefix === "https") {
    1824                             cbObj.frameData = "https://" + result.settings.eddyStoneUrl;
    1825                         } else {
    1826                             cbObj.frameData = "https://www." + result.settings.eddyStoneUrl;
    1827                         }
    1828                     }
    1829
    1830                     if (typeof successCallback === 'function') {
    1831                         successCallback(cbObj);
    1832                     }
    1833                 }
    1834             },
    1835             onFailure: function(result) {
    1836                 log("getEddystoneInfo: On Failure");
    1837                 delete result.returnValue;
    1838                 if (typeof errorCallback === 'function') {
    1839                     checkErrorCodeNText(result, "DGEI", "DeviceInfo.getEddystoneInfo returns failure.");
    1840                     errorCallback(result);
    1841                 }
    1842             }
    1843         });
    1844
    1845         log("DeviceInfo.getEddystoneInfo Done");
    1846     };
    1847
    1848     module.exports = DeviceInfo;
    1849 });
    1850
    1851 DeviceInfo = cordova.require('cordova/plugin/deviceInfo'); // jshint ignore:line
    1852
    1853