• Hi +Gordon,

    I am doing some tests on BLE UART using the ble_simple_uart module from the guide at http://www.espruino.com/Puck.js+BLE+UART­

    Using the guide, I am able to program a Puck to "forward" the commands sent from the PC (Web Bluetooth IDE) In this case, I am able to turn on the LED of a second Puck without prior programming on that Puck.

    The code that I am using is:

    NRF.requestDevice({ filters: [{ namePrefix: 'Puck.js' }] }).then(function(device) {
      require("ble_simple_uart").write(device,­ "digitalPulse(LED3,1,1000)\n", function() {
        print('Done!');
      });
    });
    

    However, I have some questions:

    1. When I upload the code I sometimes get the error Uncaught Error: Unhandled promise rejection: undefined, it seems to be pretty random as I am able to get it to work after reuploading the code a few times. Why does this happen? (My Pucks are on 1v88)
    2. When I try to send a Eddystone broadcast command using this method e.g. require("ble_eddystone").advertise("goo.­gl/B3J0Oc"); I am unable to detect the Eddystone broadcast using Beacon Tools app on my phone. Disconnecting and reconnecting the second Puck ends up with a Connection error. In the end I am forced to reset the second Puck by pulling out the battery. Is it possible that the UART connection will interfere with the Eddystone broadcast?
    3. Currently I am only testing on two Pucks, but is there an efficient way to make the code "recursive", such that if I add more Pucks and they are only in range of the second Puck, I can make the second Puck search for other Pucks nearby, then send the command again? I know that one way to do it is to put the whole code in the "commands to be sent field" i.e.

      
      NRF.requestDevice({ filters: [{ namePrefix: 'Puck.js' }] }).then(function(device) {
      require("ble_simple_uart").write(device,­
      "NRF.requestDevice({ filters: [{ namePrefix: 'Puck.js' }] }).then(function(device) {\n
        require('ble_simple_uart').write(device,­ 'digitalPulse(LED3,1,1000)\n', function() {\n
          print('Done!');\n
        });\n
      });\n", function() {
      print('Done!');
      });
      });
      
      

    But this will only make the command broadcast 2 times in total which does not help if the number of Pucks increase. It would be great if the command becomes recursive so that each Puck that receives the broadcast can turn on the LED + search for other Pucks nearby and send them the command. Does the Puck have some functions to do this?

    #4. What is the maximum command length that the require("ble_simple_uart").write() function supports?

    Thanks.

About

Avatar for intern @intern started