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

NRF51822 connect to PC then disconnect to link with other PC.

Hi,

Just like the topic description.

The sample code I used is ble_app_hids_keyboard (V11 S130) and the development board is PCA10028.

I found after I load the code I can connect with the first PC and the function is worked.

When I disconnect the board, it just cannot connect with the second PC and the second PC cannot scan the board.

Thus I just erase the program and load the code again, it just can connect with the PC but still cannot connect with the second one.

Have anyone meet the same problem, could someone help to deal with it?

kind regards,

Wedy

Parents Reply Children
  • Hi Terje,

    Thank you for the response.

    Maybe I should clarify the difficult I met.

    Actually I just couldn't found the BT device when I want to use the second PC to connect it.

    And I just modified by your recommendation, it can be scanned by the second PC now but when I linked with it, the driver error is showed even I turn back to try the first PC it show the same error.

    /**@brief Function for initializing the Advertising functionality.
     */
    static void advertising_init(void)
    {
        uint32_t       err_code;
        uint8_t        adv_flags;
        ble_advdata_t  advdata;
    
        // Build and set advertising data
        memset(&advdata, 0, sizeof(advdata));
    
        adv_flags                       = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
        advdata.name_type               = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance      = true;
        advdata.flags                   = adv_flags;
        advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        ble_adv_modes_config_t options =
        {
    				//Wedy 11/19 connect to the second device (change whitelikst status to disable)
            //BLE_ADV_WHITELIST_ENABLED,
    				BLE_ADV_WHITELIST_DISABLED,
    			
            BLE_ADV_DIRECTED_ENABLED,
            BLE_ADV_DIRECTED_SLOW_DISABLED, 0,0,
            BLE_ADV_FAST_ENABLED, APP_ADV_FAST_INTERVAL, APP_ADV_FAST_TIMEOUT,
            BLE_ADV_SLOW_ENABLED, APP_ADV_SLOW_INTERVAL, APP_ADV_SLOW_TIMEOUT
        };
    
        err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, ble_advertising_error_handler);
        APP_ERROR_CHECK(err_code);
    }
    

    As you can see in the code, I have set the whitelist disable.

    Does there has any part I didn't modified?

    BTW, the development board I used doesn't have the second button. 

    Kind regards,

    Wedy   

  • Hi,

    The pca10028, which is the nRF51 DK, should have four buttons.

    What "driver error" is shown? Can you elaborate?

    Have you tried debugging, to see if you get a hardfault or something?

    I realize that you use SDK 11, which uses the "device manager" for keeping track of bonds. (From SDK 12 we started using the "peer manager" instead, which does things a little bit differently.) From what I can see in this example the bond manager is used to only keep track of one peer, and that may have to be handled as well if you want to handle multiple peers.

    You could compare the project to one that does not use whitelisting, e.g. the ble_app_hrs example.

    In any case I would recommend moving to SDK v12.3 for the nRF51 series, as that is the newest SDK release with support for nRF51.

    Regards,
    Terje

  • Hi Terje,

    I am using the PCA10028 but I would like to do the development by 1 buttons feature.

    And I just realize that button1 (put device to sleep) and button2 (wake up the device), thus whenever I try to connect to the next device when it disconnect with the first PC I just cannot scan it with the second one, I must need to put the device into sleep mode then wake up to connect with the second PC.

    According to this, I should clarify my question again: Does there have any way can erase the record when disconnected then be capable to link by the second PC.

    Thanks

    BR,

    Wedy

  • Hi Terje,

    I just have try to use the SDK12, but according to the code size...I couldn't load it into device by MDK Lite version.

    I also try to use the hex which was include in the SDK file but the nRFgo Studio show error when I tried to program the hex. 

    According to the above problems, I was trying to modified the code of SDK12 ble_hid_keaboard, I remove the parts of ble_dis and ble_bas then I can program and load it finally. Unfortunately, the device wasn't work correctly.

    Is it possible to add the peer manager into SDK11 directly to test the peer function? I just saw there are different header are included in main, such like fds.h, fstorage.h, should I also replace the restorage.h with those header?

  • Hi,

    Yes, if you use the trial version of the Keil IDE then there is a limit on code size of 32 kb.

    What is the error that you get from nRFgo Studio? Alternatively you can use the command line tool "nrfjprog" to program the board.

    nrfjprog --eraseall
    nrfjprog --program hexfile.hex
    nrfjprog --reset

    Where hexfile.hex is the hexfile that you want to program. If you also need the SoftDevice then you can program that one before the call to reset the board.

    Removing parts of the example is not recommended, as that may lead to undefined behavior. If you remove BLE services then you must take care to remove all the related code and settings.

    I do not recommend adding peer manager to SDK 11, if you have the option to use SDK 12 instead. Also, modifying the SDK 11 example to use peer manager is likely to make the project bigger, so that you get the same size limitation issue as with the SDK 12 example.

    Regards,
    Terje

Related