diff --git a/ports/nrf/common-hal/_bleio/Service.c b/ports/nrf/common-hal/_bleio/Service.c index 4980b70fe1..b0a6eeb83b 100644 --- a/ports/nrf/common-hal/_bleio/Service.c +++ b/ports/nrf/common-hal/_bleio/Service.c @@ -127,7 +127,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, .vloc = BLE_GATTS_VLOC_STACK, }; - ble_uuid_t char_uuid; + ble_uuid_t char_uuid = {}; bleio_uuid_convert_to_nrf_ble_uuid(characteristic->uuid, &char_uuid); ble_gatts_attr_md_t char_attr_md = { @@ -143,7 +143,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, char_md.p_cccd_md = &cccd_md; } - ble_gatts_attr_md_t user_desc_md; + ble_gatts_attr_md_t user_desc_md = {}; if (user_description != NULL && strlen(user_description) > 0) { BLE_GAP_CONN_SEC_MODE_SET_OPEN(&user_desc_md.read_perm); // If the description is on the Python heap, then have the SD copy it. If not, assume it's diff --git a/supervisor/shared/bluetooth/bluetooth.c b/supervisor/shared/bluetooth/bluetooth.c index 9799a74e9b..ade20a9f07 100644 --- a/supervisor/shared/bluetooth/bluetooth.c +++ b/supervisor/shared/bluetooth/bluetooth.c @@ -137,6 +137,9 @@ STATIC void supervisor_bluetooth_start_advertising(void) { #define BLE_DISCOVERY_DATA_GUARD_MASK 0xff0000ff void supervisor_bluetooth_init(void) { + #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE + return; + #endif uint32_t reset_state = port_get_saved_word(); uint32_t ble_mode = 0; if ((reset_state & BLE_DISCOVERY_DATA_GUARD_MASK) == BLE_DISCOVERY_DATA_GUARD) { @@ -174,10 +177,19 @@ void supervisor_bluetooth_init(void) { boot_in_discovery_mode = true; reset_state = 0x0; } + #if !CIRCUITPY_USB + // 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); + if (!bonded) { + boot_in_discovery_mode = true; + } + #endif while (diff < 1000) { #ifdef CIRCUITPY_STATUS_LED // Blink on for 50 and off for 100 - bool led_on = ble_mode != 0 || (diff % 150) <= 50; + bool led_on = boot_in_discovery_mode || (diff % 150) <= 50; if (led_on) { new_status_color(0x0000ff); } else {