• Hi Robin,

    I experimented with this some more now. I simplified the setup and removed the TX/RX Serial1 lines, so only using Web Bluetooth to connect the MDBT42Q to the IDE.

    I am connecting to this sensor:
    https://www.aspion.de/en/transport-data-­logger-aspion-g-log-2/
    I have the protocol specs but cannot provide them as they are not public. The sensor behaves like a Nordic UART. I am pretty sure the sensor is the not culprit as I am seeing the same MDBT42Q behavior using the nRF app as a peripheral.

    Thanks for the hint with the power supply. I just switched to a fresh 4 x AA (6V) battery power supply, so power should not be an issue ... and it doesn't appear to be (no change in behavior).

    Right now, the MDBT42Q is just very unreliable. I can connect to the sensor and get data with the Android nRF app reliably 100% of the time, but executing the below MDBT42Q code gives me the following results:

    • About 30% of the time: "ERROR No device found matching filters"
    • About 30% of the time: "ERROR Connection Timeout"
    • About 30% of the time: IDE disconnects from MDBT42Q during execution of the program (usually around connect()), so I loose the console and don't know what's happening
    • About 10% of the time: Connection succeeds, sensor data is displayed, then connection is successfully closed

    I see the same behavior regardless of whether I freshly power-cycle the MDBT42Q or run the program several times in a row using the IDE upload button. I also checked the Bluetooth traffic in my vicinity but the nRF app actually only sees about 10 devices advertising, so traffic density is not a problem (my 2.4 Ghz WiFi environment is also not crowded) ... and again, the Android nRF app works fine so the wireless environment is likely not the issue.

    At this point the evidence points to a bug in the Espruino stack making the MDBT42Q too unreliable to be useful.

    Thanks,
    -- Terrence

    var gatt;
    var service;
    
    console.log("start: searching for devices ...");
    
    NRF.requestDevice({ timeout: 20000, filters: [{ name: 'devicename'}] })
    .then(function(device){
        console.log("found - connecting ...");
        return device.gatt.connect();
    })
    .then(function(gattp){
        console.log("get primary service");
        gatt = gattp;
        return gatt.getPrimaryService("6e400001-b5a3-f3­93-e0a9-e50e24dcca9e");
    })
    .then(function(servicep){
        console.log("get TX characteristic");
        service = servicep;
        return service.getCharacteristic("6e400003-b5a3­-f393-e0a9-e50e24dcca9e");
    })
    .then(function(characteristicp){
        console.log("start notfifications");
        characteristicp.on('characteristicvaluec­hanged', function(event) {
          console.log("RX: "+JSON.stringify(event.target.value.buff­er));
        });
        return characteristicp.startNotifications();
    })
    .then(function(){
        console.log("get RX characteristic");
        return service.getCharacteristic("6e400002-b5a3­-f393-e0a9-e50e24dcca9e");
    })
    .then(function(characteristicp){
        console.log("send command");
        characteristicp.writeValue('g');
    })
    .then(function() {
      return new Promise(function(resolve) {
        setTimeout(resolve, 10000);
        console.log("delayed for 10s");
      });
    })
    .then(function() {
      console.log("end delay - disconnecting ...");
      gatt.disconnect();
      console.log("Done!");
    })
    .catch(function(err) {
      console.log("ERROR", err);
    });
    
  • Sun 2019.10.06

    Good Morning Terrence,
    Nothing immediately stands out, and having a solid power bank should rule out a power issue.

    I posted a link in #3

    GATT connection timeout?

    It would be really helpful to others is you would post the output as was done as the first #1 posting shows there, when connected and any state when not connected if possible.

    Confirming we have: 'MDBT42Q with software version 2v04'

    and is that with the breakout board or just the 42Q module itself?

About

Avatar for Robin @Robin started