         socket: L2CAPSocket,
         maximumTransmissionUnit: ATTMaximumTransmissionUnit,
         callback: GATTClientConnectionCallback
-    ) {
+    ) async {
         self.peripheral = peripheral
         self.callback = callback
-        self.client = GATTClient(
+        self.client = await GATTClient(
             socket: socket,
             maximumTransmissionUnit: maximumTransmissionUnit,
-            log: { callback.log?("[\(peripheral)]: " + $0) },
+            log: { callback.log?("[\(peripheral)]: " + $0) }
         )
-        /*
-        self.client.writePending = { [weak self] in
-            guard let self = self else { return }
-            Task(priority: .userInitiated) {
-                do {
-                    var didWrite = true
-                    repeat {
-                        didWrite = try await self.client.write()
-                    } while didWrite
-                }
-                catch {
-                    
-                }
-            }
-        }*/
     }
     
     // MARK: - Methods

    
    public private(set) var error: Swift.Error?
    
    /*
    private lazy var connectionThread: Thread = Thread { [weak self] in
        
        do {
            
            var didWrite = true
            var didRead = true
            
            // run until object is released
            while self != nil, self?.error == nil {
                
                // sleep if we did not previously read / write to save energy
                if didRead == false,
                    didWrite == false,
                    (self?.writePending ?? false) == false {
                    
                    // did not previously read or write, no pending writes
                    // sleep thread to save energy
                    usleep(100)
                }
                
                // attempt write
                didWrite = try self?.client.write() ?? false
                
                if didWrite {
                    self?.writePending = false
                }
                
                // attempt read
                didRead = try self?.client.read() ?? false
            }
        }
        
        catch { self?.disconnect(error) }
    }*/
    
    internal private(set) var cache = GATTClientConnectionCache()
    
    internal var maximumUpdateValueLength: Int {
        
        // ATT_MTU-3
        return Int(client.maximumTransmissionUnit.rawValue) - 3
    }
    
    // MARK: - Initialization

    }
}

#endif

