Incorporate changes from upstream 1.82

This commit is contained in:
jacob.eva 2025-05-31 15:28:56 +01:00
commit fd5520d95f
No known key found for this signature in database
GPG key ID: 0B92E083BBCCAA1E
12 changed files with 251 additions and 128 deletions

View file

@ -97,6 +97,17 @@ void BLESerial::flush() {
}
}
void BLESerial::disconnect() {
if (ble_server->getConnectedCount() > 0) {
uint16_t conn_id = ble_server->getConnId();
// Serial.printf("Have connected: %d\n", conn_id);
ble_server->disconnect(conn_id);
// Serial.println("Disconnected");
} else {
// Serial.println("No connected");
}
}
void BLESerial::begin(const char *name) {
ConnectedDeviceCount = 0;
BLEDevice::init(name);
@ -111,7 +122,10 @@ void BLESerial::begin(const char *name) {
BLEDevice::setSecurityCallbacks(this);
SetupSerialService();
this->startAdvertising();
}
void BLESerial::startAdvertising() {
ble_adv = BLEDevice::getAdvertising();
ble_adv->addServiceUUID(BLE_SERIAL_SERVICE_UUID);
ble_adv->setMinPreferred(0x20);
@ -120,6 +134,11 @@ void BLESerial::begin(const char *name) {
ble_adv->start();
}
void BLESerial::stopAdvertising() {
ble_adv = BLEDevice::getAdvertising();
ble_adv->stop();
}
void BLESerial::end() { BLEDevice::deinit(); }
void BLESerial::onWrite(BLECharacteristic *characteristic) {