File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
ports/nrf/common-hal/_bleio
supervisor/shared/bluetooth Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
127
127
.vloc = BLE_GATTS_VLOC_STACK ,
128
128
};
129
129
130
- ble_uuid_t char_uuid ;
130
+ ble_uuid_t char_uuid = {} ;
131
131
bleio_uuid_convert_to_nrf_ble_uuid (characteristic -> uuid , & char_uuid );
132
132
133
133
ble_gatts_attr_md_t char_attr_md = {
@@ -143,7 +143,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
143
143
char_md .p_cccd_md = & cccd_md ;
144
144
}
145
145
146
- ble_gatts_attr_md_t user_desc_md ;
146
+ ble_gatts_attr_md_t user_desc_md = {} ;
147
147
if (user_description != NULL && strlen (user_description ) > 0 ) {
148
148
BLE_GAP_CONN_SEC_MODE_SET_OPEN (& user_desc_md .read_perm );
149
149
// If the description is on the Python heap, then have the SD copy it. If not, assume it's
Original file line number Diff line number Diff line change @@ -137,6 +137,9 @@ STATIC void supervisor_bluetooth_start_advertising(void) {
137
137
#define BLE_DISCOVERY_DATA_GUARD_MASK 0xff0000ff
138
138
139
139
void supervisor_bluetooth_init (void ) {
140
+ #if !CIRCUITPY_BLE_FILE_SERVICE && !CIRCUITPY_SERIAL_BLE
141
+ return ;
142
+ #endif
140
143
uint32_t reset_state = port_get_saved_word ();
141
144
uint32_t ble_mode = 0 ;
142
145
if ((reset_state & BLE_DISCOVERY_DATA_GUARD_MASK ) == BLE_DISCOVERY_DATA_GUARD ) {
@@ -174,10 +177,19 @@ void supervisor_bluetooth_init(void) {
174
177
boot_in_discovery_mode = true;
175
178
reset_state = 0x0 ;
176
179
}
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
177
189
while (diff < 1000 ) {
178
190
#ifdef CIRCUITPY_STATUS_LED
179
191
// 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 ;
181
193
if (led_on ) {
182
194
new_status_color (0x0000ff );
183
195
} else {
You can’t perform that action at this time.
0 commit comments