mirror of
https://github.com/servo/servo
synced 2026-04-28 02:19:14 +02:00
77 lines
2.3 KiB
HTML
77 lines
2.3 KiB
HTML
<!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>
|