Я пытаюсь создать хром-приложение, которое отображается, когда определенное устройство Bluetooth отправляет данные. в частности, у меня есть 2 мыши bluetooth, и я хочу определить, какой из них перемещается в определенное время. Я следовал за Chrome dev doc и был успешным, пока не попытался реализовать добавление слушателя при приеме для просмотра данных, поступающих с устройства. Я получаю сообщение «Не могу прочитать свойство» addListener «неопределенной» ошибки.Chrome App bluetooth
Это когда я начал получать эту ошибку: Error message
Вот код, я работаю с
chrome.bluetooth.getDevices(function(devices) {
for (var i = 0; i < devices.length; i++) {
//Displaying device names
console.log(i+": "+devices[i].name);
}
//uuid for a specific device
var uuid = "00001200-0000-1000-8000-00805f9b34fb";
// var uuid = devices[4].uuid;
var onConnectedCallback = function() {
if (chrome.runtime.lastError) {
console.log("Connection failed: " + chrome.runtime.lastError.message);
} else {
// Profile implementation here.
}
};
chrome.bluetoothSocket.create(function(createInfo) {
chrome.bluetoothSocket.connect(createInfo.socketId,
devices[4].address, uuid, onConnectedCallback);
console.log(createInfo);
chrome.bluetoothSocket.onRecieve.addListener(function(receiveInfo) {
if (receiveInfo.socketId != socketId)
return;
console.log(receiveInfo);
});
});
});