-//
-// Copyright © 2015 Apparata AB. All rights reserved.
 //
 // MIT License
 //
-// Copyright (C) 2015 by Apparata AB
+// Copyright (C) 2016 by Apparata AB
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal

    ///     - minor: The least significant value of the beacon.
    ///
    /// - SeeAlso: CoreLocation.CLBeacon
    public func startAdvertising(uuid uuid: NSUUID, major: CLBeaconMajorValue, minor: CLBeaconMinorValue) {
        let isBluetoothEnabled = peripheralManager.state == .PoweredOn
        if isBluetoothEnabled {
            region = CLBeaconRegion(proximityUUID: uuid, major: major, minor: minor, identifier: VirtualBeacon.regionIdentifier)
            if isAdvertising {
                peripheralManager.stopAdvertising()
            }
            startAdvertisingRegion(region)
        } else {
            delegate?.virtualBeaconDidFailToStartAdvertisingDueToBluetoothNotEnabled(self)
        }

    
    private var peripheralManager: CBPeripheralManager!
    
    private var region: BeaconRegion!
    
    private static let regionIdentifier = UUID().uuidString
    
    public override init() {
        super.init()
        peripheralManager = CBPeripheralManager()
        peripheralManager.delegate = self
    }
    
    deinit {
        stopAdvertising()
    }
    
    /// Start advertising the beacon.
    ///
    /// NOTE: CoreBluetooth only allows virtual beacons while the app is in
    ///       the foreground, so VirtualBeacon sets idleTimerDisabled to true
    ///       while it is advertising.
    ///
    /// - Parameters:
