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

error 7 after ble_db_discovery_start

Hi,

I am using SDK15.3 and nrf52832. I am using multilink central example to connect to my peripheral device. I have one peripheral and one central device.

As soon as I connect to the peripheral device I call ble_db_discovery_start(). This returns error 7.

What could be the issue?

Thank you,

Ashish

  • Hi.

    Are you absolutely sure that it returns error 7? It should not be able to return error 7, only error 14, 8, 17, and 0.

    Could you please confirm this?

    Best regards,

    Andreas

  • Thank you for the prompt response.

    Yes that's the error code I get. I print out the error code after a call to ble_db_discovery_start

    case BLE_GAP_EVT_CONNECTED:
            {
                NRF_LOG_INFO("Connection 0x%x established, starting DB discovery.",
                             p_gap_evt->conn_handle);
    
                APP_ERROR_CHECK_BOOL(p_gap_evt->conn_handle < NRF_SDH_BLE_CENTRAL_LINK_COUNT);
    
                err_code = ble_trs_c_handles_assign(&m_trs_c[p_gap_evt->conn_handle],
                                                   p_gap_evt->conn_handle,NULL);
                APP_ERROR_CHECK(err_code);
    			
    			memcpy(p_addr.addr, p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr, 6);
    			//generate_key(p_addr.addr);
    
    			//memset(&m_db_disc, 0x00, sizeof(m_db_disc));
    			memset(&m_db_disc[p_gap_evt->conn_handle], 0x00, sizeof(ble_db_discovery_t));
    			
                err_code = ble_db_discovery_start(&m_db_disc[p_gap_evt->conn_handle],
                                                  p_gap_evt->conn_handle);
    											  
    			NRF_LOG_INFO(" Error %x", err_code);
                if (err_code != NRF_ERROR_BUSY)
                {
                    APP_ERROR_CHECK(err_code);
                }
    			
                // Update LEDs status and check whether it is needed to look for more
                // peripherals to connect to.
                //bsp_board_led_on(CENTRAL_CONNECTED_LED);
                if (ble_conn_state_central_conn_count() == NRF_SDH_BLE_CENTRAL_LINK_COUNT)
                {
                    //bsp_board_led_off(CENTRAL_SCANNING_LED);
                }
                else
                {
                    // Resume scanning.
                    //bsp_board_led_on(CENTRAL_SCANNING_LED);
                    //scan_start();
                }
    			//scan_start();
    			
    			#ifdef CBLE_Add_Debug_Device
    					uint8_t Conn_count = 0;
    					Conn_count = ble_conn_state_central_conn_count();
    					SEGGER_RTT_printf(0, "Connected %d to %02x%02x%02x%02x%02x%02x" RTT_CTRL_RESET"\n", Conn_count, p_addr.addr[5],
    												p_addr.addr[4], p_addr.addr[3], p_addr.addr[2], p_addr.addr[1],p_addr.addr[0]);
    			#endif
            } break; // BLE_GAP_EVT_CONNECTED

    I further investigated the issues and it seems the error happens after a call to sd_ble_gattc_primary_services_discover.

    Thank you,

    Ashish

  • Hi Ashish, 

    Andreas has left Nordic, I'm taking over his case. 

    You are right, most likely the error 7 returned by sd_ble_gattc_primary_services_discover() . We need to update ble_db_discovery_start() description. 

    We need to have a look at the parameters you provided to sd_ble_gattc_primary_services_discover(). Could you add a breakpoint and check the value ? 

  • Hi,

    I think I found out why it was giving me error. I had forgotten to include battery services on the central side.

    Once I included it, the code works fine. Thank you for your help. 

    Also can you point me to example code other than UART for sending data from central to peripheral and vice versa.

    Thank you,

    Ashish

  • Hi Ashish, 

    Glad that you found the issue. Besides the UART example you can also have a look at the ble_app_blinky_c and the ble_app_hrs_c example. 

Related