My bluetooth product is frequently turned on and off, and I need to detect this much quicker than the ACL_DISCONNECT allows. I've moved all bluetooth connection handling into a service, in which BT is enabled at Service start (if not already enabled), then Listen is called, and my products connects quickly and send s data which I get.
If I stop getting data, my unit has been turned off, so I flag the unit as disconnected, but I can't wait around for ACL_DISCONNECT before re-enabling, I need the BT to be listening again asap for when my product powers back up. This part I am having problems with.
So the moment when I detect data isn't arriving and it's clear the unit is off, I do admin.Disable, then in the State_Changed function I enable the BT again if it is disabled, and then admin.Listen right away and expect my unit to reconnect when I power it on (the auto reconnect is initiated by my product, the nexus BT never needs to actively connect), but it never reconnects when I try this.
So am I missing something in the strategy in the above paragraph? The other way I thought to do it was after disabling the BT, if there was some way I could force a restart of the whole service. Is that possible?
If I stop getting data, my unit has been turned off, so I flag the unit as disconnected, but I can't wait around for ACL_DISCONNECT before re-enabling, I need the BT to be listening again asap for when my product powers back up. This part I am having problems with.
So the moment when I detect data isn't arriving and it's clear the unit is off, I do admin.Disable, then in the State_Changed function I enable the BT again if it is disabled, and then admin.Listen right away and expect my unit to reconnect when I power it on (the auto reconnect is initiated by my product, the nexus BT never needs to actively connect), but it never reconnects when I try this.
So am I missing something in the strategy in the above paragraph? The other way I thought to do it was after disabling the BT, if there was some way I could force a restart of the whole service. Is that possible?