You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Just spend a few hours looking into this. If you'd put setSecurity after setServices it would have worked I believe, although there are some other issues.

    • passkey:"123456" isn't valid in setServices
    • If you specify lesc: true but then don't have it in setSecurity then it'll bond but you still won't be able to access
    • I don't believe the passkey is good enough for lesc - at least pairing with then enabled fails

    So if you do the following, you should be good:

    NRF.setServices({
      0xabcd : {
        0xAB40 : {
          value : "Hello",
          maxLen : 50,
          notify: true,
          readable: true,
          writable: true,
        },
        0xAB41 : {
          value : "Hello",
          maxLen : 50,
          notify: true,
          readable: true,
          writable: true,
          security: {
            read: {
              encrypted: true,
              mitm: true
            }, write: {
              encrypted: true,
              mitm: true
            }
          },
          onWrite : function(evt) { // optional
            console.log("Written ", evt.data); // an ArrayBuffer
          }
        }
      }
    }, {advertise: [ 0xabcd ]});
    NRF.setSecurity({passkey:"123456", mitm:1, display:1});
    NRF.on('disconnect',x=>print('disconnect',x));
    NRF.on('connect',x=>print('connect',x));
    
About

Avatar for Gordon @Gordon started