Skip to content

Commit

Permalink
Merge pull request #300 from NordicSemiconductor/develop
Browse files Browse the repository at this point in the history
Version 4.4.2
  • Loading branch information
philips77 authored Apr 23, 2019
2 parents 53c7942 + c6ce77e commit 4a2b9c0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "weichsel/ZIPFoundation" ~> 0.9.9
github "weichsel/ZIPFoundation" == 0.9.9

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion changelog → changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
### Changelog
- **4.4.2**
- Bugfix: Missing buttonless service statuses added (#297)
- Improvement: Added support for older Swift versions (#295)
- Improvement: ZIPFoundation dependency bound to 0.9.9.

- **4.4.1**
- Bugfix: Fixed calculatign number of bytes received from PRN (#288).
- Improvement: ZIPFoundation dependency upgraded to 0.9.9. (#281)
- Improvement: ZIPFoundation dependency upgraded to 0.9.9. (#281)

- **4.4.0**
- Improvement: Swift 5.0 migration.
Expand Down
4 changes: 2 additions & 2 deletions iOSDFULibrary.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "iOSDFULibrary"
s.version = "4.4.1"
s.version = "4.4.2"
s.summary = "This repository contains a tested library for iOS 9+ devices to perform Device Firmware Update on the nRF5x devices"
s.description = <<-DESC
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.
Expand All @@ -18,5 +18,5 @@ The nRF5x Series chips are flash-based SoCs, and as such they represent the most

s.source_files = 'iOSDFULibrary/Classes/**/*'

s.dependency 'ZIPFoundation', '~> 0.9.9'
s.dependency 'ZIPFoundation', '= 0.9.9'
end
23 changes: 17 additions & 6 deletions iOSDFULibrary/Classes/Utilities/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ extension Data {
/// - returns: The value of type of the return type.
func asValue<R>(offset: Int = 0) -> R {
let length = MemoryLayout<R>.size
return subdata(in: offset ..< offset + length).withUnsafeBytes {
$0.baseAddress!.bindMemory(to: R.self, capacity: 1).pointee
}

#if swift(>=5.0)
return subdata(in: offset ..< offset + length).withUnsafeBytes { $0.load(as: R.self) }
#else
return subdata(in: offset ..< offset + length).withUnsafeBytes { $0.pointee }
#endif
}

}
Expand All @@ -46,14 +49,22 @@ extension Data {
/// Returns the Data as hexadecimal string.
var hexString: String {
var array: [UInt8] = []
self.withUnsafeBytes {
array.append(contentsOf: $0)
}

#if swift(>=5.0)
withUnsafeBytes { array.append(contentsOf: $0) }
#else
withUnsafeBytes { array.append(contentsOf: getByteArray($0)) }
#endif

return array.reduce("") { (result, byte) -> String in
result + String(format: "%02x", byte)
}
}

private func getByteArray(_ pointer: UnsafePointer<UInt8>) -> [UInt8] {
let buffer = UnsafeBufferPointer<UInt8>(start: pointer, count: count)
return [UInt8](buffer)
}

}

Expand Down

0 comments on commit 4a2b9c0

Please sign in to comment.