I can send data from nRF Connect App to nRF52-DK. But what are the data type of sent data type?

Hello,

I can see sent data in data variable when i send to data from Android app to nRF52-DK. But i have a question about this situation. How can i use this data type in printf function and if loop? The code is below.

Sent data equal to pointer type variable in nRF52-DK. Because of this i can't use this sent data. I have to compare sent data and any constant  variable. For example, if(send_data == constant value) {bps_board_leds_on; printf("leds on"); } I try to do that but it can't work. How can i fix this problem?  

Thank you.

static void nus_data_handler(ble_nus_evt_t * p_evt)
{

if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
uint32_t err_code;
uint32_t i=0;

//NRF_LOG_DEBUG("Received data from BLE NUS. Writing data on UART.");
//NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);

for (i = 0; i < p_evt->params.rx_data.length; i++)
{
do
{
//err_code = app_uart_put(p_evt->params.rx_data.p_data[i]);

if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
{
NRF_LOG_ERROR("Failed receiving NUS message. Error 0x%x. ", err_code);
APP_ERROR_CHECK(err_code);

}

} while (err_code == NRF_ERROR_BUSY);
}
if (p_evt->params.rx_data.p_data[p_evt->params.rx_data.length - 1] == '\r')
{
while (app_uart_put('\n') == NRF_ERROR_BUSY);
}
//printf(p_evt->params.rx_data.p_data);

unsigned int data = (char *)p_evt->params.rx_data.p_data;

printf("DATA: ");
printf(data);
printf("\n\n");

int var_one = 100;
int var_two = 200;

printf("AC DEGERI: %d \n\n",var_one);
printf("KAPA DEGERI: %d\n\n",var_two);

if(data == var_one)
{
bsp_board_leds_on();
printf(p_evt->params.rx_data.p_data);
printf("LEDs OPENNED \n");
}

if(data == var_two)
{
bsp_board_leds_off();
printf(p_evt->params.rx_data.p_data);
printf("LEDs CLOSED \n");
}

}
}

Related