07-05-2022, 04:18 PM
(This post was last modified: 07-05-2022, 04:19 PM by donghaipark.)
Thank you for your kind reply.
I did close Phyphox, but still not able to connect the ESP32 again unless I reboot the ESP32.
I used the following code for my ESP32:
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
void setup() {
Serial.begin(115200);
BLEDevice::init("ESP32");
// Create the BLE Server
pServer = BLEDevice::createServer();
// Create the BLE Service
BLEService *pService = pServer->createService(SERVICE_UUID);
// Create a BLE Characteristic
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic:ROPERTY_NOTIFY
);
// Start the service
pService->start();
// Start advertising
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
BLEDevice:tartAdvertising();
}
void loop() {
// notify changed value
int ran = random(0,11); //
Serial.println(ran);
pCharacteristic->setValue(ran); //
pCharacteristic->notify();
delay(100);
}
I did close Phyphox, but still not able to connect the ESP32 again unless I reboot the ESP32.
I used the following code for my ESP32:
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
void setup() {
Serial.begin(115200);
BLEDevice::init("ESP32");
// Create the BLE Server
pServer = BLEDevice::createServer();
// Create the BLE Service
BLEService *pService = pServer->createService(SERVICE_UUID);
// Create a BLE Characteristic
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic:ROPERTY_NOTIFY
);
// Start the service
pService->start();
// Start advertising
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
BLEDevice:tartAdvertising();
}
void loop() {
// notify changed value
int ran = random(0,11); //
Serial.println(ran);
pCharacteristic->setValue(ran); //
pCharacteristic->notify();
delay(100);
}