2 Replies
      Latest reply on Nov 30, 2019 11:01 AM by DavidC
      DavidC Level 1 Level 1 (0 points)

        Hi all,

        In our use case the iOS mobile device is peripheral, that advertises in order to be found by our hardware device that is in central role.

         

        Since iOS 13 we struggle with a very strange behaviour:

         

        When the app is closed, we programatically stop advertising, but it is reactivated by the iOS. From then on the mobile device advertises endlessly. This causes some trouble when our hardware device is nearby, as it cannot connect, because the app is not running.

         

        The only thing that helps to stop advertising is to disable bluetooth in the system settings. Even using the control center does not stop advertising.

        Is there a place to configure this behaviour in a way, that advertising will kept stopped?

         

        Kind Regards

        David

        • Re: Bluetooth Advertises in peripheral mode, even after the app is closed
          KMT Level 9 Level 9 (15,215 points)

               >Since iOS 13 we struggle with a very strange behaviour:

           

          Things changed w/iOS 13.x. Confirm your app is compliant with the new user notification requirements. This might be your main issue.

           

               >Is there a place to configure this behaviour in a way, that advertising will kept stopped?

           

          Centrals (your hardware) scan for peripherals that are advertising*. I don't think you want the OS to stop it's own advertising, even if your testing shows that helps your app get thru. I think your app needs to stand it's ground.

           

          Show your code for backgrounding. Also, what does your BT device actually do? Are you required to be in the MFi Program?

           

          *From the docs:

          Centrals and Peripherals Are the Key Players in Core Bluetooth

          In Bluetooth low energy communication, there are two key players: the central and the peripheral. Each player has a different role. A peripheral typically has data that is needed by other devices. A central typically uses the information served up by a peripheral to accomplish some task. For example, a digital thermostat equipped with Bluetooth low energy technology might provide the temperature of a room to an iOS app that then displays the temperature in a user-friendly way.

           

          Each player performs a different set of tasks when carrying out its role. Peripherals make their presence known by advertising the data they have over the air. Centrals scan for nearby peripherals that might have data they’re interested in. When a central discovers such a peripheral, the central requests to connect to the peripheral and begins exploring and interacting with the peripheral’s data. The peripheral is responsible for responding to the central in appropriate ways.

            • Re: Bluetooth Advertises in peripheral mode, even after the app is closed
              DavidC Level 1 Level 1 (0 points)

              we will doublecheck the user notification requirements.

              I asked our developers to post the code snippets here, when closing the app or bringing it into the background.

               

              Our device is a gateway to control some physical devices. It is in the central role, because it can connect to several mobile devices at a time, that all can control the physical devices via the gateway.

              We are registered for MFI, but this was not neccessary for this application, because we use BLE not BR/EDR.

               

              The main problem is, that the iOS mobile still advertises, even when the app is not running at all. When our device (central) wants to connect to the mobile (peripheral), but the app is not there to respond on a higher protocol level, it disconnects and reconnects all the time.

               

              The other thing is, the the mobile iOS device advertises all the time, what of course is consuming a lot of battery power.

               

              Looking at the spec of core bluetooth, func startAdvertising([String : Any]?) and func stopAdvertising()

              are still available and were working for years now.

               

              Regards

              David