Android Question BLE2 dropouts when WiFi inactive

Discussion in 'Android Questions' started by emexes, Feb 17, 2019.

  1. emexes

    emexes Active Member Licensed User

    This isn't a question, just an observation that might save someone the days of stress that I've just had.

    Symptom is an app that reads a BLE sensor, works great during development using B4A Bridge, solid as a rock. Then I recompile it with logging disabled (and now even comment out all Log[Color] calls), install the ready-for-release version using B4A Bridge again, test it, still works great.

    Then I upload it to Google Play, download it, test it, and it is no longer solid as a rock, and certainly not saleable. Spewin!

    I eventually found that the app runs fine if B4A Bridge is up and active, fails otherwise.

    After some more experimenting, I've found that if I continuously ping the Android device over WiFi from another computer, then the app runs fine without B4A Bridge running too.

    My theory is that the power management on this device must be over-enthusiastically powering down the Bluetooth receiver, and that keeping the WiFi active stops this and leaves the Bluetooth receiver on, and thus I no longer miss packets that are sent sporadically by the Bluetooth sensor (ie as Notifications).

    The device is a cheap generic Android tablet, ie not a phone. The five phones I have for testing all seem to work ok.

    I will have to follow this up further, but I am under the pump right now to port this app to iOS, so it'll be a couple of weeks before I get back to this issue.

    If anybody else has experienced similar, or has discovered other causes for BLE operation varying with/without B4A Bridge etc, I'd be interested to hear about it.
     
    Last edited: Feb 17, 2019
    Erel likes this.
  2. emexes

    emexes Active Member Licensed User

    Whilst I'm here, I'd like to submit my entry for "Kludge Of The Week", namely:

    Leave BLE scan running even after you've found your device, so that the BLE receiver isn't powered down causing missed notifications.

    Mind you, I think this'll bite me down the track when I encounter a single-receiver Bluetooth chip that can't receive data and advertisements concurrently.

    :-/
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    The debugger performance depends on the network latency. I found out that in order to keep the latency as low as possible, the network must be active all the time. The solution was to send frequent "ping" requests while the debugger is connected.
    Without it the latency can be high as 1 or more seconds.
     
    emexes likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice