mirror of
https://github.com/servo/servo.git
synced 2025-06-28 02:53:48 +01:00
94 lines
5.7 KiB
HTML
94 lines
5.7 KiB
HTML
<!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>
|