             userInfo: ["peripheral": peripheral, "RSSI": RSSI])
         
         central.connectPeripheral(peripheral, options: nil)
-        
-        
-    }
+    }
+    
     
     func handleLowSignal(signal: Int) {
         println("  Do not connect rssi: \(signal)")
+        
         var msg = "Low Signal: \(signal)"
         nc.postNotificationName("btStateChangedNotification", object: msg)
         
         self.centralManager?.stopScan()
         self.resetConnection()
+        
         delay(1.0) {
             // Wait one second to start scanning again.
             self.startScanning()
         }
     }
+    
     
     func centralManager(central: CBCentralManager!, didFailToConnectPeripheral peripheral: CBPeripheral!, error: NSError!) {
         println("Called didFailToConnectPeripheral")


import Foundation
import CoreBluetooth

class BTDiscoveryManager: NSObject, CBCentralManagerDelegate {
    

        central.stopScan()
    }
    
    
    func centralManager(central: CBCentralManager!, didDisconnectPeripheral peripheral: CBPeripheral!, error: NSError!) {
        println("Called did Disconnect Peripheral: \(peripheral)")
        
        nc.postNotificationName("btStateChangedNotification", object: "Disconnected", userInfo: ["peripheral": peripheral])
        
        // when activePeripheral is set to nil we know we don't need to reconnect.
        if (peripheral == self.activePeripheral) {
            self.resetConnection()
            self.startScanning()
        }
    }
    
    
    func centralManager(
        central: CBCentralManager!,
        didDiscoverPeripheral peripheral: CBPeripheral!,
        advertisementData: [NSObject : AnyObject]!,
        RSSI: NSNumber!) {
        
        let uuid = peripheral.identifier.UUIDString;
        
