• And BTW I took some ESP32 C3 board from drawer, installed latest Arduino, then installed ESP32 as per https://github.com/espressif/arduino-esp32 and tried to do some example too. The one you are using look a bit strange but I see where it comes from :-)
    https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/examples/BLE_notify/BLE_notify.ino
    Well it is Arduino after all so no wonder it is so sketchy :-)
    Anyway, going through the BLE library sources is interesting - when calling notify() nothing is actually sent unless someone subscribed for notifications (which is good). Also I compiled that example and unfortunately it is working for me from Espruino side. My device is named C3 so this

    NRF.findDevices(function(devices) {
      console.log(devices);
    },{timeout:5000,filters : [{ name:"C3" }] }); 
    

    gives me

    [
      BluetoothDevice: {
        "id": "60:55:f9:79:a7:2a public",
        "rssi": -36,
        "data": new Uint8Array([2, 1, 6, 3, 9, 67, 51, 2, 10, 9, 17, 7, 75, 145, 49, 195, 201, 197, 204, 143, 158, 69, 181, 31, 1, 194, 175, 79]).buffer,
        "name": "C3",
        "services": [
          "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
         ]
       }
     ]
    

    and your code just with my mac address

    NRF.connect("60:55:f9:79:a7:2a").then(function(gatt) {
      console.log(gatt);
      console.log("connected");
      var t = getTime();
      gatt.device.on('gattserverdisconnected', function(reason) {
        console.log("disconnected (" + reason + ") after " + (getTime()-t) + " secs");
      });
    }).catch(function(e) {
      console.log("error: " + e);
    });
    

    gives me immediate connect

    =Promise: {  }
    BluetoothRemoteGATTServer: {
      "device": BluetoothDevice: {
        "id": "60:55:f9:79:a7:2a",
        "gatt":  ...
       },
      "connected": true }
    connected
    

    So I am not sure what is wrong in your case.
    My example is here https://gist.github.com/fanoush/cf64ab204f9f200ee15cf1c1ec60ed1c it is mostly the same as yours.

About

Avatar for fanoush @fanoush started