1. I had done the pairing without any authentication but now I want to do it with the authentication with an authentication key.
2. please provide some sample code regarding the pairing authentication and its process.
1. I had done the pairing without any authentication but now I want to do it with the authentication with an authentication key.
2. please provide some sample code regarding the pairing authentication and its process.
Hi,
Are you using NCS or nRF5SDK?
-Amanda
Hi team,
I am using the nRF52DK module PCA10040 board
You can take a look at this UART/Serial Port Emulation over BLE.
-Amanda
Respected Amanda,
I had one more doute and that is
1. Once the data was received from the nrf_connect app(master) to PCA10040(nrf52832). I want to store that data into the variable
2. and Once the data is received data is stored in the variable after that I want to perform the accordingly.
3. is there is any example based on above situation in the sdk.
Hi,
You can take a look at this UART/Serial Port Emulation over BLE. The Receive data is p_evt->params.rx_data.p_data.
-Amanda
Hi, Amanda,
need some help,
I want to wait till the new data has not been received from the (p_evt->params.rx_data.p_data.) from the nrf connect app.
could u please tell me how its done
and I am storing that new data in the array.
would u please tell me how its been done.
depends on I want to write logic
Hi, Amanda,
need some help,
I want to wait till the new data has been received from the (p_evt->params.rx_data.p_data.) from the nrf connect app.
could u please tell me how it is done
and I am storing that new data in the array
would u please tell me how it's been done?
depends on I want to write logic.
Hi, Amanda,
need some help,
I want to wait till the new data has been received from the (p_evt->params.rx_data.p_data.) from the nrf connect app.
could u please tell me how it is done
and I am storing that new data in the array
would u please tell me how it's been done?
depends on I want to write logic.
and once the data has received then I want to out of that wait state
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
int attempt = 0;
char arr[6];
char arr_1[6];
bool flag = 0;
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
uint32_t err_code;
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 (uint32_t 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);
}
//storing the data into array which is comming from the ble_master(nrf_connect app)
for(int i=0; i<=5; i++)
{
arr[i] = p_evt->params.rx_data.p_data[i];
}
if(strcmp(arr, "123456") == 0)
{
printf("\nPassword is correct");
}
if(strcmp(arr, "123456") != 0)
{
printf("\nPassword is incorrect!!! Please try again");
printf("\nPassword : ");
//strcpy(arr_1, arr);
if(strcmp(arr, "123456") == 0)
{
printf("\nPassword is correct");
}
}
}
}
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
int attempt = 0;
char arr[6];
char arr_1[6];
bool flag = 0;
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
uint32_t err_code;
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 (uint32_t 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);
}
//storing the data into array which is comming from the ble_master(nrf_connect app)
for(int i=0; i<=5; i++)
{
arr[i] = p_evt->params.rx_data.p_data[i];
}
if(strcmp(arr, "123456") == 0)
{
printf("\nPassword is correct");
}
if(strcmp(arr, "123456") != 0)
{
printf("\nPassword is incorrect!!! Please try again");
printf("\nPassword : "); // Here I want to wait till the new data had arrived
//strcpy(arr_1, arr);
if(strcmp(arr, "123456") == 0)
{
printf("\nPassword is correct");
}
}
}
}I want implement the logic as like it as it as follow like normal C code below. with 3 password attempt.
#include<stdio.h>
#include<string.h>
int main()
{
char password[6];
// 1st attempt
printf("\nPlease enter the password : ");
scanf("%s",&password); // provides the wait state
if(strcmp(password, "123456") == 0)
{
printf("\nPassword is correct");
}
if(strcmp(password, "123456") != 0)
{ // 2nd attempt
printf("\nPassword is not correct!!! please try again");
printf("\nPlease enter the password : ");
scanf("%s",&password); // provide the wait state
if(strcmp(password, "123456") == 0)
{
printf("\nPassword is correct");
}
if(strcmp(password, "123456") != 0)
{
// 3rd attempt
printf("\nPassword is not correct!!! please try again");
printf("\nPlease enter the password : ");
scanf("%s",&password); // provide the wait state
if(strcmp(password, "123456") == 0)
{
printf("\nPassword is correct");
}
if(strcmp(password, "123456") != 0)
{
printf("\nYour all attempt had finished!! Please reset device");
}
}
}
return 0;
}the above same type of logic I want to Implement in the nus data handler "Password with 3 attempt".
for that I want to add the wait state till the new data had arrives.