Most recent activity
-
@Gordon, thank you very much for support.
Will try this evening if it works.
I confirm, comment is totally unlinked from content.
-
-
Hello!
I am trying without success since couple hours to make work a simple system: button press turns on a light bulb.
Regarding the reverse engineering of the bulb https://medium.com/@urish/reverse-engineering-a-bluetooth-lightbulb-56580fcb7546
I managed to control the bulb from a Cordova app, so the javascript should already be ready. I manage to connect to the device, to get the service and characteristic I need...but cannot make it to writeValue correctly (the bulb is not reacting). No error is thrown.
I suppose the problem hides in the value passed - in Cordova through I library should be an ArrayBuffer - but here?
My code
LED1.write(false); LED2.write(false); var connected = false; setWatch(function() { // NRF.findDevices(function(ds){ //console.log(ds); if(!connected){ connecty();} else{console.log('already connected');} //},1000); }, BTN, {edge:"rising", debounce:50, repeat:true}); function connecty() { var gatt; NRF.connect("c9:a2:57:28:a3:15 random").then(function(g) { connected=true; LED2.write(true); gatt = g; return gatt.getPrimaryService("0000ffe5-0000-1000-8000-00805f9b34fb"); }).then(function(service) { return service.getCharacteristic("0000ffe9-0000-1000-8000-00805f9b34fb"); }).then(function(chara) { LED3.write(true); chara.writeValue(makearr()); }).then(function(a) { gatt.disconnect(); connected=false; setTimeout(function(){ LED2.write(); LED3.write();},1000); console.log("Done!"); }).catch(function(e){ console.log('error'); connected=false; }); } function makearr(){ var hex = 'ff085a'; //'02','40','00','0e','00','0a','00','04','00', var arra = ['56',hex.substr(0,2),hex.substr(2,2),hex.substr(4,2),'00','f0','aa']; var bf = new Uint8Array(arra.length); for (var y in arra){ bf[y]='0x'+arra[y]; } return bf.buffer; }
Any suggestion will be very appreciated!
Like a charm...thank you @Gordon!