Hello Juan Antonio,
Thanks for your tutos and developpments.
Completely new with ESP and Mit app Inventor, you gave me the possibility to develop what I needed based on your sketches ( 10.- From App ON/OFF 3 LEDs. Get status of the LEDs.) ie. a remote base with 5 relays and specifically a BLE remote to control 2 relays for an E Scooter. (ON OFF Motor / ON OFF Lights).
Since I need to connect to 4 different EScooter (separately) i registered all 4 x 2 UUIDS and after list picking (with device Name) the connection is done displaying also a picture of each E Scoot model.
Also I get connection infos from the ESP as a returned string to make sure that the order is taken into consideration (instead of displaying from the app when sending ON OFF (A0 A1, B0 , B1,....) "commands.
Hereby the Esp & App Inventor Sketches
Again thank you so much.
I also facing a small difficulty (where I mostly find similar questions on the net) that is proper disconnection from the app with the ESP and its re-connection. For exemple I connect to 1 scooter and change my mind to disconnect and connect to another one to check it and come back to the 1st one the connection is quite tough (even if disconnected on the app with BLE disconect, Disconnect with adress or both. Even with a "reboot" from the ESP (ON OFF). So far I have seen accordingly to several same issue on the net, the solution might be as per your description
""
bool deviceConnected = false;
bool oldDeviceConnected = false;
//uint32_t value = 0;
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
};
////////////////////// WriteStrings /////////////////////////////
class MyCallbacks: public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string value = pCharacteristic->getValue();
if (value.length() > 0) {
valor = "";
for (int i = 0; i < value.length(); i++){
// Serial.print(value[i]); // Presenta value.
valor = valor + value[i];
}
Serial.println("*********");
Serial.print("valor = ");
Serial.println(valor); // Presenta valor.
}
}
};
But.....I have no clue how to implement it with your APP dvlpment 10- ON/OFF 3 Leds with Led status.
If you can help, I would appreciate.
In case not I 'll continue looking around and testing.
In any case thank You for your publications and the way you are helping readers.
It is very helpfull.
Best Regards,
Jean-Luc
Trot1.aia (3.5 MB)
ESP32.pdf (10.8 KB)