W3C home > Mailing lists > Public > public-web-bluetooth-log@w3.org > July 2017

[web-bluetooth] errorSecurityError: Origin is not allowed to access the service. Tip: Add the service UUID to 'optionalServices' in requestDevice() options. https://goo.gl/HxfxSQ

From: Zhangrui via GitHub <sysbot+gh@w3.org>
Date: Mon, 17 Jul 2017 07:03:52 +0000
To: public-web-bluetooth-log@w3.org
Message-ID: <issues.opened-243310513-1500275030-sysbot+gh@w3.org>
brave2016 has just created a new issue for https://github.com/WebBluetoothCG/web-bluetooth:

== errorSecurityError: Origin is not allowed to access the service. Tip: Add the service UUID to 'optionalServices' in requestDevice() options. https://goo.gl/HxfxSQ ==
function search(){
	document.getElementById("demo").innerHTML="My First JavaScript";
	let options = {};
	let filters = [];
	let filterName = document.querySelector('#name').value;
  if (filterName) {
    filters.push({name: filterName});
	 options.filters = filters;
  }else{
  options.acceptAllDevices = true;
  }
  
	navigator.bluetooth.requestDevice(options).then(device => {
			console.log('Got device:', device.name);
			console.log('id:', device.id);
			console.log('Connected:' + device.gatt.connected);
			console.log('Connected:' + device.gatt.connected);
			document.getElementById("demo").innerHTML="My First JavaScript"+device.name;
	return	device.gatt.connect();
		       
			}).then(server => {
				document.getElementById("service").innerHTML="trurservcice";
			
			 return server.getPrimaryService('00000000-0000-1000-8000-00805f9b34fb');
			}).then(service => {
			
			return Promise.all([
			
	              service.getCharacteristic('00000002-0000-1000-8000-00805f9b34fb'),
				  
				  service.getCharacteristic('00000003-0000-1000-8000-00805f9b34fb').then(read)
			
			]);
	
             })
			
			.catch(error => {
			document.getElementById("demo").innerHTML="error"+error;
			});
	
}

function read(characteristic){
    return characteristic.startNotifications()
    .then(char => {
	   characteristic.addEventListener('characteristicvaluechanged',
                                    onHeartRateChanged);
    });
}

function onHeartRateChanged(event) {
  let characteristic = event.target;
  console.log(parseHeartRate(characteristic.value));
  document.getElementById("data").innerHTML="D"+characteristic.value;
}

Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/issues/370 using your GitHub account
Received on Monday, 17 July 2017 07:03:59 UTC

This archive was generated by hypermail 2.3.1 : Monday, 17 July 2017 07:04:00 UTC