1//============================================================================== 2// 3// TOBESOFT Co., Ltd. 4// Copyright 2017 TOBESOFT Co., Ltd. 5// All Rights Reserved. 6// 7// NOTICE: TOBESOFT permits you to use, modify, and distribute this file 8// in accordance with the terms of the license agreement accompanying it. 9// 10// Readme URL: http://www.nexacro.co.kr/legal/nexacro17-public-license-readme-1.0.html 11// 12//============================================================================== 13 14if (!nexacro.BluetoothLE) { 15 nexacro.BluetoothLE = function (name, parent) { 16 this.id = this.name = name || null; 17 if (parent) { 18 this.parent = parent; 19 } 20 21 22 23 this._id = nexacro.Device.makeID(); 24 nexacro.Device._userCreatedObj[this._id] = this; 25 this.handle = nexacro._createBluetoothLEConnectionObject(this); 26 27 this._event_list = { 28 "onscanresult" : 1, 29 "onsubscriberesult" : 1, 30 "onsuccess" : 1, 31 "onerror" : 1 32 }; 33 34 35 this.onscanresult = null; 36 this.onsubscriberesult = null; 37 this.onsuccess = null; 38 this.onerror = null; 39 40 this.osSpecifiedJSONString = this._makeOSSpecifiedJSONString(this); 41 42 var params = '""'; 43 var jsonstr = '{"id":' + this._id + ', "div":"BluetoothLE", "method":"constructor", "params":' + params + '}'; 44 nexacro.Device.exec(jsonstr); 45 }; 46 47 var _pBluetoothLE = nexacro.BluetoothLE.prototype = nexacro._createPrototype(nexacro._EventSinkObject, nexacro.BluetoothLE); 48 _pBluetoothLE._type_name = "BluetoothLE"; 49 50 _pBluetoothLE.destroy = function () { 51 var params = '""'; 52 var jsonstr; 53 54 nexacro._destroyBluetoothLEConnectionObject(this.handle); 55 56 delete nexacro.Device._userCreatedObj[this._id]; 57 58 59 60 return true; 61 }; 62 63 _pBluetoothLE.scanStart = function (duration, service_uuid) { 64 var params = '{ "duration":"' + duration; 65 params += '", "service_uuid":"' + service_uuid; 66 params += '"}'; 67 jsonstr = this.makeJSONString('"scanStart"', params); 68 nexacro.Device.exec(jsonstr); 69 }; 70 71 _pBluetoothLE.scanStop = function () { 72 var params = '""'; 73 jsonstr = this.makeJSONString('"scanStop"', params); 74 nexacro.Device.exec(jsonstr); 75 }; 76 77 _pBluetoothLE.connect = function (device_address) { 78 var params = '{ "device_address":"' + device_address; 79 params += '"}'; 80 jsonstr = this.makeJSONString('"connect"', params); 81 nexacro.Device.exec(jsonstr); 82 }; 83 84 _pBluetoothLE.disconnect = function () { 85 var params = '""'; 86 jsonstr = this.makeJSONString('"disconnect"', params); 87 nexacro.Device.exec(jsonstr); 88 }; 89 90 _pBluetoothLE.discoverService = function (device_address) { 91 var params = '""'; 92 jsonstr = this.makeJSONString('"discoverServices"', params); 93 nexacro.Device.exec(jsonstr); 94 }; 95 96 _pBluetoothLE.subscribe = function (service_uuid, characteristic_uuid) { 97 var params = '{ "service_uuid":"' + service_uuid; 98 params += '", "characteristic_uuid":"' + characteristic_uuid; 99 params += '"}'; 100 jsonstr = this.makeJSONString('"subscribe"', params); 101 nexacro.Device.exec(jsonstr); 102 }; 103 104 105 _pBluetoothLE.unsubscribe = function (service_uuid, characteristic_uuid) { 106 var params = '{ "service_uuid":"' + service_uuid; 107 params += '", "characteristic_uuid":"' + characteristic_uuid; 108 params += '"}'; 109 jsonstr = this.makeJSONString('"unsubscribe"', params); 110 nexacro.Device.exec(jsonstr); 111 }; 112 113 _pBluetoothLE.writeCharacteristic = function (service_uuid, characteristic_uuid, value, valuetype) { 114 var params = '{ "service_uuid":"' + service_uuid; 115 params += '", "characteristic_uuid":"' + characteristic_uuid; 116 params += '", "value":"' + value; 117 params += '"}'; 118 jsonstr = this.makeJSONString('"writeCharacteristic"', params); 119 nexacro.Device.exec(jsonstr); 120 }; 121 122 _pBluetoothLE.readCharacteristic = function (service_uuid, characteristic_uuid) { 123 var params = '{ "service_uuid":"' + service_uuid; 124 params += '", "characteristic_uuid":"' + characteristic_uuid; 125 params += '"}'; 126 jsonstr = this.makeJSONString('"readCharacteristic"', params); 127 nexacro.Device.exec(jsonstr); 128 }; 129 130 _pBluetoothLE.test = function (device_address) { 131 var params = '{ device_address:"' + device_address; 132 params += '"}'; 133 var jsonstr = '{"id":' + this._id + ', "div":"BluetoothLE", "windows_platform":"WIN32", "method":"test", "params":' + params + '}'; 134 nexacro.Device.exec(jsonstr); 135 }; 136 137 _pBluetoothLE.makeJSONString = function (method, params) { 138 var jsonstr = '{"id":' + this._id; 139 jsonstr += ', "div":"BluetoothLE"'; 140 jsonstr += ', "method":' + method; 141 jsonstr += this.osSpecifiedJSONString; 142 jsonstr += ', "params":' + params + '}'; 143 return jsonstr; 144 }; 145 146 _pBluetoothLE._makeOSSpecifiedJSONString = function (target) { 147 var OSSpecifiedJSONString = ''; 148 if (nexacro._OS == "Windows") { 149 OSSpecifiedJSONString += ', "windowhandle":' + target.parent._getWindow().handle; 150 OSSpecifiedJSONString += ', "objecthandle":' + target.handle; 151 OSSpecifiedJSONString += ', "windows_platform":"WIN32"'; 152 } 153 else { 154 } 155 return OSSpecifiedJSONString; 156 }; 157 158 _pBluetoothLE.on_created = function () { 159 }; 160 161 _pBluetoothLE.hasBluetoothLE = function () { 162 if (nexacro.Device.curDevice == DeviceType.ANDROID) { 163 return nexacro.__hasBluetoothLE(); 164 } 165 else { 166 if (nexacro.Device.isphone == 1) { 167 return true; 168 } 169 else { 170 return false; 171 } 172 } 173 }; 174 175 176 _pBluetoothLE._onscanresult = function (objData) { 177 if (nexacro._OS == "Windows") { 178 var objDataParsed = JSON.parse(objData); 179 var e = new nexacro.BluetoothLEScanDeviceEventInfo("onscanresult", objDataParsed.devicename, objDataParsed.deviceaddress); 180 } 181 else { 182 var e = new nexacro.BluetoothLEScanDeviceEventInfo("onscanresult", objData.devicename, objData.deviceaddress); 183 } 184 this._fire_onscanresult(this, e); 185 }; 186 187 _pBluetoothLE._fire_onscanresult = function (objBluetoothLE, eBluetoothLEScanDeviceEventInfo) { 188 if (this.onscanresult && this.onscanresult._has_handlers) { 189 return this.onscanresult._fireEvent(this, eBluetoothLEScanDeviceEventInfo); 190 } 191 }; 192 193 194 195 196 _pBluetoothLE._onsubscriberesult = function (objData) { 197 if (nexacro._OS == "Windows") { 198 var objDataParsed = JSON.parse(objData); 199 var e = new nexacro.BluetoothLEEventInfo(objDataParsed.eventid, objDataParsed.reason, objDataParsed.service_uuid, objDataParsed.message); 200 } 201 else { 202 var e = new nexacro.BluetoothLEEventInfo(objData.eventid, objData.reason, objData.service_uuid, objData.message); 203 } 204 205 this._fire_onsubscriberesult(this, e); 206 }; 207 208 _pBluetoothLE._fire_onsubscriberesult = function (objBluetoothLE, eBluetoothLEEventInfo) { 209 if (this.onsubscriberesult && this.onsubscriberesult._has_handlers) { 210 return this.onsubscriberesult._fireEvent(this, eBluetoothLEEventInfo); 211 } 212 return true; 213 }; 214 215 216 _pBluetoothLE._onsuccess = function (objData) { 217 if (nexacro._OS == "Windows") { 218 var objDataParsed = JSON.parse(objData); 219 var e = new nexacro.BluetoothLEEventInfo(objDataParsed.eventid, objDataParsed.reason, objDataParsed.service_uuid, objDataParsed.message); 220 } 221 else { 222 var e = new nexacro.BluetoothLEEventInfo(objData.eventid, objData.reason, objData.service_uuid, objData.message); 223 } 224 225 this._fire_onsuccess(this, e); 226 }; 227 228 _pBluetoothLE._fire_onsuccess = function (objBluetoothLE, eBluetoothLEEventInfo) { 229 if (this.onsuccess && this.onsuccess._has_handlers) { 230 return this.onsuccess._fireEvent(this, eBluetoothLEEventInfo); 231 } 232 return true; 233 }; 234 235 _pBluetoothLE._onerror = function (objData) { 236 if (nexacro._OS == "Windows") { 237 var objDataParsed = JSON.parse(objData); 238 var e = new nexacro.BluetoothLEErrorEventInfo(objDataParsed.eventid, objDataParsed.reason, objDataParsed.errormsg); 239 } 240 else { 241 var e = new nexacro.BluetoothLEErrorEventInfo(objData.eventid, objData.reason, objData.errormsg); 242 } 243 244
245 this._fire_onerror(this, e); 246 }; 247 248 _pBluetoothLE._fire_onerror = function (objBluetoothLE, BluetoothLEErrorEventInfo) { 249 if (this.onerror && this.onerror._has_handlers) { 250 return this.onerror._fireEvent(this, BluetoothLEErrorEventInfo); 251 } 252 return true; 253 }; 254 255 delete _pBluetoothLE; 256} 257 258if (!nexacro.BluetoothLEScanDeviceEventInfo) { 259 nexacro.BluetoothLEScanDeviceEventInfo = function (strEventId, strDeviceName, strDeviceAdress) { 260 this.eventid = strEventId; 261 this.device_name = strDeviceName; 262 this.device_address = strDeviceAdress; 263 }; 264 var _pBluetoothLEScanDeviceEventInfo = nexacro.BluetoothLEScanDeviceEventInfo.prototype = nexacro._createPrototype(nexacro.Event, nexacro.BluetoothLEScanDeviceEventInfo); 265 _pBluetoothLEScanDeviceEventInfo._type_name = "BluetoothLEScanDeviceEventInfo"; 266 267 delete _pBluetoothLEScanDeviceEventInfo; 268} 269 270if (!nexacro.BluetoothLEEventInfo) { 271 nexacro.BluetoothLEEventInfo = function (strEventId, strReason, strServiceUuid, strMessage) { 272 this.eventid = strEventId; 273 this.reason = strReason; 274 this.service_uuid = strServiceUuid; 275 this.message = strMessage; 276 }; 277 var _pBluetoothLEEventInfo = nexacro.BluetoothLEEventInfo.prototype = nexacro._createPrototype(nexacro.Event, nexacro.BluetoothLEEventInfo); 278 _pBluetoothLEEventInfo._type_name = "BluetoothLEEventInfo"; 279 280 delete _pBluetoothLEEventInfo; 281} 282 283if (!nexacro.BluetoothLEErrorEventInfo) { 284 nexacro.BluetoothLEErrorEventInfo = function (strEventId, strReason, strErrorMsg) { 285 this.eventid = strEventId; 286 this.reason = strReason; 287 this.errortype = "ObjectError"; 288 this.errormsg = strErrorMsg; 289 }; 290 var _pBluetoothLEErrorEventInfo = nexacro.BluetoothLEErrorEventInfo.prototype = nexacro._createPrototype(nexacro.Event, nexacro.BluetoothLEErrorEventInfo); 291 _pBluetoothLEErrorEventInfo._type_name = "BluetoothLEErrorEventInfo"; 292 293 delete _pBluetoothLEErrorEventInfo; 294} 295 296if (nexacro._Browser == "Runtime") { 297 if (nexacro._OS == "Windows") { 298 nexacro._createBluetoothLEConnectionObject = function (target) { 299 return nexacro.__createBluetoothLEObject(target, target.on_success, target._onconnect, target._onservicediscovered, target.on_error, target._oncharacteristicchanged); 300 }; 301 302 nexacro._destroyBluetoothLEConnectionObject = function (target) { 303 }; 304 } 305 306 else if (nexacro._OS == "Android") { 307 nexacro._createBluetoothLEConnectionObject = function (target) { 308 }; 309 nexacro._destroyBluetoothLEConnectionObject = function (target) { 310 }; 311 } 312 else if (nexacro._OS == "OSX") { 313 nexacro._createBluetoothLEConnectionObject = function (target) { 314 }; 315 nexacro._destroyBluetoothLEConnectionObject = function (target) { 316 }; 317 } 318} 319else { 320 if (nexacro._OS == "iOS" && nexacro._isHybrid && nexacro._isHybrid()) { 321 nexacro._createBluetoothLEConnectionObject = function (target) { 322 }; 323 324 nexacro._destroyBluetoothLEConnectionObject = function (target) { 325 }; 326 } 327}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.