Ahh, I did just spot something...
scanMenu[device.name]= ()=>{ console.log(device); // is displayed the device NRF.connect(device.id) .then((g)=>{ console.log("NRF connection ok!");//is displayed var gatt = g; console.log(gatt); var device = g.device; //Second attempt of sending password device.on('passkeyRequest', function() {
By the time you add the passkeyRequest listener it's already connected - that could be it.
passkeyRequest
Maybe try:
scanMenu[device.name]= ()=>{ console.log(device); // is displayed the device device.on('passkeyRequest', function() { console.log("passKeyRequested"); device.sendPasskey("012034"); }); device.gatt.connect().then((g)=>{ console.log("NRF connection ok!");//is displayed var gatt = g; console.log(gatt); return new Promise(resolve => setTimeout(resolve, 1000)); // wait 1 sec - just in case }).then(()=>{ return gatt.startBonding() }).then(()=>{
You also had some slightly odd nested promise stuff that could have been a bit confusing too, so I unrolled that above as well.
@Gordon started
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.
Ahh, I did just spot something...
By the time you add the
passkeyRequest
listener it's already connected - that could be it.Maybe try:
You also had some slightly odd nested promise stuff that could have been a bit confusing too, so I unrolled that above as well.