Merge pull request #9344 from tannewt/disable_ble_completely

Only start BLE for workflow when desired
This commit is contained in:
Dan Halbert 2024-06-18 17:01:10 -04:00 committed by GitHub
commit f66313c93b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -212,11 +212,11 @@ void supervisor_bluetooth_init(void) {
boot_in_discovery_mode = true;
reset_state = 0x0;
}
bool bonded = common_hal_bleio_adapter_is_bonded_to_central(&common_hal_bleio_adapter_obj);
#if !CIRCUITPY_USB_DEVICE
// Boot into discovery if USB isn't available and we aren't bonded already.
// Checking here allows us to have the status LED solidly on even if no button was
// pressed.
bool bonded = common_hal_bleio_adapter_is_bonded_to_central(&common_hal_bleio_adapter_obj);
bool wifi_workflow_active = false;
#if CIRCUITPY_WEB_WORKFLOW && CIRCUITPY_WIFI && CIRCUITPY_OS_GETENV
char _api_password[64];
@ -255,6 +255,11 @@ void supervisor_bluetooth_init(void) {
if (boot_in_discovery_mode) {
common_hal_bleio_adapter_erase_bonding(&common_hal_bleio_adapter_obj);
}
if (boot_in_discovery_mode || bonded) {
workflow_state = WORKFLOW_ENABLED;
} else {
workflow_state = WORKFLOW_DISABLED;
}
#if CIRCUITPY_STATUS_LED
new_status_color(BLACK);
status_led_deinit();
@ -358,7 +363,7 @@ void supervisor_bluetooth_disable_workflow(void) {
bool supervisor_bluetooth_workflow_is_enabled(void) {
#if CIRCUITPY_BLE_FILE_SERVICE || CIRCUITPY_SERIAL_BLE
if (workflow_state == 1) {
if (workflow_state == WORKFLOW_ENABLED) {
return true;
}
#endif

View file

@ -100,7 +100,6 @@ void supervisor_workflow_start(void) {
#if CIRCUITPY_BLEIO
bleio_reset();
supervisor_bluetooth_enable_workflow();
supervisor_start_bluetooth();
#endif