Using 2 I can use .notify command to start publishing the value. Using 3 there is no documentation for this command, it looks like I should only use .writeValue and the .poll is taking care of publishing the value.Also 3 is using setEventHandler , while 1 and 2 don't have this described.
Is it right to use 3 because it is officially published by Arduino IDE and has full documentation within Ardiuno IDE ?
You can see the documentation for the ArduinoBLE library here:
This library supports all the Arduino boards that have the hardware enabled for BLE and Bluetooth 4.0 and above; these include Nano 33 BLE, Arduino NANO 33 IoT, Uno WiFi Rev 2, MKR WiFi 1010.
This library is intended to provide BLE support for the official Arduino boards that have such a capability. Even though the ESP32 is the microcontroller that provides the BLE radio capability on the official boards with the NINA-W102 module (e.g., MKR WiFi 1010, Nano 33 IoT, Nano RP2040 Connect), the library code does not run on the ESP32, but instead of the primary microcontroller (e.g., ATSAMD21G18, RP2040). So there is not official support of this library for the ESP32. However, the Arduino community is not to be underestimated, and I notice that someone has a fork of the library that is claimed to have ESP32 support added:
I haven't tried it, so no idea whether it works or not, but certainly worth a look!
in the Boards Manager installed ESP32 version 2.0.0-rc1
compiled again and programmed an ESP32-WROOM-32E
My example has an environmental sensing service, some characteristics with READ and Notify and additional descriptors. There was no code modification necessary for my Arduino example and everything works as expected.