1.- Software.
- Extension BLE: http://iot.appinventor.mit.edu/#/bluetoothle/bluetoothleintro
- Old example of BLE (2016): http://ai2.appinventor.mit.edu/reference/other/IoT.html
- Codes of Neil Kolban: https://github.com/nkolban/ESP32_BLE_Arduino/tree/7951347ed68313d75c367e1f2cce763cb56d1eb2
- To disable and enable the device's bluetooth, I'll use my extension: com.KIO4_Bluetooth.aix
- Codes and Extension: http://kio4.com/arduino/160i_Wemos_ESP32_BLE.htm
- Read: Location needs to be enabled for Bluetooth Low Energy Scanning.
https://stackoverflow.com/questions/33045581/location-needs-to-be-enabled-for-bluetooth-low-energy-scanning-on-android-6-0
---- Connection. Bare minimum.
p110i_esp32_ble_conexion.aia (199.5 KB)
- This code is tested with an Android 9, the extension BLE 20201223 and an ESP32.
If it doesn't work for you with that extension, try this ...
Bluetooth bLE not connect
// http://kio4.com/arduino/160_Wemos_ESP32_BLE.htm
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
void setup() {
BLEDevice::init("Here_ESP32");
BLEServer *pServer = BLEDevice::createServer();
BLEService *pService = pServer->createService(SERVICE_UUID);
BLECharacteristic *pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE
);
pCharacteristic->setValue("Connected.");
pService->start();
BLEAdvertising *pAdvertising = pServer->getAdvertising();
pAdvertising->start();
}
void loop() {
// put your main code here, to run repeatedly:
}