I connected my esp32 via Bluetooth (BLE) to my iphone. And I already can send messages form the iPhone to the arduino serial monitor, but the problem is I don't know how to do it the other way; by that, I mean, that I don't know how to send a string from the Serial Monitor to my iPhone. To get the messages I am using an app called BLE Scanner on my iPhone. I would appreciate your point of view.
class MyCallbacks: public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string value = pCharacteristic->getValue();
if (value.length() > 0) {
Serial.print("Respuesta: ");
for (int i = 0; i < value.length(); i++)
Serial.print(value[i]);
Serial.println();
}
}
};
void setup() {
Serial.begin(115200);
BLEDevice::init("yoESP32");
BLEServer *pServer = BLEDevice::createServer();
BLEService *pService = pServer->createService(SERVICE_UUID);
BLECharacteristic *pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE
);
pCharacteristic->setCallbacks(new MyCallbacks());
pService->start();
BLEAdvertising *pAdvertising = pServer->getAdvertising();
pAdvertising->start();
}