Code Monkey home page Code Monkey logo

ios-dfu-library's Introduction

Device Firmware Update application

DFU application allows to flash new firmware on the DK. The process has three steps:

  1. Selecting zip file with an appropriate firmware.
  2. Selecting BLE device with open bootloader.
  3. Starting firmware upload.

Settings screen allows to change the DFU library parameters used for uploading firmware.

iOS DFU Library

Version Carthage compatible

Installation

For Cocoapods:

  • Create/Update your Podfile with the following contents
target 'YourAppTargetName' do
    use_frameworks!
    pod 'iOSDFULibrary'
end
  • Install dependencies
pod install
  • Open the newly created .xcworkspace

  • Import the library to any of your classes by using import NordicDFU and begin working on your project

For Carthage:

  • Create a new Cartfile in your project's root with the following contents
github "NordicSemiconductor/IOS-DFU-Library" ~> x.y // Replace x.y with your required version
  • Build with carthage
carthage update --use-xcframeworks --platform iOS // other supported platforms: macOS, tvOS, watchOS
  • Carthage will build the iOSDFULibrary.framework and ZipFramework.framework files in Carthage/Build/, you may now copy all those files to your project and use the library, additionally, carthage also builds *.dsym files if you need to resymbolicate crash logs. you may want to keep those files bundled with your builds for future use.

For Swift Package Manager:

// swift-tools-version:5.6
import PackageDescription

let package = Package(
  name: "<Your Product Name>",
  dependencies: [
    .package(
      url: "https://github.com/NordicSemiconductor/IOS-DFU-Library", 
      .upToNextMajor(from: "<Desired Version>")
    )
  ],
  targets: [.target(name: "<Your Target Name>", dependencies: ["NordicDFU"])]
)

Device Firmware Update (DFU)

The nRF5x Series chips are flash-based SoCs, and as such they represent the most flexible solution available. A key feature of the nRF5x Series and their associated software architecture and S-Series SoftDevices is the possibility for Over-The-Air Device Firmware Upgrade (OTA-DFU). See Figure 1. OTA-DFU allows firmware upgrades to be issued and downloaded to products in the field via the cloud and so enables OEMs to fix bugs and introduce new features to products that are already out on the market. This brings added security and flexibility to product development when using the nRF5x Series SoCs.

This repository contains a tested library for iOS 8+ platform which may be used to perform Device Firmware Update on the nRF5x device using an iPhone or an iPad.

DFU library has been designed to make it very easy to include these devices into your application. It is compatible with all Bootloader/DFU versions.

Alt text for your video

Service Changed characteristic

In order the DFU to work with iOS, the target device MUST have the Service Changed characteristic with Indicate property in the Generic Attribute service. Without this characteristic iOS will assume that services of this device will never change and will not invalidate them after switching to DFU bootloader mode.

Service Changed characteristic behavior:
  • On paired devices a change of the attribute table must be indicated using an indication to the Service Changed characteristic. iOS automatically enables the CCC and handles this indication and performs a service discovery. This indication is handled correctly in Legacy DFU since SDK 8.0.
  • On non-trusted devices (not paired) iOS will clear the service cache every time the device disconnects.
Secure DFU from SDK 12:
  • The Secure DFU implementation from SDK 12 does not support bonding (experimental buttonless sample does not pass bond information when switching to DFU bootloader mode and the bootloader does not send S-C indication). As a workaround, the bootloader starts to advertise with MAC address incremented by 1, so from the phone's perspective it's a completely new device and a fresh service discovery will be done. When your new firmware is going to change the list of services you may consider adding another 1 to the MAC address for the new application to make sure the cache will not conflict (unless the device is not bonded and you have Service Changed characteristic, then no caching is used as written above). Be aware, that adding 1 to a public address is not possible (unless you register a new one). Also, devices may be sold with following MAC addresses and it may happen that 2 devices have the same one. Use this feature carefully.
Secure DFU from SDK 14:
  • Buttonless DFU with Bonds Sharing has been added to the SDK. Bonded relationship is required to use this service. Address does not change when in DFU mode, instead the bootloader sends Service Changed indication when entered DFU mode and app mode. For bonded devices it is recommended to use this service.

Documentation

See the documentation for more information.


Requirements

The library is compatible with nRF51 and nRF52 devices with S-Series Soft Device and the DFU Bootloader flashed on.


DFU History

Legacy DFU

  • SDK 4.3.0 - First version of DFU over Bluetooth Smart. DFU supports Application update.
  • SDK 6.1.0 - DFU Bootloader supports Soft Device and Bootloader update. As the updated Bootloader may be dependent on the new Soft Device, those two may be sent and installed together.
  • Buttonless update support for non-bonded devices.
  • SDK 7.0.0 - The extended init packet is required. The init packet contains additional validation information: device type and revision, application version, compatible Soft Devices and the firmware CRC.
  • SDK 8.0.0 - The bond information may be preserved after an application update. The new application, when first started, will send the Service Change indication to the phone to refresh the services. New features:
  • Buttonless update support for bonded devices
  • sharing the LTK between an app and the bootloader.

Secure DFU

  • SDK 12.0.0 - New Secure DFU has been released. This library is fully backwards compatible so supports both the new and legacy DFU.
  • SDK 13.0.0 - Buttonless DFU (still experimental) uses different UUIDs. No bond sharing supported. Bootloader will use address +1.
  • SDK 14.0.0 - Buttonless DFU no longer experimental. New buttonless characteristic added for bonded devices (requires bond, cache cleaning relies on Service Changed indication).
  • SDK 15.0.0 - Support for higher MTUs added.

This library is fully backwards compatible and supports both the new and legacy DFU. The experimental buttonless DFU service from SDK 12 is supported since version 1.1.0. Due to the fact, that this experimental service from SDK 12 is not safe, you have to set enableUnsafeExperimentalButtonlessServiceInSecureDfu to true to enable it, this is off by default. Read the method documentation for details. It is recommended to use the Buttonless service from SDK 13 (for non-bonded devices, or 14 for bonded). Both are supported since DFU Library 1.3.0.

Check platform folders for mode details about compatibility for each library.

Other frameworks

React Native

An unofficial library for both iOS and Android that is based on this library is available for React Native: react-native-nordic-dfu

Flutter

A library for both iOS and Android that is based on this library is available for Flutter: nordic_dfu

Xamarin

Simple binding library for iOS is available on nuget: Laerdal.Dfu


Resources

ios-dfu-library's People

Contributors

86 avatar alanfischer avatar andrei-zgirvaci avatar brockboland avatar devandartist avatar dinesharjani avatar emiliopavia avatar evgzor avatar fbernaly avatar fengqiangboy avatar jakerockland avatar jlubawy avatar juliansteenbakker avatar kelvin-lima avatar khoogheem avatar larsblumberg avatar mateusforgi avatar mostafaberg avatar nrbrook avatar philips77 avatar pruthvikar avatar simonseyer avatar sylwester-zielinski avatar tompi avatar trzy avatar zeveisenberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-dfu-library's Issues

DFU Error - Writing to characteristic failed

The DFUServiceDelegate never receives a DFUStateCompleted event with version 2.1.1 of the library. During a flashing update, the delegate receives these state changes: DFUStateConnecting, DFUStateStarting, DFUStateUploading.
Please give me some help thx
2016-10-05 3 55 54

Generate IPA file

When I add the DFULibrary, I can't archive my target to a IPA file. In Organizer appears as Other Items, but cannot export as IPA file. Any help? Thanks

Example for iOSDFULibrary dont works with iOS 10

Hi,

I'm testing the example for iOSDFULibrary with my XCode 8 and iOS 10 but always repeat the same loop:

Could you help me?

I : Changed state to: Connecting
V : Discovering all services for peripheral <CBPeripheral: 0x1740e1480, identifier = F48B99D1-CE34-74EE-60DC-446BC5A4723E, name = iMove, state = connected>
V : Discovered Service 6E400001-B5A3-F393-E0A9-E50E24DCCA9E on peripheral <CBPeripheral: 0x1740e1480, identifier = F48B99D1-CE34-74EE-60DC-446BC5A4723E, name = iMove, state = connected>
V : Discovered Service Battery on peripheral <CBPeripheral: 0x1740e1480, identifier = F48B99D1-CE34-74EE-60DC-446BC5A4723E, name = iMove, state = connected>
V : Discovered Service Device Information on peripheral <CBPeripheral: 0x1740e1480, identifier = F48B99D1-CE34-74EE-60DC-446BC5A4723E, name = iMove, state = connected>
V : Discovered Service 00001530-1212-EFDE-1523-785FEABCD123 on peripheral <CBPeripheral: 0x1740e1480, identifier = F48B99D1-CE34-74EE-60DC-446BC5A4723E, name = iMove, state = connected>
V : Did discover legacy DFU service
V : Starting legacy DFU Service initiator
V : Instantiated Legacy DFU peripheral selector
V : Connecting to iMove...
D : centralManager.connectPeripheral(peripheral, options:nil)
V : Started Legacy DFU service controller
I : Changed state to: Connecting
D : [Callback] Central Manager did connect peripheral
I : Connected to iMove
V : Discovering services...
D : peripheral.discoverServices(nil)
I : Services discovered
V : DFU Service found
V : Discovering characteristics in DFU Service...
D : peripheral.discoverCharacteristics(nil, forService:DFUService)
I : DFU characteristics discovered
V : Reading DFU Version number...
D : peripheral.readValueForCharacteristic(00001534-1212-EFDE-1523-785FEABCD123)
I : Read Response received from 00001534-1212-EFDE-1523-785FEABCD123, value (0x):0100
A : Version number read: 0.1
V : Enabling notifiactions for 00001531-1212-EFDE-1523-785FEABCD123...
D : peripheral.setNotifyValue(true, forCharacteristic: 00001531-1212-EFDE-1523-785FEABCD123)
I : Changed state to: Starting
V : Notifications enabled for 00001534-1212-EFDE-1523-785FEABCD123
A : DFU Control Point notifications enabled
W : Application with buttonless update found
V : Writing to characteristic 00001531-1212-EFDE-1523-785FEABCD123...
D : peripheral.writeValue(0x0104, forCharacteristic: 00001531-1212-EFDE-1523-785FEABCD123, type: WithResponse)
I : Changed state to: Enabling DFU Mode
I : Data written to 00001531-1212-EFDE-1523-785FEABCD123
A : Jump to bootloader (Op Code = 1, Upload Mode = 4) request sent
D : [Callback] Central Manager did disconnect peripheral
I : Disconnected by the remote device
V : Connecting to iMove...
D : centralManager.connectPeripheral(peripheral, options:nil)

Connected peripherals don't work

I am working with a buttonless DFU configuration, so I only start the DFU process after I've connected, but the library starts out by trying to connect to the peripheral and never progresses.

It would be nice to have connected peripheral support added. For example, I've added a quick hack to my local copy of DFUExecutor's start function:

func start() {
        DispatchQueue.main.async(execute: {
            self.delegate?.didStateChangedTo(DFUState.connecting)
        })

        let centralManager = self.initiator.centralManager
        centralManager.delegate = self
        if peripheral.state == .connected {
            peripheral.delegate = self
            // Caller is responsible for having discovered the DFU service and characteristics
            for aService in peripheral.services! {
                initiator.logger?.logWith(.verbose, message: "Discovered Service \(aService.uuid) on peripheral \(peripheral)")
                if aService.uuid == SecureDFUService.UUID {
                    //First priority if SDFU
                    self.didDiscoverDFUService(true)
                    return
                }

                if aService.uuid == LegacyDFUService.UUID {
                    //Second priority is legacy DFU
                    self.didDiscoverDFUService(false)
                    return
                }
            }
            //No DFU found at this point, disconnect and report
            self.deviceNotSupported()

        } else {
            centralManager.connect(peripheral, options: nil)
        }
    }

Error when Dfu_v1 firmware is greater than 0xFFFF bytes

Copy from #25

The exact error we are seeing is "Error: 65760 bytes were sent while 224 bytes were reported as received"

The issues stems from the fact that older bootloader versions represented the received firmware image size as a uint16_t (thus we saturate) and sometime later it changed to uint32_t. This library always interprets the field as a uint32_t. https://github.com/NordicSemiconductor/IOS-DFU-Library/blob/master/DFULibrary/DFUControlPoint.swift#L196

Since we still have old devices in the field to support I've had to modify LegacyDFUService.swift from
if bytesSent == bytesReceived {
to
if bytesSent == bytesReceived || bytesSent == (bytesReceived + 0x10000) {

Is there an option to forward CBCentralManager Delegate method?

Hi, while in the DFU process, I want to know if user by acident turn off bluetooth, so I can change UI accordingly. Currently the delegate is used inside your library, so I can't track in which state is CBCentralManager.

func centralManagerDidUpdateState(central: CBCentralManager) {
        logCentralManagerState(central.state)
    }

This line inside your library could be used to forward this info outside your library. Thanks.

Crash in LegacyDFUPeripheral's isInApplicationMode

First of all, thank you to the team for responding so quickly to all the issues. I've been following the repo and it's incredibly helpful.

On unmodified v2.1.6 I received a crash in isInApplicationMode as the LegacyDFUPeripheral's dfuService is nil. I might have had two peripherals in dfu mode at the same time judging by the logs.

According to our HockeyApp reporting, another user experienced a similar issue in many points of the file, again where the dfuService was nil each time. I've attached an additional log as well.
969bc0d393b81d4f9b424c79b363bca5.txt

LOG:
DFU Log: Connected to DFU_ERA
DFU Log: Services discovered
DFU Log: DFU characteristics discovered
DFU Log: Read Response received from 00001534-1212-EFDE-1523-785FEABCD123, value (0x):0800
DFU Log: Version number read: 0.8
DFU Log: Connected to DFU_ERA
DFU Log: DFU Control Point notifications enabled
fatal error: unexpectedly found nil while unwrapping an Optional value
fatal error: unexpectedly found nil while unwrapping an Optional value

CALLSTACK:
0x0000000100b891ec in specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never ()
0x0000000100888a0c in LegacyDFUPeripheral.isInApplicationMode(Bool) -> Bool at /Volumes/Development/pax-app-ios/PaxApp/Pods/iOSDFULibrary/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift:150
0x00000001008847a8 in LegacyDFUExecutor.onControlPointEnabled() -> () at /Volumes/Development/pax-app-ios/PaxApp/Pods/iOSDFULibrary/iOSDFULibrary/Classes/Implementation/LegacyDFU/DFU/LegacyDFUExecutor.swift:96
0x00000001008868c8 in protocol witness for DFUPeripheralDelegate.onControlPointEnabled() -> () in conformance LegacyDFUExecutor ()
0x0000000100888608 in LegacyDFUPeripheral.(enableControlPoint() -> ()).(closure #1) at /Volumes/Development/pax-app-ios/PaxApp/Pods/iOSDFULibrary/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift:136
0x00000001008635f4 in thunk ()
0x0000000100864fb0 in DFUControlPoint.peripheral(CBPeripheral, didUpdateNotificationStateFor : CBCharacteristic, error : Error?) -> () at /Volumes/Development/pax-app-ios/PaxApp/Pods/iOSDFULibrary/iOSDFULibrary/Classes/Implementation/LegacyDFU/Characteristics/DFUControlPoint.swift:313
0x0000000100865098 in @objc DFUControlPoint.peripheral(CBPeripheral, didUpdateNotificationStateFor : CBCharacteristic, error : Error?) -> () ()
0x0000000191ee3364 in -[CBPeripheral handleAttributeEvent:args:attributeSelector:delegateSelector:delegateFlag:] ()
0x0000000191ee34c4 in -[CBPeripheral handleCharacteristicEvent:characteristicSelector:delegateSelector:delegateFlag:] ()
0x0000000191edfef4 in -[CBPeripheral handleMsg:args:] ()
0x0000000191edb018 in -[CBCentralManager handleMsg:args:] ()
0x0000000191eeef58 in -[CBManager xpcConnectionDidReceiveMsg:args:] ()
0x0000000191ee770c in __30-[CBXpcConnection _handleMsg:]_block_invoke ()
0x00000001009d525c in _dispatch_call_block_and_release ()
0x00000001009d521c in _dispatch_client_callout ()
0x00000001009e2b54 in _dispatch_queue_serial_drain ()

Fail to connect to peripheral after updating the library

I was using the old library from the other repository (1.0.8), and updated it to the newest release as updagrading to Xcode 8 and iOS10.
However I can't get it to work.
On iOS 10, its stuck at connecting to the device (nothing happens), and on iOS9 the following error occurs:

2016-10-06 18:04:23.266 AppName[773:134716] initiator : Optional(<iOSDFULibrary.DFUServiceInitiator: 0x137dd6bb0>)
2016-10-06 18:04:23.268 AppName[773:134716] FirmwareUpdateView ViewDidDisappear
2016-10-06 18:04:23.270 AppName[773:134716] didStateChangedTo state : 0
2016-10-06 18:04:23.270 AppName[773:134716] call back : didStateChangeTo
2016-10-06 18:04:23.271 AppName[773:134716] *** -[iOSDFULibrary.DFUExecutor centralManager:didConnectPeripheral:]: message sent to deallocated instance 0x13919aac0

This is the backtrace:

* thread #1: tid = 0x20e3c, 0x0000000181356bc8 CoreFoundation`___forwarding___ + 700, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x181356bc8)
  * frame #0: 0x0000000181356bc8 CoreFoundation`___forwarding___ + 700
    frame #1: 0x0000000181254d1c CoreFoundation`_CF_forwarding_prep_0 + 92
    frame #2: 0x00000001870c4e68 CoreBluetooth`__29-[CBXpcConnection handleMsg:]_block_invoke + 60
    frame #3: 0x0000000100bf5a7c libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #4: 0x0000000100bf5a3c libdispatch.dylib`_dispatch_client_callout + 16
    frame #5: 0x0000000100bfb4e4 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 2096
    frame #6: 0x0000000181308dd8 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    frame #7: 0x0000000181306c40 CoreFoundation`__CFRunLoopRun + 1628
    frame #8: 0x0000000181230d10 CoreFoundation`CFRunLoopRunSpecific + 384
    frame #9: 0x0000000182b18088 GraphicsServices`GSEventRunModal + 180
    frame #10: 0x0000000186505f70 UIKit`UIApplicationMain + 204
    frame #11: 0x00000001000cda48 AppName`main + 140 at AppDelegate.swift:30
    frame #12: 0x0000000180dce8b8 libdyld.dylib`start + 4

Any suggestion on the fix to this?

Validation of archive fails at codesigning Zip.framework

Built 2.1.6 in Xcode 8.1 with "carthage build --platform iOS". Everything seems to work fine when running on my development devices. But when I try to put it up on iTunes Connect for my beta testers, it fails during validation, saying "Codesign failed" and "Unable to validate your application.
The archive is invalid. /var/folders/xx/blahblah/T/XcodeDistPipeline.5Lf/Packages/MyApp.ipa does not exist." It does this when the status is "Codesigning Zip.framework..."

New to Carthage so wondering if I missed something, but the copy-frameworks script does appear to be doing its job of stripping out unneeded architectures, and digging into the .ipa, the Zip binary does appear to be signed. Any ideas?

DFUPeripheralSelectorDelegate is not present in Obj-C

DFUPeripheralSelectorDelegate protocol is missing an @objc.

And public var peripheralSelector:DFUPeripheralSelector? in DFUServiceInitiator should be reverted to public var peripheralSelector:DFUPeripheralSelectorDelegate?

DFU update cannot be started without turning bluetooth on/off

Hey guys,

I'm struggling with this issue. In my app I can't really force user to turn bluetooth on and off. I was looking at some posts on your forums, but no one really stumble upon some reasonable solution.

Is it possible to make DFU service visible without this?

initWithUrlToZipFile return nil

My Installation :

  1. build IOS-Pods-DFU-Library
  2. Drag iOSDFULibrary.framework to my objective-C project
  3. Set iOSDFULibrary.framework as optional in Linked Frameworks and Libraries

My Enviorments:
Macos 10.12
Xcode 8.0

Now:
I use the demo firmware "dfu_test_app_hrm_s110.zip" to test the function.
But -initWithUrlToZipFile always return nil.
Am I doing something wrong here?

1.Get URL. Return value is correct. (fileURL = file:///var/mobile/Containers/Data/Application/14F7C7B3-A2F2-4704-87B6-1A5E6EC7C2C9/Library/Caches/GOOTA/ota.zip)

NSURL *fileURL = [NSURL fileURLWithPath:OTA_GO_FIRMWARE_FILEPATH];

2.Test if the file is empty. Return value is correct, it's not empty.

NSData *fileData = [NSData dataWithContentsOfURL:fileURL];

3.Creat DFUFirmware object. Return value is nil.

DFUFirmware *selectedFirmware = [[DFUFirmware alloc] initWithUrlToZipFile:fileURL];

Connected peripheral doesn't start DFU

I've tested 2.1.6 after seeing issue #23 closed and still can't get a connected peripheral to work. The issue seems to be that I've already discovered the services in my app after connecting, so the discoverServices call in DFUExecutor doesn't discover anything. Maybe the assumption should that the user has already done service discovery on a connected device, and iterate through peripheral.services just like the code in the didDiscoverServices callback? (I've hacked the code locally to do just that).

Thanks!

Can characteristic 0x1534 be used to store firmware version

Hi,
The library uses a DFU version characteristic 0x1534. The library infers certain states based on particular values of this service. Given this, I gather that this characteristic can not be used to store the actual firmware version. Am I correct? If so, is there a way to expose the firmware version as a part of DFU Service itself?

DFU state sticks on `.disconnecting`

When the DFU process exits with error 302, it seems to stay perpetually on the .disconnecting state. I've tried calling the abort() controller method in my didErrorOccur() implementation, but am having a different issue there which I noted in #42

DFULibrary not loaded

Environment:
Xcode:8.0
objective-c
iPhone: 5s, iOS 8.1.3
and download dependencies
Installing Zip (0.6.0)
Installing iOSDFULibrary (2.1.2)

Xcode build succeeded, but running in iPhone fail.
I got the output log as following. Please tell me what should I do?

dyld: Library not loaded: @rpath/DFULibrary.framework/DFULibrary
Referenced from: /private/var/mobile/Containers/Bundle/Application/85488289-0B51-434C-ACAF-89C3D590D909/HealthCube.app/HealthCube
Reason: image not found

Multiple DFU operations at the same time

Hey!

First of all, thank you for this library; it was really easy to integrate the DFU in our application (I love that).
I was wondering if there is a way (without modifiying the library) to execute two DFU operations at the same time; our company is building small sensors that are mounted on the hands of the user (both hands). The user experience would be much better if we could upgrade the firmware of the two sensors at the same time instead of doing it one after the other.

For now my workaround to make it work was to comment the lines in the destroy and cleanUp functions. (Avoiding unwrapping nil object)

func destroy() {
    //centralManager.delegate = nil
    //peripheral!.delegate = nil
    //peripheral = nil
    //delegate = nil
}

fileprivate func cleanUp() {
    //dfuService = nil
}

Thank you!

Alex

Xcode 8 asks to convert Swift for 2.1.1

After installing successfully (pod install verifies iOSDFULibrary 2.1.1 and Zip 0.6.0), Xcode 8 still asks me to convert to latest Swift syntax for iOSDFULibrary and Zip when opening the workspace.

Should this be working for Xcode 8?

Re-trying DFU begins before `initiator.start()` is called

When attempting to perform a DFU, if the DFU fails for the first time for whatever reason, when trying to re-perform the DFU, it immediately begins upon connection to our peripheral, before the initiator.start() method had even been called.

Our current setup is that we have a button that initiates the DFU process. Pressing this button should initiate a connection to our peripheral, once connected to our peripheral there is some setup code that is run which retrieves the appropriate .zip file from a server of ours (this is all in our centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) method), and once that is retrieved we initiate the DFU as follows:

let selectedFirmware = DFUFirmware(urlToZipFile:firmwareURL)
let initiator = DFUServiceInitiator(centralManager: self.manager.central, target: self.manager.peripheral!).withFirmwareFile(selectedFirmware!)
                
initiator.logger = self // To get log info
initiator.delegate = self // To be informed about current state and errors
initiator.progressDelegate = self // To show progress bar

self.controller = initiator.start()

This all works as expected the first time we attempt the DFU; however if the DFU fails and we try to re-attempt performing the DFU (by pressing our button again), as soon as we connect to our peripheral with the CBCentralManager .connect() method, the DFU process begins again, bypassing our centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) method and preventing our necessary setup code from being called.

Is there something here that we're doing wrong @mostafaberg ? I'm not sure if I may just be misunderstanding the expected behaviour of the library or if this is a bug.

I'm not sure if this is connected at all to the other recent issues I had opened, or potentially just an issue with how I'm using the DFU library but would really appreciate any input that could help explain why we're seeing this behavior.

How is IOS-Pods-DFU-Library different than IOS-DFU-Library?

Hello,
I see there are two DFU library repositories here. Do they differ simply in the packaging or is there any other difference? Also, do the updates in one repository get added to the other as well?

Which one is recommended?

Thanks.

Peripheral disconnects after discovering characteristics for DFUService

Hello,
I just updated to the Swift 3 DFU library, and I am having an issue where my peripheral gets disconnected every time when the DFU Service tries to discover characteristics for the DFUService. There are a few details that seems specific to this issue:

  • The app is written in Objective-C.
  • The code I'm using worked prior to updating the DFU Library, and prior to iOS10.
  • This same code works on an iOS9 device, so this disconnection is ONLY happening on iOS10.
  • I've tested my peripheral and my firmware ZIP with the DFU-Library example app on iOS10, and that works as well. So I'm only seeing this issue on iOS10 when the DFU-library is called from Objective-C code.
  • I'm using the Legacy DFU service.

The process I'm taking is: connect to device, discover Legacy DFU service, write 0x0104 to reboot into bootloader. Connect to DFUTarg, then start the DFU process via the following function:

- (void)startDFU {    
    if ( [BTManager sharedInstance].connectedPeripheral != nil && self.firmwareZIPForDFU != nil ) {
        DFUServiceInitiator *dfuInitiator = [[DFUServiceInitiator alloc] initWithCentralManager:[BTManager sharedInstance].centralManager target:[BTManager sharedInstance].connectedPeripheral];

        [dfuInitiator withFirmwareFile: self.firmwareZIPForDFU];
        [dfuInitiator setLogger: self];
        [dfuInitiator setDelegate: self];
        [dfuInitiator setProgressDelegate: self];
        self.dfuController = [dfuInitiator start];
    }
}

The DFU Service seems to start normally, but every time I run it, the peripheral disconnects at the exact same place. Here is the log starting from my connection to DFUTarg:

2016-10-10 13:46:39.497344 DFUTest[894:338968] Connected peripheral with name: DfuTarg
2016-10-10 13:46:39.497418 DFUTest[894:338968] -[ViewController didConnectDFUTarg]
2016-10-10 13:46:39.497469 DFUTest[894:338968] -[ViewController startDFU]
2016-10-10 13:46:39.501960 DFUTest[894:338728] DFU Service didStateChangedTo: 0
2016-10-10 13:46:39.505383 DFUTest[894:338973] LoggerDelegate logWith: 1 message: Discovering all services for peripheral <CBPeripheral: 0x1740fd500, identifier = 5CB14D36-3993-412F-A3FD-B15E138F088E, name = DfuTarg, state = connected>
2016-10-10 13:46:39.879373 DFUTest[894:338968] LoggerDelegate logWith: 1 message: Discovered Service 00001530-1212-EFDE-1523-785FEABCD123 on peripheral <CBPeripheral: 0x1740fd500, identifier = 5CB14D36-3993-412F-A3FD-B15E138F088E, name = DfuTarg, state = connected>
2016-10-10 13:46:39.883675 DFUTest[894:338968] LoggerDelegate logWith: 1 message: Did discover legacy DFU service
2016-10-10 13:46:39.883864 DFUTest[894:338968] LoggerDelegate logWith: 1 message: Starting legacy DFU Service initiator
2016-10-10 13:46:39.885382 DFUTest[894:338968] LoggerDelegate logWith: 1 message: Instantiated Legacy DFU peripheral selector
2016-10-10 13:46:39.887011 DFUTest[894:338968] LoggerDelegate logWith: 1 message: Connecting to DfuTarg...
2016-10-10 13:46:39.887126 DFUTest[894:338728] DFU Service didStateChangedTo: 0
2016-10-10 13:46:39.887507 DFUTest[894:338968] LoggerDelegate logWith: 0 message: centralManager.connectPeripheral(peripheral, options:nil)
2016-10-10 13:46:39.888250 DFUTest[894:338968] LoggerDelegate logWith: 1 message: Started Legacy DFU service controller
2016-10-10 13:46:39.891766 DFUTest[894:338973] LoggerDelegate logWith: 0 message: [Callback] Central Manager did connect peripheral
2016-10-10 13:46:39.891974 DFUTest[894:338973] LoggerDelegate logWith: 5 message: Connected to DfuTarg
2016-10-10 13:46:39.893759 DFUTest[894:338973] LoggerDelegate logWith: 1 message: Discovering services...
2016-10-10 13:46:39.894073 DFUTest[894:338973] LoggerDelegate logWith: 0 message: peripheral.discoverServices(nil)
2016-10-10 13:46:39.897030 DFUTest[894:338968] LoggerDelegate logWith: 5 message: Services discovered
2016-10-10 13:46:39.897466 DFUTest[894:338968] LoggerDelegate logWith: 1 message: DFU Service found
2016-10-10 13:46:39.897770 DFUTest[894:338968] LoggerDelegate logWith: 1 message: Discovering characteristics in DFU Service...
2016-10-10 13:46:39.897893 DFUTest[894:338968] LoggerDelegate logWith: 0 message: peripheral.discoverCharacteristics(nil, forService:DFUService)
2016-10-10 13:46:40.115262 DFUTest[894:338973] LoggerDelegate logWith: 0 message: [Callback] Central Manager did disconnect peripheral
2016-10-10 13:46:40.115430 DFUTest[894:338973] LoggerDelegate logWith: 5 message: Disconnected
2016-10-10 13:46:40.120561 DFUTest[894:338973] LoggerDelegate logWith: 20 message: Error 6: The connection has timed out unexpectedly.
2016-10-10 13:46:40.120947 DFUTest[894:338728] DFU Service didErrorOccur: 202 withMessage: The connection has timed out unexpectedly. (code: 6)

Cannot abort DFU controller

When trying to abort my DFU controller like this, I'm getting a runtime error:

 var controller: DFUServiceController!
 let selectedFirmware = DFUFirmware(urlToZipFile:firmwareURL)
 let initiator = DFUServiceInitiator(centralManager: self.central, target: self.peripheral).withFirmwareFile(selectedFirmware!)

initiator.logger = self
initiator.delegate = self
initiator.progressDelegate = self

self.controller = initiator.start()

_ = self.controller.abort()

screenshot 2016-10-25 14 42 32

DFU 'Reading DFU Version characteristic failed' with 'The handle is invalid' Error

(i'm korean, im can't speak english. please consider that...)
im using iOSDFULibrary with my company BLE and Firmware.
it run on Android DFULibrary, nrf Toolbox very well.
but on ios, not working DFULibrary and nrf Toolbox.
i don't know why

that's my Log. Using iOSDFULibrary

connecting
V : Discovering all services for peripheral <CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
V : Discovered Service 9FD41000-E46F-7C9A-57B1-2DA365E18FA1 on peripheral <CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
V : Discovered Service 9FD42000-E46F-7C9A-57B1-2DA365E18FA1 on peripheral <CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
V : Discovered Service 9FD43000-E46F-7C9A-57B1-2DA365E18FA1 on peripheral <CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
V : Discovered Service 00001530-1212-EFDE-1523-785FEABCD123 on peripheral <CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
V : Did discover legacy DFU service
V : Starting legacy DFU Service initiator
V : Instantiated Legacy DFU peripheral selector
V : Connecting to DfuTarg...
D : centralManager.connectPeripheral(peripheral, options:nil)
V : Started Legacy DFU service controller
connecting
D : [Callback] Central Manager did connect peripheral
I : Connected to DfuTarg
V : Discovering services...
D : peripheral.discoverServices(nil)
I : Services discovered
V : DFU Service found
V : Discovering characteristics in DFU Service...
D : peripheral.discoverCharacteristics(nil, forService:DFUService)
I : DFU characteristics discovered
D : <CBCharacteristic: 0x1740b2e40, UUID = 00001532-1212-EFDE-1523-785FEABCD123, properties = 0x4, value = (null), notifying = NO>
D : DFUPacket
D : <CBCharacteristic: 0x1700b9fe0, UUID = 00001531-1212-EFDE-1523-785FEABCD123, properties = 0x18, value = (null), notifying = NO>
D : DFUControlPoint
D : <CBCharacteristic: 0x1700b9f80, UUID = 00001534-1212-EFDE-1523-785FEABCD123, properties = 0x2, value = <0100>, notifying = NO>
D : DFUVersion
V : Reading DFU Version number...
D : peripheral.readValueForCharacteristic(00001534-1212-EFDE-1523-785FEABCD123)
D : <CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
D : <CBCharacteristic: 0x1700b9f80, UUID = 00001534-1212-EFDE-1523-785FEABCD123, properties = 0x2, value = <0100>, notifying = NO>
<CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
<CBCharacteristic: 0x1700b9f80, UUID = 00001534-1212-EFDE-1523-785FEABCD123, properties = 0x2, value = <0100>, notifying = NO>
nil
I : Read Response received from 00001534-1212-EFDE-1523-785FEABCD123, value (0x):0100
A : Version number read: 0.1
V : Enabling notifiactions for 00001531-1212-EFDE-1523-785FEABCD123...
D : peripheral.setNotifyValue(true, forCharacteristic: 00001531-1212-EFDE-1523-785FEABCD123)
starting
V : Notifications enabled for 00001534-1212-EFDE-1523-785FEABCD123
A : DFU Control Point notifications enabled
W : Application with buttonless update found
V : Writing to characteristic 00001531-1212-EFDE-1523-785FEABCD123...
D : peripheral.writeValue(0x0104, forCharacteristic: 00001531-1212-EFDE-1523-785FEABCD123, type: WithResponse)
enablingDfuMode
I : Data written to 00001531-1212-EFDE-1523-785FEABCD123
A : Jump to bootloader (Op Code = 1, Upload Mode = 4) request sent
Optional(Error Domain=CBErrorDomain Code=7 "The specified device has disconnected from us." UserInfo={NSLocalizedDescription=The specified device has disconnected from us.})
D : The specified device has disconnected from us.
D : [Callback] Central Manager did disconnect peripheral
I : Disconnected by the remote device
jumpingToBootloader
V : Connecting to DfuTarg...
D : centralManager.connectPeripheral(peripheral, options:nil)
D : [Callback] Central Manager did connect peripheral
I : Connected to DfuTarg
V : Discovering services...
D : peripheral.discoverServices(nil)
I : Services discovered
V : DFU Service found
V : Discovering characteristics in DFU Service...
D : peripheral.discoverCharacteristics(nil, forService:DFUService)
I : DFU characteristics discovered
D : <CBCharacteristic: 0x1700b9860, UUID = 00001532-1212-EFDE-1523-785FEABCD123, properties = 0x4, value = (null), notifying = NO>
D : DFUPacket
D : <CBCharacteristic: 0x1700b4040, UUID = 00001531-1212-EFDE-1523-785FEABCD123, properties = 0x18, value = (null), notifying = NO>
D : DFUControlPoint
D : <CBCharacteristic: 0x1700b9f20, UUID = 00001534-1212-EFDE-1523-785FEABCD123, properties = 0x2, value = <0100>, notifying = NO>
D : DFUVersion
V : Reading DFU Version number...
D : peripheral.readValueForCharacteristic(00001534-1212-EFDE-1523-785FEABCD123)
D : <CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
D : <CBCharacteristic: 0x1700b9f20, UUID = 00001534-1212-EFDE-1523-785FEABCD123, properties = 0x2, value = <0100>, notifying = NO>
<CBPeripheral: 0x1740ff600, identifier = 864BAD24-5F97-4E02-96E1-AF130E2E0325, name = DfuTarg, state = connected>
<CBCharacteristic: 0x1700b9f20, UUID = 00001534-1212-EFDE-1523-785FEABCD123, properties = 0x2, value = <0100>, notifying = NO>
Optional(Error Domain=CBATTErrorDomain Code=1 "The handle is invalid." UserInfo={NSLocalizedDescription=The handle is invalid.})
E : Reading DFU Version characteristic failed
Optional(2 bytes)
E : Error 1: The handle is invalid.
E : The handle is invalid.
V : Disconnecting...
D : centralManager.cancelPeripheralConnection(peripheral)
D : [Callback] Central Manager did disconnect peripheral without error
I : Disconnected
didErrorOccur: Reading DFU Version characteristic failed
E : Reading DFU Version characteristic failed

what is the dat file?

When i want to send the hex file to the fw, but faild...

Error 103: The init packet is required by the target device

Dead link in README.md

Link under documentation is not working :

See the documentation for more information.

Conflict with `Zip` dependency for Carthage users

Though the Zip dependency has been somewhat handled by making it explicit in the Cartfile of the repo here, there is still a conflict between the Zip library that is checked out as a dependency and the one in the Example/Pods directory. Is it possible to remove the Zip directory there altogether? I don't use CocoaPods so I may not be fully understanding part of this, but isn't it something that should be checked out as a dependency and not committed directly to the library repo here?

Compiling error with IOS-Pods-DFU-Library installed

After install your POD in my XCode project, I get the following error when compiling :

ld: warning: directory not found for option '-F/Users/Despont/Library/Developer/Xcode/DerivedData/SHR-cebhiiybhzbjpgefaonqtocowutd/Build/Products/Debug-iphoneos/EVReflection'
ld: warning: directory not found for option '-F/Users/Despont/Library/Developer/Xcode/DerivedData/SHR-cebhiiybhzbjpgefaonqtocowutd/Build/Products/Debug-iphoneos/Zip'
ld: warning: directory not found for option '-F/Users/Despont/Library/Developer/Xcode/DerivedData/SHR-cebhiiybhzbjpgefaonqtocowutd/Build/Products/Debug-iphoneos/iOSDFULibrary'
ld: framework not found EVReflection
clang: error: linker command failed with exit code 1 (use -v to see invocation)

DFUServiceController resume not work

Hi, I had use [controller resume] , but it's not update firmware continued.
Environment: objective-c, iOS 8.1.3, iOSDFULibrary (2.1.2).
I got the output log as following. Please tell me what should I do?

Progress: 26% (part 1/1). Speed: 65574.422513 bps, Avg speed: 2538.034336 bps
Progress: 27% (part 1/1). Speed: 56186.255861 bps, Avg speed: 2522.083538 bps
Progress: 28% (part 1/1). Speed: 66894.800638 bps, Avg speed: 2541.240389 bps
LogLevel:0, [Callback] Central Manager did disconnect peripheral
LogLevel:5, Disconnected
LogLevel:20, Error 6: The connection has timed out unexpectedly.
DFUServiceDelegate Error -->202: The connection has timed out unexpectedly. (code: 6)

DFU Stuck on Connecting

We have a device that has DFU enabled on it, and my iOS code was working, but recently stopped working (around the time of iOS 10 and Swift 3). The latest issue that I have is that I am getting stuck on the didChangeStateTo call back of "connecting". I set the flag high on the DFU service so that I disconnect and change to the bootloader so I am getting DFUTarg and the advertisement. I set the DFUFirmware with a .bin and .dat file from my server. I connect to the DFUTarg peripheral, and once the connection is complete, the following code executes:

let initiator = DFUServiceInitiator(centralManager: self.centralManager!, target: peripheral)
initiator.withFirmwareFile(firmware)
// Optional:
// initiator.forceDfu = true/false; // default false
// initiator.packetReceiptNotificationParameter = N; // default is 12
initiator.logger = self // - to get log info
initiator.delegate = self // - to be informed about current state and errors
initiator.progressDelegate = self // - to show progress bar
// initiator.peripheralSelector = ... // the default selector is used
initiator.start()

I then get the call back response of "Connecting" and it gets stuck there. I seem to be implementing the code from nRFToolbox the same way, and as I said before, it seemed to be working fine before.

This is a pretty hot issue for my company, so any help would be greatly appreciated. Thanks a bunch.

current bundled example firmware not compatible with example bootloader

The .zip of the secure bundled firmware that is currently used in the example project (sdfu_test_app_hrm_s132.zip) does not seem to be compatible with the example bootloader provided by Nordic for the development kit.

When trying to run the example project, I would always get an error that ended with something like:

D : peripheral.writeValue(0x04, forCharacteristic: 8EC90001-F315-4F60-9FB8-838830DAEA50, type: WithResponse)
I : Notification received from 8EC90001-F315-4F60-9FB8-838830DAEA50, value (0x):600405
A : Response (Op Code = Execute, Status = Invalid object) received
E : Error Optional("Invalid object"): Optional("Invalid object")
E : Error occured: invalidObject, Invalid object
E : Invalid object
E : Invalid object
I : Changed state to: Failed
V : Disconnecting...
D : centralManager.cancelPeripheralConnection(peripheral)
D : [Callback] Central Manager did disconnect peripheral without error
I : Disconnected
A : Operation Aborted by user, peripheral has been disconnected
I : Changed state to: Aborted

Updating the bundled firmware to this recent example firmware (dfu_test_app_hrm_s132.zip) from Nordic seemed to remedy the situation.

It's a pretty simple fix, but I've included the changes we've made on our fork if you want to compare or pull the changes into the main repo: https://github.com/SomaticLabs/IOS-Pods-DFU-Library/pull/2

Also happy to make a PR if you let me know which branch to make it to @mostafaberg, not sure if you want to create a new bugfix branch.

DFU state is `.completed` twice in a row

@mostafaberg I'm not sure if this also might be connected to #43 and #42, but when completing the DFU, I'm seeing the state change to .completed twice in succession, is this expected behavior or a bug?

I've included a some print debug statements to give a better idea of what's going on:

DFU Progress: 99% completed.
DFU Progress: 99% completed.
DFU Progress: 99% completed.
DFU Progress: 99% completed.
DFU Progress: 100% completed.
DFU State: Completed
Cleanup performed successfully.
DFU State: Completed
Error: “firmware.zip” couldn’t be removed.

Where our state change handler looks something like:

    /**
     Handles changes in the DFU state, called whenever the state of the DFU Service has changed

     - Parameter state: The new current DFU state
     */
    func didStateChangedTo(_ state: DFUState) {
        #if DEBUG
            print("DFU State: \(state.description())")
        #endif
        switch state {
        case .completed:
            // Delete temporarily stored firmware ZIP
            cleanup(localFirmwarePath!)
        case .connecting, .starting, .enablingDfuMode, .uploading, .validating, .disconnecting: break
        case .aborted, .signatureMismatch, .operationNotPermitted, .failed: break
        }
    }

Pod install error

Hello,

I am trying to install the framework using podfile as explained in the documentation, but I am getting this error :

[!] InvalidPodfilefile: syntax error, unexpected keyword_end, expecting end-of-input.

My podfile is:

use_frameworks!
    pod 'iOSDFULibrary'
end

Any idea?

suggest for "LoggerHelper"

image

'logger' is a nullable variable. so suggest rewrite as follows:

//Class LegacyDFUPeripheral
 init(_ initiator:LegacyDFUServiceInitiator) {
        self.centralManager = initiator.centralManager
        self.peripheral = initiator.target
        self.logger = LoggerHelper(initiator.logger)
        super.init()

    // self.peripheral.delegate = self // this is set when device got connected
    self.centralManager.delegate = self
}
//Class LoggerHelper
class LoggerHelper {
    fileprivate var logger:LoggerDelegate?

init(_ logger:LoggerDelegate?) {
    self.logger = logger
}

func d(_ message:String) {
    logger?.logWith(.debug, message: message)
}

func v(_ message:String) {
    logger?.logWith(.verbose, message: message)
}

func i(_ message:String) {
    logger?.logWith(.info, message: message)
}

func a(_ message:String) {
    logger?.logWith(.application, message: message)
}

func w(_ message:String) {
    logger?.logWith(.warning, message: message)
}

func w(_ error:Error) {
    logger?.logWith(.warning, message: "Error \((error as NSError).code): \(error.localizedDescription)");
}

func e(_ message:String) {
    logger?.logWith(.error, message: message)
}

func e(_ error:Error) {
    logger?.logWith(.error, message: "Error \((error as NSError).code): \(error.localizedDescription)");
}
}

centralManager unable to be used after DFU

We are allocating our CBCentralManager as so:

myCentralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{CBCentralManagerOptionRestoreIdentifierKey : @"MyBTCentral"}];

We perform a DFU and we attempt to reconnect to our device via the device UUID
eg:
NSArray *peripheralArray = [myCentralManager retrievePeripheralsWithIdentifiers:@[nsUUID]];
if([peripheralArray count] > 0)
{
[myCentralManager connectPeripheral: peripheralArray[0] options:nil];
}

At this point, centralManager centralManagerDidUpdateState delegate is called and the centralManager state is CBManagerStateUnsupported

Is there a way for us to reset the centralManager ?

When updating to version 2.0 the library disappear.

screen shot 2016-09-28 at 6 03 06 pm

screen shot 2016-09-28 at 5 59 00 pm

I'm also using xcode 8 for the first time. I'll try to solve this by myself, but just so you know there is maybe an issue on your side. As you can see, there is just LICENSE and README file in the folder.

UPDATE

I created an empty xcode project and the issue remain. I use the latest cocoapods pre-release version (https://github.com/CocoaPods/CocoaPods/releases/tag/1.1.0.rc.2) that is recommended for xcode 8.

This guy claims to have found a solution for pods that use swift 3.0.
https://blog.sabintsev.com/submitting-swift-3-libraries-to-the-cocoapods-trunk-1-1-0-rc-2-2d07c22c9754#.ditdqbkd7
(I see you already make this)

UPDATE 1
And I case of having both xcode 7 and xcode 8 installed on a system you should run this:

sudo xcode-select -switch /pathTo/Xcode8.app

to make the xcode 8 the default app for generating pod. Here's the post about this:https://medium.com/@filipealva/cocoapods-lint-failing-with-xcode-8-a2c255e78108#.k3ql8n5cw

UPDATE 2
Tried your example file from git and and it also fails to run. Saying: No such module 'iOSDFULibrary'.

Cannot connect with peripheral

Hi,
I am developing application and trying to use this library to implement FOTA into it. I am using Swift 3.0 and testing everything on device with iOS 10. Peripheral is based on nRF51822 SoC.

Unfortunatelly library cannot connect with peripheral - stucks on "Connecting".

I tried running initiator.start() method in different conditions (connected with the device, disconnected with the device, in DFU mode, in normal mode) nothing works. Do you have any idea what am I missing?

bluetooth.manager and bluetooth.connectedPeripheral are not nil.

My implementation:

        let bluetooth = SensorManager.sharedInstance
        self.downloadUpdateFile(uuid: forUUID) { (localFirmwareUrl) in
            if let selectedFirmware = DFUFirmware(urlToZipFile: localFirmwareUrl) {
                let initiator = DFUServiceInitiator(centralManager: bluetooth.manager, target: bluetooth.connectedPeripheral).withFirmwareFile(selectedFirmware)

                initiator.packetReceiptNotificationParameter = 12
                initiator.forceDfu = true
                initiator.logger = self
                initiator.delegate = self
                initiator.progressDelegate = self
                print("START")
                let controller = initiator.start()
            }
        }

Crash with 1.0.12

LegacyDFUPeripheral.init, line 58

self.logger = LoggerHelper(initiator.logger!)

initiator.logger is nil and thus crashes firmware update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.