Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bluetooth Medic #644

Merged
merged 5 commits into from
Feb 23, 2018
Merged

Add Bluetooth Medic #644

merged 5 commits into from
Feb 23, 2018

Conversation

davidgyoung
Copy link
Member

@davidgyoung davidgyoung commented Feb 15, 2018

This adds an optional Bluetooth Medic class that can be used to look for crashes in the Bluetooth stack, and optionally power cycle bluetooth to attempt to recover when crashes are found. This has been proven to be effective in testing with the the Samsung J3 and the Huawei P9 Lite.

The medic performs two optionally configurable tests, one that does a brief bluetooth scan and one that transmits over bluetooth. Both can detect a bluetooth stack crash based on the error codes returned if there are failures.

The Medic can be run in three modes: passive manual and automatic. Automatic mode uses a Scheduled Job to run the configured tests every 15 minutes. Manual mode allows the user to run the tests manually at a time of their choosing. Passive mode simply looks for failures on the library's regular scanning, for which local broadcast events have been added in the event of failures.

By default, the medic does nothing.

To start the medic passively to recover from crashes:

BluetoothMedic medic = BluetoothMedic.getInstance();
medic.enablePowerCycleOnFailures(context);

To start the medic manually to recover from crashes:

BluetoothMedic medic = BluetoothMedic.getInstance();
medic.enablePowerCycleOnFailures(context);
if (!medic.runScanTest(context)) {
     // Bluetooth stack is in a bad state
}
if (!medic.runTransmitterTest(context)) {
     // Bluetooth stack is in a bad state
}

To start the medic to automatically run tests and recover from crashes:

BluetoothMedic medic = BluetoothMedic.getInstance();
medic.enablePowerCycleOnFailures(context);
medic.enablePeriodicTests(context, BluetoothMedic.SCAN_TEST | BluetoothMedic.TRANSMIT_TEST);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant