Can connect to uart_peripheral by UUID, but can't connect to a non-Zephyr product

I have managed to get, somehow, a central_uart talking to a peripheral_uart on a pair of  52840 DKs.

I've changed the UUIDs of what I'm trying to connect to, to be those of a different device that has BLE in it.

I've previously connected to this using an RPi and its UART, getting data in and out of it. So I went PC UART <-> Rpi BLE <-> Other Unit

Am trying to repeat that but using the 52840 DK

I've taken the central UART project and changed the code  do to this:

#define XLRT_SERVICE_UUID_VAL \
BT_UUID_128_ENCODE(0x2a1f963c, 0x143a, 0x4f7d, 0x9107, 0x6315196a02a6)

/** @brief UUID of the TX Characteristic. **/
#define XLRT_TX_UUID_VAL \
BT_UUID_128_ENCODE(0x651135b0, 0xdfe9, 0x45a2, 0x95c1, 0x46552a8a77e2)


/** @brief UUID of the RX Characteristic. **/
#define XLRT_RX_UUID_VAL \
BT_UUID_128_ENCODE(0xe7d6274e, 0xb765, 0x11e9, 0xa2a3, 0x2a2ae2dbcce4)


#define BT_UUID_XLRT_SERVICE BT_UUID_DECLARE_128(XLRT_SERVICE_UUID_VAL)
#define BT_UUID_XLRT_RX BT_UUID_DECLARE_128(XLRT_RX_UUID_VAL)
#define BT_UUID_XLRT_TX BT_UUID_DECLARE_128(XLRT_TX_UUID_VAL)

Previously this worked fine connecting to the peripheral_uart example project running on the second 52840DK. The only thing I have done is change the UUIDs of the service I want to connect to and the the UUIDs of the two characteristics that I want to read from  and write to.

Can you think of any reason why it would connect to the DK running peripheral_unit and not this other unit? The other unit has an older chip in, using SES and has   the same types od read/write characteristics.

I would expect it to simply connect to the unit because the service UUID matches, even if the BLE data might not get to/from at first due to some other bug in the code. I'm nevere getting the call to function:

static void connected(struct bt_conn *conn, uint8_t conn_err)

Which I do if I try to connect to peripheral_uart.

Thanks
Parents
  • Hi,

    I would also expect the connection to be established. I assume the scan_filter_match callback is not invoked either? This usually suggests that the service UUID declared in the firmware does not match the UUID included in the advertisement. Could you please double or tripple check that the UUID is correct? Note that in the nRF5 SDK, the UUID was declared in little-endian format, while in the nRF Connect SDK it is big-endian. The UUID declaration in the nRF Connect SDK should match the representation used for UUIDs in the nRF Connect app on Android/iOS.

    Best regards,

    Vidar

  • Hi, yes,

    scan_filter_match
    is never called. I get this in the temrinal at boot:

    [00:00:00.025,482] <inf> central_uart: Scan module initialized
    [00:00:00.025,512] <inf> central_uart: NUS Client module initialized
    [00:00:00.030,548] <inf> central_uart: Scanning successfully started

    I have checked the UUID over and over, it's what I would have expected to be wrong. I put the app on my Android  phone to see if the UUID looked any different to others BLE Android apps, but it looks identical there too.

    If I go back to the Nordic UUIDs to pair up with another DK running peripheral_uart exampkle I get this:

    [00:00:00.025,451] <inf> central_uart: Scan module initialized
    [00:00:00.025,482] <inf> central_uart: NUS Client module initialized
    [00:00:00.030,487] <inf> central_uart: Scanning successfully started
    34:A3:0A:8F:0A (random) connectable: 0
    [00:00:00.389,465] <inf> central_uart: Connected: C8:34:A3:0A:8F:0A (random)
    [00:00:00.389,831] <err> central_uart: Stop LE scan failed (err 0)
    [00:00:00.591,033] <inf> central_uart: MTU exchange done
    [00:00:00.691,009] <err> bt_smp: pairing failed (peer reason 0x3)
    [00:00:00.691,253] <wrn> central_uart: Security failed: C8:34:A3:0A:8F:0A (random) level 1 err 4
    [00:00:00.691,436] <wrn> central_uart: Pairing failed conn: C8:34:A3:0A:8F:0A (random), reason 4

    Which looks a bit odd, seems like it's saying it failed to "pair", but does work. I thought pairing wasn't a word used with LE BTW. 

  • This:

    #ifdef SCAN_BY_SERVICE_UUID
    err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_XLRT_SERVICE);
    #else
    bt_addr_le_t addr = {
    .type = BT_ADDR_LE_RANDOM,
    .a.val = {0x62, 0x21, 0x24, 0xDB, 0xA0, 0xE8},
    };
    err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_ADDR, &addr);
    #endif

    Gives me this result:

    [00:00:00.025,451] <0x1b>[1;31m<err> central_uart: Scanning filters cannot be set (err -12)<0x1b>[0m␍␊

    [00:00:00.025,451] <0x1b>[1;31m<err> central_uart: scan_init failed (err -12)<0x1b>[0m␍␊

    This:

    BLE scan filter by device name

    Makes me think maybe I have to add something to prj.conf?

    CONFIG_BT_SCAN_FILTER_ENABLE=y
    CONFIG_BT_SCAN_UUID_CNT=1

    I have the above, but maybe there's something I need to add along the lines of

    CONFIG_BT_SCAN_ADDR_CNT=1

    It throws a wobbler if I try that even though this page:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/v1.6-branch/kconfig/CONFIG_BT_SCAN_ADDRESS_CNT.html

    Suggests that's a valid thing.
  • Forgot to add that you need to add CONFIG_BT_SCAN_ADDR_CNT=1 to your project configuration (prj.conf). Then it should work. Which SDK version are you testing with?

  • As I said above, I tried that and it says:

    prj.conf:25: warning: attempt to assign the value '1' to the undefined symbol BT_SCAN_ADDR_CNT

    error: Aborting due to Kconfig warnings

    Using 2.8.0

    Also it's now telling me I have no build configuration.

  • Thanks for confirming. The build configuration will disappear since the build failed. Did you add the symbol like this:

    ?

  • I did:


    # Enable the BLE modules from NCS
    CONFIG_BT_NUS_CLIENT=y
    CONFIG_BT_SCAN=y
    CONFIG_BT_SCAN_FILTER_ENABLE=y
    CONFIG_BT_SCAN_UUID_CNT=1
    CONFIG_BT_SCAN_ADDR_CNT=1
    CONFIG_BT_GATT_DM=y
    CONFIG_HEAP_MEM_POOL_SIZE=2048
Reply Children
Related