Skip to content

BLEAdvertising stop doesn't stop advertising #797

Open
@tpitman

Description

@tpitman

I have a simple application that I want to be able to start and stop advertising so that other devices are prevented from connecting when I don't want them too. This needs to be turned on and off at runtime.

Here is my startup code:

  
  pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  pServer->setCallbacks(new BTServerCallbacks());

  pCharacteristicCommand = pService->createCharacteristic(
                             COMMAND_UUID,
                             BLECharacteristic::PROPERTY_READ |
                             BLECharacteristic::PROPERTY_WRITE |
                             BLECharacteristic::PROPERTY_NOTIFY
                           );

  pCharacteristicCommand->setCallbacks(new BTCallbacks());
  pCharacteristicCommand->setValue("");
  pCharacteristicCommand->addDescriptor(new BLE2902());

  pService->start();
  BLEAdvertising *pAdvertising = pServer->getAdvertising();
  pAdvertising->start();

This works great and my service advertises and I am able to connect with it and process things.

Then when I want my device to become unavailable I do this:

        BLEAdvertising *pAdvertising = pServer->getAdvertising();
        pAdvertising->stop();

It calls it and doesn't give any errors or exceptions, but my device is still visible to my iPhone and I can still connect to it.

How do I disable advertising and connecting during runtime?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions