You are reading a single comment by @ThePlayShed and its replies. Click here to read the full conversation.
  • Thanks For have a look Robin is this a better layout ?

    var devices;
    var gatt;
    var DevName="e0:7d:ea:0c:03:29";
    var serviceUUID="00001623-1212-efde-1623-785feabcd123";
    var characteristicUUID="00001624-1212-efde-1623-785feabcd123";
    var MessageToSend=[0x81, 0x00, 0x11, 0x51, 0x00, 0x64];
    pinMode(D15, 'input_pulldown');
    global.LED2=D2;
    
    NRF.connect("e0:7d:ea:0c:03:29").then(function(g) {
      console.log("Starting connecting");
      gatt = g;
      return gatt.getPrimaryService("00001623-1212-efde-1623-785feabcd123");
    }).then(function(service) {
      return service.getCharacteristic("00001624-1212-efde-1623-785feabcd123");
    }).then(function(characteristic) {
      return characteristic.writeValue(MessageToSend);
    }).then(function() {
      //gatt.disconnect();
      console.log("Done!");
    });
    
    function send_message() {
      console.log("Moving Train");
      NRF.nfcSend(new Uint8Array([0x81, 0x00, 0x11, 0x51, 0x00, 0x64]));
    }
    
    function train_disconnect() {
      console.log("Disconnecting");
      gatt.disconnect();
    }
    
    setInterval(function() {
      digitalWrite(LED2, digitalRead(D15));
      if (digitalRead(D15) == 1) {
        send_message();
      }
      console.log("Button pressed", digitalRead(D15));
    }, 300);
    
About

Avatar for ThePlayShed @ThePlayShed started