Avatar for user104759

user104759

Member since Nov 2019 • Last active Jan 2020
  • 1 conversations
  • 11 comments

Most recent activity

  • in General
    Avatar for user104759

    Sorry for late rely, yes I ditched the NRF.nfcSend, and used characteristic.writeValue, I will get my code together and try and write up brief tutorial

  • in General
    Avatar for user104759

    Thanks Robin, that eventually worked however i realise i was missing a step and had to send a two different commands to make it work.

    I managed to get me remote made in time for christmas so thank you all for you help, here a video of my remote in action

    https://www.instagram.com/p/B6inY2XgasT/­?igshid=16amjui8jcves

    I hope you all had great a christmas

  • in General
    Avatar for user104759

    Thanks for replying

    unfortantly it does like Array.from unless is need to done a slight different way in espruino

    Uncaught Error: Function "from" not found!
    at line 7 col 19
    var myArr = Array.from("ABCDEFG");

  • in General
    Avatar for user104759

    Sorry To keep asking,

    I am seem to making some progress using a paired back node script and now rewriting in to use on the espruino, however I am stuck finding a way of making 'Buffer.from' working, Is there espruino equivalent ?

    I am looking to run this line

    const sounddata = Buffer.from([0x08, 0x00, 0x81, 0x01, 0x11, 0x51, 0x01, 0x05]);
    
  • in General
    Avatar for user104759

    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-785­feabcd123";
    var characteristicUUID="00001624-1212-efde-1­623-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(fu­nction(g) {
      console.log("Starting connecting");
      gatt = g;
      return gatt.getPrimaryService("00001623-1212-ef­de-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);
    
  • in General
    Avatar for user104759

    Hi All

    Thanks allobjects that helped but my progress is still quite slow, i have managed to connect to the train and disconnect but can't work out the best way to send the buffer. I am still trying to get my head around javascript so maybe missing something quite obvious

    here's my current code

    var devices;
    var gatt;
    var DevName="e0:7d:ea:0c:03:29";
    var serviceUUID="00001623-1212-efde-1623-785­feabcd123";
    var characteristicUUID="00001624-1212-efde-1­623-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(fu­nction(g) {
    console.log("Starting connecting");
    gatt = g;
    return gatt.getPrimaryService("00001623-1212-ef­de-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);

    any advice would be greatly appreciated

    Cheers

    James

  • in General
    Avatar for user104759

    Thanks the lego link very helpful

    Yes it looks like the message it send contains the 16 bytes in hex followed buffer string that appears to vary in length. ie Buffer 05 00 01 02 02 or 0a 00 41 00 00 01 00 00 00 01

    sorry didn't realise i was using two account the previous message was sent from my work.

  • in General
    Avatar for user104759

    Hi All

    Just a little update, I've managed to hack in the node-module when it's running on my mac and got it print me the code for certain commands, so it should be a little simpler

    If anyone could point me in right direct for the best way to this raw data to my device that would be grand

    "Code to Send: 00001624-1212-efde-1623-785feabcd123 Buffer 81 00 11 51 00 64"

    I am very greatful for any help

    James

  • in General
    Avatar for user104759

    Thanks for everyone for the reply, Yes it looks like the the modules is multi files, and it seems very complicated to try and combine into one.

    The project is to try and make a remote for daughters bluetooth lego train, it had working in browser so was hoping to port it over but nothing is ever that simple

    I am currently trying to see adapting 'Bluetooth LE HID Keyboards' library work. I just need to try and find the correct modifier keys

    Wish me luck

Actions