You are reading a single comment by @jes and its replies. Click here to read the full conversation.
  • I'm trying to use my Bangle.js 2 to connect to a Bluetooth service running on an ESP32.

    This is the Arduino code running on the ESP32: https://gist.github.com/jes/65832156dc0eded2b167c3c1da184cde - it creates a single characteristic that repeatedly writes "hello\0" and notifies. It is based on an example program I copied.

    This is the Espruino code running on the Bangle.js 2: https://gist.github.com/jes/36b8ea811706ee1db4ceab6e37ab8af2 - it connects to the Bluetooth device and tells me how long it took to disconnect, it's always about 1.0 seconds.

    This is the output I get on the Web IDE console: https://gist.github.com/jes/731b57ce4c62ba8fcb451858f7dfa024 - reason 62 is BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED.

    And this is a session using gatttool, just to show that the Arduino code actually does work: https://gist.github.com/jes/34b7dd8fb1ec4737bb3950ce7f649dd6

    I'm using the "upload to RAM" method in the Web IDE, but the behaviour seems to be the same even if I write the code to disk, disconnect from Web Bluetooth, and send output to the LCD instead of the console.

    If instead of just connecting to the Bluetooth device, I actually try to get a service, then I get an additional error:

    Uncaught InternalError: BLE task completed that wasn't scheduled (SERVICE/NONE)

    From what I've been able to find on this forum, the most likely cause for this is that the device I'm trying to connect to is simply ignoring the connection attempt. I have tried varying the minInterval and maxInterval options, and it seems as though the disconnection always comes after 5x maxInterval, regardless of what I set it to.

    Can anyone see anything wrong in either my Arduino code or Espruino code that would cause the problem? Or otherwise suggest what I might be doing wrong? The 2 devices are within 20 centimetres on my desk, the Espruino-reported rssi is very good (about -40) and the problem happens every single time, not intermittently, do I don't think it's a signal strength problem.

    Thanks.

About

Avatar for jes @jes started