Skip to content

Commit

Permalink
little endian fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Apr 5, 2016
1 parent 5dae614 commit bf8f3ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions Sources/Address.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,21 @@ extension Address: RawRepresentable {

public var rawValue: String {

// little endian
let bytes = [byteValue.0, byteValue.1, byteValue.2, byteValue.3, byteValue.4, byteValue.5]
let bytes = [byteValue.5, byteValue.4, byteValue.3, byteValue.2, byteValue.1, byteValue.0]

var string = ""

for (index, byte) in bytes.enumerate() {

string += byte.toHexadecimal()

if index != bytes.endIndex {
if index != bytes.count - 1 {

string += ":"
}
}

assert(string.utf8.count == 17)
assert(string.utf8.count == 17, "\"\(string)\" should be 17 characters")

return string
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/UUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public extension Bluetooth.UUID {
/// Creates an UUID from its little-endian representation, changing the byte order if necessary.
init?(littleEndian: [UInt8]) {

let byteValue = isBigEndian ? littleEndian.reverse() : littleEndian
let byteValue = isBigEndian ? littleEndian : littleEndian.reverse()

guard let UUID = Bluetooth.UUID(data: Data(byteValue: byteValue))
else { return nil }
Expand All @@ -139,7 +139,7 @@ public extension Bluetooth.UUID {

let byteValue = self.toData().byteValue

return isBigEndian ? byteValue.reverse() : byteValue
return isBigEndian ? byteValue : byteValue.reverse()
}
}

Expand Down

0 comments on commit bf8f3ad

Please sign in to comment.