This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

DFU bootloader with Qt - problem for iOS

Hello everyone,

I am working on DFU bootloader application for android  and iOS (using Qt C++).

For android everything works fine, but for iOS I have problems.

In order to enter DFU mode I need to send 0x0104 to control point dfu characteristic and after this device is reset in DFU mode.

After this my app doing next steps: connect to device again > discover services (there is only DFU service now) > write descriptor for  CP characteristic (to enable notifications) > THERE IS A PROBLEM - The delegate for CBPeripheral does not implement -[peripheral:didModifyServices:].

I tried to increment MAC address (device uuid) when enter in DFU mode because I read that devices may be cached by the phone and if they change services list while connected that could cause the problem, but the problem is still there.

Has anyone had a similar problem/experience?

Thanks in advance.

  • Hi Mostafa,

    I tried and problem is still there. I also tried to modify small app for mac desktop where I can manually  scan for devices after first restart (when restart into DFU mode), than I connect to DfuTarg, discover services (here is only DFU service present) and when try to write descriptor to enable notification for DFU control point char, then app is crashed.  

    I thing that maybe there is some problem with Qt's writeDescriptor function.

  • Aha, I see your problem I think, to enable notifications on iOS / macOS you can't write to the descriptor, the `CoreBluetooth` api doesn't allow that, what you can do instead is use a `CoreBluetooth` method called `setNotifyValue:(Bool)forCharacteristic:(CBCharacteristic)`, found here

    I guess when you try to write to that descriptor using Qt it will still try to write anyway, causing that issue, do you know if Qt Bluetooth has any way of setting the notify property without writing to descriptor ?

    also, do you have any logs from that crash ?

  • Hi Mostafa,

    As far as I know there is no another way to set notification from Qt.

    When app is crashed, I'm getting next message: 

    [CoreBluetooth] WARNING: The delegate for <CBPeripheral: 0x10174f410, identifier = 42593BBF-40E8-4BED-A813-20540069584A, name = DfuTarg, state = connected> does not implement -[peripheral:didModifyServices:]

    I'm thinking about mixing native code with C++. To call setNotify function somehow from my C++ code.

    I'll continue to investigate.

    Thank you for your time.

    Best regards

Related