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

Reg : NUS_C Multilink issue

Dear Nordic Team, 

Thanks for supporting. 

Currently i am trying to work with multilink central in NUS_C example based on ble_app_multilink_central. The edited code was compiled successfully. But i got error " 0> <error> app: Fatal error" like this. Please support anyone. My complete code is here https://drive.google.com/open?id=1OO7ElWb5YVgkD8MlFNxThWn6vCiZrJuy

SDK : SDK15.2.0

Softdevice :s132_nrf52_6.1.0_softdevice

HW : DK52

Parents
  • Hi.

    When you provide a project for us to examine, please provide a project which compiles without any errors, there were some missing .c files and includes.

    If you had debugged the code you would have seen that in the function scan_init(void), the API call nrf_ble_scan_filer_set triggers the error code 7 (NRF_ERROR_INVALID_PARAM).

    If you look at the nrf_ble_scan.h file, you can read that this error is triggered because the filter type is incorrect, as shown below:

    /**@brief Function for adding any type of filter to the scanning.
     *
     * @details This function adds a new filter by type @ref nrf_ble_scan_filter_type_t.
     *          The filter will be added if the number of filters of a given type does not exceed @ref NRF_BLE_SCAN_UUID_CNT,
     *          @ref NRF_BLE_SCAN_NAME_CNT, @ref NRF_BLE_SCAN_ADDRESS_CNT, or @ref NRF_BLE_SCAN_APPEARANCE_CNT, depending on the filter type,
     *          and if the same filter has not already been set.
     *
     * @param[in,out] p_scan_ctx        Pointer to the Scanning Module instance.
     * @param[in]     type              Filter type.
     * @param[in]     p_data            The filter data to add.
     *
     * @retval NRF_SUCCESS                    If the filter is added successfully.
     * @retval NRF_ERROR_NULL                 If a NULL pointer is passed as input.
     * @retval NRF_ERROR_DATA_SIZE            If the name filter length is too long. Maximum name filter length corresponds to @ref NRF_BLE_SCAN_NAME_MAX_LEN.
     * @retval NRF_ERROR_NO_MEMORY            If the number of available filters is exceeded.
     * @retval NRF_ERROR_INVALID_PARAM        If the filter type is incorrect. Available filter types: @ref nrf_ble_scan_filter_type_t.
     * @retval BLE_ERROR_GAP_INVALID_BLE_ADDR If the BLE address type is invalid.
     */
    ret_code_t nrf_ble_scan_filter_set(nrf_ble_scan_t     * const p_scan_ctx,
                                       nrf_ble_scan_filter_type_t type,
                                       void const               * p_data);
    

    If you take a look inside nrf_ble_scan_filter_set() in nrf_ble_scan.c you can see that this is a default return error.

    And you want to scan on names, so the code needs to enter the NRF_BLE_SCAN_NAME_CNT switch case:

    #if (NRF_BLE_SCAN_NAME_CNT > 0)
            case SCAN_NAME_FILTER:
            {
                char * p_name = (char *)p_data;
                return nrf_ble_scan_name_filter_add(p_scan_ctx, p_name);
            }
    #endif

    This will only be entered if NRF_BLE_SCAN_NAME_CNT is set to 1 in sdk_config.h, which it was not set to.

    So you have to edit in sdk_config.h:

    // <o> NRF_BLE_SCAN_NAME_CNT - Number of name filters. 
    #ifndef NRF_BLE_SCAN_NAME_CNT
    #define NRF_BLE_SCAN_NAME_CNT 1
    #endif

    Hope this helps.

    - Andreas

Reply
  • Hi.

    When you provide a project for us to examine, please provide a project which compiles without any errors, there were some missing .c files and includes.

    If you had debugged the code you would have seen that in the function scan_init(void), the API call nrf_ble_scan_filer_set triggers the error code 7 (NRF_ERROR_INVALID_PARAM).

    If you look at the nrf_ble_scan.h file, you can read that this error is triggered because the filter type is incorrect, as shown below:

    /**@brief Function for adding any type of filter to the scanning.
     *
     * @details This function adds a new filter by type @ref nrf_ble_scan_filter_type_t.
     *          The filter will be added if the number of filters of a given type does not exceed @ref NRF_BLE_SCAN_UUID_CNT,
     *          @ref NRF_BLE_SCAN_NAME_CNT, @ref NRF_BLE_SCAN_ADDRESS_CNT, or @ref NRF_BLE_SCAN_APPEARANCE_CNT, depending on the filter type,
     *          and if the same filter has not already been set.
     *
     * @param[in,out] p_scan_ctx        Pointer to the Scanning Module instance.
     * @param[in]     type              Filter type.
     * @param[in]     p_data            The filter data to add.
     *
     * @retval NRF_SUCCESS                    If the filter is added successfully.
     * @retval NRF_ERROR_NULL                 If a NULL pointer is passed as input.
     * @retval NRF_ERROR_DATA_SIZE            If the name filter length is too long. Maximum name filter length corresponds to @ref NRF_BLE_SCAN_NAME_MAX_LEN.
     * @retval NRF_ERROR_NO_MEMORY            If the number of available filters is exceeded.
     * @retval NRF_ERROR_INVALID_PARAM        If the filter type is incorrect. Available filter types: @ref nrf_ble_scan_filter_type_t.
     * @retval BLE_ERROR_GAP_INVALID_BLE_ADDR If the BLE address type is invalid.
     */
    ret_code_t nrf_ble_scan_filter_set(nrf_ble_scan_t     * const p_scan_ctx,
                                       nrf_ble_scan_filter_type_t type,
                                       void const               * p_data);
    

    If you take a look inside nrf_ble_scan_filter_set() in nrf_ble_scan.c you can see that this is a default return error.

    And you want to scan on names, so the code needs to enter the NRF_BLE_SCAN_NAME_CNT switch case:

    #if (NRF_BLE_SCAN_NAME_CNT > 0)
            case SCAN_NAME_FILTER:
            {
                char * p_name = (char *)p_data;
                return nrf_ble_scan_name_filter_add(p_scan_ctx, p_name);
            }
    #endif

    This will only be entered if NRF_BLE_SCAN_NAME_CNT is set to 1 in sdk_config.h, which it was not set to.

    So you have to edit in sdk_config.h:

    // <o> NRF_BLE_SCAN_NAME_CNT - Number of name filters. 
    #ifndef NRF_BLE_SCAN_NAME_CNT
    #define NRF_BLE_SCAN_NAME_CNT 1
    #endif

    Hope this helps.

    - Andreas

Children
  • @Andreas thanks for reply. Here i am compile without error and upload firmware then only i got above mentioned error. 

    anyway thanks for your advice. As per your suggestion set NRF_BLE_SCAN_NAME_CNT 0 to 1 fatal error is solved.

    But i am face new issue, when i send data from peripheral i got below error

     0> <warning> ble_nus_c: Connection handle invalid.
    0> <error> app: Failed sending NUS message. Error 0x8.
    0> <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at ..\..\..\main.c:237
    0> PC at: 0x00027BE9
    0> <error> app: End of error report

     

  • Hi.

    I get no errors sending back and forward from the project you provided to a clean ble_peripheral\ble_app_uart example project.

     

    Murugan said:
     0> <warning> ble_nus_c: Connection handle invalid.

     Whats the name of the device you try to connect to?

    If you filter for names then this in your central:

    static char const m_target_periph_name[] = "Nordic_UART";   

    Should match this in your peripheral:

    #define DEVICE_NAME                     "Nordic_UART"    

    Here is the output I get when I try to scan for a device which I cant find (because the name is wrong) and i try to send a UART message:

    <info> app: Multilink NUS example started.
    <info> app: Start scanning for device name Nordic_UAR.
    <warning> ble_nus_c: Connection handle invalid.
    <warning> ble_nus_c: Connection handle invalid.
    <warning> ble_nus_c: Connection handle invalid.

    - Andreas

  • I am noticed Device names are same both side. One more question how to find peripheral when message received which data from which peripheral?. 

Related