This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to make the ble_app_uart demo not advertising once power on?

Hi guys, I design one custom application based on the ble_app_uart demo and find the device is advertising when power on. I want to set it auto connect once the device has bonded. I add the dm APIs into this project and modify the adverting_init() and advertising_start(), which do as the hid keyboard project, but nothing change. It seems the bond info does not write to the flash correctly. could you guide me how to make it true ? with the flow better.

Thanks a lot.

Parents
  • You meant this flag BLE_GAP_ADV_TYPE_ADV_DIRECT_IND? It's the directed advertising.

    However, it doesn't mean the phone OS need to connect to the device when it receive the advertising packet. What directed advertising does is to tell other device that it advertising exclusively for one central device only.

    There is only one connection between a central (phone) and the peripheral. When there are several apps running on the phone that communicate with the same device, they share the same connection.

    As long as your app is running, you can choose the option to let the operating system to reconnect automatically when the link is lost. Please have a look at the connectGatt function [here](developer.android.com/.../BluetoothDevice.html, boolean, android.bluetooth.BluetoothGattCallback)). There is an option to choose to autoConnect

    But if your app is closed the command will no longer be valid. You can of course keep it run in background as a service.

Reply
  • You meant this flag BLE_GAP_ADV_TYPE_ADV_DIRECT_IND? It's the directed advertising.

    However, it doesn't mean the phone OS need to connect to the device when it receive the advertising packet. What directed advertising does is to tell other device that it advertising exclusively for one central device only.

    There is only one connection between a central (phone) and the peripheral. When there are several apps running on the phone that communicate with the same device, they share the same connection.

    As long as your app is running, you can choose the option to let the operating system to reconnect automatically when the link is lost. Please have a look at the connectGatt function [here](developer.android.com/.../BluetoothDevice.html, boolean, android.bluetooth.BluetoothGattCallback)). There is an option to choose to autoConnect

    But if your app is closed the command will no longer be valid. You can of course keep it run in background as a service.

Children
No Data
Related