BLE connection by UUID

Hello there,
I want to connect my nordic nrf52840 with another BLE device and then I'll try to send from the nordic to the device some data.

The nordic acts as central and I made it scan by name the BLE devices.
So I can connect to the other device.

But I want to scan filtering by UUID and connect with the device that has certain specific UUID and/pr characteristics.
I know the other device has these BLE settings:


Service UUID: 49535343FE7D4AE58FA99FAFD205E455
TX characteristic UUID: 495353431E4D4BD9BA6123C647249616
RX characteristic UUID: 49535343884143F4A8D4ECBE34729BB3

#define BT_UUID_MICROCHIP_VAL \
	BT_UUID_128_ENCODE(0x49535343, 0xfe7d, 0x4ae5, 0x8fa9, 0x9fafd205e455)
#define BT_UUID_MICROCHIP_TX_VAL \
	BT_UUID_128_ENCODE(0x49535343, 0x1e4d, 0x4bd9, 0xba61, 0x23c647249616)
#define BT_UUID_MICROCHIP_RX_VAL \
	BT_UUID_128_ENCODE(0x49535343, 0x8841, 0x43f4, 0xa8d4, 0xecbe34729bb3)

#define BT_UUID_MICROCHIP_SERVICE   BT_UUID_DECLARE_128(BT_UUID_MICROCHIP_VAL)
#define BT_UUID_MICROCHIP_TX        BT_UUID_DECLARE_128(BT_UUID_MICROCHIP_TX_VAL)
#define BT_UUID_MICROCHIP_RX        BT_UUID_DECLARE_128(BT_UUID_MICROCHIP_RX_VAL)

...

bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_MICROCHIP_SERVICE);

...


I tried to scan adding an UUID filter but it apparently doesn't work. What I'm doing wrong with this? 
Trying filtering by name of device the connection succeded well and immediately.

but I'm not able to use the UUID service and characteristics of the other device to send data from the nordic to the other device.
What are the steps to make this?

Thank you in advance for your help.

  • bt_nus_send() is the function used for the peripheral to send a notification to the central (if the central has enabled notifications. You want to look at the central_uart sample, and how it uses bt_nus_client_send(). Note that in order for this to work, you need to do a service discovery. Note how discovery_complete uses bt_nus_handles_assign() to assign the correct handles to the different characteristics. You need to do the same for your service/characteristics.

    BR,
    Edvin

Related