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

			winble.logger.logDebug("writeCharacteristic", "deviceHandle='" + deviceHandle + ", charHandle='" + charHandle + "'");

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

			// Find the requested characteristic in the device's list of characteristics
			var characteristic = winble.deviceManager.getCharacteristicFromHandle(device, charHandle, "writeCharacteristic", errorCallback);
			if (characteristic == null)
				return;

			// Write the data. The incoming buffer is and ArrayBuffer, and the writeValueAsync() function takes an iBuffer as its
			// parameter, so we need to do some conversion here.
			// https://msdn.microsoft.com/en-us/library/windows/apps/windows.security.cryptography.cryptographicbuffer.createfrombytearray
			// https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.bluetooth.genericattributeprofile.gattcharacteristic.readvalueasync.aspx
			var data = new Uint8Array(dataBuffer);
			var dataOut = Windows.Security.Cryptography.CryptographicBuffer.createFromByteArray(data);
			var writeOption;
			if (characteristic.gattChar.characteristicProperties & winble.gatt.GattCharacteristicProperties.writeWithoutResponse)
				writeOption = winble.gatt.GattWriteOption.writeWithoutResponse;
			else
				writeOption = winble.gatt.GattWriteOption.writeWithResponse;
			characteristic.gattChar.writeValueAsync(dataOut, writeOption).done(
				function (commStatus) {
					if (commStatus == winble.gatt.GattCommunicationStatus.success) {
						winble.logger.logDebug("writeCharacteristic", "gattChar.writeValueAsync completed with success");
						successCallback();
					} else {
						winble.logger.logDebug("writeCharacteristic", "gattChar.writeValueAsync completed with error");
						var msg = "Write failed or device unreachable, GattCommunicationStatus = " + commStatus;
						winble.logger.logError("writeCharacteristic", msg);
						errorCallback(msg);
					}
				},
				function (error) {
					var msg = "gattChar.writeValueAsync() failed: " + error;
					winble.logger.logError("writeCharacteristic", msg);
					errorCallback(msg);
				});
		}
function (successCallback, errorCallback, deviceHandle, charHandle, dataBuffer) {

			winble.logger.logDebug("writeCharacteristic", "deviceHandle='" + deviceHandle + ", charHandle='" + charHandle + "'");

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

			// Find the requested characteristic in the device's list of characteristics
			var characteristic = winble.deviceManager.getCharacteristicFromHandle(device, charHandle, "writeCharacteristic", errorCallback);
			if (characteristic == null)
				return;

			// Write the data. The incoming buffer is and ArrayBuffer, and the writeValueAsync() function takes an iBuffer as its
			// parameter, so we need to do some conversion here.
			// https://msdn.microsoft.com/en-us/library/windows/apps/windows.security.cryptography.cryptographicbuffer.createfrombytearray
			// https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.bluetooth.genericattributeprofile.gattcharacteristic.readvalueasync.aspx
			var data = new Uint8Array(dataBuffer);
			var dataOut = Windows.Security.Cryptography.CryptographicBuffer.createFromByteArray(data);
			var writeOption;
			if (characteristic.gattChar.characteristicProperties & winble.gatt.GattCharacteristicProperties.writeWithoutResponse)
				writeOption = winble.gatt.GattWriteOption.writeWithoutResponse;
			else
				writeOption = winble.gatt.GattWriteOption.writeWithResponse;
			characteristic.gattChar.writeValueAsync(dataOut, writeOption).done(
				function (commStatus) {
					if (commStatus == winble.gatt.GattCommunicationStatus.success) {
						winble.logger.logDebug("writeCharacteristic", "gattChar.writeValueAsync completed with success");
						successCallback();
					} else {
						winble.logger.logDebug("writeCharacteristic", "gattChar.writeValueAsync completed with error");
						var msg = "Write failed or device unreachable, GattCommunicationStatus = " + commStatus;
						winble.logger.logError("writeCharacteristic", msg);
						errorCallback(msg);
					}
				},
				function (error) {
					var msg = "gattChar.writeValueAsync() failed: " + error;
					winble.logger.logError("writeCharacteristic", msg);
					errorCallback(msg);
				});
		}
function ( successCallback , errorCallback , deviceHandle , charHandle , dataBuffer ) { winble . logger . logDebug ( "writeCharacteristic" , "deviceHandle='" + deviceHandle + ", charHandle='" + charHandle + "'" ) ; // Find the requested device in our list of discovered devices var device = winble . deviceManager . getDeviceFromHandle ( deviceHandle , "writeCharacteristic" , errorCallback ) ; if ( device == null ) return ; // Find the requested characteristic in the device's list of characteristics var characteristic = winble . deviceManager . getCharacteristicFromHandle ( device , charHandle , "writeCharacteristic" , errorCallback ) ; if ( characteristic == null ) return ; // Write the data. The incoming buffer is and ArrayBuffer, and the writeValueAsync() function takes an iBuffer as its // parameter, so we need to do some conversion here. // https://msdn.microsoft.com/en-us/library/windows/apps/windows.security.cryptography.cryptographicbuffer.createfrombytearray // https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.bluetooth.genericattributeprofile.gattcharacteristic.readvalueasync.aspx var data = new Uint8Array ( dataBuffer ) ; var dataOut = Windows . Security . Cryptography . CryptographicBuffer . createFromByteArray ( data ) ; var writeOption ; if ( characteristic . gattChar . characteristicProperties & winble . gatt . GattCharacteristicProperties . writeWithoutResponse ) writeOption = winble . gatt . GattWriteOption . writeWithoutResponse ; else writeOption = winble . gatt . GattWriteOption . writeWithResponse ; characteristic . gattChar . writeValueAsync ( dataOut , writeOption ) . done ( function ( commStatus ) { if ( commStatus == winble . gatt . GattCommunicationStatus . success ) { winble . logger . logDebug ( "writeCharacteristic" , "gattChar.writeValueAsync completed with success" ) ; successCallback ( ) ; } else { winble . logger . logDebug ( "writeCharacteristic" , "gattChar.writeValueAsync completed with error" ) ; var msg = "Write failed or device unreachable, GattCommunicationStatus = " + commStatus ; winble . logger . logError ( "writeCharacteristic" , msg ) ; errorCallback ( msg ) ; } } , function ( error ) { var msg = "gattChar.writeValueAsync() failed: " + error ; winble . logger . logError ( "writeCharacteristic" , msg ) ; errorCallback ( msg ) ; } ) ; }
Called from the writeCharacteristic API; write the data to the specified characteristic.
Called from the writeCharacteristic API ; write the data to the specified characteristic .