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

Refresh services in nrf Master Control Panel

Sometimes the service discovery procedure in Android will discover all services but not the characteristics included in them. So all services will be empty. If I then open the nrf Master Control Panel and connect to the peripheral it will also show all the services but no characteristics. However, if I then choose Refresh Services in the menu all the charcteristics will be discovered ok.

I know this is a problem with the ble stack in Android and my question is exactly what does the Refresh Services procedure in nrf Control Panel do?

Update: Sorry but I can't get refresh to work properly. It works fine in the MCP but in my app it does not. I can see in the log that is getting called but it does not refresh the services. I have been careful to call it from the main thread only (via a handler).

When should refresh be called; when connected or disconnected. Do I have to call discoverServices() afterwards or is that done automatically? It there any other thing I need to know?

Regards /Erik

  • There is a hidden method in BluetoothGatt, refresh(); You can see more details here

  • Hi,

    The refresh() method does perform the service discovery, but you are not aware of it (no callback is called). My suggestion would be either to call it after you disconnected (on onConnectionStateChanged->STATE_DISCONNECTED, before you call close() ), or after you connected but delay calling discoverServices() about 600ms. If you are bonded, shortly after you get state connected the device may receive the Service Changed indication and may refresh services automatically. I recommend checking the source code of nRF Toolbox here: github.com/.../BleManager.java

    Sequence of actions:

    1. State changed to connected
    2. Refresh
    3. Wait 600 ms
    4. Call discoverServices()

    Also, I have never experienced issue you are talking about. What phone are you using?

  • Ok, I think I understand now whats going on. I noticed a lot of 133 status error codes in the log when doing a service discovery and just assumed that the service table was corrupt, since that was my problem in the first place. But then I noticed the same error codes when doing a refresh in the MCP. So after digging a bit in the sources I note that a lot of the events delivered to BluetoothGatt are in fact normal errors during a discovery, for instance trying to lookup an included service when there is none present. So, in short it does work, but the status errors in the android debug log made me confused. Thanks for your help. /Erik

Related