"GATT Error Unknown"
See original GitHub issueHi, I’m not sure where this issue lie, but I’m running a simple peripheral with bleno which I can connect to from a web app, but as soon as I try to read from or write to my characteristic, I get:
(index):1 Uncaught (in promise) DOMException: GATT Error Unknown.
My Node code looks like this:
//// SERVICE
var BlenoPrimaryService = bleno.PrimaryService;
var RemoteCharacteristic = require('./remote-characteristic');
function RemoteService() {
RemoteService.super_.call(this, {
uuid: '180E',
characteristics: [
new RemoteCharacteristic()
]
});
}
util.inherits(RemoteService, BlenoPrimaryService);
module.exports = RemoteService;
//// CHARACTERISTIC
var Descriptor = bleno.Descriptor;
var Characteristic = bleno.Characteristic;
var RemoteCharacteristic = function() {
RemoteCharacteristic.super_.call(this, {
uuid: '2A19',
properties: ['read', 'write'],
descriptors: [
new Descriptor({
uuid: '2901',
value: 'Remote control'
})
]
});
};
util.inherits(RemoteCharacteristic, Characteristic);
RemoteCharacteristic.prototype.onReadRequest = function(offset, callback) {
// return hardcoded value just for testing
callback(this.RESULT_SUCCESS, new Buffer([98]));
};
RemoteCharacteristic.prototype.onWriteRequest = function(data, offset, withoutResponse, callback) {
if (offset) {
callback(this.RESULT_ATTR_NOT_LONG);
}
else if (data.length !== 1) {
callback(this.RESULT_INVALID_ATTRIBUTE_LENGTH);
}
else {
var button = data.getUint8(0);
console.log('button', button);
switch (button) {
case 1:
console.log('left');
break;
case 2:
console.log('right');
break;
}
callback(this.RESULT_SUCCESS);
}
};
module.exports = RemoteCharacteristic;
My central code - I’m using Web Bluetooth - looks like this:
var serviceUuid = 0x180E;
var charUuid = 0x2A19;
var characteristic;
function connect() {
navigator.bluetooth.requestDevice({
filters: [{ services: [serviceUuid] }]
})
.then(function(device) {
return device.gatt.connect();
})
.then(function(server) {
return server.getPrimaryService(serviceUuid);
})
.then(function(service) {
return service.getCharacteristic(charUuid);
})
.then(function(char) {
characteristic = char;
});
}
function write(cmd) {
characteristic.writeValue(cmd);
}
function left() {
var cmd = new Uint8Array(1);
cmd[0] = 1;
write(cmd);
}
function right() {
var cmd = new Uint8Array(1);
cmd[0] = 2;
write(cmd);
}
(I’ve tried just reading a value too but it’s the same).
(Full code: https://github.com/poshaughnessy/over-the-air-2016-hack)
(I also tried the pizza example and got another error with that: https://github.com/strangesast/bleno-web-pizza-example/issues/3)
Thanks in advance!
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
NotSupportedError: GATT Error unknown when writing to ...
I am using Angular version 7 on windows 10 and @types/web-bluetooth package. My App was working as expected. The data was being written...
Read more >NotSupportedError: GATT Error Unknown - Stack Overflow
I am trying to write data which is 490 in length to a device using Web Bluetooth API. When I try to write...
Read more >bluetooth: Make "GATT Error Unknown" message more specific
1. Make sure nearby device is not paired yet. 2. Attempt to write a value to a characteristic that requires encryption. What is...
Read more >How to fix: localhost/:1 Uncaught (in promise) DOMException
I get this error: Uncaught (in promise) DOMException: GATT Error Unknown. The code that I am writing was modified from my earlier work, ......
Read more >Connection establishment fails with GATT ERROR 133 ...
I use BLE SDK 5.40. When I try connecting my device with nRF mobile app, it disconnects immediately throwing Error 133 - GATT...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
See https://www.chromium.org/developers/how-tos/file-web-bluetooth-bugs
@poshaughnessy no worries, thanks for trying my suggestion out. Yes, let’s close this for now, if there’s something wrong when bleno, please re-open again.