how to achieve the ble shift between keyboard and different ble host in ncs sdk?

hello 

dear nordic team,im use the nrf5284 develop a keyboard by nrf desktop sdk ,but i dont konw how to chang the ble status in ncs sdk .i hope my keyboard can connect different ble host at certain time,for example,my keyboard be connected by host A,and than i change the mac id in ble adv,it is connected by host B.even i want change the connect between host A and B by key press.for example now it is connected by host A,then i want it disconnect to host A,and connect to host B.but i dont kown how to operate.i see the ble_bond.c code,but i cant gusse the meaning of enum. 

Parents Reply Children
  • What error did you see? I didn't get any errors when I built with those Kconfig changes and used the system default configuration, and added the prj_keyboard.conf as an extra config file.

  • it report as fllow:

    Building nrf_desktop_1
    C:\windows\system32\cmd.exe /d /s /c "west build --build-dir d:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build d:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1 --pristine --board nrf52840dk_nrf52840 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -Db0_CONF_FILE=D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/child_image/b0/prj.conf -Db0_OVERLAY_CONFIG=D:/NCS/V2.6/v2.6.0/nrf/subsys/partition_manager/partition_manager_enabled.conf -Ds1_image_OVERLAY_CONFIG=D:/NCS/V2.6/v2.6.0/nrf/subsys/partition_manager/partition_manager_enabled.conf -DCACHED_CONF_FILE=d:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/prj.conf -DDTC_OVERLAY_FILE=d:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/app.overlay"

    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1
    -- CMake version: 3.21.0
    -- Found Python3: D:/NCS/V2.6/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: D:/NCS/V2.6/v2.6.0/zephyr/.cache
    -- Zephyr version: 3.5.99 (D:/NCS/V2.6/v2.6.0/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.16.5 (D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.5 (D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found Dtc: D:/NCS/V2.6/toolchains/cf2149caf2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: D:/NCS/V2.6/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: d:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/app.overlay
    -- Generated zephyr.dts: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/zephyr/dts.cmake
    Parsing D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/Kconfig
    Loaded configuration 'D:/NCS/V2.6/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'd:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/prj.conf'
    Configuration saved to 'D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/zephyr/.config'
    Kconfig header saved to 'D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: d:/ncs/v2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe

    === child image b0 - begin ===
    loading initial cache file D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/b0/child_image_preload.cmake
    Loading Zephyr default modules (Zephyr base).
    -- Application: D:/NCS/V2.6/v2.6.0/nrf/samples/bootloader
    -- CMake version: 3.21.0
    -- Found Python3: D:/NCS/V2.6/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: D:/NCS/V2.6/v2.6.0/zephyr/.cache
    -- Zephyr version: 3.5.99 (D:/NCS/V2.6/v2.6.0/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.16.5 (D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.5 (D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found Dtc: D:/NCS/V2.6/toolchains/cf2149caf2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: D:/NCS/V2.6/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Generated zephyr.dts: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/b0/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/b0/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/b0/zephyr/dts.cmake

    warning: HW_STACK_PROTECTION (defined at arch/Kconfig:259) was assigned the value 'y' but got the
    value 'n'. Check these unsatisfied dependencies: ARCH_HAS_STACK_PROTECTION (=n). See
    docs.zephyrproject.org/.../kconfig.html and/or look up
    HW_STACK_PROTECTION in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.

    Parsing D:/NCS/V2.6/v2.6.0/zephyr/Kconfig
    Loaded configuration 'D:/NCS/V2.6/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/child_image/b0/prj.conf'
    Merged configuration 'D:/NCS/V2.6/v2.6.0/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Configuration saved to 'D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/b0/zephyr/.config'
    Kconfig header saved to 'D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/b0/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: d:/ncs/v2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Warning at D:/NCS/V2.6/v2.6.0/nrf/lib/flash_patch/CMakeLists.txt:8 (message):

    ----------------------------------------------------------
    --- WARNING: To maintain the integrity of secure boot, ---
    --- enable CONFIG_DISABLE_FLASH_PATCH in production. ---
    ----------------------------------------------------------


    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/b0
    === child image b0 - end ===


    === child image s1_image - begin ===
    loading initial cache file D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/image_preload.cmake
    Loading Zephyr default modules (Zephyr base).
    -- Application: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1
    -- CMake version: 3.21.0
    -- Found Python3: D:/NCS/V2.6/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: D:/NCS/V2.6/v2.6.0/zephyr/.cache
    -- Zephyr version: 3.5.99 (D:/NCS/V2.6/v2.6.0/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.16.5 (D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.5 (D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found Dtc: D:/NCS/V2.6/toolchains/cf2149caf2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: D:/NCS/V2.6/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: d:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/app.overlay
    -- Generated zephyr.dts: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/s1_image/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/s1_image/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/s1_image/zephyr/dts.cmake
    -- Found GnuLd: d:/ncs/v2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Warning at D:/NCS/V2.6/v2.6.0/zephyr/CMakeLists.txt:1957 (message):
    __ASSERT() statements are globally ENABLED


    -- Found partition manager static configuration: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/pm_static.yml
    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/s1_image
    === child image s1_image - end ===

    CMake Warning at D:/NCS/V2.6/v2.6.0/zephyr/CMakeLists.txt:1957 (message):
    __ASSERT() statements are globally ENABLED


    -- Found partition manager static configuration: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840/pm_static.yml
    Partition 'b0_container' is not included in the dynamic resolving since it is statically defined.
    Partition 'b0' is not included in the dynamic resolving since it is statically defined.
    Partition 'provision' is not included in the dynamic resolving since it is statically defined.
    Partition 's0' is not included in the dynamic resolving since it is statically defined.
    Partition 's0_image' is not included in the dynamic resolving since it is statically defined.
    Partition 's1' is not included in the dynamic resolving since it is statically defined.
    Partition 's1_image' is not included in the dynamic resolving since it is statically defined.
    Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
    Dropping partition 's0_pad' since its size is 0.
    Dropping partition 's1_pad' since its size is 0.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build
    -- west build: building application
    [5/351] Generating include/generated/version.h
    -- Zephyr version: 3.5.99 (D:/NCS/V2.6/v2.6.0/zephyr), build: v3.5.99-ncs1
    [2/134] Generating include/generated/version.h
    -- Zephyr version: 3.5.99 (D:/NCS/V2.6/v2.6.0/zephyr), build: v3.5.99-ncs1
    [134/134] Linking C executable zephyr\zephyr.elf
    Memory region Used Size Region Size %age Used
    FLASH: 12612 B 20 KB 61.58%
    RAM: 38288 B 256 KB 14.61%
    IDT_LIST: 0 GB 32 KB 0.00%
    [45/351] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
    FAILED: zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
    D:\NCS\V2.6\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DEXT_API_MAGIC=0x281ee6de,0xb845acea,13314 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13314 -DKERNEL -DNRF52840_XXAA -DUSE_PARTITION_MANAGER=1 -DVALIDATION_INFO_MAGIC=0x281ee6de,0x86518483,78850 -DVALIDATION_POINTER_MAGIC=0x281ee6de,0x6919b47e,78850 -D__PROGRAM_START -D__ZEPHYR__=1 -ID:/NCS/V2.6/v2.6.0/zephyr/kernel/include -ID:/NCS/V2.6/v2.6.0/zephyr/arch/arm/include -ID:/NCS/V2.6/v2.6.0/nrf/drivers/mpsl/clock_control -ID:/NCS/V2.6/v2.6.0/zephyr/include -ID:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/zephyr/include/generated -ID:/NCS/V2.6/v2.6.0/zephyr/soc/arm/nordic_nrf/nrf52 -ID:/NCS/V2.6/v2.6.0/zephyr/soc/common/nordic_nrf/. -ID:/NCS/V2.6/v2.6.0/zephyr/soc/arm/nordic_nrf/common/. -ID:/NCS/V2.6/v2.6.0/zephyr/subsys/usb/device -ID:/NCS/V2.6/v2.6.0/zephyr/subsys/bluetooth -ID:/NCS/V2.6/v2.6.0/zephyr/subsys/settings/include -ID:/NCS/V2.6/v2.6.0/zephyr/drivers/usb/common/nrf_usbd_common/. -ID:/NCS/V2.6/v2.6.0/nrf/include -ID:/NCS/V2.6/v2.6.0/nrf/lib/multithreading_lock/. -ID:/NCS/V2.6/v2.6.0/nrf/subsys/bluetooth/controller/. -ID:/NCS/V2.6/v2.6.0/nrf/subsys/app_event_manager/. -ID:/NCS/V2.6/v2.6.0/nrf/subsys/app_event_manager_profiler_tracer/. -ID:/NCS/V2.6/v2.6.0/zephyr/drivers/flash -ID:/NCS/V2.6/v2.6.0/nrf/tests/include -ID:/NCS/V2.6/v2.6.0/modules/hal/cmsis/CMSIS/Core/Include -ID:/NCS/V2.6/v2.6.0/zephyr/modules/cmsis/. -ID:/NCS/V2.6/v2.6.0/modules/hal/nordic/nrfx -ID:/NCS/V2.6/v2.6.0/modules/hal/nordic/nrfx/drivers/include -ID:/NCS/V2.6/v2.6.0/modules/hal/nordic/nrfx/mdk -ID:/NCS/V2.6/v2.6.0/zephyr/modules/hal_nordic/nrfx/. -ID:/NCS/V2.6/v2.6.0/modules/debug/segger/SEGGER -ID:/NCS/V2.6/v2.6.0/modules/debug/segger/Config -ID:/NCS/V2.6/v2.6.0/modules/crypto/tinycrypt/lib/include -ID:/NCS/V2.6/v2.6.0/nrfxlib/mpsl/fem/common/include -ID:/NCS/V2.6/v2.6.0/nrfxlib/mpsl/fem/nrf21540_gpio/include -ID:/NCS/V2.6/v2.6.0/nrfxlib/mpsl/fem/nrf21540_gpio_spi/include -ID:/NCS/V2.6/v2.6.0/nrfxlib/mpsl/fem/simple_gpio/include -ID:/NCS/V2.6/v2.6.0/nrfxlib/mpsl/fem/include -ID:/NCS/V2.6/v2.6.0/nrfxlib/mpsl/fem/include/protocol -ID:/NCS/V2.6/v2.6.0/nrfxlib/mpsl/include -ID:/NCS/V2.6/v2.6.0/nrfxlib/mpsl/include/protocol -ID:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/common -ID:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/configuration/nrf52840dk_nrf52840 -ID:/NCS/V2.6/v2.6.0/nrfxlib/softdevice_controller/include -isystem D:/NCS/V2.6/v2.6.0/zephyr/lib/libc/minimal/include -isystem D:/NCS/V2.6/v2.6.0/zephyr/lib/libc/common/include -isystem d:/ncs/v2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include -isystem d:/ncs/v2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/include-fixed -isystem D:/NCS/V2.6/v2.6.0/nrfxlib/crypto/nrf_cc310_platform/include -fno-strict-aliasing -O2 -imacros D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=D:/NCS/V2.6/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros D:/NCS/V2.6/v2.6.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1=CMAKE_SOURCE_DIR -fmacro-prefix-map=D:/NCS/V2.6/v2.6.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=D:/NCS/V2.6/v2.6.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj -MF zephyr\CMakeFiles\zephyr.dir\misc\generated\configs.c.obj.d -o zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj -c D:/NCS/V2.6/v2.6.0/nrf/applications/nrf_desktop_1/build/zephyr/misc/generated/configs.c
    C:\Users\ADMINI~1\AppData\Local\Temp\ccMBwIH4.s: Assembler messages:

    C:\Users\ADMINI~1\AppData\Local\Temp\ccMBwIH4.s:728: Error: missing expression

    [57/351] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/fs/nvs/nvs.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'D:\NCS\V2.6\toolchains\cf2149caf2\opt\bin\cmake.EXE' --build 'd:\NCS\V2.6\v2.6.0\nrf\applications\nrf_desktop_1\build'

  • I can't see from the build log that the extra overlay config file prk_keyboard.conf was included in this case. Can you show me a picture of what your build configuration in NCS looks like? You can right click the build configuration in the menu on the left in VS Code and select "Edit build configuration":

    BR,

    Edvin

Related