Seeed studio xiao nrf52840 sense has a slow ble notify problem

Products used: Seeed studio xiao nrf52840
Development environment: ArduinoIDE 1.8.19
Board manager: seeed nrf52 boards
Libraries used: Bluefruit52Lib

Hello.

I am currently creating a communication program with an iPhone using the microcontroller mentioned in the title.
The function of the microcontroller is to simply send the time since startup using notify(), but it takes 30ms each time this notify function is executed.
The relevant part of the code is listed below.

#define TEST_UUID (“36a8c7a5-aa3b-459f-8d7e-b0a80724c02c”)

static BLECharacteristic testRR = BLECharacteristic(TEST_UUID);
testRR.setProperties(CHR_PROPS_NOTIFY | CHR_PROPS_INDICATE);
testRR.setFixedLen(1);
testRR.begin();



bool bret = testRR.notify(&test_data, 1); //It takes 30ms for the function to return here.

When checking with nrfconnect, the notify data has arrived at the iPhone.

When checking with a sniffer next, the iPhone’s connection interval is 30ms, so it appears to be waiting for a response.

If this is how it should work, I thought that after notify() is executed, it would simply be stored in the BLE buffer(?) and control would return immediately, but is that wrong?

Also, how can I implement it so that it returns immediately?

I look forward to your response.

(The reason I’m using bluefruit is because I want to change the signal strength.)

Welcome! Thanks for the detail… Im sure someone will be able to help you… probably PJ

I think notify is only valid in BLE in the paired & connected state.
nrfConnect will connect when you try to view the data on Characteristics.
Do you have an iPhone app that has connected and is waiting for the notify in your second case? If not, that sounds like the problem.

Hi there,
So starting with this understanding moving forward.
" The main difference between BLE Notify and BLE Indicate is that BLE Notify is unacknowledged, while BLE Indicate is acknowledged:

  • BLE Notify

A one-way communication method that broadcasts data to any neighboring devices within range. BLE Notify is faster than BLE Indicate, but it’s also less reliable. It’s energy efficient because it saves on radio airtime.

  • BLE Indicate

An acknowledged message or update that requires a response from the client.

Both BLE Notify and BLE Indicate are methods for pushing data to a remote client when a Bluetooth Low Energy (BLE) device has new data. The client enables the operations, but the server initiates them "
Given that It sounds to me maybe Just advertising the data would be a better fit ?
A connection is always required otherwise… Check the Nordic Button Service Demo on here for how it works.

HTH
GL :slight_smile: PJ :v:

1 Like

Hi

Thank you for your reply.

Of course, it is connected and paired with the iPhone.

Hi there,
Can you try with an Android mobile phone & Nrf_Connect ?
GL :slight_smile: PJ :v:

NRF connect is on iphone app too!

Hi.

Sorry, I think I found the cause.

In my source code, I call the following part with loop() at intervals of about 30ms+α.

bool bret = testRR.notify(&test_data, 1);

The “processing time” of this function was 30ms,

but when I tried calling it at 1 second intervals, the “processing time” was less than 1ms.

Does the notify() function cause problems with slow processing when called at short intervals?

1 Like

Nice information

I like it

1 Like