Skip to content

Commit

Permalink
Updated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 29, 2017
1 parent 05c4287 commit 3625692
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/BluetoothLinux/LowEnergyScan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ internal func PollScannedDevices(_ deviceDescriptor: CInt,

doRead()

// try for errors
while actualBytesRead < 0 {

// ignore these errors
Expand All @@ -139,20 +140,22 @@ internal func PollScannedDevices(_ deviceDescriptor: CInt,
}
}

//let headerData = Array(eventBuffer[1 ..< 1 + HCIEventHeader.length])
let eventData = Array(eventBuffer[(1 + HCIEventHeader.length) ..< actualBytesRead])

// parse LE meta event
guard let meta = HCIGeneralEvent.LowEnergyMetaParameter(byteValue: eventData),
let lowEnergyEvent = LowEnergyEvent(rawValue: meta.subevent)
else { throw AdapterError.GarbageResponse(Data(eventData)) }

// only want adv report
// only want advertising report
guard lowEnergyEvent == .advertisingReport
else { continue }

// parse LE advertising report
guard let advertisingReport = LowEnergyEvent.AdvertisingReportEventParameter(byteValue: meta.data)
else { throw AdapterError.GarbageResponse(Data(meta.data)) }

// call closure on each device found
advertisingReport.reports.forEach { foundDevice($0) }
}
}
Expand Down

0 comments on commit 3625692

Please sign in to comment.