Get eddystone beacon url string

364 Views Asked by At

I have an android app. I use Altbeacon "BeaconParser.EDDYSTONE_URL_LAYOUT" for transmiting as an beacon. On the other hand ı have an ıos app. I use BluetoothKit library to scan this beacon. I can scan and see my device RSSI value but ı can not get url string. This is my swift code;

public class BeaconScanning: NSObject, BKCentralDelegate{

    let central = BKCentral()

    override init(){
        super.init()
        startCentral()
    }
    private func startCentral() {
        central.delegate = self
        do {
            let serviceUUID = CBUUID(string: "0xFEAA")
            let characteristicUUID = CBUUID( )
            let configuration = BKConfiguration(dataServiceUUID: serviceUUID, dataServiceCharacteristicUUID: characteristicUUID)
            try central.startWithConfiguration(configuration)
        } catch let error { }
        scanBeacon()
    }


    public func scanBeacon() {

       central.scanContinuouslyWithChangeHandler({ changes, discoveries in }, stateHandler: { newState in
        }, duration: 3, inBetweenDelay: 0.1, beaconHandler: { beacons in

                for beacon in beacons! {

                  print(beacon.getRunningAverageRssi()) // ı can get it
                  print(beacon.getBluetoothName()) //return null

                  // ı want to get eddystone url.

                }
        }, errorHandler: { error in })
    }

How can I get url string for my android device?

1

There are 1 best solutions below

0
davidgyoung On

BluetoothKit does not provide functionality to decompress Eddystone-URL transmissions. You might try ios-beacon-tools which does:

    scanner = RNLBeaconScanner.shared()
    scanner?.startScanning()
    
    // Execute this code periodically (every second or so) to view the beacons detected

    if let detectedBeacons = scanner?.trackedBeacons() as? [RNLBeacon] {
        for beacon in detectedBeacons {
             if (beacon.beaconTypeCode.intValue == 0x10 && beacon.serviceUuid.intValue == 0xFEAA) {
                // this is eddystone url
                NSLog("Detected EDDYSTONE-URL with %@", RNLURLBeaconCompressor.urlString(fromEddystoneURLIdentifier: beacon.id1))
            }
            else {
                // some other beacon type
            }
        }
    }