How to use passkey in BT_NUS_SECURITY_ENABLED

Hello

I   need passkey

I  am working  on  a   project 

I connected the  peripheral_uart  to android application 

So   I send the data on   application  , I need a secure connection to   connected the  ble device on   application   . So  i set a passkey for   secure connection 

So the peripheral_uart request for passkey to application then we enter a passkey   then the peripheral_uart is connected with application . .

I Enabled the   BT_NUS_SECURITY_ENABLED  ,

CONFIG_BT_FIXED_PASSKEY=y in prj.config 

I used this Board - NRF5340_DK

version-nrf connect sdk v 1.9.1 

This is my  prj.config

##

# Copyright (c) 2018 Nordic Semiconductor

#

# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

#



# Enable the UART driver

CONFIG_UART_ASYNC_API=y

CONFIG_NRFX_UARTE0=y

CONFIG_SERIAL=y



CONFIG_GPIO=y



# Make sure printk is printing to the UART console

CONFIG_CONSOLE=y

CONFIG_UART_CONSOLE=y



CONFIG_BT=y

CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="kulr-12345"
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_APPEARANCE=833

CONFIG_BT_MAX_CONN=1

CONFIG_BT_MAX_PAIRED=1

CONFIG_BT_SMP_ENFORCE_MITM=n



# Enable the NUS service

CONFIG_BT_NUS=y



# Enable bonding

CONFIG_BT_SETTINGS=y

CONFIG_FLASH=y

CONFIG_FLASH_PAGE_LAYOUT=y

CONFIG_FLASH_MAP=y

CONFIG_NVS=y

CONFIG_SETTINGS=y




# Enable DK LED and Buttons library

CONFIG_DK_LIBRARY=y



# This example requires more workqueue stack

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048



# Config logger

CONFIG_LOG=y

CONFIG_USE_SEGGER_RTT=y

CONFIG_LOG_BACKEND_RTT=y

CONFIG_LOG_BACKEND_UART=n

CONFIG_ASSERT=y



CONFIG_SEGGER_RTT_BUFFER_SIZE_DOWN=64

CONFIG_MAIN_STACK_SIZE=4096

CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096

CONFIG_LOG_BUFFER_SIZE=4096

CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_BT_NUS_SECURITY_ENABLED=y

CONFIG_BT_BUF_ACL_RX_SIZE=128

CONFIG_BT_L2CAP_TX_MTU=128

CONFIG_BT_SMP=y



CONFIG_FPU=y
CONFIG_BT_FIXED_PASSKEY=y

Parents
  • Hi abhay_keyss,

    Am I right to understand that you expect passkey to be required, but when you perform pairing, you don't see it?

    The reason is because in your prj.conf you are explicitly setting CONFIG_BT_SMP_ENFORCE_MITM=n.

    If you set it to y, you should see passkey being requested by the peripheral application right away.

    Why did you have to set CONFIG_BT_SMP_ENFORCE_MITM?

    Hieu

  • Hi

    Thanks for your response

    Hieu said:Am I right to understand that you expect passkey to be required, but when you perform pairing, you don't see it?

    Yes, but for that I have not written a code yet, I need a start point to understand where/how should I hardcode the passkey so that the board won't connect to app till it get passkey.

    Hieu said:

    CONFIG_BT_SMP_ENFORCE_MITM=n

    Gotcha, I have enabled this and CONFIG_BT_FIXED_PASSKEY=y 

    Note: If you have the sample or example application where I can get this feature, Please suggest

Reply
  • Hi

    Thanks for your response

    Hieu said:Am I right to understand that you expect passkey to be required, but when you perform pairing, you don't see it?

    Yes, but for that I have not written a code yet, I need a start point to understand where/how should I hardcode the passkey so that the board won't connect to app till it get passkey.

    Hieu said:

    CONFIG_BT_SMP_ENFORCE_MITM=n

    Gotcha, I have enabled this and CONFIG_BT_FIXED_PASSKEY=y 

    Note: If you have the sample or example application where I can get this feature, Please suggest

Children
Related