You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -200,6 +200,75 @@ void setup() {
200
200
}
201
201
```
202
202
203
+
## Handling Re-encryption Failures
204
+
205
+
### Problem
206
+
207
+
When a Pico device has been bonded with a central device (like a smartphone) and then the Pico is flashed with new firmware, the following error sequence may occur when attempting to reconnect:
208
+
209
+
```
210
+
Re-encryption started with bonded device
211
+
Pairing started
212
+
Re-encryption failed, status: 61
213
+
Pairing failed
214
+
```
215
+
216
+
This occurs because:
217
+
1. The central device (smartphone) still has the bonding information
218
+
2. The Pico has lost all bonding data after being flashed
219
+
3. The central device attempts to use the old bonding keys to re-establish a secure connection
220
+
4. The pairing fails because the Pico no longer recognizes these keys
221
+
222
+
### Solutions
223
+
224
+
There are several approaches to handle this situation:
225
+
226
+
#### Option 1: Remove Bonding on Central Device
227
+
228
+
The simplest approach for development is to remove the bonded device from your smartphone/central device:
229
+
230
+
- **On Android**: Go to Settings → Bluetooth → Previously Connected Devices → Tap the gear or arrow icon next to your device → "Forget" or "Unpair"
231
+
- **On iOS**: Go to Settings → Bluetooth → Tap the "i" next to your device → "Forget This Device"
Serial.println("Pairing failed - attempting to clear existing bond");
250
+
// In a real application, you might want to:
251
+
// 1. Request the central device to forget the bond
252
+
// 2. Try a fresh pairing after a delay
253
+
254
+
// For now, we can just disconnect to force a fresh connection
255
+
if (device) {
256
+
gap_disconnect(device->getHandle());
257
+
}
258
+
break;
259
+
// Other cases...
260
+
}
261
+
}
262
+
```
263
+
264
+
### Recommendation for Development
265
+
266
+
During development, use Option 1 (removing the bond on the central device) for simplicity. For production devices, consider implementing a more robust solution with persistent storage (Option 2).
267
+
268
+
### Important Note
269
+
270
+
This behavior is common in BLE development and not specific to this library. Any time bonding information is lost on either the peripheral or central device, re-encryption will fail, and the bond must be reestablished.
0 commit comments