Skip to content

Commit

Permalink
#161 Fix LowEnergyAdvertisingData.init(beacon:flags:)
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 5, 2024
1 parent 9efbac0 commit 59f8b88
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Sources/BluetoothGAP/iBeacon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ internal extension AppleBeacon {
static var length: UInt8 { 0x15 } // length: 21 = 16 byte UUID + 2 bytes major + 2 bytes minor + 1 byte RSSI

static var additionalDataLength: Int { return Int(length) + 2 }
/*
static func from(advertisingData: LowEnergyAdvertisingData) -> (beacon: AppleBeacon, flags: GAPFlags)? {

guard let (flags, manufacturerData) = try? GAPDataDecoder.decode(GAPFlags.self, AppleBeacon.ManufacturerData.self, from: advertisingData)
else { return nil }


static func from(advertisingData: LowEnergyAdvertisingData) throws(GAPDataDecoderError) -> (beacon: AppleBeacon, flags: GAPFlags)? {
let (flags, manufacturerData) = try GAPDataDecoder.decode(GAPFlags.self, AppleBeacon.ManufacturerData.self, from: advertisingData)
return (manufacturerData.beacon, flags)
}*/
}

func appendAdditionalManufacturerData <T: DataContainer> (to data: inout T) {

Expand All @@ -86,10 +83,8 @@ public extension LowEnergyAdvertisingData {

init(beacon: AppleBeacon,
flags: GAPFlags = [.lowEnergyGeneralDiscoverableMode, .notSupportedBREDR]) {

let encoder = GAPDataEncoder<LowEnergyAdvertisingData>()
let manufacturerData = AppleBeacon.ManufacturerData(beacon) // storage on stack
self = encoder.encode(flags, manufacturerData)
self = GAPDataEncoder.encode(flags, manufacturerData)
}
}

Expand Down

0 comments on commit 59f8b88

Please sign in to comment.