• Ok, so it looks like your first issue (getting the data in a write notification) is sorted?

    How do I make the second service with button state?

    You just add an extra element to the object. For example:

    NRF.setServices({
      "3e440001-f5bb-357d-719d-179272e4d4d9": {
        "3e440002-f5bb-357d-719d-179272e4d4d9": {
          value : [0],
          maxLen : 1,
          writable : true,
          onWrite : function(evt) {      }
        },
        "3e440003-f5bb-357d-719d-179272e4d4d9": {
          value : [0],
          maxLen : 1,
          writable : true,
          onWrite : function(evt) {  }
        }
      }
    }, { uart : false });
    

    What you're doing with updateServices looks fine. All I'd say is it's far more efficient to use the same basic UUID and to change the second group of 4 digits as you did in the first example.

    I just tried this code and it works fine:

    NRF.setServices({
     "3e440001-f5bb-357d-719d-179272e4d4d9": {
       "3e440003-f5bb-357d-719d-179272e4d4d9": {
          value : 0,
          writable : false,
          notify:true
        }
      }
    });
    
    var n=1;
    setWatch(function() {
      NRF.updateServices({
        "3e440001-f5bb-357d-719d-179272e4d4d9": {
          "3e440003-f5bb-357d-719d-179272e4d4d9": {
            value : n++,
            notify: true
          }
        }
      });
    }, BTN1, {repeat:true,edge:"rising"});
    
About

Avatar for Gordon @Gordon started