Skip to content

Commit ce73015

Browse files
authored
Merge pull request micropython#5024 from tannewt/rp2_ble_wait
Don't blink blue on non-BLE workflow boards
2 parents 5e773b8 + f8290e7 commit ce73015

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

ports/nrf/common-hal/_bleio/Service.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
127127
.vloc = BLE_GATTS_VLOC_STACK,
128128
};
129129

130-
ble_uuid_t char_uuid;
130+
ble_uuid_t char_uuid = {};
131131
bleio_uuid_convert_to_nrf_ble_uuid(characteristic->uuid, &char_uuid);
132132

133133
ble_gatts_attr_md_t char_attr_md = {
@@ -143,7 +143,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
143143
char_md.p_cccd_md = &cccd_md;
144144
}
145145

146-
ble_gatts_attr_md_t user_desc_md;
146+
ble_gatts_attr_md_t user_desc_md = {};
147147
if (user_description != NULL && strlen(user_description) > 0) {
148148
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&user_desc_md.read_perm);
149149
// If the description is on the Python heap, then have the SD copy it. If not, assume it's

supervisor/shared/bluetooth/bluetooth.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ STATIC void supervisor_bluetooth_start_advertising(void) {
137137
#define BLE_DISCOVERY_DATA_GUARD_MASK 0xff0000ff
138138

139139
void supervisor_bluetooth_init(void) {
140+
#if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
141+
return;
142+
#endif
140143
uint32_t reset_state = port_get_saved_word();
141144
uint32_t ble_mode = 0;
142145
if ((reset_state & BLE_DISCOVERY_DATA_GUARD_MASK) == BLE_DISCOVERY_DATA_GUARD) {
@@ -174,10 +177,19 @@ void supervisor_bluetooth_init(void) {
174177
boot_in_discovery_mode = true;
175178
reset_state = 0x0;
176179
}
180+
#if !CIRCUITPY_USB
181+
// Boot into discovery if USB isn't available and we aren't bonded already.
182+
// Checking here allows us to have the status LED solidly on even if no button was
183+
// pressed.
184+
bool bonded = common_hal_bleio_adapter_is_bonded_to_central(&common_hal_bleio_adapter_obj);
185+
if (!bonded) {
186+
boot_in_discovery_mode = true;
187+
}
188+
#endif
177189
while (diff < 1000) {
178190
#ifdef CIRCUITPY_STATUS_LED
179191
// Blink on for 50 and off for 100
180-
bool led_on = ble_mode != 0 || (diff % 150) <= 50;
192+
bool led_on = boot_in_discovery_mode || (diff % 150) <= 50;
181193
if (led_on) {
182194
new_status_color(0x0000ff);
183195
} else {

0 commit comments

Comments
 (0)