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

unable to enter passkey using uart after BLE_GAP_EVT_AUTH_KEY_REQUEST event

hii team,

iam trying to pair my central app with one peripheral device which is generating random passkey while pairing .when central (my App) is sending pairing request to peripheral iam getting BLE_GAP_EVT_AUTH_KEY_REQUEST event then iam trying uart_get to take PASSKEY but when iam calling this UART_GET function my app is stucking in that function and iam unable to enter anything in my uart to get passkey which is required for pairing.please help me how to solve this problem.

thank you.

APP_code:

	case BLE_GAP_EVT_AUTH_KEY_REQUEST:
		printf("Enter 6 DIGIT Passkey \r\n");
		UART_GET(p_ble_evt);
	break;				

void UART_GET(ble_evt_t * p_ble_evt)
{
	uint8_t Passkey[10]="526453",i=0;
	ret_code_t err_code;
	printf(" in req_passkey function \r\n");
	
    while (i <6)
    {
        uint8_t cr;
        while (app_uart_get(&cr) != NRF_SUCCESS){};
        while (app_uart_put(cr) != NRF_SUCCESS){};

        if (cr != 0xD)
        {  
			Passkey[i] = cr;
			i++;
        }
	    else
	    {
		    break;
        }
    }
		
	err_code = sd_ble_gap_auth_key_reply(p_ble_evt->evt.gap_evt.conn_handle,BLE_GAP_AUTH_KEY_TYPE_PASSKEY,Passkey);
	NRF_LOG_INFO(" auth_key _reply err_code : %d \r\n",err_code);
	APP_ERROR_CHECK(err_code);
}
Related