src/windows/bleProxy.js
function (successCallback, errorCallback, deviceHandle) {

			// Find the requested device in our list of discovered devices
			var device = winble.deviceManager.getDeviceFromHandle(deviceHandle, "getDeviceServices", errorCallback);
			if (device == null)
				return;

			// Enumerate the services
			winble.bleDevice.fromIdAsync(device.gattDevice.id).done(
				function (bleDevice) {
					winble.logger.logDebug("getDeviceServices", "BluetoothLEDevice.fromIdAsync completed with success");

					// Store the services and return an API-specified list to the caller
					var serviceListOut = [];
					for (var i = 0; i < bleDevice.gattServices.length; i++) {

						// Add service internally to the device so we can retrieve it later by its handle
						winble.logger.logDebug("getDeviceServices", "Found " + device.gattDevice.name + " service '" + bleDevice.gattServices[i].uuid + "'");
						var serviceStore = {
							"gattService": bleDevice.gattServices[i],
							"handle": winble.nextGattHandle++
						};
						device.serviceList[serviceStore.handle] = serviceStore;

						// Add service to return list
						var serviceOut = {
							"handle": serviceStore.handle,
							"uuid": serviceStore.gattService.uuid,
							"type": 0 // 0 = Primary, 1 = Secondary (Windows only returns primary services in the ble.gattServices list)
						};
						serviceListOut.push(serviceOut);
					}

					// Report the list of services back to the caller
					successCallback(serviceListOut);
				},
				function (error) {
					var msg = "BluetoothLEDevice.fromIdAsync('" + device.gattDevice.id + "') failed: " + error;
					winble.logger.logError("getDeviceServices", msg);
					errorCallback(msg);
				});
		}
function (successCallback, errorCallback, deviceHandle) {

			// Find the requested device in our list of discovered devices
			var device = winble.deviceManager.getDeviceFromHandle(deviceHandle, "getDeviceServices", errorCallback);
			if (device == null)
				return;

			// Enumerate the services
			winble.bleDevice.fromIdAsync(device.gattDevice.id).done(
				function (bleDevice) {
					winble.logger.logDebug("getDeviceServices", "BluetoothLEDevice.fromIdAsync completed with success");

					// Store the services and return an API-specified list to the caller
					var serviceListOut = [];
					for (var i = 0; i < bleDevice.gattServices.length; i++) {

						// Add service internally to the device so we can retrieve it later by its handle
						winble.logger.logDebug("getDeviceServices", "Found " + device.gattDevice.name + " service '" + bleDevice.gattServices[i].uuid + "'");
						var serviceStore = {
							"gattService": bleDevice.gattServices[i],
							"handle": winble.nextGattHandle++
						};
						device.serviceList[serviceStore.handle] = serviceStore;

						// Add service to return list
						var serviceOut = {
							"handle": serviceStore.handle,
							"uuid": serviceStore.gattService.uuid,
							"type": 0 // 0 = Primary, 1 = Secondary (Windows only returns primary services in the ble.gattServices list)
						};
						serviceListOut.push(serviceOut);
					}

					// Report the list of services back to the caller
					successCallback(serviceListOut);
				},
				function (error) {
					var msg = "BluetoothLEDevice.fromIdAsync('" + device.gattDevice.id + "') failed: " + error;
					winble.logger.logError("getDeviceServices", msg);
					errorCallback(msg);
				});
		}
function ( successCallback , errorCallback , deviceHandle ) { // Find the requested device in our list of discovered devices var device = winble . deviceManager . getDeviceFromHandle ( deviceHandle , "getDeviceServices" , errorCallback ) ; if ( device == null ) return ; // Enumerate the services winble . bleDevice . fromIdAsync ( device . gattDevice . id ) . done ( function ( bleDevice ) { winble . logger . logDebug ( "getDeviceServices" , "BluetoothLEDevice.fromIdAsync completed with success" ) ; // Store the services and return an API-specified list to the caller var serviceListOut = [ ] ; for ( var i = 0 ; i < bleDevice . gattServices . length ; i ++ ) { // Add service internally to the device so we can retrieve it later by its handle winble . logger . logDebug ( "getDeviceServices" , "Found " + device . gattDevice . name + " service '" + bleDevice . gattServices [ i ] . uuid + "'" ) ; var serviceStore = { "gattService" : bleDevice . gattServices [ i ] , "handle" : winble . nextGattHandle ++ } ; device . serviceList [ serviceStore . handle ] = serviceStore ; // Add service to return list var serviceOut = { "handle" : serviceStore . handle , "uuid" : serviceStore . gattService . uuid , "type" : 0 // 0 = Primary, 1 = Secondary (Windows only returns primary services in the ble.gattServices list) } ; serviceListOut . push ( serviceOut ) ; } // Report the list of services back to the caller successCallback ( serviceListOut ) ; } , function ( error ) { var msg = "BluetoothLEDevice.fromIdAsync('" + device . gattDevice . id + "') failed: " + error ; winble . logger . logError ( "getDeviceServices" , msg ) ; errorCallback ( msg ) ; } ) ; }
Called from the services API; return a list of all BLE services supported by the specified device.
Called from the services API ; return a list of all BLE services supported by the specified device .