Merge pull request #5024 from tannewt/rp2_ble_wait

Don't blink blue on non-BLE workflow boards
This commit is contained in:
Dan Halbert 2021-07-19 23:51:27 -04:00 committed by GitHub
commit ce7301527a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -127,7 +127,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
.vloc = BLE_GATTS_VLOC_STACK, .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); bleio_uuid_convert_to_nrf_ble_uuid(characteristic->uuid, &char_uuid);
ble_gatts_attr_md_t char_attr_md = { 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; 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) { if (user_description != NULL && strlen(user_description) > 0) {
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&user_desc_md.read_perm); 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 // If the description is on the Python heap, then have the SD copy it. If not, assume it's

View File

@ -137,6 +137,9 @@ STATIC void supervisor_bluetooth_start_advertising(void) {
#define BLE_DISCOVERY_DATA_GUARD_MASK 0xff0000ff #define BLE_DISCOVERY_DATA_GUARD_MASK 0xff0000ff
void supervisor_bluetooth_init(void) { 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 reset_state = port_get_saved_word();
uint32_t ble_mode = 0; uint32_t ble_mode = 0;
if ((reset_state & BLE_DISCOVERY_DATA_GUARD_MASK) == BLE_DISCOVERY_DATA_GUARD) { 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; boot_in_discovery_mode = true;
reset_state = 0x0; 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) { while (diff < 1000) {
#ifdef CIRCUITPY_STATUS_LED #ifdef CIRCUITPY_STATUS_LED
// Blink on for 50 and off for 100 // 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) { if (led_on) {
new_status_color(0x0000ff); new_status_color(0x0000ff);
} else { } else {