var Comm = { customMgr : {}, deviceInstance : [] }; Comm.init = function () { // >> Register custom manager callback to receive device connect and disconnect events Comm.customMgr = webapis.customdevice || {}; Comm.customMgr.registerManagerCallback(Comm.onDeviceStatusChange); // >> Initializes custom device profile and gets available devices Comm.customMgr.getCustomDevices(Comm.onCustomObtained); Main.log("curWidget.id= " + curWidget.id); Main.logToServer("curWidget.id= (" + curWidget.id+")"); }; Comm.onDeviceStatusChange = function (sParam) { switch( Number(sParam.eventType) ) { case Comm.customMgr.MGR_EVENT_DEV_CONNECT: Main.logToServer("onDeviceStatusChange - MGR_EVENT_DEV_CONNECT: name= " + sParam.name + " type= " +sParam.deviceType); break; case Comm.customMgr.MGR_EVENT_DEV_DISCONNECT: Main.logToServer("onDeviceStatusChange - MGR_EVENT_DEV_DISCONNECT: name= " + sParam.name + " type= " +sParam.deviceType); break; default: Main.logToServer("onDeviceStatusChange - Unknown event eType= " + sParam.eventType + " name= " + sParam.name+ " dType= "+sParam.deviceType); break; } Comm.customMgr.getCustomDevices(Comm.onCustomObtained); }; Comm.onCustomObtained = function (customs) { Main.logToServer("onCustomObtained - found " + customs.length + " custom device(s)"); for(var i=0; i