• Hi @Gordon,
    I'm using the espruino_2v01.10_nrf52832.hex load of firmware on a Nordic Dev board. I'm trying to turn off connectability, but keep advertising (this is a beacon application). Looking at https://www.espruino.com/BLE+Security and am using

    NRF.setAdvertising({}, { connectable:false });
    

    in my code. The device then stops advertising completely (I'm sniffing with nRFConnect to verify).

    Is there something I'm missing?

    Thanks,
    Bill

  • That should work - is it just that you're connected to the device via Bluetooth LE to upload code? That stops advertising until you disconnect.

  • Hi @Gordon, I assure you I'm disconnected from the IDE. Here's a portion of the code (setup), since there's a bit more involved. If you know DMX lighting protocols, this is advertising code for DMX over Bluetooth. I've tested this with the last line commented out (turn off connectability), and there is no advertising. I've also tried changing the 'connectability' parameter in the initial setAdvertising with the same results: once I turn off conductibility, the device ceases to advertise.
    /

    /
    //  OSF Between Two Knees lighting effect translator
    //
    
    var count = 0;  // for testing
    var i = 0;
    
    // port definitions
    
    const SCL = D26;
    const SDA = D25;
    const data_ready = D7;
    const DMX_length = 18;
    const DMX_channel = 0x05;
    
    // setup I2C
    I2C1.setup({ scl : SCL, sda: SDA });
    
    // change to "input" for direct CPU connection from "input_pulldown"
    pinMode(data_ready, "input");  // for switch for testing
    
    var DMX_data = new Uint8Array(DMX_length);      // array to store DMX data received
    
    for (i = 0; i < DMX_data.length; i++)
    {
      DMX_data[i] = 0;
    }
    
    //
    // Initialize; set up
    //
    
    NRF.setTxPower(4);         // +4 dBM (maximum)
    NRF.setAdvertising({},{
      name: "PTG",
      interval: 30,
      connectable: true,      // change to false before deployment
      manufacturer: 0x0583,    // Code Blue Communications
      manufacturerData:[DMX_data]
    });
    
    NRF.setAdvertising({}, { connectable:false });
    
  • I just tried here on an nRF52DK - completely fresh - and entered NRF.setAdvertising({}, { connectable:false }); - and it's fine.

    So it appears to be something to do with the contents of your first setAdvertising - nothing springs to mind as to what it could be though

  • Hi @Gordon, just to simplify; I eliminated the second setAdvertising (it was added for debugging) and went back to changing the initial setup. In the following code, when the parameter is set to true, everything works. When it is set to false, the board ceases to advertise. Please try it for yourself...

    The only other thing I'd add is that I'm uploading to flash (save on send = directly to flash).

    Thanks for checking this out.

    //
    //  OSF Between Two Knees lighting effect translator
    //
    
    var count = 0;  // for testing
    var i = 0;
    
    // port definitions
    
    const SCL = D26;
    const SDA = D25;
    const data_ready = D7;
    const DMX_length = 18;
    const DMX_channel = 0x05;
    
    // setup I2C
    I2C1.setup({ scl : SCL, sda: SDA });
    
    // change to "input" for direct CPU connection from "input_pulldown"
    pinMode(data_ready, "input");  // for switch for testing
    
    var DMX_data = new Uint8Array(DMX_length);      // array to store DMX data received
    
    for (i = 0; i < DMX_data.length; i++)
    {
      DMX_data[i] = 0;
    }
    
    //
    // Initialize; set up
    //
    
    NRF.setTxPower(4);         // +4 dBM (maximum)
    NRF.setAdvertising({},{
      name: "PTG",
      interval: 30,
      connectable: false,      // change to false before deployment
      manufacturer: 0x0583,    // Code Blue Communications
      manufacturerData:[DMX_data]
    });
    
  • Yes, I get that. However since this isn't an official board it'd be good if you could help me by narrowing it down to the bare minimum.

    So we know this does it:

    NRF.setAdvertising({},{
      name: "PTG",
      interval: 30,
      connectable: false,
      manufacturer: 0x0583,
      manufacturerData:new Uint8Array(18)
    });
    

    And this doesn't (on its own):

    NRF.setAdvertising({},{
      connectable: false,
    });
    

    What lines can be removed such that it still breaks?

  • I'm sorry that I have confused you. The first case you show does NOT work. I removed the 2nd call: I added for debugging when the simpler case did not work, but is confusing the issue.

    Anytime I turn off connectable (through either set of code) it stops advertising.

  • By 'does it', I meant 'stops advertising'.

    NRF.setAdvertising({},{connectable: false}); by itself does not stop advertising, unless you've already added that other code beforehand

  • Ok, I just commented out lines and uploaded until I found what was causing the problem. It's interval: 30,.

    I don't know why, but remove that or set it to 100 or above and you'll be fine.

  • Hi @Gordon, I tested the following on a Pixl running released 2v01 code. It ceases to advertise. When set to true for connectable, it works fine. It is reproducible.

    Help? Bill

    //
    //  OSF Between Two Knees lighting effect translator
    //
    
    var count = 0;  // for testing
    var i = 0;
    
    // port definitions
    
    
    const DMX_length = 18;
    const DMX_channel = 0x05;
    
    
    
    var DMX_data = new Uint8Array(DMX_length);      // array to store DMX data received
    
    for (i = 0; i < DMX_data.length; i++)
    {
      DMX_data[i] = 0;
    }
    
    //
    // Initialize; set up
    //
    
    NRF.setTxPower(4);         // +4 dBM (maximum)
    NRF.setAdvertising({},{
      name: "PTG",
      interval: 30,
      connectable: false,      // change to false before deployment
      manufacturer: 0x0583,    // Code Blue Communications
      manufacturerData:[DMX_data]
    });
    
  • I'm not sure we're really on the same wavelength here - please can you read my last 2 posts? It isn't possible to do what you want, the spec forbids it.

    The issue here was Espruino not throwing an error to tell you that, but I just fixed it so latest builds will now throw an exception (and the limitation is now documented).

    But please - if you have issues in the future, can you just take a few minutes to try and get down to a reasonably minimal bit of code that has the problem.

    It means I can fix the issue far more quickly.

  • Apologies @Gordon. It has been that kind of day for me. I was spending multitasking cycles with other projects and replicating it on a supported platform as was suggested. I wasn't aware of this specification limitation, so thank you. Interestingly, this has been eliminated for 5.0 since it is something that we actually want to do. Looks like a new softdevice to enable that capability :-{

  • Thank you @Gordon! REALLY appreciate your help. The code is part of a DMX lighting protocol over Bluetooth to on-stage lighting effects. The show has its final dress rehearsal tonight and I made the appropriate changes and everything is working, just in time! I'll send you some photos of the result when the show pics are posted. It will run about 80 performances over the summer. I was concerned about someone in the audience connecting and stopping the advertising which would be a show-stopper (literally).
    Thanks again! Bill

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

Advertising connectable: false stops advertising (nrf52832 dev board).

Posted by Avatar for billsalt @billsalt

Actions