NordicSemiconductor / IOS-DFU-Library

OTA DFU Library for Mac and iOS, compatible with nRF5x SoCs
http://www.nordicsemi.com
BSD 3-Clause "New" or "Revised" License
525 stars 214 forks source link

Two devices, upgrade crossover #502

Closed ZWP233 closed 1 year ago

ZWP233 commented 1 year ago

DFU Bootloader version (please complete the following information):

Device information (please complete the following information):

Describe the bug I have two devices. When I upgrade one of them, the upgraded one does not respond, and the other one is upgraded to this version. This happens repeatedly, and the version is displayed on the other machine! I suspect that the unresponsive machine is in DFU mode, and when I was upgrading, I entered DFU mode and was replaced, causing the firmware to be uploaded to another machine to complete the upgrade process, because the code returned means that the upgrade is successful, but the upgraded one is another a machine .i need help

philips77 commented 1 year ago

Hello,

On iOS the device MAC is not available using the public API. During the DFU procedure, when a device switches from the application mode to the DFU bootloader mode it changes its MAC address to +1. From an iPhone perspective it now advertises as completely new device. But as we don't have access to MAC we can't easily find which device to connect to after the switch.

For that reason the library implements 2 features:

  1. Requesting a unique name to be advertised in bootloader mode (available since nRF5 SDK 14, enabled by default) See: https://github.com/NordicSemiconductor/IOS-DFU-Library/blob/22952128c6499740f0d04b3dba9b51813cc19a4c/iOSDFULibrary/Classes/Implementation/DFUServiceInitiator.swift#L248
  2. A DFUPeripheralSelectorDelegate (default implementation). You may write a custom selector that should return true when a correct bootloader is found. This is useful if you have modified the default DFU bootloader advertising and the default impl won't work. This has to be set here: https://github.com/NordicSemiconductor/IOS-DFU-Library/blob/22952128c6499740f0d04b3dba9b51813cc19a4c/iOSDFULibrary/Classes/Implementation/DFUServiceInitiator.swift#L96

In general, if your DFU bootloader implementation has not been modified, and the nRF5 SDK is > 14, that situation should not happen assuming you're selecting the correct device to initiate the DFU.