 }
 
 
-internal class PairingService: NSObject {
+public class PairingService: NSObject {
     fileprivate enum Status: Int {
         case unknown
         case scanning


extension PairingService: CBPeripheralManagerDelegate {
    public func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
        if peripheralManager.isAdvertising == false, status == .scanning, peripheralManager.state == .poweredOn {
            peripheralManager.startAdvertising(nil)
        }
    }
    
    public func peripheralManagerIsReady(toUpdateSubscribers peripheral: CBPeripheralManager) {

    
    
    public func startPairing() {
        isPairing = true
        
        guard peripheralManager.state == .poweredOn, centralManager.state == .poweredOn else { return }
        
        let service = CBMutableService(type: serviceId, primary: true)
        service.characteristics = [pairingStatusCharacteristic]
        
        peripheralManager.add(service)
        centralManager.scanForPeripherals(withServices: [serviceId], options: nil)
        status = .scanning
    }
    
    fileprivate func checkForCompletion() {
        guard
            let peripheral = remotePeripheral,
            peripheralManager.state == .poweredOn,
            centralManager.state == .poweredOn,
            status == .completionPendingRemotePeer,
            remotePeerStatus == .completionPendingRemotePeer
        else {
