Long range data transfer from central to peripheral

Hi,

 In my application i am trying out to transfer data in Long range BLE_GAP_PHY_CODED mode , i have set my peripheral has to advertise in PHY coded mode below is the advertising init function which changed to phy coded. i am using ble_app_blinky_c  for central and ble_app_blinky  example in peripheral

static void advertising_init_phycoded(uint16_t adv_timeout)
{
ret_code_t err_code;
ble_advdata_t advdata;
ble_advdata_t srdata;
ble_advdata_manuf_data_t manuf_specific_data;

manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
manuf_specific_data.data.p_data = (uint8_t *) NORMAL_BEACON;
manuf_specific_data.data.size = APP_BEACON_INFO_LENGTH;

// ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}};

// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));

// advdata.name_type = BLE_ADVDATA_NO_NAME;
advdata.include_appearance = false;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
advdata.p_manuf_specific_data = &manuf_specific_data;
memset(&srdata, 0, sizeof(srdata));
// srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
// srdata.uuids_complete.p_uuids = adv_uuids;

err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
APP_ERROR_CHECK(err_code);

err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
APP_ERROR_CHECK(err_code);

ble_gap_adv_params_t adv_params;

// Set advertising parameters.
memset(&adv_params, 0, sizeof(adv_params));

adv_params.primary_phy = BLE_GAP_PHY_CODED;
adv_params.secondary_phy = BLE_GAP_PHY_CODED;
adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED;
// }
// else{
// adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED;
// }
adv_params.p_peer_addr = NULL;
adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
adv_params.scan_req_notification = 1;
if(battery_level == 0 || battery_level >= BATTERY_VOLTAGE_MIN_FOR_DISPLAY){
adv_params.interval = COASTER_ADV_INTERVAL;
}
else{
adv_params.interval = LOW_LEVEL_BATTERY_INTERVAL;
}
adv_params.duration = adv_timeout; // Never time out.

err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
APP_ERROR_CHECK(err_code);
sd_ble_gap_adv_set_configure(&m_adv_handle,&m_adv_data,&adv_params);
NRF_LOG_INFO("m_adv_data.adv_data.p_data address %p", m_adv_data.adv_data.p_data);
}

same as my central is in scannng the beacon which is in phy coded and gets connected also but no data transfrer happens after MTU request gets disconnecting from the peripheral .

#define SCAN_INTERVAL (2*0x00A0) /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW 0x00A0 /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_DURATION 0x0000


static ble_gap_scan_params_t m_scan_param = /**< Scan parameters requested for scanning and connection. */
{
.active = 0x01,
.interval = SCAN_INTERVAL,
.window = SCAN_WINDOW,
.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
.timeout = SCAN_DURATION,
.scan_phys = BLE_GAP_PHY_1MBPS|BLE_GAP_PHY_CODED,
.extended = 1,
};

please advise what i have missed here for PHY coded data transfer .

Thanks in advance.

best regards.

  • Hi 

    Are you able to share your project with me? 
    If so, please just zip the project folder, with source and project files included. 

    If so I can try to run it here, and see if I can reproduce the issue. 

    Best regards
    Torbjørn

  • hi ,

    its working in LBS service now !! and data transfer maximum length 27 bytes when using Coded PHY ?it possible to extend the length ?

  • Hi 

    Good to hear you got it working Slight smile

    It should be possible to extend the length, yes, but you need to increase the NRF_SDH_BLE_GAP_DATA_LENGTH and NRF_SDH_BLE_GATT_MAX_MTU_SIZE parameters in sdk_config.h in order to be able to support extended MTU. Once you do this you will also need to increase the amount of RAM assigned to the SoftDevice (as shown in this Youtube video). 

    Finally, you would need to change the service configuration as well, since the LBS service only supports 1 byte data transfer, but possibly you already did this?
    This is another reason to use the NUS service instead, as it is set up to support longer packets. 

    Best regards
    Torbjørn

  • NRF_15_2.rar

    yes , Lbs i have already changes done on service configurations. and For PHY coded increased the size of GAP_DATA_LENGTH but not able to transfer more then 27 bytes , i have attached  my demo file please advice what  i have missed here.

    #ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
    #define NRF_SDH_BLE_GAP_DATA_LENGTH 251
    #endif

    #ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH
    #define NRF_SDH_BLE_GAP_EVENT_LENGTH 6
    #endif

    // <o> NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size.
    #ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
    #define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
    #endif

    regards

    sowmiya

  • Hi Sowmiya

    Another reason to use the ble_app_uart example is that it handles the MTU exchange for you. The blinky example does not, since you don't need extended MTU to send a single byte back and forth ;)

    In order to see how this is done I would recommend simply having a look at the ble_app_uart and ble_app_uart_c example. In particular, take a look at the implementation of the void gatt_init(void) function in main.c, which configures the GATT module that is responsible for handling the MTU exchange. 

    Best regards
    Torbjørn

Related