Skip to content

Commit

Permalink
Fixed GATT Notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Jan 21, 2019
1 parent 5752c67 commit db9f964
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Sources/GATT/GATTPeripheral.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,19 @@ public final class GATTPeripheral <HostController: BluetoothHostControllerInterf
maximumPreparedWrites: options.maximumPreparedWrites)

connection.callback.log = { [unowned self] in self.log?("[\(connection.central)]: " + $0) }
connection.callback.didWrite = { [unowned self] in self.didWrite?($0) }
connection.callback.didWrite = { [unowned self] (write) in

// notify other connected centrals
self.connectionsQueue.sync { [unowned self] in
self.connections.values.forEach {
if $0.central != write.central {
$0.writeValue(write.value, forCharacteristic: write.handle)
}
}
}

self.didWrite?(write) // notify delegate
}
connection.callback.willWrite = { [unowned self] in self.willWrite?($0) }
connection.callback.willRead = { [unowned self] in self.willRead?($0) }
connection.callback.writeDatabase = { [unowned self] in self.writeDatabase($0) }
Expand Down

0 comments on commit db9f964

Please sign in to comment.