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

Easiest way for two nRF52x devices to ping each other?

Greetings Nords, total noob here, I've got two preview nRF52840 devices (as well as the two normal nRF52 devices), I want my two preview devices to be able to ping each other, what is the easiest way to achieve this? Do I need to setup a router, or not?

Can someone point me to the right direction, regards and many thanks

[update] in this blog, talking about communication between two devices, they say: "This is more or less the same as if we had used Bluetooth advertising with 125 kbps Long Range mode, one of the differences being that only one channel was used." that's what I want to achieve, but how?

Parents
  • If you just want two nRF52840 kits to talk to each other you can use any combination of central and peripheral in the SDK.

    If you want bluetooth long range you need to be in a connection and set the PHYsical layer data rate. The SoftDevice does not support long range advertising at the moment. One example that shows how to set the PHY data rate is the ATT MTU throughput example, but you can easily modify any examples to change to long range mode during a connection. What you have to do is first set the preferred PHY at startup to include long range mode (called CODED_PHY), for example:

    ble_opt_t opts;
    memset(&opts, 0x00, sizeof(ble_opt_t));
    
    opts.gap_opt.preferred_phys.tx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_CODED;
    opts.gap_opt.preferred_phys.rx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_CODED;
    
    ret_code_t err_code = sd_ble_opt_set(BLE_GAP_OPT_PREFERRED_PHYS_SET, &opts);
    APP_ERROR_CHECK(err_code);
    

    Then when you connect (for example in on_ble_gap_evt_connected(..) function) you have to call sd_ble_gap_phy_request(..) from either the peripheral or the central to actually set the PHY data rate:

    ble_gap_phys_t phys =
    {
        .tx_phys = BLE_GAP_PHY_CODED,
        .rx_phys = BLE_GAP_PHY_CODED,
    };
    
    err_code = sd_ble_gap_phy_request(p_gap_evt->conn_handle, &phys);
    APP_ERROR_CHECK(err_code);
    

    You should also check that you get the BLE_GAP_EVT_PHY_UPDATE event in on_ble_evt(..) and check that the PHY data rate was set correctly.

Reply
  • If you just want two nRF52840 kits to talk to each other you can use any combination of central and peripheral in the SDK.

    If you want bluetooth long range you need to be in a connection and set the PHYsical layer data rate. The SoftDevice does not support long range advertising at the moment. One example that shows how to set the PHY data rate is the ATT MTU throughput example, but you can easily modify any examples to change to long range mode during a connection. What you have to do is first set the preferred PHY at startup to include long range mode (called CODED_PHY), for example:

    ble_opt_t opts;
    memset(&opts, 0x00, sizeof(ble_opt_t));
    
    opts.gap_opt.preferred_phys.tx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_CODED;
    opts.gap_opt.preferred_phys.rx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_CODED;
    
    ret_code_t err_code = sd_ble_opt_set(BLE_GAP_OPT_PREFERRED_PHYS_SET, &opts);
    APP_ERROR_CHECK(err_code);
    

    Then when you connect (for example in on_ble_gap_evt_connected(..) function) you have to call sd_ble_gap_phy_request(..) from either the peripheral or the central to actually set the PHY data rate:

    ble_gap_phys_t phys =
    {
        .tx_phys = BLE_GAP_PHY_CODED,
        .rx_phys = BLE_GAP_PHY_CODED,
    };
    
    err_code = sd_ble_gap_phy_request(p_gap_evt->conn_handle, &phys);
    APP_ERROR_CHECK(err_code);
    

    You should also check that you get the BLE_GAP_EVT_PHY_UPDATE event in on_ble_evt(..) and check that the PHY data rate was set correctly.

Children
Related