<commit_before>//
//  RFDuinoBTManager.swift
//  Pods
//
//  Created by <NAME> on 27/01/16.
//
//

import Foundation
import CoreBluetooth

@objc public protocol RFDuinoBTManagerDelegate {
    func rfDuinoManagerDidDiscoverRFDuino(manager: RFDuinoBTManager, rfDuino: RFDuino)
    func rfDuinoManagerDidConnectRFDuino(manager: RFDuinoBTManager, rfDuino: RFDuino)
}

internal enum RFDuinoUUID {
    case Discover
    case Disconnect
    case Receive
    case Send
    
    var id: CBUUID {
        get {
            switch self {
            case .Discover:
                return CBUUID(string: "2220")
            case .Receive:
                return CBUUID(string: "2221")
            case .Send:
                return CBUUID(string: "2222")
            case .Disconnect:
                return CBUUID(string: "2223")
            }
        }
    }
}

public class RFDuinoBTManager : NSObject {
    
    /* Public variables */
    public static let sharedInstance = RFDuinoBTManager()
    public var delegate: RFDuinoBTManagerDelegate?
    
    /* Private variables */
    lazy private var centralManager:CBCentralManager = {
        let manager = CBCentralManager(delegate: sharedInstance, queue: dispatch_get_main_queue())
        return manager
    }()
    private var reScanTimer: NSTimer?
    private static var reScanInterval = 3.0
    internal static var logging = false
    
    private var _discoveredRFDuinos: [RFDuino] = []
    public var discoveredRFDuinos: [RFDuino] = [] {
        didSet {
            if oldValue.count != discoveredRFDuinos.count {
                delegate?.rfDuinoManagerDidDiscoverRFDuino(self, rfDuino: discoveredRFDuinos.last!)
            }
        }
    }
    
    override init() {
        super.init()
        "initialized RFDuinoBTRManager".log()
    }
}
    
/* Public methods */
public extension RFDuinoBTManager {<commit_msg>only notify delegate of newly discovered rfduinos when new rfduinos are found<commit_after>//
//  RFDuinoBTManager.swift
//  Pods
//
//  Created by <NAME> on 27/01/16.
//
//

import Foundation
import CoreBluetooth

@objc public protocol RFDuinoBTManagerDelegate {
    func rfDuinoManagerDidDiscoverRFDuino(manager: RFDuinoBTManager, rfDuino: RFDuino)
    func rfDuinoManagerDidConnectRFDuino(manager: RFDuinoBTManager, rfDuino: RFDuino)
}

internal enum RFDuinoUUID {
    case Discover
    case Disconnect
    case Receive
    case Send
    
    var id: CBUUID {
        get {
            switch self {
            case .Discover:
                return CBUUID(string: "2220")
            case .Receive:
                return CBUUID(string: "2221")
            case .Send:
                return CBUUID(string: "2222")
            case .Disconnect:
                return CBUUID(string: "2223")
            }
        }
    }
}

public class RFDuinoBTManager : NSObject {
    
    /* Public variables */
    public static let sharedInstance = RFDuinoBTManager()
    public var delegate: RFDuinoBTManagerDelegate?
    
    /* Private variables */
    lazy private var centralManager:CBCentralManager = {
        let manager = CBCentralManager(delegate: sharedInstance, queue: dispatch_get_main_queue())
        return manager
    }()
    private var reScanTimer: NSTimer?
    private static var reScanInterval = 3.0
    internal static var logging = false
    
    private var _discoveredRFDuinos: [RFDuino] = []
    public var discoveredRFDuinos: [RFDuino] = [] {
        didSet {
            if oldValue.count < discoveredRFDuinos.count {
                delegate?.rfDuinoManagerDidDiscoverRFDuino(self, rfDuino: discoveredRFDuinos.last!)
            }
        }
    }
    
    override init() {
        super.init()
        "initialized RFDuinoBTRManager".log()
    }
}
    
/* Public methods */
public extension RFDuinoBTManager {
{'fraction_non_alphanumeric': 0.08125164343938995, 'fraction_numerical': 0.012621614514856692, 'mean_word_length': 2.268041237113402, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4900484', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1157, 'n_words': 273}