                 // end of service
                 operation.success()
             }
+        }*/
+    }
+    
+    private func readByType(_ response: ATTResponse<ATTReadByTypeResponse>, operation: DiscoveryOperation<Characteristic>) {
+        
+        // Read By Type Response returns a list of Attribute Handle and Attribute Value pairs corresponding to the
+        // characteristics in the service definition. The Attribute Handle is the handle for the characteristic declaration. 
+        // The Attribute Value is the Characteristic Properties, Characteristic Value Handle and Characteristic UUID. 
+        // The Read By Type Request shall be called again with the Starting Handle set to one greater than the last 
+        // Attribute Handle in the Read By Type Response.
+        
+        switch response {
+            
+        case let .error(errorResponse):
+            
+            operation.error(errorResponse)
+            
+        case let .value(pdu):
+            
+            // pre-allocate array
+            operation.foundData.reserveCapacity(operation.foundData.count + pdu.data.count)
+            
+            // parse pdu data
+            for characteristicData in pdu.data {
+                
+                let handle = characteristicData.handle
+                
+                guard let declaration = CharacteristicDeclaration(littleEndian: characteristicData.value)
+                    else { operation.completion(.error(Error.invalidResponse(pdu))); return }
+                
+                let characteristic = Characteristic(uuid: declaration.uuid,
+                                                    properties: declaration.properties,
+                                                    handle: (handle, declaration.valueHandle))
+                
+                operation.foundData.append(characteristic)
+                
+                // if we specified a UUID to be searched,
+                // then call completion if it matches
+                if let operationUUID = operation.uuid {
+                    
+                    guard characteristic.uuid != operationUUID
+                        else { operation.success(); return }
+                }
+            }
+            
+            // get more if possible
+            let lastEnd = pdu.data.last?.handle ?? 0x00
+            
+            // prevent infinite loop
+            guard lastEnd >= operation.start
+                else { operation.completion(.error(Error.invalidResponse(pdu))); return }
+            
+            operation.start = lastEnd + 1
+            
+            // need to continue discovery
+            if lastEnd != 0, operation.start < operation.end {
+                
+                let pdu = ATTReadByTypeRequest(startHandle: operation.start,
+                                               endHandle: operation.end,
+                                               attributeType: operation.type.uuid)
+                
+                send(pdu) { [unowned self] in self.readByType($0, operation: operation) }
+                
+            } else {
+                
+                // end of service
+                operation.success()
+            }
         }
     }
     

        }
    }
    
    private func readByType( _ response: ATTResponse<ATTReadByTypeResponse>, operation: DiscoveryOperation<Characteristic>) {
        
        // Read By Type Response returns a list of Attribute Handle and Attribute Value pairs corresponding to the
        // characteristics in the service definition. The Attribute Handle is the handle for the characteristic declaration. 
        // The Attribute Value is the Characteristic Properties, Characteristic Value Handle and Characteristic UUID. 
        // The Read By Type Request shall be called again with the Starting Handle set to one greater than the last 
        // Attribute Handle in the Read By Type Response.
        
        switch response {
            
        case let .error(errorResponse):

        public let end: UInt16
    }
    
    /// A discovered characteristic.
    public struct Characteristic {
        
        public typealias Property = GATT.CharacteristicProperty
