]> git.tnoah.ca Git - lora-radio.git/commitdiff
BLE improvements
authorMark Qvist <mark@unsigned.io>
Sun, 13 Apr 2025 00:23:01 +0000 (02:23 +0200)
committerMark Qvist <mark@unsigned.io>
Sun, 13 Apr 2025 00:23:01 +0000 (02:23 +0200)
BLESerial.cpp
BLESerial.h
Bluetooth.h

index 3460a86b3c89e06d8fa18a8f1169ccd05066aa10..80bcaf2ec034ec8fd1ecebce7f7bf4ac955af8e3 100644 (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) {
index 7b6d1c6f747d06ab057bbbc4f184bbfe08db07ae..1dcae996e154fb84609f8ce23cc85170cbc7803b 100644 (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();
index a93a2dff3a92100b6e3d29d11ad778b515684448..3d2917863912a47c23e9f23e9304192718aca648 100644 (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;