Connection terminated by remote user, why?

Dear All

I tried to connect to an apple device, it is successful but soon after that, it is disconnected with reason code 0x13 - terminated by remote user, I tried to change the connection parameters to its preference, and disconnection still happens . Here is the log file using nrf connection desktop as suggested by the post here connection parameters ,  sorry I accidently closed the ticket, so have to open a new discussion here. The MAC address of the device is AC233F8153CE, the connection/disconnection happens at the end of logs. Can someone have a look at it and let me know the reason please?

Thank you.

Ping 

2022-06-14T11_22_34.031Z-log.txt

Parents Reply
  • I am developing a central app - a generic one applies to all peripherals hopefully, so need to figure out what other centrals do in terms of findings all services and UUIDs - there must be a procedure/way for these centrals like nRF Connect to follow to find all services available from any peripheral without knowing its protocols already - am I right?   

    Regards!

    Ping  

Children
  • You can use the bt_gatt_discover() API for that. From: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/bluetooth/gatt.html#generic-attribute-profile-gatt

    "Discover procedures can be initiated with the use of bt_gatt_discover() API which takes the bt_gatt_discover_params struct which describes the type of discovery. The parameters also serves as a filter when setting the uuid field only attributes which matches will be discovered, in contrast setting it to NULL allows all attributes to be discovered."

  • Hello, Sigurd

    Thank you for reply.

    I started from central BAS example, and call the following to do discovery.

    err = bt_gatt_dm_start(conn, BT_UUID_BAS, &discovery_cb, NULL);  //or NULL 
    when I pass BT_UUID_BAS as uuid, the service it found is printed as below:
    The discovery procedure succeeded
    
    ATT[1]:     UUID: 0x2803    Handle: 0x0011    Value:
    
        Characteristic: 0x2a19    Properties: 0x0012
    
    ATT[2]:     UUID: 0x2a19    Handle: 0x0012    Value:
    
    ATT[3]:     UUID: 0x2902    Handle: 0x0013    Value:
    
        CCCD
    while when I pass NULL as uuid, following attributes are found - it is the mandatory Generic Attribute(0x1801) of the peripheral rather than BT_UUID_BAS.

    The discovery procedure succeeded
    
    ATT[1]:     UUID: 0x2803    Handle: 0x0002    Value:
    
        Characteristic: 0x2a05    Properties: 0x0020
    
    ATT[2]:     UUID: 0x2a05    Handle: 0x0003    Value:
    
    ATT[3]:     UUID: 0x2902    Handle: 0x0004    Value:
    
        CCCD
    
    ATT[4]:     UUID: 0x2803    Handle: 0x0005    Value:
    
        Characteristic: 0x2b29    Properties: 0x000A
    
    ATT[5]:     UUID: 0x2b29    Handle: 0x0006    Value:
    
    ATT[6]:     UUID: 0x2803    Handle: 0x0007    Value:
    
        Characteristic: 0x2b2a    Properties: 0x0002
    
    ATT[7]:     UUID: 0x2b2a    Handle: 0x0008    Value:
    

    They are for same peripheral - the Nordic mouse one. I expect it to find all services include BT_UUID_BAS(0x180F) and another one 0x1812, and more. But it doesn't.

    Could you explain what I have done wrong please? how can I find all without knowing the UUID in advance please?

    Regards!

    Ping

  • Just noticed you suggest to call bt_gatt_discover() function , while in my example, I call bt_gatt_discover_start() function. The later pass more parameters down and allow calling a callback function afterwards.

    But what is the difference fundamentally? which one I should use ? do I need to call bt_gatt_discover_continue()?

    Regards!

    Ping

  • Hi, Sigurd

    I tried to call bt_gatt_discover_continue() afterwards and it works.

    To find all services without knowing any UUID first, call  bt_gatt_discover_start() with NULL as UUID and call bt_gatt_discover_continue() afterwards until no more service is discovered. 

    bt_gatt_discover_start() finds only 1 service at a time.

    thanks for your help!

    Ping

Related