Files
servo/tests/html/bluetooth/bluetooth_characteristic_read_value_test_cases.html
2016-07-28 14:26:23 +02:00

67 lines
2.5 KiB
HTML

<!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();
try {
log('Requesting Bluetooth Device...');
var device = window.navigator.bluetooth.requestDevice({filters: [{services: ['heart_rate']}]});
log('Connecting to GATTserver on device...');
var server = device.gatt.connect();
log('Getting Primary Service "heart_rate"...');
var primaryService = server.getPrimaryService('heart_rate');
log('Getting Characteristic "' + testCases[testNumber].characteristic + '"...');
var characteristic = primaryService.getCharacteristic(testCases[testNumber].characteristic);
log('Characteristic found!');
if (testCases[testNumber].mustDisconnect) {
log('Disconnecting from server...');
device.gatt.disconnect();
}
log('Reading the value of the Characteristic...');
characteristic.readValue();
log('> Characteristic value: ' + asciiToDecimal(characteristic.value));
} catch(err) {
log(err);
}
}
populate(testCases);
</script>
</body>
</html>