How to disable UART service?

Posted on
  • I am using a puck.js to advertise like an AirTag working good:

    NRF.setAdvertising([adv, {}],{interval:1500,name:ble_name,showNam­e:true,discoverable:true,connectable:fal­se,scannable:true});
    

    Somehow it also "offers" the service "Nordic UART", although it is not connectable and I also do not use DFU. I have tried to disable this by adding "uart:false" to the options list – no change.
    How can I disable NUS?

  • You need uart:false in NRF.setServices: https://www.espruino.com/Reference#l_NRF­_setServices

    NRF.setServices(undefined, {uart:false}) but this does disable the BLE UART completely so you'll no longer be able to program the device (until a reboot). Not an issue if you're not making it connectable though!

    The UART service is advertised in the scan response packet, so you can also remove it by setting scannable:false (which saves power too) or using NRF.setScanResponse: https://www.espruino.com/Reference#l_NRF­_setScanResponse

  • Thank you @Gordon: works!

  • Me again ... I am trying to add some services to let my puck look like an AirTag, without actually implementing the function behind them. I have set one like this:

    NRF.setServices(undefined, {uart:false, advertise: ['7dfc9000-7d1c-4951-86aa-8d9728f8d66c']­});
    

    Works okay, the UUID gets displayed when I scan around. But I probably need to add three more and tried this:

    NRF.setServices(undefined, {uart:false, advertise: ["7dfc9000-7d1c-4951-86aa-8d9728f8d66c",­"7dfc8000-7d1c-4951-86aa-8d9728f8d66c","­7dfc7000-7d1c-4951-86aa-8d9728f8d66c","7­dfc6000-7d1c-4951-86aa-8d9728f8d66c"]});­
    

    This doesn't seem to work, the device will not show up anymore ... what am I doing wrong?

    I am also setting a custom advertisement, maybe these collide??

    const adv = [ 0x1e, 0xff, 0x4c, 0x00, 0x12, 0x19, 0x08, key[6], key[7], key[8], key[9], key[10], key[11], key[12], key[13], key[14], key[15], key[16], key[17], key[18], key[19], key[20], key[21], key[22], key[23], key[24], key[25], key[26], key[27], key[0] >> 6, key[5]];
    NRF.setAdvertising([adv, {}],{interval:1000,name:ble_name,showNam­e:true,discoverable:true,connectable:tru­e,scannable:true});
    
  • Each custom UUID is 128 bits (16 bytes, plus the 2 byte header) so you can't fit all 3 into the ~20 byte scan response (which is the default).

    However, you could put them into different advertising packets and alternate between them (you're already alternating between your custom one, and the default which is specified with {}.

    So:

    const adv = ...;
    const adv1 = [ 17/*length*/, 6/*128 bit UUID*/, ...16 bytes of UUID... ];
    ...
    NRF.setAdvertising([adv, adv1, adv2, adv3, {}],{ .... })
    
  • Of course, thank you very much!

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

How to disable UART service?

Posted by Avatar for DanDyse @DanDyse

Actions