Be able to have a pairing BLE connexion with fixed password/passkey

Hi,

I would like to make it mandatory to enter a password whenever you want to connect to my peripheral device nrf52840.

I use NCS 2.4.2.

First of all i want to succed connexion with a password when i try connexion with my phone and after i will need to implement also a central device nrf52840.

I don't find any example to succed this secure connexion, can you help me ?

Best regards,

Pierre-yves

Parents
  • Hi

    To make a project require bonding, you can use the CONFIG_BT_BONDING_REQUIRED to make sure remote devices are required to bond in a pairing request. There are multiple projects in the Bluetooth samples that do pairing and can be configured to do bonding. 

    As for the passkey, this has already been asked in the DevZone, and you can take a look at I.E. this ticket on the matter already.

    Best regards,

    Simon

  • Ty !
    I added this config to my project but when i try connection there isn't paring request at all. I checks many project but don't understand how to have the request..
    i saw many tickets but the password request don't appear wheni try to connect and some ticket talk about passkey for characteristics but not connexion.

    Here is my prj.conf

    # nothing here
    # nothing here
    # Enable Bluetooth
    CONFIG_BT=y
    #CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_SMP=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DIS=y
    CONFIG_BT_DIS_PNP=n
    
    CONFIG_BT_DEVICE_NAME="Heating_Sensor"
    #CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y 
    CONFIG_BT_EXT_ADV=y
    CONFIG_BT_USER_PHY_UPDATE=y
    CONFIG_BT_CTLR_PHY_CODED=y
    
    # Use connection parameters that ensure quick data transfer
    #CONFIG_BT_PERIPHERAL_PREF_MIN_INT=800
    #CONFIG_BT_PERIPHERAL_PREF_MAX_INT=800
    #CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
    #CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
    #CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=y
    
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_L2CAP_TX_MTU=498
    CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_BUF_ACL_TX_SIZE=502
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_PHY_UPDATE=y
    CONFIG_BT_GATT_CLIENT=y
    #CONFIG_BT_BONDABLE=n
    CONFIG_BT_RX_STACK_SIZE=2048
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_NVS=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    
    CONFIG_BT_CTLR_TX_PWR_PLUS_8=y
    
    #CONFIG_BT_CTLR_CONN_RSSI=y
    
    #CONFIG_BT_L2CAP_TX_MTU=498
    #CONFIG_BT_BUF_ACL_RX_SIZE=502
    #CONFIG_BT_BUF_ACL_TX_SIZE=502
    
    #CONFIG_BT_GATT_AUTO_UPDATE_MTU=y
    
    # Enable buttons and LEDs
    #CONFIG_DK_LIBRARY=y
    
    # Configure sensors
    
    #CONFIG_I2C=y
    #CONFIG_SENSOR=y
    #CONFIG_LIS2DW12=y
    
    CONFIG_ADC=n
    CONFIG_NRFX_SAADC=y
    
    CONFIG_SIZE_OPTIMIZATIONS=y
    
    #Librairy necessaire pour edge impulse et pour math.h
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    
    
    # Enable Bootloader
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUBOOT_IMAGE_VERSION="0.0.1"
    
    # Enable SMP Server
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_OS=y
    
    # CONFIG_MCUMGR_GRP_IMG dependencies
    CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    
    # CONFIG_IMG_MANAGER dependencies
    CONFIG_STREAM_FLASH=y
    
    # CONFIG_MCUMGR dependencies
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y
    
    # Required for CONFIG_IMG_MANAGER
    CONFIG_FLASH_MAP=y
    
    # Enable BLE transfer DFU
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    CONFIG_MAIN_STACK_SIZE=4096
    #CONFIG_MULTITHREADING=y
    
    
    
    
    
    CONFIG_GPIO=y
    
    # Use deferred logging
    #CONFIG_NCS_SAMPLES_DEFAULTS=n
    CONFIG_LOG=y
    CONFIG_SERIAL=n
    CONFIG_LOG_PRINTK=y
    CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096
    CONFIG_LOG_PROCESS_THREAD_STARTUP_DELAY_MS=4000
    CONFIG_ASSERT=y
    CONFIG_ASSERT_NO_COND_INFO=y
    CONFIG_ASSERT_NO_MSG_INFO=y
    CONFIG_MCUBOOT_UTIL_LOG_LEVEL_INF=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    CONFIG_LOG_MODE_MINIMAL=n
    
    
    CONFIG_FPU=y
    
    #CONFIG_NRFX_TIMER1=y
    
    
    # Enable the UART driver
    #CONFIG_UART_ASYNC_API=y
    #CONFIG_UART_INTERRUPT_DRIVEN=y
    #CONFIG_NRFX_UARTE0=y
    #CONFIG_SERIAL=y
    
    # Enable the NUS service
    #CONFIG_BT_NUS=y
    #CONFIG_BT_NUS_AUTHEN=n
    #CONFIG_BT_NUS_UART_BUFFER_SIZE=1024
    #CONFIG_BT_NUS_UART_ASYNC_ADAPTER=y
    
    #Power Management
    CONFIG_PM=y
    CONFIG_PM_DEVICE=y
    CONFIG_PM_DEVICE_RUNTIME=y
    #CONFIG_TFM_LOG_LEVEL_SILENCE=y
    CONFIG_RAM_POWER_DOWN_LIBRARY=y
    
    CONFIG_SENSOR=y
    CONFIG_NRFX_GPIOTE_NUM_OF_EVT_HANDLERS=6
    CONFIG_NEWLIB_LIBC_MIN_REQUIRED_HEAP_SIZE=2048
    
    CONFIG_NRFX_GPIOTE=y
    CONFIG_NRFX_QSPI=y
    
    #NUS service
    CONFIG_BT_NUS=y
    CONFIG_BT_NUS_AUTHEN=n
    CONFIG_BT_NUS_SECURITY_ENABLED=y
    CONFIG_BT_NUS_UART_BUFFER_SIZE=256
    #CONFIG_BT_FIXED_PASSKEY=y
    
    #CONFIG_BT_SMP_SC_ONLY=y
    #CONFIG_BT_TINYCRYPT_ECC=y
    
    #CONFIG_HEAP_MEM_POOL_SIZE=2048
    
    #CONFIG_NRFX_TIMER2=y
    CONFIG_SYS_HEAP_AUTO=y
    CONFIG_HEAP_MEM_POOL_SIZE=8192
    #CONFIG_NET_BUF_LOG=y
    CONFIG_BT_BONDABLE=y
    CONFIG_BT_BONDING_REQUIRED=y
    
    


    Best regards,

    Pierre-Yves

  • Hi, do you have any idea to help to have this kind of connexion ?

  • It seems like you might be looking for a static password as mentioned in the linked thread enabling CONFIG_BT_FIXED_PASSKEY.

  • Ty, it's help me to set up a peripheral, when i try to connect with my phone there is a request and if the code is wrong, i disconnect.I needed to add bt_conn_set_security(conn,BT_SECURITY_L4); to have the request...


    But i don't have the request with another device nrf52840. i use bluetooth shell sample with the command connect and i can connect like if there was no request.

    Then how to have the request on all device to force code pin connexion ?

    Also with a phone, if there apossibility to refuse pairing request and connect ?

  • No, I do not have an idea about the issue.

    Piwy said:
    Then how to have the request on all device to force code pin connexion ?

    This topic has been discussed a lot on how to have a connection only with passcode. Please check if one of the discussions helps here.  Very Similar request like yours can be found here

Reply Children
No Data
Related