Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buttonless DFU not working on iOS #3

Closed
jthansen opened this issue Jun 27, 2019 · 8 comments
Closed

Buttonless DFU not working on iOS #3

jthansen opened this issue Jun 27, 2019 · 8 comments

Comments

@jthansen
Copy link

jthansen commented Jun 27, 2019

I am unable to get DFU to work with iOS. I believe it has to deal with the device id being different in iOS with Flutter Blue. Since iOS creates their own UUID instead of using the MAC address like Android.

@jthansen jthansen changed the title iOS Not Working Due to UUID instead of MAC iOS Not Working Due to UUID instead of MAC Address Jun 27, 2019
@fengqiangboy
Copy link
Owner

Did NRFConnect worked?

@jthansen
Copy link
Author

jthansen commented Jun 28, 2019

Yeah, that works on iOS. Is there something I need to add with iOS as opposed to Android?

This code works with Android and then with iOS I get a PlatformException thrown.

  • PlatformException(DFU_FAILED, iOS UUID, null)
Future<bool> performDfu() async {
    dfuRunning = true;
    try {
      var s = await FlutterNordicDfu.startDfu(device.id.id,'assets/file.zip',
        fileInAsset: true,
        enableUnsafeExperimentalButtonlessServiceInSecureDfu: true,
        progressListener:
        DefaultDfuProgressListenerAdapter(onProgressChangedHandle: (
            deviceAddress,
            percent,
            speed,
            avgSpeed,
            currentPart,
            partsTotal,
            ) {
          print('deviceAddress: $deviceAddress, percent: $percent');
        }),
      );
      print(s);
      dfuRunning = false;
      return true; 
    } catch (e) {
      dfuRunning = false;
      print(e);
      return false;
    }
  }

@fengqiangboy
Copy link
Owner

Can you paste more log that console print?

@jthansen
Copy link
Author

jthansen commented Jul 1, 2019

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(DFU_FAILED, Device address: 502CCB90-5B67-4287-3C7F-A17AD3124958, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
<asynchronous suspension>
#2      FlutterNordicDfu.startDfu (package:flutter_nordic_dfu/flutter_nordic_dfu.dart:141:27)
<asynchronous suspension>
#3      _x.performDfu (package:xxx/widgets/x.dart:1137:38)
<asynchronous suspension>
#4      System._updateFirmwareTapped.<anonymous closure> (package:xxx/screens/more/settings/system.dart:57:18)
#5      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
#6      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
#7      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
#8      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
#9      TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:211:7)
#10     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
#11     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:225:20)
#12     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:199:22)
#13     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
#14     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
#15     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
#16     _rootRunUnary (dart:async/zone.dart:1136:13)
#17     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#18     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#19     _invoke1 (dart:ui/hooks.dart:233:10)
#20     _dispatchPointerDataPacket (dart:ui/hooks.dart:154:5)

@fengqiangboy
Copy link
Owner

Sorry, I can't find the problem by this log message, can you try to use IOS-Pods-DFU-Library?
And tell me the right code, I will compare them with my DFU platform code. Thx~

@jthansen
Copy link
Author

jthansen commented Jul 2, 2019

I got the iOS DFU library to work with this code, nRF Toolbox Repo. I had to change: @objc public var alternativeAdvertisingNameEnabled from true to false. I tried changing that property in your plugin but it still didn't work. Are you calling the DFU initiator differently? They have this for their DFU function:

func performDFU() {
        self.disableOtherButtons()
        progress.isHidden = false
        progressLabel.text = nil
        progressLabel.isHidden = false
        uploadStatus.isHidden = false
        uploadButton.isEnabled = false

        self.registerObservers()
        
        // To start the DFU operation the DFUServiceInitiator must be used
        let initiator = DFUServiceInitiator(centralManager: centralManager!, target: selectedPeripheral!)
        initiator.forceDfu = UserDefaults.standard.bool(forKey: "dfu_force_dfu")
        initiator.packetReceiptNotificationParameter = UInt16(UserDefaults.standard.integer(forKey: "dfu_number_of_packets"))
        initiator.logger = self
        initiator.delegate = self
        initiator.progressDelegate = self
        initiator.enableUnsafeExperimentalButtonlessServiceInSecureDfu = true
        dfuController = initiator.with(firmware: selectedFirmware!).start()
        uploadButton.setTitle("Cancel", for: UIControlState())
        uploadButton.isEnabled = true
    }

Have you accomplished buttonless DFU with this plugin yet?

@fengqiangboy
Copy link
Owner

Yes, we use dfuInitiator.start(targetWithIdentifier: uuid) to start dfu

@jthansen
Copy link
Author

jthansen commented Jul 3, 2019

It's working today with a different unit. So I'm not sure what was all wrong.

@jthansen jthansen changed the title iOS Not Working Due to UUID instead of MAC Address Buttonless DFU not working on iOS Jul 3, 2019
@jthansen jthansen closed this as completed Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants