how to send string data from nrf51 to nrf 52 with BLE

Hello ! I encountered a problem in sending and receiving data from one nrf51 card to another nrf52 card

i use this method in (ble_config.c) to send string data : 

void send_string(char * string_to_send)
{
ble_nus_string_send(&m_nus, (uint8_t *) string_to_send, strlen(string_to_send));
}

----------------------------------------------------------------------------------------------------------------------------------------------------

in main.c :


if (hakim.state == BLUETOOTH_COMMUNICATION_STATE)
{
bno055_read_euler_hrp(&(hakim.motion_sensor.angles));
sprintf(result, "%d",hakim.motion_sensor.angles.p);
send_string(result) ;
SEGGER_RTT_printf(0," \n données envoyé= %s \n",result) ;
nrf_delay_ms(500);


SEGGER_RTT_printf(0, " roll =%d pitch=%d yaw=%d \n",hakim.motion_sensor.angles.r,hakim.motion_sensor.angles.p , hakim.motion_sensor.angles.h); //for debug

}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

and for receive data i use this method 

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);
SEGGER_RTT_printf(0, "Receive %s\n", p_data);
while(app_uart_put(p_data[i]) != NRF_SUCCESS);
}
while(app_uart_put('\r') != NRF_SUCCESS);
while(app_uart_put('\n') != NRF_SUCCESS);
}

/**@brief Function for initializing services that will be used by the application.
*/
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);
}

void mainInit(void)
{

services_init();

}

Parents
No Data
Reply Children
No Data