Hello all,
my first post here.
I'm trying to establish communication between my phone (Redmi note 11, Android 13) and an ESP32.
The issue I have is that the devices are disconnecting after timeout (whatever time I set). Below my blocks and my Arduino code.
Any idea how to solve?
Many thanks in advance
Antonio
#include <ArduinoBLE.h>
char* messaggio = {"1010010"};
const char * SERVICE_UUID = "4fafc201-1fb5-459e-8fcc-c5c9c331914b";
const char * CHARACTERISTIC_UUID_3 = "beb5483e-36e1-4688-b7f5-ea07361b26a8"; // giorni accensione
BLEService pratoService(SERVICE_UUID);
BLEStringCharacteristic giorni_char(CHARACTERISTIC_UUID_3, BLEWrite|BLERead|BLENotify, 9);
void setup() {
Serial.begin(9600);
if(!BLE.begin()){
Serial.println("avvio BLE non riuscito");
while(1);
}
BLE.setDeviceName("Prato");
BLE.setLocalName("Prato");
pratoService.addCharacteristic(giorni_char);
BLE.addService(pratoService);
BLE.setAdvertisedService(pratoService);
BLE.advertise();
Serial.println("Waiting a client connection to notify...");
delay(1000);
}
void loop() {
BLEDevice central = BLE.central();
if (central){
Serial.println("connesso");
while (central.connected()){
giorni_char.writeValue(messaggio);
delay(1000);
Serial.println("loop");
// }
}
Serial.println("disconnesso");
}
}