first of all
thank you fir the help so far , you don't need to apologize :-)
this is what I have now :
created a device called "Test_Read_Write" - I can see it on BLE Scan
I have open "nRf" on by Android device and mange to connect to it .
sending < 18 - led is on , > 18 led is off - so communication is working.
I'm trying to add update service , did I do it right ?
I can see the data is changing when I send something to the device
but is there a function I can call to update the value only after the data is change?
and not print it once every 1000mSec (like I did)?
it will be better no ?
My_MAC = NRF.getAddress();
print("My MAC address is " , My_MAC);
var n = 0;
NRF.setAdvertising({}, {name:"Test_Read_Write1"});
NRF.setServices({
"3e440001-f5bb-357d-719d-179272e4d4d9": {
"3e440002-f5bb-357d-719d-179272e4d4d9": {
writable : true,
maxLen : 5,
onWrite : function(evt) {
n = evt.data[0];
if (n < 18) {
digitalWrite(LED, 1);
}
else {
digitalWrite(LED, 0);}
}
},
"3e440003-f5bb-357d-719d-179272e4d4d9": {
readable : true,
notify: true,
value : ["hello"]
}
}
}, {});
setInterval(function() {
NRF.updateServices({
"3e440001-f5bb-357d-719d-179272e4d4d9" : {
"3e440003-f5bb-357d-719d-179272e4d4d9" : {
value : [n],
notify: true
}
}
}); }, 1000);
// On disconnect, turn off led
NRF.on('disconnect', function() {
digitalWrite(LED, 0);
});
when I upload the code I see this error :
BLE Connected, queueing BLE restart for later
Uncaught Error: Can't update services until BLE restart
at line 37 col 2 in .bootcde
is this OK ? or does it mean I have a problem ?
***after I will see everything is working on with my phone , I will need your help with the python error of sending data
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.
first of all
thank you fir the help so far , you don't need to apologize :-)
this is what I have now :
sending < 18 - led is on , > 18 led is off - so communication is working.
I'm trying to add update service , did I do it right ?
I can see the data is changing when I send something to the device
but is there a function I can call to update the value only after the data is change?
and not print it once every 1000mSec (like I did)?
it will be better no ?
when I upload the code I see this error :
is this OK ? or does it mean I have a problem ?
***after I will see everything is working on with my phone , I will need your help with the python error of sending data
Thanks ,