What is the function of BLE.poll()?

I appreciate, if can anyone explain what is the exact function of BLE.poll();.

I found one explanation in GitHub, but could not understand its exact function.

"Poll for BLE radio events for the specified BLE device and handle them."

In other words it does all the work of talking to the device and checking for stuff happening and calling any event handlers you've registered with the library. You just have to call it in loop() and not worry about it :slight_smile:

You can find the sourcecode for ArduinoBLE library on github if you want to know the full details - but be warned its complicated.

HI @MarkT ,

calling any event handlers you've registered with the library.

Does that mean that if I do not have any event handler, I do not need that?

In my code, I have 2 event handlers only:

void blePeripheralConnectHandler( BLEDevice central )
  digitalWrite( BLE_LED_PIN, HIGH );
  Serial.print( F ( "Connected to central: " ) );
  Serial.println( central.address() );

void blePeripheralDisconnectHandler( BLEDevice central )
  digitalWrite( BLE_LED_PIN, LOW );
  Serial.print( F( "Disconnected from central: " ) );
  Serial.println( central.address() );

Quite likely, but I'm not sure you can then do anything at all without handlers as this is a library driven by callbacks I think.