Connect external BLE device

Posted on
  • Hi,

    I have to ad the usual appology if this is in the wrong forum or to basic of a question.

    I have an external wearable device with BLE functionality. What I want to do is to write a code for Espruino to connect with that device and use the data from it live for a game one the watch. Is that possible? I will find my way if its possible, but I wanted to ask first :)

  • Yes it is possible :-)

  • Yes! You probably want to look at https://www.espruino.com/Reference#l_NRF_requestDevice

    For instance there's an example there like this:

    var gatt;
    NRF.requestDevice({ filters: [{ namePrefix: 'Puck.js' }] }).then(function(device) {
      return device.gatt.connect();
    }).then(function(g) {
      gatt = g;
      return gatt.getPrimaryService("6e400001-b5a3-f393-e0a9-e50e24dcca9e");
    }).then(function(service) {
      return service.getCharacteristic("6e400002-b5a3-f393-e0a9-e50e24dcca9e");
    }).then(function(characteristic) {
      return characteristic.writeValue("LED1.set()\n");
    }).then(function() {
      gatt.disconnect();
      console.log("Done!");
    });
    

    Apart from the NRF bit in NRF.requestDevice, the API itself is based on "Web Bluetooth" so you can always Google that and look for examples.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Connect external BLE device

Posted by Avatar for user158398 @user158398

Actions