WebBluetooth Failing a Write Characteristic on Windows but not OSX
up vote
2
down vote
favorite
I'm trying to send a sample hex string to a BLE device via web bluetooth.
This string is sending perfectly fine on OSX, but when I attempt to send it on windows I'm getting the following error:
Uncaught (in promise) DOMException: GATT operation failed for unknown reason.
Here is the code I'm using to send the string and convert it:
event.target.writeValue(str2ab(":100000000C9434000C943E000C943E000C943E0082*"));
Here is my str2ab function:
function str2ab(str) {
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
javascript google-chrome bluetooth web-bluetooth
add a comment |
up vote
2
down vote
favorite
I'm trying to send a sample hex string to a BLE device via web bluetooth.
This string is sending perfectly fine on OSX, but when I attempt to send it on windows I'm getting the following error:
Uncaught (in promise) DOMException: GATT operation failed for unknown reason.
Here is the code I'm using to send the string and convert it:
event.target.writeValue(str2ab(":100000000C9434000C943E000C943E000C943E0082*"));
Here is my str2ab function:
function str2ab(str) {
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
javascript google-chrome bluetooth web-bluetooth
1
I'm seeing the same problems on Windows also, you aren't alone!
– EL45
Nov 7 at 21:30
@EL45 I've narrowed the problem down to being that on Windows you can only send 20 bytes at a time! I'll rewrite the way I'm sending data and post it as a solution.
– Wezley
Nov 7 at 23:09
@EL45 I just posted a fix!
– Wezley
Nov 8 at 1:49
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm trying to send a sample hex string to a BLE device via web bluetooth.
This string is sending perfectly fine on OSX, but when I attempt to send it on windows I'm getting the following error:
Uncaught (in promise) DOMException: GATT operation failed for unknown reason.
Here is the code I'm using to send the string and convert it:
event.target.writeValue(str2ab(":100000000C9434000C943E000C943E000C943E0082*"));
Here is my str2ab function:
function str2ab(str) {
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
javascript google-chrome bluetooth web-bluetooth
I'm trying to send a sample hex string to a BLE device via web bluetooth.
This string is sending perfectly fine on OSX, but when I attempt to send it on windows I'm getting the following error:
Uncaught (in promise) DOMException: GATT operation failed for unknown reason.
Here is the code I'm using to send the string and convert it:
event.target.writeValue(str2ab(":100000000C9434000C943E000C943E000C943E0082*"));
Here is my str2ab function:
function str2ab(str) {
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}
javascript google-chrome bluetooth web-bluetooth
javascript google-chrome bluetooth web-bluetooth
asked Nov 7 at 17:09
Wezley
1081113
1081113
1
I'm seeing the same problems on Windows also, you aren't alone!
– EL45
Nov 7 at 21:30
@EL45 I've narrowed the problem down to being that on Windows you can only send 20 bytes at a time! I'll rewrite the way I'm sending data and post it as a solution.
– Wezley
Nov 7 at 23:09
@EL45 I just posted a fix!
– Wezley
Nov 8 at 1:49
add a comment |
1
I'm seeing the same problems on Windows also, you aren't alone!
– EL45
Nov 7 at 21:30
@EL45 I've narrowed the problem down to being that on Windows you can only send 20 bytes at a time! I'll rewrite the way I'm sending data and post it as a solution.
– Wezley
Nov 7 at 23:09
@EL45 I just posted a fix!
– Wezley
Nov 8 at 1:49
1
1
I'm seeing the same problems on Windows also, you aren't alone!
– EL45
Nov 7 at 21:30
I'm seeing the same problems on Windows also, you aren't alone!
– EL45
Nov 7 at 21:30
@EL45 I've narrowed the problem down to being that on Windows you can only send 20 bytes at a time! I'll rewrite the way I'm sending data and post it as a solution.
– Wezley
Nov 7 at 23:09
@EL45 I've narrowed the problem down to being that on Windows you can only send 20 bytes at a time! I'll rewrite the way I'm sending data and post it as a solution.
– Wezley
Nov 7 at 23:09
@EL45 I just posted a fix!
– Wezley
Nov 8 at 1:49
@EL45 I just posted a fix!
– Wezley
Nov 8 at 1:49
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
So it looks like for windows you have a 20 byte limit.
To correct the issue I'm using a write buffer and recursively going over it until all the bites have been written. Here is the code.
function writeBuffer(string) {
writeOut(string, 0);
}
function writeOut(string, start) {
if(start >= string.length) return;
myCharacteristic.writeValue(str2ab(string.substring(start, (start+20)))).then(foo => {
writeOut(string, (start+20));
});
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
So it looks like for windows you have a 20 byte limit.
To correct the issue I'm using a write buffer and recursively going over it until all the bites have been written. Here is the code.
function writeBuffer(string) {
writeOut(string, 0);
}
function writeOut(string, start) {
if(start >= string.length) return;
myCharacteristic.writeValue(str2ab(string.substring(start, (start+20)))).then(foo => {
writeOut(string, (start+20));
});
}
add a comment |
up vote
1
down vote
So it looks like for windows you have a 20 byte limit.
To correct the issue I'm using a write buffer and recursively going over it until all the bites have been written. Here is the code.
function writeBuffer(string) {
writeOut(string, 0);
}
function writeOut(string, start) {
if(start >= string.length) return;
myCharacteristic.writeValue(str2ab(string.substring(start, (start+20)))).then(foo => {
writeOut(string, (start+20));
});
}
add a comment |
up vote
1
down vote
up vote
1
down vote
So it looks like for windows you have a 20 byte limit.
To correct the issue I'm using a write buffer and recursively going over it until all the bites have been written. Here is the code.
function writeBuffer(string) {
writeOut(string, 0);
}
function writeOut(string, start) {
if(start >= string.length) return;
myCharacteristic.writeValue(str2ab(string.substring(start, (start+20)))).then(foo => {
writeOut(string, (start+20));
});
}
So it looks like for windows you have a 20 byte limit.
To correct the issue I'm using a write buffer and recursively going over it until all the bites have been written. Here is the code.
function writeBuffer(string) {
writeOut(string, 0);
}
function writeOut(string, start) {
if(start >= string.length) return;
myCharacteristic.writeValue(str2ab(string.substring(start, (start+20)))).then(foo => {
writeOut(string, (start+20));
});
}
answered Nov 8 at 1:48
Wezley
1081113
1081113
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53194416%2fwebbluetooth-failing-a-write-characteristic-on-windows-but-not-osx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I'm seeing the same problems on Windows also, you aren't alone!
– EL45
Nov 7 at 21:30
@EL45 I've narrowed the problem down to being that on Windows you can only send 20 bytes at a time! I'll rewrite the way I'm sending data and post it as a solution.
– Wezley
Nov 7 at 23:09
@EL45 I just posted a fix!
– Wezley
Nov 8 at 1:49