• iOSDFULibrary固件升级代码和踩的坑


    //固件升级代码(设置代理之类的就不说了,代码这么多原理也看不过来)
    //
    DFUFirmware *selectedFirmware = [[DFUFirmware alloc] initWithZipFile:firmWareData];
        dispatch_queue_t eventQueue = dispatch_queue_create("com.ota.updater", DISPATCH_QUEUE_CONCURRENT);
        DFUServiceInitiator * dfuInitiator = [[DFUServiceInitiator alloc] initWithQueue:eventQueue delegateQueue:eventQueue progressQueue:eventQueue loggerQueue:eventQueue];
        dfuInitiator = [dfuInitiator withFirmware:selectedFirmware];
        dfuInitiator.delegate = self;
        dfuInitiator.progressDelegate = self;
        dfuInitiator.logger = self;
    ///这个设置无关精要
        //dfuInitiator.packetReceiptNotificationParameter = 4;
    ///之前一直处理不成功,自动断开连接然后又一直重试连接,重试是sdk搞出来的事情,最后发现是一直在尝试给硬件设置名称(我们的硬件这类命令发过去都是要先绑定和授权的)所以一直失败,由此设置这个属性不让它进行这种莫名其妙的操作,接下来就是见证奇迹的时刻了
        dfuInitiator.alternativeAdvertisingNameEnabled = NO;
        dfuInitiator.enableUnsafeExperimentalButtonlessServiceInSecureDfu = YES;
    self.dfuController = [[dfuInitiator withFirmware:selectedFirmware] startWithTarget:peripheral];

    不进行这个配置,使用其他工具 nRF Connect上报的错误信息(后来看这个报错也比较明确说了处理方式)

    [Callback] Central Manager did disconnect peripheral
    Disconnected by the remote device
    Buttonless service not configured, see: https://devzone.nordicsemi.com/f/nordic-q-a/59881/advertising-rename-feature-not-working/243566#243566. To workaround, disable alternative advertising name.
    Connecting to T001...
    centralManager.connect(peripheral, options: nil)
    [Callback] Central Manager did connect peripheral
    Connected to T001
    Discovering services...

    系统给出的断连错误信息:

    Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo={NSLocalizedDescription=The connection has timed out unexpectedly.}

  • 相关阅读:
    gulp serve 报错 gulp.ps1
    执行git命令时出现fatal: 'origin' does not appear to be a git repository错误
    利用 SASS 简化 `nth-child` 样式的生成
    git的一些常用命令
    回调函数
    匿名函数
    css消除行内元素的间隙
    @click.native的使用
    Element-ui 下拉列表 选项过多时如何解决卡顿问题
    vue组件通信(父子之间,兄弟之间)
  • 原文地址:https://www.cnblogs.com/yuxiaoyiyou/p/12925316.html
Copyright © 2020-2023  润新知