This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

S130 Notification error BLE_ERROR_GATTS_SYS_ATTR_MISSING

Hello! I am trying to send a notification to a peer device when a certain event occurs. To do so, I'm using the same procedure as with every other characteristic with enabled notifications.

void init_buffer_status_char(){
    uint32_t err_code=0;

    ble_uuid_t char_uuid;
    char_uuid.uuid = BLE_UUID_BUFFER_STATUS_CHARACTERISTC_UUID;
    ble_uuid128_t base_uuid = BLE_UUID_OUR_BASE_UUID;
    err_code = sd_ble_uuid_vs_add(&base_uuid, &char_uuid.type);
    APP_ERROR_CHECK(err_code);


    //Attribute metadata
    ble_gatts_attr_md_t attr_md;
    memset(&attr_md, 0, sizeof(attr_md));
    attr_md.vlen = 1;
    attr_md.vloc = BLE_GATTS_VLOC_USER;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);


    //Characteristic metadata
    ble_gatts_attr_md_t cccd_md;
    memset(&cccd_md, 0, sizeof(cccd_md));
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
    cccd_md.vloc = BLE_GATTS_VLOC_STACK;


    ble_gatts_char_md_t char_md;
    memset(&char_md, 0, sizeof(char_md));
    char_md.char_props.read = 1;
    char_md.char_props.write = 1;
    char_md.char_props.notify = 1;
    char_md.p_cccd_md = &cccd_md;


    //Characteristic value
    ble_gatts_attr_t attr_char_value;
    memset(&attr_char_value, 0, sizeof(attr_char_value));
    attr_char_value.p_uuid = &char_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.max_len     = 1;
    attr_char_value.init_len    = 1;
    attr_char_value.p_value     = buffer_status_char_value;


    err_code = sd_ble_gatts_characteristic_add(ble_struct.status_service_handle, &char_md, &attr_char_value, &ble_struct.buffer_status_char_handle);
    APP_ERROR_CHECK(err_code);
}

However, when the notification function is ran, 0x3401 error occurs. According to documenttion that error is BLE_ERROR_GATTS_SYS_ATTR_MISSING. What may be causing this? When I connect with the nRF Master Control I can see the characteristic and its value, so does exist.

void notify_buffer_status(uint8_t status){
    int i=0;

    uint32_t err_code;

    buffer_status_char_value[0] = status;

    if (ble_struct.conn_handle != BLE_CONN_HANDLE_INVALID){
        uint16_t               len = 1;
        ble_gatts_hvx_params_t hvx_params;
        memset(&hvx_params, 0, sizeof(hvx_params));

        hvx_params.handle = ble_struct.buffer_status_char_handle.value_handle;
        hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
        hvx_params.offset = 0;
        hvx_params.p_len  = &len;
        hvx_params.p_data = buffer_status_char_value;

        if((err_code = sd_ble_gatts_hvx(ble_struct.conn_handle, &hvx_params)) != NRF_SUCCESS)
            SEGGER_RTT_printf(0, "Notification failed code: %d\n", err_code);
        else
            SEGGER_RTT_printf(0, "Sent notification\n");
    }

    else
    SEGGER_RTT_printf(0, "No connection.\n");
}
Parents Reply Children
No Data
Related