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

BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND not found error in nrf52

Hi,

I am using NRF52840 DK in our project . I  am using 15.3.0 SDK  and soft device s140 in our project .Here the nrf52840 dk board is client and other controller bluetooth is used as slave which as 1 base uuid and 4  128 bit characteristics uuid .I am able to connect to the peripheral by scanning device name.Now  i successfully connected to the peripheral devuce. But while doing service discovery i am getting BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND  in service discovery. can you tell me  how to resolve this issue. as i know only 128 bit base uuid and i dont know the service uuid . Plz help me to resolve this issue.

Parents
  • Hi,

    The BLE_GATTS_EVT_SYS_ATTR_MISSING (MSC) event must be handled by your application if you don't use the Peer manager module. Try to include the following code in your ble_evt_handler (copied from ble_app_uart example):

    /**@brief Function for handling BLE events.
     *
     * @param[in]   p_ble_evt   Bluetooth stack event.
     * @param[in]   p_context   Unused.
     */
    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        uint32_t err_code;
    
        switch (p_ble_evt->header.evt_id)
        {
        
         ...
        case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
                // Pairing not supported
                err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
                APP_ERROR_CHECK(err_code);
                break;
    
        case BLE_GATTS_EVT_SYS_ATTR_MISSING:
                // No system attributes have been stored.
                err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
                APP_ERROR_CHECK(err_code);
                break;
         ...

  • Thanks for the reply.

    I have tried to include the BLE_GATTS_EVT_SYS_ATTR_MISSING event but still it is getting attribute not found and service not found at the peer. Plz  help me.

  • Sorry, I misread the question, the BLE_GATTS_EVT_SYS_ATTR_MISSING event handling is not related to the error you got. Have you added the base uuid with the sd_ble_uuid_vs_add() function in your client code? Remember that the byte order is little-endian when you add you add new based UUID (opposite of what's displayed in nrf connect app)  

  • Yes,

    I have added the 128 bit base uuid and  128 bit service uuid to the function  sd_ble_uuid_vs_add()  in client. still i am getting the same error.I have attached the code below  plz check the code.

    uint32_t ble_lbs_c_init(ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_init_t * p_ble_lbs_c_init)
    {
    uint32_t err_code;
    ble_uuid_t lbs_uuid;
    ble_uuid128_t lbs_base_uuid = {LBS_UUID_BASE};
    ble_uuid128_t lbs_service_uuid = {LBS_UUID_SERVICE_UUID};

    VERIFY_PARAM_NOT_NULL(p_ble_lbs_c);
    VERIFY_PARAM_NOT_NULL(p_ble_lbs_c_init);
    VERIFY_PARAM_NOT_NULL(p_ble_lbs_c_init->evt_handler);

    p_ble_lbs_c->peer_lbs_db.button_cccd_handle = BLE_GATT_HANDLE_INVALID;
    p_ble_lbs_c->peer_lbs_db.button_handle = BLE_GATT_HANDLE_INVALID;
    p_ble_lbs_c->peer_lbs_db.led_handle = BLE_GATT_HANDLE_INVALID;
    p_ble_lbs_c->conn_handle = BLE_CONN_HANDLE_INVALID;
    p_ble_lbs_c->evt_handler = p_ble_lbs_c_init->evt_handler;

    err_code = sd_ble_uuid_vs_add(&lbs_base_uuid, &p_ble_lbs_c->uuid_type);
    if (err_code != NRF_SUCCESS)
    {
    return err_code;
    }
    VERIFY_SUCCESS(err_code);
    err_code = sd_ble_uuid_vs_add(&lbs_service_uuid, &p_ble_lbs_c->uuid_type);
    if (err_code != NRF_SUCCESS)
    {
    return err_code;
    }
    VERIFY_SUCCESS(err_code);


    lbs_uuid.type = p_ble_lbs_c->uuid_type;
    lbs_uuid.uuid = LBS_UUID_SERVICE;
    return ble_db_discovery_evt_register(&lbs_uuid);
    }

    #define LBS_UUID_BASE {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
    0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb} /**< Used vendor specific UUID. **/


    #define LBS_UUID_SERVICE_UUID {0x39, 0x23, 0xcf, 0x40, 0x73, 0x16, 0x42, 0x9a, \
    0x5c, 0x41, 0x7e, 0x7d, 0xc4, 0x9a, 0x83, 0x14} /**< Used vendor specific UUID. */


    #define LBS_UUID_SERVICE 0x9AC4

    Plz check the code and plz help me.

  • Hi,

    What services does the GATT server have? LBS_UUID_BASE is set to the official SIG based UUID (link) and should not be used together with custom vendor-specific UUIDs

Reply Children
  • Thanks for the reply.

    Sorry for the late reply. I was on the holiday.

    The GATT server uses SPPLE service which has 128 bit UUID.I am didn't get  official SIG based UUID .

    Can you tell me what is this UUID ?Plz help me to resolve the issue.

  • Do you have a link to the SPPLE service? I'm not sure what service that is.  

    sharmelaraju said:
    .I am didn't get  official SIG based UUID .

     The SIG base UUID is already included in the Softdevice and does not need to be added through sd_ble_uuid_vs_add() call. It should only be used together with 16-bit UUIDs assigned by Bluetooth SIG (link)

  • It appears to be 4 or 5 unique UUID bases. I suggest you start by trying to discover the main Service since any typo or error in the byte order will cause service discovery to fail. 

    I didn't find the UUID below in the documentation you linked to. Can you point me to the Service or characteristic it belongs to?

     #define LBS_UUID_SERVICE_UUID {0x39, 0x23, 0xcf, 0x40, 0x73, 0x16, 0x42, 0x9a, \
    0x5c, 0x41, 0x7e, 0x7d, 0xc4, 0x9a, 0x83, 0x14} /**< Used vendor specific UUID. */

  • Thanks for the reply.

    Below I have attached the program of the service table in the peripheral side.

    /*********************************************************************/
    /** SPPLE Service Table **/
    /*********************************************************************/

    /* The SPPLE Service Declaration UUID. */
    static BTPSCONST GATT_Primary_Service_128_Entry_t SPPLE_Service_UUID =
    {
    SPPLE_SERVICE_BLUETOOTH_UUID_CONSTANT
    };
    /*static BTPSCONST GATT_Primary_Service_16_Entry_t SPPLE_Service_UUID =
    {
    SPPLE_SERVICE_BLUETOOTH_UUID_CONSTANT
    };*/

    /* The Tx Characteristic Declaration. */
    static BTPSCONST GATT_Characteristic_Declaration_128_Entry_t SPPLE_Tx_Declaration =
    {
    GATT_CHARACTERISTIC_PROPERTIES_NOTIFY,
    SPPLE_TX_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT
    };

    /* The Tx Characteristic Value. */
    static BTPSCONST GATT_Characteristic_Value_128_Entry_t SPPLE_Tx_Value =
    {
    SPPLE_TX_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT,
    0,
    NULL
    };

    /* The Tx Credits Characteristic Declaration. */
    static BTPSCONST GATT_Characteristic_Declaration_128_Entry_t SPPLE_Tx_Credits_Declaration =
    {
    (GATT_CHARACTERISTIC_PROPERTIES_READ|GATT_CHARACTERISTIC_PROPERTIES_WRITE_WITHOUT_RESPONSE|GATT_CHARACTERISTIC_PROPERTIES_WRITE),
    SPPLE_TX_CREDITS_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT
    };

    /* The Tx Credits Characteristic Value. */
    static BTPSCONST GATT_Characteristic_Value_128_Entry_t SPPLE_Tx_Credits_Value =
    {
    SPPLE_TX_CREDITS_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT,
    0,
    NULL
    };

    /* The SPPLE RX Characteristic Declaration. */
    static BTPSCONST GATT_Characteristic_Declaration_128_Entry_t SPPLE_Rx_Declaration =
    {
    (GATT_CHARACTERISTIC_PROPERTIES_WRITE_WITHOUT_RESPONSE),
    SPPLE_RX_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT
    };

    /* The SPPLE RX Characteristic Value. */
    static BTPSCONST GATT_Characteristic_Value_128_Entry_t SPPLE_Rx_Value =
    {
    SPPLE_RX_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT,
    0,
    NULL
    };


    /* The SPPLE Rx Credits Characteristic Declaration. */
    static BTPSCONST GATT_Characteristic_Declaration_128_Entry_t SPPLE_Rx_Credits_Declaration =
    {
    (GATT_CHARACTERISTIC_PROPERTIES_READ|GATT_CHARACTERISTIC_PROPERTIES_NOTIFY),
    SPPLE_RX_CREDITS_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT
    };

    /* The SPPLE Rx Credits Characteristic Value. */
    static BTPSCONST GATT_Characteristic_Value_128_Entry_t SPPLE_Rx_Credits_Value =
    {
    SPPLE_RX_CREDITS_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT,
    0,
    NULL
    };

    /* Client Characteristic Configuration Descriptor. */
    static GATT_Characteristic_Descriptor_16_Entry_t Client_Characteristic_Configuration =
    {
    GATT_CLIENT_CHARACTERISTIC_CONFIGURATION_BLUETOOTH_UUID_CONSTANT,
    GATT_CLIENT_CHARACTERISTIC_CONFIGURATION_LENGTH,
    NULL
    };

    /* The following defines the SPPLE service that is registered with */
    /* the GATT_Register_Service function call. */
    /* * NOTE * This array will be registered with GATT in the call to */
    /* GATT_Register_Service. */
    BTPSCONST GATT_Service_Attribute_Entry_t SPPLE_Service[] =
    {
    {GATT_ATTRIBUTE_FLAGS_READABLE, aetPrimaryService128, (Byte_t *)&SPPLE_Service_UUID}, //0
    {GATT_ATTRIBUTE_FLAGS_READABLE, aetCharacteristicDeclaration128, (Byte_t *)&SPPLE_Tx_Declaration}, //1
    {0, aetCharacteristicValue128, (Byte_t *)&SPPLE_Tx_Value}, //2
    {GATT_ATTRIBUTE_FLAGS_READABLE_WRITABLE, aetCharacteristicDescriptor16, (Byte_t *)&Client_Characteristic_Configuration}, //3
    {GATT_ATTRIBUTE_FLAGS_READABLE, aetCharacteristicDeclaration128, (Byte_t *)&SPPLE_Tx_Credits_Declaration}, //4
    {GATT_ATTRIBUTE_FLAGS_READABLE_WRITABLE, aetCharacteristicValue128, (Byte_t *)&SPPLE_Tx_Credits_Value}, //5
    {GATT_ATTRIBUTE_FLAGS_READABLE, aetCharacteristicDeclaration128, (Byte_t *)&SPPLE_Rx_Declaration}, //6
    {GATT_ATTRIBUTE_FLAGS_WRITABLE, aetCharacteristicValue128, (Byte_t *)&SPPLE_Rx_Value}, //7
    {GATT_ATTRIBUTE_FLAGS_READABLE, aetCharacteristicDeclaration128, (Byte_t *)&SPPLE_Rx_Credits_Declaration}, //8
    {GATT_ATTRIBUTE_FLAGS_READABLE, aetCharacteristicValue128, (Byte_t *)&SPPLE_Rx_Credits_Value}, //9
    {GATT_ATTRIBUTE_FLAGS_READABLE_WRITABLE, aetCharacteristicDescriptor16, (Byte_t *)&Client_Characteristic_Configuration}, //10
    };

    #define SPPLE_SERVICE_ATTRIBUTE_COUNT (sizeof(SPPLE_Service)/sizeof(GATT_Service_Attribute_Entry_t))

    #define SPPLE_TX_CHARACTERISTIC_ATTRIBUTE_OFFSET 2
    #define SPPLE_TX_CHARACTERISTIC_CCD_ATTRIBUTE_OFFSET 3
    #define SPPLE_TX_CREDITS_CHARACTERISTIC_ATTRIBUTE_OFFSET 5
    #define SPPLE_RX_CHARACTERISTIC_ATTRIBUTE_OFFSET 7
    #define SPPLE_RX_CREDITS_CHARACTERISTIC_ATTRIBUTE_OFFSET 9
    #define SPPLE_RX_CREDITS_CHARACTERISTIC_CCD_ATTRIBUTE_OFFSET 10

    /*********************************************************************/
    /** END OF SERVICE TABLE **/
    /*********************************************************************/

    /* The following MACRO is a utility MACRO that assigns the SPPLE */
    /* Service 16 bit UUID to the specified UUID_128_t variable. This */
    /* MACRO accepts one parameter which is a pointer to a UUID_128_t */
    /* variable that is to receive the SPPLE UUID Constant value. */
    /* * NOTE * The UUID will be assigned into the UUID_128_t variable in*/
    /* Little-Endian format. */
    #define SPPLE_ASSIGN_SPPLE_SERVICE_UUID_128(_x) ASSIGN_BLUETOOTH_UUID_128(*((UUID_128_t *)(_x)), 0x14, 0x83, 0x9A, 0xC4, 0x7D, 0x7E, 0x41, 0x5c, 0x9A, 0x42, 0x16, 0x73, 0x40, 0xCF, 0x23, 0x39)

    /* The following MACRO is a utility MACRO that exist to compare a */
    /* UUID 16 to the defined SPPLE Service UUID in UUID16 form. This */
    /* MACRO only returns whether the UUID_128_t variable is equal to the*/
    /* SPPLE Service UUID (MACRO returns boolean result) NOT less */
    /* than/greater than. The first parameter is the UUID_128_t variable*/
    /* to compare to the SPPLE Service UUID. */
    #define SPPLE_COMPARE_SPPLE_SERVICE_UUID_TO_UUID_128(_x) COMPARE_BLUETOOTH_UUID_128_TO_CONSTANT((_x), 0x14, 0x83, 0x9A, 0xC4, 0x7D, 0x7E, 0x41, 0x5c, 0x9A, 0x42, 0x16, 0x73, 0x40, 0xCF, 0x23, 0x39)

    /* The following defines the SPPLE Service UUID that is used when */
    /* building the SPPLE Service Table. */
    #define SPPLE_SERVICE_BLUETOOTH_UUID_CONSTANT { 0x39, 0x23, 0xCF, 0x40, 0x73, 0x16, 0x42, 0x9A, 0x5c, 0x41, 0x7E, 0x7D, 0xC4, 0x9A, 0x83, 0x14 }
    //#define SPPLE_SERVICE_BLUETOOTH_UUID_CONSTANT { 0x9a, 0xc4 }

    /* The following MACRO is a utility MACRO that assigns the SPPLE TX */
    /* Characteristic 16 bit UUID to the specified UUID_128_t variable. */
    /* This MACRO accepts one parameter which is the UUID_128_t variable */
    /* that is to receive the SPPLE TX UUID Constant value. */
    /* * NOTE * The UUID will be assigned into the UUID_128_t variable in*/
    /* Little-Endian format. */
    #define SPPLE_ASSIGN_TX_UUID_128(_x) ASSIGN_BLUETOOTH_UUID_128((_x), 0x07, 0x34, 0x59, 0x4A, 0xA8, 0xE7, 0x4b, 0x1a, 0xA6, 0xB1, 0xCD, 0x52, 0x43, 0x05, 0x9A, 0x57)

    /* The following MACRO is a utility MACRO that exist to compare a */
    /* UUID 16 to the defined SPPLE TX UUID in UUID16 form. This MACRO */
    /* only returns whether the UUID_128_t variable is equal to the TX */
    /* UUID (MACRO returns boolean result) NOT less than/greater than. */
    /* The first parameter is the UUID_128_t variable to compare to the */
    /* SPPLE TX UUID. */
    #define SPPLE_COMPARE_SPPLE_TX_UUID_TO_UUID_128(_x) COMPARE_BLUETOOTH_UUID_128_TO_CONSTANT((_x), 0x07, 0x34, 0x59, 0x4A, 0xA8, 0xE7, 0x4b, 0x1a, 0xA6, 0xB1, 0xCD, 0x52, 0x43, 0x05, 0x9A, 0x57)

    /* The following defines the SPPLE TX Characteristic UUID that is */
    /* used when building the SPPLE Service Table. */
    #define SPPLE_TX_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT { 0x57, 0x9A, 0x05, 0x43, 0x52, 0xCD, 0xB1, 0xA6, 0x1a, 0x4b, 0xE7, 0xA8, 0x4A, 0x59, 0x34, 0x07 }

    /* The following MACRO is a utility MACRO that assigns the SPPLE */
    /* TX_CREDITS Characteristic 16 bit UUID to the specified UUID_128_t */
    /* variable. This MACRO accepts one parameter which is the */
    /* UUID_128_t variable that is to receive the SPPLE TX_CREDITS UUID */
    /* Constant value. */
    /* * NOTE * The UUID will be assigned into the UUID_128_t variable in*/
    /* Little-Endian format. */
    #define SPPLE_ASSIGN_TX_CREDITS_UUID_128(_x) ASSIGN_BLUETOOTH_UUID_128((_x), 0xBA, 0x04, 0xC4, 0xB2, 0x89, 0x2B, 0x43, 0xbe, 0xB6, 0x9C, 0x5D, 0x13, 0xF2, 0x19, 0x53, 0x92)

    /* The following MACRO is a utility MACRO that exist to compare a */
    /* UUID 16 to the defined SPPLE TX_CREDITS UUID in UUID16 form. This*/
    /* MACRO only returns whether the UUID_128_t variable is equal to the*/
    /* TX_CREDITS UUID (MACRO returns boolean result) NOT less */
    /* than/greater than. The first parameter is the UUID_128_t variable*/
    /* to compare to the SPPLE TX_CREDITS UUID. */
    #define SPPLE_COMPARE_SPPLE_TX_CREDITS_UUID_TO_UUID_128(_x) COMPARE_BLUETOOTH_UUID_128_TO_CONSTANT((_x), 0xBA, 0x04, 0xC4, 0xB2, 0x89, 0x2B, 0x43, 0xbe, 0xB6, 0x9C, 0x5D, 0x13, 0xF2, 0x19, 0x53, 0x92)

    /* The following defines the SPPLE TX_CREDITS Characteristic UUID */
    /* that is used when building the SPPLE Service Table. */
    #define SPPLE_TX_CREDITS_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT { 0x92, 0x53, 0x19, 0xF2, 0x13, 0x5D, 0x9C, 0xB6, 0xbe, 0x43, 0x2B, 0x89, 0xB2, 0xC4, 0x04, 0xBA }

    /* The following MACRO is a utility MACRO that assigns the SPPLE RX */
    /* Characteristic 16 bit UUID to the specified UUID_128_t variable. */
    /* This MACRO accepts one parameter which is the UUID_128_t variable */
    /* that is to receive the SPPLE RX UUID Constant value. */
    /* * NOTE * The UUID will be assigned into the UUID_128_t variable in*/
    /* Little-Endian format. */
    #define SPPLE_ASSIGN_RX_UUID_128(_x) ASSIGN_BLUETOOTH_UUID_128((_x), 0x8B, 0x00, 0xAC, 0xE7, 0xEB, 0x0B, 0x49, 0xb0, 0xBB, 0xE9, 0x9A, 0xEE, 0x0A, 0x26, 0xE1, 0xA3)

    /* The following MACRO is a utility MACRO that exist to compare a */
    /* UUID 16 to the defined SPPLE RX UUID in UUID16 form. This MACRO */
    /* only returns whether the UUID_128_t variable is equal to the RX */
    /* UUID (MACRO returns boolean result) NOT less than/greater than. */
    /* The first parameter is the UUID_128_t variable to compare to the */
    /* SPPLE RX UUID. */
    #define SPPLE_COMPARE_SPPLE_RX_UUID_TO_UUID_128(_x) COMPARE_BLUETOOTH_UUID_128_TO_CONSTANT((_x), 0x8B, 0x00, 0xAC, 0xE7, 0xEB, 0x0B, 0x49, 0xb0, 0xBB, 0xE9, 0x9A, 0xEE, 0x0A, 0x26, 0xE1, 0xA3)

    /* The following defines the SPPLE RX Characteristic UUID that is */
    /* used when building the SPPLE Service Table. */
    #define SPPLE_RX_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT { 0xA3, 0xE1, 0x26, 0x0A, 0xEE, 0x9A, 0xE9, 0xBB, 0xb0, 0x49, 0x0B, 0xEB, 0xE7, 0xAC, 0x00, 0x8B }

    /* The following MACRO is a utility MACRO that assigns the SPPLE */
    /* RX_CREDITS Characteristic 16 bit UUID to the specified UUID_128_t */
    /* variable. This MACRO accepts one parameter which is the */
    /* UUID_128_t variable that is to receive the SPPLE RX_CREDITS UUID */
    /* Constant value. */
    /* * NOTE * The UUID will be assigned into the UUID_128_t variable in*/
    /* Little-Endian format. */
    #define SPPLE_ASSIGN_RX_CREDITS_UUID_128(_x) ASSIGN_BLUETOOTH_UUID_128((_x), 0xE0, 0x6D, 0x5E, 0xFB, 0x4F, 0x4A, 0x45, 0xc0, 0x9E, 0xB1, 0x37, 0x1A, 0xE5, 0xA1, 0x4A, 0xD4)

    /* The following MACRO is a utility MACRO that exist to compare a */
    /* UUID 16 to the defined SPPLE RX_CREDITS UUID in UUID16 form. This*/
    /* MACRO only returns whether the UUID_128_t variable is equal to the*/
    /* RX_CREDITS UUID (MACRO returns boolean result) NOT less */
    /* than/greater than. The first parameter is the UUID_128_t variable*/
    /* to compare to the SPPLE RX_CREDITS UUID. */
    #define SPPLE_COMPARE_SPPLE_RX_CREDITS_UUID_TO_UUID_128(_x) COMPARE_BLUETOOTH_UUID_128_TO_CONSTANT((_x), 0xE0, 0x6D, 0x5E, 0xFB, 0x4F, 0x4A, 0x45, 0xc0, 0x9E, 0xB1, 0x37, 0x1A, 0xE5, 0xA1, 0x4A, 0xD4)

    /* The following defines the SPPLE RX_CREDITS Characteristic UUID */
    /* that is used when building the SPPLE Service Table. */
    #define SPPLE_RX_CREDITS_CHARACTERISTIC_BLUETOOTH_UUID_CONSTANT { 0xD4, 0x4A, 0xA1, 0xE5, 0x1A, 0x37, 0xB1, 0x9E, 0xc0, 0x45, 0x4A, 0x4F, 0xFB, 0x5E, 0x6D, 0xE0 }

    These are the UUID  of the SPPLE service and characteristics in the program of peripheral side.

    Attached uuid of the characteristic of the spple service.

    Here there is 5 UUID of 128 bit . My doubt is how to add all uuid  which is 128 bit characteristics. In the  example program of the LBS service they are adding 16 bit characteristics and 16 bit Service UUID .

    And one more doubt is what do i need to add the LBS BASE UUID  ..I dont know the base uuid  of the spple service . I know only the spple service uuid  which is of 128 bit UUID. 

    Plz give me the solution.

Related