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

how to receive data with ble_app_multilink_central ?

// code to receive data
void getData(uint8_t* recData,uint8_t* saveData, uint8_t index)
	{
		saveData[index] = recData[index];
		
}

void  nus_data_handler(ble_nus_t *p_nus, uint8_t * p_data, uint16_t length) 
{
for (uint32_t i = 0; i < length; i++)
{
getData(p_data, bleRecData, i);
	NRF_LOG_INFO("Receive\n");

    while(app_uart_put(p_data[i]) != NRF_SUCCESS);
}
while(app_uart_put('\n') != NRF_SUCCESS); 
}



// initialization of services
void services_init(void)
{
    uint32_t       err_code;
    ble_nus_init_t nus_init;

    memset(&nus_init, 0, sizeof(nus_init)); 
	
    nus_init.data_handler = nus_data_handler;

    err_code = ble_nus_init(&m_nus,&nus_init);
	
    APP_ERROR_CHECK(err_code);
    
    
//int main
int main(void)
{
    ret_code_t err_code;

    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);
    NRF_LOG_INFO(" Multilink Example\r\n");
	
    leds_init();
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    buttons_init();
    ble_stack_init();
    services_init();
    db_discovery_init();
    lbs_c_init();
    uart_init();
	  
    // Start scanning for peripherals and initiate connection to devices which advertise.
    scan_start();
    // Turn on the LED to signal scanning.
    bsp_board_led_on(CENTRAL_SCANNING_LED);

    for (;;)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            // Wait for BLE events.
            power_manage();
        }
    }
}

    
    
    

	
	
	
}

I have a problem that bothers me for days.

I try to run this code on nrf51 to receive data from anathor nrf51 

please i need help for my final project  

Parents
  • Hi!  I want to send data from nrf51 to another nrf51 multilink_central! I don't have any problem about sending data! It's work with a perfect way! But my problem is how to receive data with multilink_central! the connection is established between sender and the receiver ( multilink_central).
    So i use the nus_data_handler()  to analyze the data received and i called in init_service()
    Please help me because this method doesn't work

Reply
  • Hi!  I want to send data from nrf51 to another nrf51 multilink_central! I don't have any problem about sending data! It's work with a perfect way! But my problem is how to receive data with multilink_central! the connection is established between sender and the receiver ( multilink_central).
    So i use the nus_data_handler()  to analyze the data received and i called in init_service()
    Please help me because this method doesn't work

Children
No Data
Related