How to get UUID, major and minor from beacon on IOS

I have tried to get UUID, major and minor through connect beacon,
my question is “can I get value without connect beacon?”

this is my viewcontroller:

class PairPageController: UIViewController , ESTDeviceManagerDelegate, ESTDeviceConnectableDelegate{

var deviceManger: ESTDeviceManager!
var beaconManger = ESTBeaconManager()
var ownBeaconlistID: Array<String>! = []

@IBAction func menuClick(_ sender: Any) {
    navigationController?.view.menu()
}

override func viewDidLoad() {
    super.viewDidLoad()
    self.deviceManger = ESTDeviceManager()
    self.deviceManger.delegate = self
    self.deviceManger.startDeviceDiscovery(with: ESTDeviceFilterLocationBeacon(identifiers: self.ownBeaconlistID))
    
}

//when discover device
func deviceManager(_ manager: ESTDeviceManager, didDiscover devices: [ESTDevice]) {
    guard let beacon = devices.first as? ESTDeviceLocationBeacon else { return }
    self.deviceManger.stopDeviceDiscovery()
 
    beacon.delegate = self
    beacon.connect()
}

func estDeviceConnectionDidSucceed(_ device: ESTDeviceConnectable) {
    print("Connected")
    guard let beacon_connected = device as? ESTDeviceLocationBeacon else { return }
    
    beacon_connected.settings?.iBeacon.major.readValue(completion: { (_ major: ESTSettingIBeaconMajor?, _ error: Error?) in
        print(major?.getValue())
    })
}

func estDevice(_ device: ESTDeviceConnectable,
               didFailConnectionWithError error: Error) {
    print("Connnection failed with error: \(error)")
}

func estDevice(_ device: ESTDeviceConnectable,
               didDisconnectWithError error: Error?) {
    print("Disconnected")
}

}

thanks for your help!!

Hey @Ray,

the monitoring or ranging technology will scan for near beacons, and give you a CLBeacon object. You can then get the UUID, major and minor with:

scannedBeacon.proximityUUID
scannedBeacon.major
scannedBeacon.minor

Thanks @Ximun,
the monitoring or ranging technology need UUID, major, minor for region when it start work,
for example:

beaconManger.startMonitoring(for: CLBeaconRegion(
proximityUUID: UUID(uuidString: “B9407F30-F5F8-466E-AFF9-25556B57FE6D”)!,
major: 22, minor: 10)

but my beacon’s UUID, major and minor are dynamic variable.

I want to get value from any beacon in the range, that have fixed ID (beacon.identifier)

is it possible?

Hey @Ray,

in iOS, unfortunately, you can’t scan all the beacons near.
You can put a null major and a null minor but you have to put a non-null UUID.

2 Likes