Skip to content

Nordic nRF5x Bluetooth host app examples for connectivity firmware

Notifications You must be signed in to change notification settings

sharowyeh/nrf-ble-app

Repository files navigation

Goals & Requirements

  • Replancement for EOL hardware(nRF51 dongle)
    • Targeting Nordic next-gen LTS BLE dongle product, nRF52840 dongle
    • Nordic BLE connectivity firmware built from later version of nRF5 SDK
    • Support SoftDevice s132 or later version for advertising extensions(details)
  • Generic software development support and maintenance plan
    • Features duplicate from Nordic Master Control Panel(obsoleted)
    • Library designed with C++ STL for Windows platform(optional:cross-platform)
    • Support and maintain console app for function demonstration
    • Support and maintain wrapper library in C# for Windows GUI sample
    • Optional support C++ GUI app for cross-platform GUI sample

Overview

TODO: graphical diagrams

Controls nRF5xDK BLE connectivity FW to communicate with target BLE devices.

The Nordic nRF Connect app is perfect, but I want to use it as fully tranditional windows desktop app

Note for my unreliable memory:

  • original source code references from nrf-ble-driver example code and firmware testcases

Environment requirement

  • nRF52 dongle board(PCA10059) support SoftDevice s132 or later version, refer to IC description section on offical github site
  • This repo adopt SD API v6 with SoftDevice s140, connectivity firmware release can be downloaded from v4.1.4
  • To use SD API v5 and SoftDevice s132, refer to nrf_ble_library\nrf_ble_library-sd-api-v5.vcxproj
  • pc-ble-driver development dependencies v4.1.4, can be downloaded from pc-ble-driver/releases Recommeded v4.1.4 header and lib files to develop board programmed v4.1.4 connectivity firmware, for better data stacks performance while receving continueous packets from peripheral device. but also works with v4.1.2 version for backward compatible.

Development dependencies

Basically use x86_32 architecture for platform compatible, or follow the same steps for x86_64 architecture

  • Extract nrf-ble-driver-4.1.4-win_x86_32.zip to parent folder of this repo directory
  • The path structure will be:
---/nrf-ble-app/...
 |-/nrf-ble-driver-4.1.4-win_x86_32/...
  • The c++ project properties will look up given folder for header and lib files automatically

  • (optional) For debug configuration, may pull nrf-ble-driver source code to parent folder of this repo directory

    • build the completed connectivity source
    • replace the built firmware hex and driver libs to offical binaries
  • C++ UI example project using imgui which required GLFW, refer to section UI dependencies for more details

Install Nordic nRF Connect for Desktop

This launcher app includes related segger programmer nrfjprog and development board driver jlinkcdcarm, or alternatively install by their own installer which can be downloaded from Nordic offical website.

(optional) BLE related apps for launcher:

  • Programmer: for programming Nordic BLE connectivity FW to nRF5xDK board(or alternatively using segger nrfjprog.exe)
  • Bluetooth Low Energy: for double check if our app works like this offical app(CANNOT run at the same time with this project's binary)

The next section contains FW programming steps by nRF Connect for Desktop

Nordic connectivity firmware programming

Recommendation is v4.1.4 which function verified for this repo, it has 3 different ways to program firmware hex file to the board.

  • Method1: Use Segger tool app(nrfjprog.exe) and dev kit driver(jlinkarm) from Nordic offical website
    • push dongle reset button to DFU mode, program hex file to dev kit by its default bootloader.

Also can simply install Nordic nRF Connect for Desktop:

  • Method2: Use programming app
    • Install refconnect-setup from nordic offical website
    • Download Programmer app from offical(or alternative offline extract .nrfconnect-apps.zip to <user_dir>/.nefconnect-apps/
    • Launch nRF Connect for Desktop, Programmer app will show on apps list
    • Plug nRF5DK board(PCA10059) into USB port
    • Open Programmer app then select detected board device
    • Add hex file for downloaded connectivity firmware hex(eg. connectivity_4.1.4_usb_with_s132_5.1.0.hex)
    • Write and wait until programming finished
  • Method3: Use bluethooth app to proceed connectivity firmware programming, steps as below:
    • Download Bluetooth Low Energy app from offical(or alternative offline extract .nrfconnect-apps.zip to <user_dir>/.nefconnect-apps/
    • Open Bluetooth Low Energy app than select device, it will ask the device must be programmed
    • Proceed firmware programming, log window will show up Nordic connectivity version and detailed information

UI dependencies

The C++ UI example app integrated GLFW via imgui

  • imgui source code is fully copied to imgui folder in the project directory as including references. - Download GLFW binaries both x86 and x64 for windows environment, extract to the parent of solution directory
  • This repo using GLFW v3.3.7 can simply download pre-compiled binaries from offical github for the specific version.
    • The project refered to lib-vs2022 DLLs align to current compiler environment, also works by lib-vsw2019
  • The path structure will be:
---/nrf-ble-app/...
 |-/nrf-ble-app/nrf_ble_sample_glfw/imgui/...
 |-/glfw-3.3.7.bin.WIN32/...
 |-/glfw-3.3.7.bin.WIN64/...

BLE pairing refs

Bluetooth pairing - blog LESC(p4), legacy(p1), keygen(p2), passkey(p3)

Deep dive into LESC

auth responding: BLE_GAP_SEC_STATUS_AUTH_REQ

S132-v5 Message Sequence Charts

Other ways to win32

  • write javascript pc-nrfconnect-ble and pc-ble-driver-js projects from nRF Connect SDK
  • provide interface for win32 app, likes local web api, OS dependent IPC, or so forth

pc-nrfconnect-ble/lib/actions/adapterActions.js

  • from:
  • adaptertoUse.xxxx
  • pc-ble-driver-js/api/adapter.js
  • xxxxAction to: pc-nrfconnect-ble/lib/reducers/bleEventReducer.js
  • AdapterActions.DEVICE_xxxx_REQUEST pc-nrfconnect-ble/lib/containers/BLEEventDialog.jsx
  • BLEEventType.xxxx_REQUEST
  • UI Submit export function xxxx(in adapterActions.js)

pc-nrfconnect-ble/lib/actions/deviceDetailsActions.js

  • adapterToUse.xxxx
  • pc-ble-driver-js/api/adapter.js

About

Nordic nRF5x Bluetooth host app examples for connectivity firmware

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published