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.
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.)
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.