BLE improvements

This commit is contained in:
Mark Qvist 2025-04-13 02:23:01 +02:00
parent 9d2da569c9
commit 16dedc72c2
3 changed files with 11 additions and 0 deletions

View file

@ -110,7 +110,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);
@ -119,6 +122,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) {

View file

@ -78,6 +78,8 @@ public:
void begin(const char *name);
void end();
void startAdvertising();
void stopAdvertising();
void onWrite(BLECharacteristic *characteristic);
int available();
int peek();

View file

@ -266,6 +266,7 @@ char bt_devname[11];
// Serial.println("Authentication fail");
ble_authenticated = false;
bt_state = BT_STATE_ON;
bt_update_passkey();
bt_security_setup();
}
bt_allow_pairing = false;