Search code examples
bluetooth-lowenergymovesense

How to disable bluetooth connectivity, only advertising


Is there possibility to disable bluetooth connection to Movesense sensor? Use is only advertisement. In App.cpp

BLE_COMMUNICATION(false)

Disables MDS but connection to sensor is still possible e.g. battery service


Solution

  • That macro is a leftover from early days so pay no attention to it.

    There are two parts to making the sensor non-connectable:

    1. The advertising must be marked non-connectable (this was implemented in 2.0)
    2. If connection is made anyways, it should be immediately disconnected

    For disconnecting when connected, you can subscribe to the /Comm/Ble/Peers and receive a notification every time that the connection is made. Then you can call DELETE on the connection resource (/Comm/Ble/Peers/).

    See Movesense BLE-API for more info.

    However do notice that this affects all BLE connections and will make updating the sensor firmware much more difficult since you can't then set it to DFU mode without using the DFU recovery process (battery removal).

    Full disclaimer: I work for the Movesense team