servo: Merge #14657 - Remove unused html bluetooth tests (from dati91:remove_html_tests); r=jdm

<!-- Please describe your changes on the following line: -->
Remove unused html bluetooth tests, because we use wpt based bluetooth tests now.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [X] These changes do not require tests because no functionality changed.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: b67bfb39aee98cba5218e8dfa0fa7019f16a4dae
This commit is contained in:
Attila Dusnoki 2016-12-21 05:55:19 -08:00
Родитель 435fd8474a
Коммит 6482812c91
24 изменённых файлов: 0 добавлений и 1615 удалений

Просмотреть файл

@ -1,40 +0,0 @@
<!DOCTYPE html>
<html>
<title>Battery Level</title>
<body>
<button type="button" onclick="onButtonClick()">Get Bluetooth Device's Battery Level</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var options = {filters: [{services: ['battery_service']}], optionalServices: []};
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(options)
.then(device => {
log('Connecting to GATT Server on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Battery Service...');
return server.getPrimaryService('battery_service');
})
.then(service => {
log('Getting Battery Level Characteristic...');
return service.getCharacteristic('battery_level');
})
.then(characteristic => {
log('Reading Battery Level...');
return characteristic.readValue();
})
.then(value => {
log('> Battery Level is ' + asciiToDecimal(value) + '%');
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,50 +0,0 @@
<!DOCTYPE html>
<html>
<title>Battery Level with filters</title>
<body>
<input id="name" type="text" placeholder="Device Name">
<input id="namePrefix" type="text" placeholder="Device Name Prefix">
<button type="button" onclick="onButtonClick()">Get Bluetooth Device's Battery Level</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var options = {filters: [{services: ['battery_service']}], optionalServices: []};
var filterName = document.getElementById('name').value;
if (filterName)
options.filters[0].name = filterName;
var filterNamePrefix = document.getElementById('namePrefix').value;
if (filterNamePrefix)
options.filters[0].namePrefix = filterNamePrefix;
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(options)
.then(device => {
log('Connecting to GATT Server on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Battery Service...');
return server.getPrimaryService('battery_service');
})
.then(service => {
log('Getting Battery Level Characteristic...');
return service.getCharacteristic('battery_level');
})
.then(characteristic => {
log('Reading Battery Level...');
return characteristic.readValue();
})
.then(value => {
log('> Battery Level is ' + asciiToDecimal(value) + '%');
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,63 +0,0 @@
<!DOCTYPE html>
<html>
<title>Characteristic info</title>
<body>
<input id="service" type="text" autofocus placeholder="Bluetooth Service">
<input id="characteristic" type="text" autofocus placeholder="Bluetooth Characteristic">
<button type="button" onclick="onButtonClick()">Get Characteristic Info</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var serviceUuid = document.getElementById('service').value;
var characteristicUuid = document.getElementById('characteristic').value;
if (!serviceUuid || !characteristicUuid) {
return log('All input field must be filled!');
}
if (serviceUuid.startsWith('0x'))
serviceUuid = parseInt(serviceUuid, 16);
if (characteristicUuid.startsWith('0x'))
characteristicUuid = parseInt(characteristicUuid, 16);
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice({filters: [{services: [serviceUuid]}]})
.then(device => {
log('Connecting to GATT Server on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service...');
return server.getPrimaryService(serviceUuid);
})
.then(service => {
log('Getting Characteristic...');
return service.getCharacteristic(characteristicUuid);
})
.then(characteristic => {
log('Characteristic found!');
log('> Characteristic service: ' + characteristic.service.uuid);
log('> Characteristic UUID: ' + characteristic.uuid);
log('> Broadcast: ' + characteristic.properties.broadcast);
log('> Read: ' + characteristic.properties.read);
log('> Write w/o response: ' + characteristic.properties.writeWithoutResponse);
log('> Write: ' + characteristic.properties.write);
log('> Notify: ' + characteristic.properties.notify);
log('> Indicate: ' + characteristic.properties.indicate);
log('> Signed Write: ' + characteristic.properties.authenticatedSignedWrites);
log('> Queued Write: ' + characteristic.properties.reliableWrite);
log('> Writable Auxiliaries: ' + characteristic.properties.writableAuxiliaries);
return characteristic.readValue();
})
.then(value => {
log('> Characteristic value: ' + asciiToDecimal(value));
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,76 +0,0 @@
<!DOCTYPE html>
<html>
<title>Characterstic's ReadValue Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({characteristic: 'body_sensor_location', mustDisconnect: true});
//Test 2
testCases.push({characteristic: 'gap.reconnection_address', mustDisconnect: false});
//Test 3
testCases.push({characteristic: 'serial_number_string', mustDisconnect: false});
//Test 4
testCases.push({characteristic: 0x00002a03, mustDisconnect: false});
//Test 5
testCases.push({characteristic: 0x00002a25, mustDisconnect: false});
//Test 6
testCases.push({characteristic: '00002a03-0000-1000-8000-00805f9b34fb', mustDisconnect: false});
//Test 7
testCases.push({characteristic: '00002a25-0000-1000-8000-00805f9b34fb', mustDisconnect: false});
//Test 8
testCases.push({characteristic: 'body_sensor_location', mustDisconnect: false});
//Test 9
testCases.push({characteristic: 0x00002a38, mustDisconnect: false});
//Test 10
testCases.push({characteristic: '00002a38-0000-1000-8000-00805f9b34fb', mustDisconnect: false});
//Test 11
testCases.push({characteristic: 'heart_rate_control_point', mustDisconnect: false});
function onButtonClick(testNumber) {
clear();
var bt_server;
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice({filters: [{services: ['heart_rate']}]})
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
bt_server = server;
log('Getting Primary Service "heart_rate"...');
return server.getPrimaryService('heart_rate');
})
.then(service => {
log('Getting Characteristic "' + testCases[testNumber].characteristic + '"...');
return service.getCharacteristic(testCases[testNumber].characteristic);
})
.then(characteristic => {
log('Characteristic found!');
if (testCases[testNumber].mustDisconnect) {
log('Disconnecting from server...');
bt_server.disconnect();
}
log('Reading the value of the Characteristic...');
return characteristic.readValue();
})
.then(value => {
log('> Characteristic value: ' + asciiToDecimal(value));
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,92 +0,0 @@
<!DOCTYPE html>
<html>
<title>Characterstic's WriteValue Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({characteristic: 0x2345, valueToWrite: [11], mustDisconnect: true});
//Test 2
testCases.push({characteristic: 0x2345, valueToWrite: new Array(513), mustDisconnect: false});
//Test 3
testCases.push({characteristic: 'gap.reconnection_address', valueToWrite: [1], mustDisconnect: false});
//Test 4
testCases.push({characteristic: 'serial_number_string', valueToWrite: [2], mustDisconnect: false});
//Test 5
testCases.push({characteristic: 0x00002a02, valueToWrite: [3], mustDisconnect: false});
//Test 6
testCases.push({characteristic: 0x00002a03, valueToWrite: [3], mustDisconnect: false});
//Test 7
testCases.push({characteristic: 0x00002a25, valueToWrite: [4], mustDisconnect: false});
//Test 8
testCases.push({characteristic: '00002a02-0000-1000-8000-00805f9b34fb', valueToWrite: [6], mustDisconnect: false});
//Test 9
testCases.push({characteristic: '00002a03-0000-1000-8000-00805f9b34fb', valueToWrite: [5], mustDisconnect: false});
//Test 10
testCases.push({characteristic: '00002a25-0000-1000-8000-00805f9b34fb', valueToWrite: [6], mustDisconnect: false});
//Test 11
testCases.push({characteristic: 0x2345, valueToWrite: [11]});
//Test 12
testCases.push({characteristic: '00002345-0000-1000-8000-00805f9b34fb', valueToWrite: [22], mustDisconnect: false});
function onButtonClick(testNumber) {
clear();
var bt_server;
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice({filters: [{services: [0x1234]}]})
.then(device => {
log('Connecting to GATT Server on device...');
return device.gatt.connect();
})
.then(server => {
bt_server = server;
log('Getting Primary Service...');
return server.getPrimaryService(0x1234);
})
.then(service => {
log('Getting Characteristic "' + testCases[testNumber].characteristic + '"...');
return service.getCharacteristic(testCases[testNumber].characteristic);
})
.then(characteristic => {
log('Characteristic found!');
log('Reading the old value of the Characteristic...');
return characteristic.readValue();
})
.then(value => {
log('> Characteristic value: ' + asciiToDecimal(characteristic.value));
if (testCases[testNumber].mustDisconnect) {
log('Disconnecting from server...');
bt_server.disconnect();
}
if (testNumber !== 1) {
log('Writing the value of the Characteristic with: ' + testCases[testNumber].valueToWrite + '...');
} else {
log('Writing the value of the Characteristic with a 513 long array...');
}
return characteristic.writeValue(testCases[testNumber].valueToWrite);
})
.then(_ => {
log('Reading the new value of the Characteristic...');
return characteristic.readValue();
})
.then(value => {
log('> Characteristic value: ' + asciiToDecimal(value));
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,63 +0,0 @@
<!DOCTYPE html>
<html>
<title>Descriptor info</title>
<body>
<input id="service" type="text" autofocus placeholder="Bluetooth Service">
<input id="characteristic" type="text" autofocus placeholder="Bluetooth Characteristic">
<input id="descriptor" type="text" autofocus placeholder="Bluetooth Descriptor">
<button type="button" onclick="onButtonClick()">Get Descriptor Info</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var serviceUuid = document.getElementById('service').value;
var characteristicUuid = document.getElementById('characteristic').value;
var descriptorUuid = document.getElementById('descriptor').value;
if (!serviceUuid || !characteristicUuid || !descriptorUuid) {
return log('All input field must be filled!');
}
if (serviceUuid.startsWith('0x'))
serviceUuid = parseInt(serviceUuid, 16);
if (characteristicUuid.startsWith('0x'))
characteristicUuid = parseInt(characteristicUuid, 16);
if (descriptorUuid.startsWith('0x'))
descriptorUuid = parseInt(descriptorUuid, 16);
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice({filters: [{services: [serviceUuid]}]})
.then(device => {
log('Connecting to GATT Server on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service...');
return server.getPrimaryService(serviceUuid);
})
.then(service => {
log('Getting Characteristic...');
return service.getCharacteristic(characteristicUuid);
})
.then(characteristic => {
log('Getting Descriptor...');
return characteristic.getDescriptor(descriptorUuid);
})
.then(descriptor => {
log('Descriptor found!');
log('> Descriptor characteristic: ' + descriptor.characteristic.uuid);
log('> Descriptor UUID: ' + descriptor.uuid);
return descriptor.readValue();
})
.then(value => {
log('> Descriptor value: ' + asciiToDecimal(value));
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,70 +0,0 @@
<!DOCTYPE html>
<html>
<title>Descriptor's ReadValue Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({descriptor: 'gatt.client_characteristic_configuration', mustDisconnect: true});
//Test 2
testCases.push({descriptor: 0x2902, mustDisconnect: true});
//Test 3
testCases.push({descriptor: '00002902-0000-1000-8000-00805f9b34fb', mustDisconnect: true});
//Test 4
testCases.push({descriptor: 'gatt.client_characteristic_configuration', mustDisconnect: false});
//Test 5
testCases.push({descriptor: 0x2902, mustDisconnect: false});
//Test 6
testCases.push({descriptor: '00002902-0000-1000-8000-00805f9b34fb', mustDisconnect: false});
function onButtonClick(testNumber) {
clear();
var bt_server;
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice({filters: [{services: ['heart_rate']}]})
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
bt_server = server;
log('Getting Primary Service "heart_rate"...');
return server.getPrimaryService('heart_rate');
})
.then(service => {
log('Getting Characteristic "heart_rate_measurement"...');
return service.getCharacteristic('heart_rate_measurement');
})
.then(characteristic => {
log('Getting Descriptor "' + testCases[testNumber].descriptor + '"...');
return characteristic.getDescriptor(testCases[testNumber].descriptor);
})
.then(descriptor => {
log('Descriptor found!');
if (testCases[testNumber].mustDisconnect) {
log('Disconecting from GATTserver');
bt_server.disconnect();
}
log("Reading descriptor's value...");
return descriptor.readValue();
})
.then(value => {
log('> Descriptor value: ' + asciiToDecimal(value));
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,88 +0,0 @@
<!DOCTYPE html>
<html>
<title>Descriptor's WriteValue Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({descriptor: '00003456-0000-1000-8000-00805f9b34fb', valueToWrite: [11], mustDisconnect: true});
//Test 2
testCases.push({descriptor: '00003456-0000-1000-8000-00805f9b34fb', valueToWrite: new Array(513), mustDisconnect: false});
//Test 3
testCases.push({descriptor: '00002902-0000-1000-8000-00805f9b34fb', valueToWrite: [1], mustDisconnect: false});
//Test 4
testCases.push({descriptor: 0x00002902, valueToWrite: [2], mustDisconnect: false});
//Test 5
testCases.push({descriptor: 0x3456, valueToWrite: [11], mustDisconnect: false});
//Test 6
testCases.push({descriptor: '00003456-0000-1000-8000-00805f9b34fb', valueToWrite: [22], mustDisconnect: false});
function onButtonClick(testNumber) {
clear();
var bt_server;
var bt_descriptor;
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice({filters: [{services: [0x1234]}]})
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
bt_server = server;
log('Getting Primary Service "Test Service"...');
return server.getPrimaryService(0x1234);
})
.then(service => {
log('Getting Characteristic "Test Characteristic (0x2345)"...');
return service.getCharacteristic(0x2345);
})
.then(characteristic => {
log('Characteristic found!');
log('Getting Descriptor "' + testCases[testNumber].descriptor + '"...');
return characteristic.getDescriptor(testCases[testNumber].descriptor);
})
.then(descriptor => {
bt_descriptor = descriptor;
log('Reading the old value of the Descriptor...');
return descriptor.readValue();
})
.then(value => {
log('> Descriptor value: ' + asciiToDecimal(value));
if (testCases[testNumber].mustDisconnect) {
log('Disconnecting from server...');
bt_server.disconnect();
}
if (testNumber !== 1) {
log('Writing the value of the Descriptor with: ' + testCases[testNumber].valueToWrite + '...');
} else {
log('Writing the value of the Descriptor with a 513 long array...');
}
return bt_descriptor.writeValue(testCases[testNumber].valueToWrite);
})
.then(_ => {
log('Reading the new value of the Descriptor...');
return bt_descriptor.readValue();
})
.then(value => {
log('> Descriptor value: ' + asciiToDecimal(value));
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,92 +0,0 @@
<!DOCTYPE html>
<html>
<title>Device Disconnect</title>
<body>
<input id="service" type="text" autofocus placeholder="Bluetooth Service">
<input id="name" type="text" placeholder="Device Name">
<input id="namePrefix" type="text" placeholder="Device Name Prefix">
<button type="button" onclick="onScanButtonClick()">Scan()</button>
<button type="button" onclick="onDisconnectButtonClick()">Disconnect()</button>
<button type="button" onclick="onReconnectButtonClick()">Reconnect()</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var bluetoothDevice;
function onScanButtonClick() {
clear();
var options = {filters: [{}]};
var filterService = document.getElementById('service').value;
if (filterService) {
if (filterService.startsWith('0x'))
filterService = parseInt(filterService, 16);
options.filters[0].services = [filterService];
}
var filterName = document.getElementById('name').value;
if (filterName)
options.filters[0].name = filterName;
var filterNamePrefix = document.getElementById('namePrefix').value;
if (filterNamePrefix)
options.filters[0].namePrefix = filterNamePrefix;
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(options)
.then(device => {
bluetoothDevice = device;
log('Connecting to Bluetooth Device...');
connect();
})
.catch(err => {
log(err);
});
}
function onDisconnectButtonClick() {
clear();
if (!bluetoothDevice)
return log('> There is no connected Bluetooth Device instance, from which we can disconnect');
try {
log('Disconnecting from Bluetooth Device...');
if (bluetoothDevice.gatt.connected) {
bluetoothDevice.gatt.disconnect();
log('> Bluetooth Device connected: ' + bluetoothDevice.gatt.connected);
} else {
log('> Bluetooth Device is already disconnected');
}
} catch(err) {
log(err);
}
}
function onReconnectButtonClick() {
clear();
if (!bluetoothDevice)
log('> There is no connected Bluetooth Device instance, so we cannot reconnect')
if (bluetoothDevice.gatt.connected) {
log('> Bluetooth Device is already connected');
return;
} else {
log('Connecting to Bluetooth Device...');
connect();
}
}
function connect() {
bluetoothDevice.gatt.connect()
.then(server => {
log('Result of the connect() method of the GATT Server: ' + server);
log('> Bluetooth Device connected: ' + server.connected);
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,47 +0,0 @@
<!DOCTYPE html>
<html>
<title>Device Info</title>
<body>
<input id="service" type="text" autofocus placeholder="Bluetooth Service">
<input id="name" type="text" placeholder="Device Name">
<input id="namePrefix" type="text" placeholder="Device Name Prefix">
<button type="button" onclick="onButtonClick()">Get Bluetooth Device Info</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var options = {filters: [], optionalServices: []};
var filterService = document.getElementById('service').value;
if (filterService) {
if (filterService.startsWith('0x'))
filterService = parseInt(filterService, 16);
options.filters.push({services: [filterService]});
}
var filterName = document.getElementById('name').value;
if (filterName)
options.filters.push({name: filterName});
var filterNamePrefix = document.getElementById('namePrefix').value;
if (filterNamePrefix)
options.filters.push({namePrefix: filterNamePrefix});
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(options)
.then(device => {
log('Found a device!');
log('> Name: ' + device.name);
log('> Id: ' + device.id);
log('> Appearance: ' + device.adData.appearance);
log('> Tx Power: ' + device.adData.txPower + ' dBm');
log('> RSSI: ' + device.adData.rssi + ' dBm');
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,32 +0,0 @@
function clear() {
document.getElementById("log").textContent = "";
}
function log(line) {
document.getElementById("log").textContent += timeStamp() + line + '\n';
}
function asciiToDecimal(bytestr) {
var result = [];
for(i = 0; i < bytestr.length; i++) {
result[i] = bytestr.charCodeAt(i) ;
}
return result;
}
function populate(testCases){
for(i = 0; i < testCases.length; ++i) {
var btn = document.createElement('button');
btn.setAttribute('onclick','onButtonClick(' + i + ')');
btn.innerHTML = 'Test '+ (i+1);
document.getElementById('buttons').appendChild(btn);
}
}
function timeStamp() {
var date = new Date;
var hours = date.getHours();
var minutes = "0" + date.getMinutes();
var seconds = "0" + date.getSeconds();
return hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2) + ' ';
}

Просмотреть файл

@ -1,88 +0,0 @@
<!DOCTYPE html>
<html>
<title>GetCharacteristic Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({characteristic: 'not_a_characteristic_name', service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 2
testCases.push({characteristic: 'battery_level', service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 3
testCases.push({characteristic: '1234567891000-1000-8000-00805f9b34fb', service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 4
testCases.push({characteristic: '11', service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 5
testCases.push({characteristic: '12345678-1234-1234-1234-123456789abc', service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 6
testCases.push({characteristic: '00000000-0000-0000-0000-000000000000', service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 7
testCases.push({characteristic: 0x0000, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 8
testCases.push({characteristic: 0x000000000, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 9
testCases.push({characteristic: 0x2a19, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 10
testCases.push({characteristic: 0x12345678, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 11
testCases.push({characteristic: 0x00002a19, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 12
testCases.push({characteristic: 0x00002a03, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 13
testCases.push({characteristic: 0x00002a25, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 14
testCases.push({characteristic: 0x2a03, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 15
testCases.push({characteristic: 0x2a25, service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 16
testCases.push({characteristic: '00002a03-0000-1000-8000-00805f9b34fb', service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 17
testCases.push({characteristic: '00002a25-0000-1000-8000-00805f9b34fb', service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(testCases[testNumber].options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service "' + testCases[testNumber].service + '"...');
return server.getPrimaryService(testCases[testNumber].service);
})
.then(service => {
log('Getting Characteristic "' + testCases[testNumber].characteristic + '"...');
return service.getCharacteristic(testCases[testNumber].characteristic);
})
.then(characteristic => {
log('Characteristic found!');
log('> Characteristic service: ' + characteristic.service.uuid);
log('> Characteristic UUID: ' + characteristic.uuid);
log('> Broadcast: ' + characteristic.properties.broadcast);
log('> Read: ' + characteristic.properties.read);
log('> Write w/o response: ' + characteristic.properties.writeWithoutResponse);
log('> Write: ' + characteristic.properties.write);
log('> Notify: ' + characteristic.properties.notify);
log('> Indicate: ' + characteristic.properties.indicate);
log('> Signed Write: ' + characteristic.properties.authenticatedSignedWrites);
log('> Queued Write: ' + characteristic.properties.reliableWrite);
log('> Writable Auxiliaries: ' + characteristic.properties.writableAuxiliaries);
return characteristic.readValue();
})
.then(value => {
log('> Characteristic value: ' + asciiToDecimal(value));
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,94 +0,0 @@
<!DOCTYPE html>
<html>
<title>GetCharacteristics Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({service: 'battery_service', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 2
testCases.push({characteristic: 'not_a_characteristic_name', service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 3
testCases.push({characteristic: 'body_sensor_location', service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 4
testCases.push({characteristic: '1234567891000-1000-8000-00805f9b34fb', service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 5
testCases.push({characteristic: '11', service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 6
testCases.push({characteristic: '12345678-1234-1234-1234-123456789abc', service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 7
testCases.push({characteristic: '00000000-0000-0000-0000-000000000000', service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 8
testCases.push({characteristic: 0x0000, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 9
testCases.push({characteristic: 0x000000000, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 10
testCases.push({characteristic: 0x2a38, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 11
testCases.push({characteristic: 0x12345678, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 12
testCases.push({characteristic: 0x00002a38, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 13
testCases.push({characteristic: 0x00002a03, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 14
testCases.push({characteristic: 0x00002a25, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 15
testCases.push({characteristic: 0x2a03, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 16
testCases.push({characteristic: 0x2a25, service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 17
testCases.push({characteristic: '00002a03-0000-1000-8000-00805f9b34fb', service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
//Test 18
testCases.push({characteristic: '00002a25-0000-1000-8000-00805f9b34fb', service: 'heart_rate', options: {filters: [{services: ['heart_rate']}], optionalServices: ['cycling_power']} });
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(testCases[testNumber].options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service "' + testCases[testNumber].service + '"...');
return server.getPrimaryService(testCases[testNumber].service);
})
.then(service => {
log('Getting Characteristic "' + testCases[testNumber].characteristic + '"...');
return service.getCharacteristics(testCases[testNumber].characteristic);
})
.then(characteristics => {
log('> List of Characteristics on the current device:');
for(i = 0; i < characteristics.length; ++i) {
log('> #' + (i+1));
log('> Characteristic service: ' + characteristics[i].service.uuid);
log('> Characteristic UUID: ' + characteristics[i].uuid);
log('> Broadcast: ' + characteristics[i].properties.broadcast);
log('> Read: ' + characteristics[i].properties.read);
log('> Write w/o response: ' + characteristics[i].properties.writeWithoutResponse);
log('> Write: ' + characteristics[i].properties.write);
log('> Notify: ' + characteristics[i].properties.notify);
log('> Indicate: ' + characteristics[i].properties.indicate);
log('> Signed Write: ' + characteristics[i].properties.authenticatedSignedWrites);
log('> Queued Write: ' + characteristics[i].properties.reliableWrite);
log('> Writable Auxiliaries: ' + characteristics[i].properties.writableAuxiliaries);
characteristics[i].readValue()
.then(value => {
log('> #' + (i+1) + ' Characteristic value: ' + asciiToDecimal(characteristics[i].value));
});
}
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,74 +0,0 @@
<!DOCTYPE html>
<html>
<title>GetDescriptor Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push('not_a_descriptor_name');
//Test 2
testCases.push('gatt.client_characteristic_configuration');
//Test 3
testCases.push('1234567891000-1000-8000-00805f9b34fb');
//Test 4
testCases.push('11');
//Test 5
testCases.push('12345678-1234-1234-1234-123456789abc');
//Test 6
testCases.push('00000000-0000-0000-0000-000000000000');
//Test 7
testCases.push(0x0000);
//Test 8
testCases.push(0x00000000);
//Test 9
testCases.push(0x2902);
//Test 10
testCases.push('00002902-0000-1000-8000-00805f9b34fb');
//Test 11
testCases.push(0x12345678);
//Test 12
testCases.push(0x00002902);
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice({filters: [{services: ['heart_rate']}]})
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service "heart_rate"...');
return server.getPrimaryService('heart_rate');
})
.then(service => {
log('Getting Characteristic "heart_rate_measurement"...');
return service.getCharacteristic('heart_rate_measurement');
})
.then(characteristic => {
log('Getting Descriptor "' + testCases[testNumber] + '"...');
return characteristic.getDescriptor(testCases[testNumber]);
})
.then(descriptor => {
log('Descriptor found!');
log('> Descriptor characteristic: ' + descriptor.characteristic.uuid);
log('> Descriptor UUID: ' + descriptor.uuid);
return descriptor.readValue();
})
.then(value => {
log('> Descriptor value: ' + asciiToDecimal(value));
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,76 +0,0 @@
<!DOCTYPE html>
<html>
<title>GetDescriptors Test Cases</title>
<body>
<div id="buttons"></div>
<button onclick="onButtonClick2()">Test 12</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push('not_a_descriptor_name');
//Test 2
testCases.push('gatt.client_characteristic_configuration');
//Test 3
testCases.push('1234567891000-1000-8000-00805f9b34fb');
//Test 4
testCases.push('11');
//Test 5
testCases.push('12345678-1234-1234-1234-123456789abc');
//Test 6
testCases.push('00000000-0000-0000-0000-000000000000');
//Test 7
testCases.push(0x0000);
//Test 8
testCases.push(0x00000000);
//Test 9
testCases.push(0x2902);
//Test 10
testCases.push(0x12345678);
//Test 11
testCases.push(0x00002902);
//Test 12
testCases.push(undefined);
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice({filters: [{services: ['heart_rate']}]})
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service "heart_rate"...');
return server.getPrimaryService('heart_rate');
})
.then(service => {
log('Getting Characteristic "heart_rate_measurement"...');
return service.getCharacteristic('heart_rate_measurement');
})
.then(characteristic => {
log('Getting Descriptors "' + testCases[testNumber] + '"...');
return characteristic.getDescriptors(testCases[testNumber]);
})
.then(descriptors => {
for(i = 0; i < descriptors.length; ++i) {
log('> #' + (i+1));
log('> UUID: ' + descriptors[i].uuid);
descriptors[i].readValue()
.then(value => {
log('> #' + (i+1)) + 'Descriptor value: ' + asciiToDecimal(value);
});
}
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,71 +0,0 @@
<!DOCTYPE html>
<html>
<title>GetIncludedService Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 'not_a_service_name', options: {filters: [{services: ['battery_service']}]} });
//Test 2
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '1234567891000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
//Test 3
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '11', options: {filters: [{services: ['battery_service']}]} });
//Test 4
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '12345678-1234-1234-1234-123456789abc', options: {filters: [{services: ['battery_service']}]} });
//Test 5
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00000000-0000-0000-0000-000000000000', options: {filters: [{services: ['battery_service']}]} });
//Test 6
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x0000, options: {filters: [{services: ['battery_service']}]} });
//Test 7
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00000000, options: {filters: [{services: ['battery_service']}]} });
//Test 8
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x12345678, options: {filters: [{services: ['battery_service']}]} });
//Test 9
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x0000180f, options: {filters: [{services: ['battery_service']}]} });
//Test 10
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00001812-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
//Test 11
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 'f000ffc0-0451-4000-b000-000000000000', options: {filters: [{services: ['battery_service']}]} });
//Test 12
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00001530-1212-efde-1523-785feabcd123', options: {filters: [{services: ['battery_service']}]} });
//Test 13
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00001812, options: {filters: [{services: ['battery_service']}]} });
//Test 14
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0xf000ffc0, options: {filters: [{services: ['battery_service']}]} });
//Test 15
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00001530, options: {filters: [{services: ['battery_service']}]} });
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(testCases[testNumber].options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service "' + testCases[testNumber].requestedService + '"...');
return server.getPrimaryService(testCases[testNumber].requestedService);
})
.then(service => {
log('Getting Included Service "' + testCases[testNumber].requestedIncludedService + '"...')
return service.getIncludedService(testCases[testNumber].requestedIncludedService);
})
.then(includedService => {
log('Primary Service found on device: ' + includedService.device.name);
log('> UUID: ' + includedService.uuid);
log('> Is primary: ' + includedService.isPrimary);
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,73 +0,0 @@
<!DOCTYPE html>
<html>
<title>GetIncludedServices Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 'not_a_service_name', options: {filters: [{services: ['battery_service']}]} });
//Test 2
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '1234567891000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
//Test 3
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '11', options: {filters: [{services: ['battery_service']}]} });
//Test 4
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '12345678-1234-1234-1234-123456789abc', options: {filters: [{services: ['battery_service']}]} });
//Test 5
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00000000-0000-0000-0000-000000000000', options: {filters: [{services: ['battery_service']}]} });
//Test 6
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x0000, options: {filters: [{services: ['battery_service']}]} });
//Test 7
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00000000, options: {filters: [{services: ['battery_service']}]} });
//Test 8
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x12345678, options: {filters: [{services: ['battery_service']}]} });
//Test 9
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x0000180f, options: {filters: [{services: ['battery_service']}]} });
//Test 10
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00001812-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
//Test 11
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 'f000ffc0-0451-4000-b000-000000000000', options: {filters: [{services: ['battery_service']}]} });
//Test 12
testCases.push({ requestedService: 'battery_service', requestedIncludedService: '00001530-1212-efde-1523-785feabcd123', options: {filters: [{services: ['battery_service']}]} });
//Test 13
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00001812, options: {filters: [{services: ['battery_service']}]} });
//Test 14
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0xf000ffc0, options: {filters: [{services: ['battery_service']}]} });
//Test 15
testCases.push({ requestedService: 'battery_service', requestedIncludedService: 0x00001530, options: {filters: [{services: ['battery_service']}]} });
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(testCases[testNumber].options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service "' + testCases[testNumber].requestedService + '"...');
return server.getPrimaryService(testCases[testNumber].requestedService);
})
.then(service => {
log('Getting Included Service "' + testCases[testNumber].requestedIncludedService + '"...')
return service.getIncludedServices(testCases[testNumber].requestedIncludedService);
})
.then(includedServices => {
for(i = 0; i < includedServices.length; ++i) {
log('> #' + (i+1));
log('> UUID: ' + includedServices[i].uuid);
log('> Is primary: ' + includedServices[i].isPrimary);
}
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,77 +0,0 @@
<!DOCTYPE html>
<html>
<title>GetPrimaryService Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({ requestedService: 'heart_rate', options: {filters: [{services: ['battery_service']}]} });
//Test 2
testCases.push({ requestedService: 'heart_rate', options: {filters: [{services: ['battery_service', 'heart_rate']}]} });
//Test 3
testCases.push({ requestedService: 'not_a_service_name', options: {filters: [{services: ['battery_service']}]} });
//Test 4
testCases.push({ requestedService: 'battery_service', options: {filters: [{services: ['battery_service']}]} });
//Test 5
testCases.push({ requestedService: '1234567891000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
//Test 6
testCases.push({ requestedService: '11', options: {filters: [{services: ['battery_service']}]} });
//Test 7
testCases.push({ requestedService: '12345678-1234-1234-1234-123456789abc', options: {filters: [{services: ['battery_service']}]} });
//Test 8
testCases.push({ requestedService: 0x0000, options: {filters: [{services: ['battery_service']}]} });
//Test 9
testCases.push({ requestedService: 0x00000000, options: {filters: [{services: ['battery_service']}]} });
//Test 10
testCases.push({ requestedService: 0x180f, options: {filters: [{services: ['battery_service']}]} });
//Test 11
testCases.push({ requestedService: 0x12345678, options: {filters: [{services: ['battery_service']}]} });
//Test 12
testCases.push({ requestedService: 0x0000180f, options: {filters: [{services: ['battery_service']}]} });
//Test 13
testCases.push({ requestedService: 0x00001812, options: {filters: [{services: ['battery_service']}]} });
//Test 14
testCases.push({ requestedService: 'f000ffc0-0451-4000-b000-000000000000', options: {filters: [{services: ['battery_service']}]} });
//Test 15
testCases.push({ requestedService: '00001530-1212-efde-1523-785feabcd123', options: {filters: [{services: ['battery_service']}]} });
//Test 16
testCases.push({ requestedService: 0xf000ffc0, options: {filters: [{services: ['battery_service']}], optionalServices: [0xf000ffc0]} });
//Test 17
testCases.push({ requestedService: 0x00001530, options: {filters: [{services: ['battery_service']}], optionalServices: [0x00001530]} });
//Test 18
testCases.push({ requestedService: '0000180f-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
//Test 19
testCases.push({ requestedService: 'cycling_power', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 20
testCases.push({ requestedService: '00001818-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(testCases[testNumber].options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service "' + testCases[testNumber].requestedService + '"...');
return server.getPrimaryService(testCases[testNumber].requestedService);
})
.then(service => {
log('Primary Service found on device: ' + service.device.name);
log('> UUID: ' + service.uuid);
log('> Is primary: ' + service.isPrimary);
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,79 +0,0 @@
<!DOCTYPE html>
<html>
<title>GetPrimaryServices Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({ requestedService: 'heart_rate', options: {filters: [{services: ['battery_service']}]} });
//Test 2
testCases.push({ requestedService: 'not_a_service_name', options: {filters: [{services: ['battery_service']}]} });
//Test 3
testCases.push({ requestedService: 'battery_service', options: {filters: [{services: ['battery_service']}]} });
//Test 4
testCases.push({ requestedService: '1234567891000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
//Test 5
testCases.push({ requestedService: '11', options: {filters: [{services: ['battery_service']}]} });
//Test 6
testCases.push({ requestedService: '12345678-1234-1234-1234-123456789abc', options: {filters: [{services: ['battery_service']}]} });
//Test 7
testCases.push({ requestedService: '00000000-0000-0000-0000-000000000000', options: {filters: [{services: ['battery_service']}]} });
//Test 8
testCases.push({ requestedService: 0x0000, options: {filters: [{services: ['battery_service']}]} });
//Test 9
testCases.push({ requestedService: 0x00000000, options: {filters: [{services: ['battery_service']}]} });
//Test 10
testCases.push({ requestedService: 0x180f, options: {filters: [{services: ['battery_service']}]} });
//Test 11
testCases.push({ requestedService: 0x12345678, options: {filters: [{services: ['battery_service']}]} });
//Test 12
testCases.push({ requestedService: 0x0000180f, options: {filters: [{services: ['battery_service']}]} });
//Test 13
testCases.push({ requestedService: 0x00001812, options: {filters: [{services: ['battery_service']}]} });
//Test 14
testCases.push({ requestedService: 'f000ffc0-0451-4000-b000-000000000000', options: {filters: [{services: ['battery_service']}]} });
//Test 15
testCases.push({ requestedService: '00001530-1212-efde-1523-785feabcd123', options: {filters: [{services: ['battery_service']}]} });
//Test 16
testCases.push({ requestedService: 0xf000ffc0, options: {filters: [{services: ['battery_service']}], optionalServices: [0xf000ffc0]} });
//Test 17
testCases.push({ requestedService: 0x00001530, options: {filters: [{services: ['battery_service']}], optionalServices: [0x00001530]} });
//Test 18
testCases.push({ requestedService: '0000180f-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}]} });
//Test 19
testCases.push({ requestedService: 'cycling_power', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
//Test 20
testCases.push({ requestedService: '00001818-0000-1000-8000-00805f9b34fb', options: {filters: [{services: ['battery_service']}], optionalServices: ['cycling_power']} });
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(testCases[testNumber].options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service "' + testCases[testNumber].requestedService + '"...');
return server.getPrimaryServices(testCases[testNumber].requestedService);
})
.then(services => {
for(i = 0; i < services.length; ++i) {
log('> #' + (i+1));
log('> UUID: ' + services[i].uuid);
log('> Is primary: ' + services[i].isPrimary);
}
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>

Просмотреть файл

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html>
<title>Included Service info</title>
<body>
<input id="service" type="text" autofocus placeholder="Bluetooth Service">
<input id="name" type="text" placeholder="Device Name">
<input id="namePrefix" type="text" placeholder="Device Name Prefix">
<button type="button" onclick="onButtonClick()">Get Primary Service Info</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var options = {filters: [], optionalServices: []};
var filterService = document.getElementById('service').value;
if (filterService) {
if (filterService.startsWith('0x'))
filterService = parseInt(filterService, 16);
options.filters.push({services: [filterService]});
}
var filterName = document.getElementById('name').value;
if (filterName)
options.filters.push({name: filterName});
var filterNamePrefix = document.getElementById('namePrefix').value;
if (filterNamePrefix)
options.filters.push({namePrefix: filterNamePrefix});
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service...');
return server.getPrimaryService(filterService);
})
.then(service => {
log('Primary Service found on device: ' + service.device.name);
log('> UUID: ' + service.uuid);
log('Getting Included Services...');
return service.getIncludedServices();
})
.then(includedServices => {
log('> Included Services: ' +
includedServices.map(s => s.uuid).join('\n' + ' '.repeat(21)));
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,52 +0,0 @@
<!DOCTYPE html>
<html>
<title>Primary Service info</title>
<body>
<input id="service" type="text" autofocus placeholder="Bluetooth Service">
<input id="name" type="text" placeholder="Device Name">
<input id="namePrefix" type="text" placeholder="Device Name Prefix">
<button type="button" onclick="onButtonClick()">Get Primary Service Info</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var options = {filters: [], optionalServices: []};
var filterService = document.getElementById('service').value;
if (filterService) {
if (filterService.startsWith('0x'))
filterService = parseInt(filterService, 16);
options.filters.push({services: [filterService]});
}
var filterName = document.getElementById('name').value;
if (filterName)
options.filters.push({name: filterName});
var filterNamePrefix = document.getElementById('namePrefix').value;
if (filterNamePrefix)
options.filters.push({namePrefix: filterNamePrefix});
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service...');
return server.getPrimaryService(filterService);
})
.then(service => {
log('Primary Service found on device: ' + service.device.name);
log('> UUID: ' + service.uuid);
log('> Is primary: ' + service.isPrimary);
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html>
<title>Primary Services info</title>
<body>
<input id="service" type="text" autofocus placeholder="Bluetooth Service">
<input id="name" type="text" placeholder="Device Name">
<input id="namePrefix" type="text" placeholder="Device Name Prefix">
<button type="button" onclick="onButtonClick()">Get Primary Services Info</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var options = {filters: [], optionalServices: []};
var filterService = document.getElementById('service').value;
if (filterService) {
if (filterService.startsWith('0x'))
filterService = parseInt(filterService, 16);
options.filters.push({services: [filterService]});
}
var filterName = document.getElementById('name').value;
if (filterName)
options.filters.push({name: filterName});
var filterNamePrefix = document.getElementById('namePrefix').value;
if (filterNamePrefix)
options.filters.push({namePrefix: filterNamePrefix});
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(options)
.then(device => {
log('Connecting to GATTserver on device...');
return device.gatt.connect();
})
.then(server => {
log('Getting Primary Service...');
if (filterService)
return server.getPrimaryServices(filterService);
else
return server.getPrimaryServices();
})
.then(services => {
log('> List of Services on the current device:');
for(i = 0; i < services.length; ++i) {
log('> #' + (i+1));
log('> UUID: ' + services[i].uuid);
log('> Is primary: ' + services[i].isPrimary);
}
})
.catch(err => {
log(err);
});
}
</script>
</body>
</html>

Просмотреть файл

@ -1,28 +0,0 @@
<!DOCTYPE html>
<html>
<title>Request All Devices</title>
<body>
<button type="button" onclick="onButtonClick()">Request All Devices</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var options = {optionalServices: ['generic_access'], acceptAllDevices:true};
try {
log('Requesting Bluetooth Device...');
var bluetooth = window.navigator.bluetooth;
var device = bluetooth.requestDevice(options);
log('Connecting to GATT Server on device...');
var server = device.gatt.connect();
log('Getting Generic Access Service...');
var service = server.getPrimaryService('generic_access');
} catch(err) {
log(err);
}
}
</script>
</body>
</html>

Просмотреть файл

@ -1,74 +0,0 @@
<!DOCTYPE html>
<html>
<title>RequestDevice Test Cases</title>
<body>
<div id="buttons"></div>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
var testCases = [];
//Test 1
testCases.push({filters: []});
//Test 2
testCases.push({filters: [{notExpectedMember: []}]});
//Test 3
testCases.push({filters: [{services: ['battery_service']}]});
//Test 4
testCases.push({filters: [{name: 'raspberrypi'}]});
//Test 5
testCases.push({filters: [{namePrefix: 'rasp'}]});
//Test 6
testCases.push({filters:[{services: []}]});
//Test 7
testCases.push({filters:[{services: [], namePrefix:'rasp'}]});
//Test 8
testCases.push({filters: [{services: ['not_a_service_name']}]});
//Test 9
testCases.push({filters: [{services: ['1234567891000-1000-8000-00805f9b34fb']}]});
//Test 10
testCases.push({filters: [{services: ['12345678-1234-1234-1234-123456789abc']}]});
//Test 11
testCases.push({filters: [{services: [0x0000]}]});
//Test 12
testCases.push({filters: [{services: [0x180f]}]});
//Test 13
testCases.push({filters: [{services: [0x12345678]}]});
//Test 14
testCases.push({filters: [{services: [0x00001812]}]});
//Test 15
testCases.push({filters: [{services: ['f000ffc0-0451-4000-b000-000000000000']}]});
//Test 16
testCases.push({filters: [{name: 'this_device_name_is_longer_than_29_bytes'}]});
//Test 17
testCases.push({filters: [{namePrefix: 'this_device_name_prefix_is_longer_than_29_bytes'}]});
//Test 18
testCases.push({filters: [{namePrefix: ''}]});
//Test 19
testCases.push({filters: [{namePrefix: 'rasp'}], optionalServices: ['1234567891000-1000-8000-00805f9b34fb']});
//Test 20
testCases.push({filters: [{namePrefix: 'rasp'}], optionalServices: ['12345678-1234-1234-1234-123456789abc']});
//Test 21
testCases.push({filters: [{namePrefix: 'rasp'}], optionalServices: ['f000ffc0-0451-4000-b000-000000000000', 0x1812]});
function onButtonClick(testNumber) {
clear();
log('Requesting Bluetooth Device...');
window.navigator.bluetooth.requestDevice(testCases[testNumber])
.then(device => {
log('Found a device!');
log('> Name: ' + device.name);
log('> Id: ' + device.id);
log('> Appearance: ' + device.adData.appearance);
log('> Tx Power: ' + device.adData.txPower + ' dBm');
log('> RSSI: ' + device.adData.rssi + ' dBm');
})
.catch(err => {
log(err);
});
}
populate(testCases);
</script>
</body>
</html>