This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Connect to phone in background

I'm trying to get my nRF52 BLE peripheral to connect to my phone while its screen is off and it's in sleep mode. Other consumer BLE peripherals that I have can connect to my phone while its screen is off but my peripheral can't and will only reconnect once I turn the screen on. Is there some sort of setting or configuration to enable the background connect functionality? Thanks!

  • @Vaiblhav: Are you talking about iOS or Android ? On Android you can create a background service, like this

    For iOS you may want to have a look at this.

  • I'm attempting to get my peripheral to work with an app that already exists and I don't have control over. Other peripheral devices can connect with it in the background but my nRF52 peripheral can't and needs the app to come into the foreground. This is on iOS. Is there some sort of setting or callback for the nRF52 to handle background connection or something? Thanks!

  • @Vaibhav: You may need to have a look at the sniffer trace to figure out why it connects to other devices but not yours.

    We need to check if the app/phone actually connect to the nRF5 or not. If it doesn't then it could be that the flag or something are different from what other device advertise to the phone doesn't send connect request.

  • @Hung Bui I have a sniffer and there is a difference in "randomized tx address" bit in the ADV_IND packet header. Do you know how to set this? Other than that, the adv packet is essentially the same, and my peripheral can communicate with the app only when the app is in the foreground, so it probably isn't an issue with advertisement since other peripherals wouldn't advertise differently since they wouldn't know when to connect to mobile app in the background or foreground. It's sort of hard to use a sniffer to catch packets when connecting in the background since the moment I turn on the device it immediately connects to the app before I can configure the sniffer. Is there a way around this issue? Thanks for the help!

  • You can test the sniffer like this:

    • You put your app in background mode

    • You turn on your device, let it advertise

    • The app won't connect to your device as you described as the issue. You can use the sniffer to follow the device

    • Check if there is any connection request when the app is in background

    • Wake the app up to foreground and see if how it's connected.

    Which type of address do you have ? Please take a screenshot of the normal device and your device.

    Please be noted that, besides advertising, the nRF5 can't do anything else to interact with the phone unless the phone connect to it.

Related