var s = false;
var c = 0;
function o() {
c++;
s=!s;
LED2.write(s);
}
Device2 has:
var busy = false;
var gatt;
setInterval(function() {
console.log("Trying to connect...");
if (!busy) {
busy = true;
NRF.connect("xx:xx:xx:xx:xx:xx random").then(function(g) {
gatt = g;
return gatt.getPrimaryService("6e400001-b5a3-f393-e0a9-e50e24dcca9e");
}).then(function(s) {
return s.getCharacteristic("6e400002-b5a3-f393-e0a9-e50e24dcca9e");
}).then(function(c) {
return c.writeValue("o()\n");
}).then(function() {
busy=false;
if(gatt !== undefined)gatt.disconnect();
console.log("Write value success!");
}).catch(function(e) {
busy=false;
if(gatt !== undefined)gatt.disconnect();
console.log("Write value error. ", e);
});
} else {
console.log("Device is busy!");
}
},1000);
Device 2 end dump is:
Uncaught Error: Unhandled promise rejection: Error: Got BLE error 0x8 (INVALID_STATE)
Trying to connect...
Trying to connect...
Device is busy!
Trying to connect...
Device is busy!
Write value success!
Trying to connect...
Trying to connect...
Device is busy!
Trying to connect...
Device is busy!
Write value success!
Trying to connect...
ERROR: Ctrl-C while processing interval - removing it.
Execution Interrupted during event processing.
New interpreter error: CALLBACK,MEMORY
Write value success!
In this concrete test Device 2 succeeded to call function on Device 1 successfully 87 times and crashed, but sometimes it is 75, 78.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi @Gordon,
I have two devices:
Device1 has:
Device2 has:
Device 2 end dump is:
Uncaught Error: Unhandled promise rejection: Error: Got BLE error 0x8 (INVALID_STATE)
Trying to connect...
Trying to connect...
Device is busy!
Trying to connect...
Device is busy!
Write value success!
Trying to connect...
Trying to connect...
Device is busy!
Trying to connect...
Device is busy!
Write value success!
Trying to connect...
ERROR: Ctrl-C while processing interval - removing it.
Execution Interrupted during event processing.
New interpreter error: CALLBACK,MEMORY
Write value success!
In this concrete test Device 2 succeeded to call function on Device 1 successfully 87 times and crashed, but sometimes it is 75, 78.
Please advice!
Thank you!