Identification of connected APP in NRF52840 devices.

Hello Everyone,

                           I am a beginner for working on Nordic devices. I have one query. I have to build a firmware in NRF52840. Now 2 different apps will be connecting to this NRF52840. I will be configuring NRF52840 as a peripheral device. Now there are 2 apps. Both the apps are different and have different functionality:-

1) 1st app.(APP A) -- after connection with BLE, the device will continuously send some data to this app.

2) 2nd app (APP B)- The device will start some activity after BLE authentication.

My question is how will the device(NRF52840) know which app is connected to the device? What code do I write in the device so that device will identify which app is connected to the device? Will I have to create 2 different services for 2 different apps?

Please help me on this.

Parents
  • You kind of already answered your own question.

    Identify by BLE authentication or identify by service. Both solutions seem ok

  • Okay but can a peripheral device connect to two apps at a time?

  • Hi I tried to test the example you shared. The NRF connect app still gets connected without any authentication. Please help me on this. 

    I was not able to compile the sdk17 version ble_app_hrs. It gave me some errors.

    tried testing with sdk15 version code. Still no authentication.

  • Hi,

    Since our DK doesn't have a display or keyboard most example does not enable the Authentication feature. but you could look at the nRF5_SDK_17.1.0_ddde560\examples\ble_peripheral\ble_app_gls example. and remember to connect to the comport to see the passkey. See Glucose Application for additional details.

  • Yes Thank you so much. I was able to test the Glucose application in sdk15. Sdk 17 I got compilation errors. I understand how the authentication works. I have 2 services for 2 respective apps in my project. So can I add the authentication only for one service in the code?

  • You can configure different security levels for different services. So it can be possible to require Authentication for only one service. But if you are planning to require bonding for the other service as well, you need to remember that the security level is "negotiated" between the devices, so after they exchange capabilities they will use the highest possible security level based on those capabilities. If you control both ends of the link I guess you could have an open characteristic that you use to tell the peer which capabilities it should use during bonding, but not sure why you would want that...

  • I am going step by step. I created 2 services: -

    Service 1


    #define BLE_UUID_RCBR_SERVICE 0xD6E2 /**< The UUID of the R3charge Borrower Service. */

    #define RCBR_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the RCBR Service (vendor specific). */


    #define BLE_UUID_RCBR_NOTIF_CHARACTERISTIC 0xD7E2 //0xD7E2 /**< The UUID of the Notification Characteristic. */
    #define BLE_UUID_RCBR_SETTING_CHARACTERISTIC 0xD7E4 //0xD7E4 /**< The UUID of the Setting Characteristic. */

    #define BLE_RCBR_MAX_NOTIF_CHAR_LEN BLE_RCBR_MAX_DATA_LEN /**< Maximum length of the RX Characteristic (in bytes). */
    #define BLE_RCBR_MAX_SETTING_CHAR_LEN BLE_RCBR_MAX_DATA_LEN /**< Maximum length of the TX Characteristic (in bytes). */

    #define RCBR_BASE_UUID {{0x77, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0x6e, 0xaa, 0xe3, 0x11, 0x76, 0x34, 0xe1, 0xd6, 0x48, 0x75}} /**< Used vendor specific UUID. */


    #define OPCODE_LENGTH 1
    #define HANDLE_LENGTH 2

    service 2:


    #define BLE_UUID_RCLR_SERVICE 0xD6E3 /**< The UUID of the R3charge Lender Service. */

    #define RCLR_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the RCLR Service (vendor specific). */

    #define BLE_UUID_RCLR_NOTIF_CHARACTERISTIC 0xD7E3 /**< The UUID of the Notification Characteristic. */
    #define BLE_UUID_RCLR_SETTING_CHARACTERISTIC 0xD7E5 /**< The UUID of the Setting Characteristic. */

    #define BLE_RCLR_MAX_NOTIF_CHAR_LEN BLE_RCLR_MAX_DATA_LEN /**< Maximum length of the RX Characteristic (in bytes). */
    #define BLE_RCLR_MAX_SETTING_CHAR_LEN BLE_RCLR_MAX_DATA_LEN /**< Maximum length of the TX Characteristic (in bytes). */

    #define RCLR_BASE_UUID {{0x66, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0x6e, 0xaa, 0xe3, 0x11, 0x76, 0x34, 0xe1, 0xd6, 0x48, 0x75}} /**< Used vendor specific UUID. */

    #define OPCODE_LENGTH 1
    #define HANDLE_LENGTH 2

    MY memory settings are as follows:- 

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x100000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x40000

    FLASH_START=0x27000

    FLASH_SIZE=0xd9000

    RAM_START=0x200059A4

    RAM_SIZE=0x3a65C

    ===========================

    FLASH RX 0x0 0x100000;RAM1 RWX 0x20000000 0x40000

    I am getting error at ble_advertising_init function. I have set NRF_SDH_BLE_VS_UUID_COUNT = 2 but still i am getting error. What might be the issue?

Reply
  • I am going step by step. I created 2 services: -

    Service 1


    #define BLE_UUID_RCBR_SERVICE 0xD6E2 /**< The UUID of the R3charge Borrower Service. */

    #define RCBR_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the RCBR Service (vendor specific). */


    #define BLE_UUID_RCBR_NOTIF_CHARACTERISTIC 0xD7E2 //0xD7E2 /**< The UUID of the Notification Characteristic. */
    #define BLE_UUID_RCBR_SETTING_CHARACTERISTIC 0xD7E4 //0xD7E4 /**< The UUID of the Setting Characteristic. */

    #define BLE_RCBR_MAX_NOTIF_CHAR_LEN BLE_RCBR_MAX_DATA_LEN /**< Maximum length of the RX Characteristic (in bytes). */
    #define BLE_RCBR_MAX_SETTING_CHAR_LEN BLE_RCBR_MAX_DATA_LEN /**< Maximum length of the TX Characteristic (in bytes). */

    #define RCBR_BASE_UUID {{0x77, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0x6e, 0xaa, 0xe3, 0x11, 0x76, 0x34, 0xe1, 0xd6, 0x48, 0x75}} /**< Used vendor specific UUID. */


    #define OPCODE_LENGTH 1
    #define HANDLE_LENGTH 2

    service 2:


    #define BLE_UUID_RCLR_SERVICE 0xD6E3 /**< The UUID of the R3charge Lender Service. */

    #define RCLR_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the RCLR Service (vendor specific). */

    #define BLE_UUID_RCLR_NOTIF_CHARACTERISTIC 0xD7E3 /**< The UUID of the Notification Characteristic. */
    #define BLE_UUID_RCLR_SETTING_CHARACTERISTIC 0xD7E5 /**< The UUID of the Setting Characteristic. */

    #define BLE_RCLR_MAX_NOTIF_CHAR_LEN BLE_RCLR_MAX_DATA_LEN /**< Maximum length of the RX Characteristic (in bytes). */
    #define BLE_RCLR_MAX_SETTING_CHAR_LEN BLE_RCLR_MAX_DATA_LEN /**< Maximum length of the TX Characteristic (in bytes). */

    #define RCLR_BASE_UUID {{0x66, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0x6e, 0xaa, 0xe3, 0x11, 0x76, 0x34, 0xe1, 0xd6, 0x48, 0x75}} /**< Used vendor specific UUID. */

    #define OPCODE_LENGTH 1
    #define HANDLE_LENGTH 2

    MY memory settings are as follows:- 

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x100000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x40000

    FLASH_START=0x27000

    FLASH_SIZE=0xd9000

    RAM_START=0x200059A4

    RAM_SIZE=0x3a65C

    ===========================

    FLASH RX 0x0 0x100000;RAM1 RWX 0x20000000 0x40000

    I am getting error at ble_advertising_init function. I have set NRF_SDH_BLE_VS_UUID_COUNT = 2 but still i am getting error. What might be the issue?

Children
Related