opendroneid / receiver-android

Example Android receiver application for unmanned aircraft Remote ID
Apache License 2.0
211 stars 64 forks source link

iOS #111

Closed Tapestes closed 1 year ago

Tapestes commented 1 year ago

This is probably the wrong place, but I'm not sure where the right place is. Are there any status updates on the iOS receiver? Thanks much.

friissoren commented 1 year ago

As far as I am aware, the info listed here is still valid. Beyond that, I unfortunately can't help. https://github.com/opendroneid/opendroneid-core-c#ios

Tapestes commented 1 year ago

Thanks for the response, @friissoren. I've managed to parse the position information in iOS. If it helps someone else, I'm testing with a DroneBeacon db120. Information is contained in the advertisement data. For some reason (one that's probably obvious if I looked at more detail at the spec) the advertisment data is 27 bytes rather than the expected 25. But, when I shift everything over I'm able to get the correct lat/lon data with the following code. Note: as best as I can tell, every ad message is not a location message. In any case, sample code using CBCentralManagerDelegate would look something like the following. Note, this just pulls out the raw value. Subsequent calculations need to be done to convert something useful.

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {       
        if let data = advertisementData["kCBAdvDataServiceData"] as? [AnyHashable:Any] {
            for (_, value) in data {

                if let d = value as? Data {
                    let flagRange:Range<Int> = 3..<4
                    let trckRange:Range<Int> = 4..<5
                    let gsRange:Range<Int> = 5..<6
                    let vsRange:Range<Int> = 6..<7
                    let latRange:Range<Int> = 7..<11
                    let lonRange:Range<Int> = 11..<15
                    let paRange:Range<Int> = 15..<17

                    let flagData = d.subdata(in: flagRange)
                    let trckData = d.subdata(in: trckRange)
                    let gsData = d.subdata(in: gsRange)
                    let vsData = d.subdata(in: vsRange)
                    let latData = d.subdata(in: latRange)
                    let lonData = d.subdata(in: lonRange)
                    let paData = d.subdata(in: paRange)

                    let flag = String(data: flagData, encoding:.utf8) //50
                    let track = String(data: trckData, encoding:.utf8) //50
                    let gs = UInt32(littleEndian: gsData.withUnsafeBytes { $0.pointee })
                    let vs = String(data: vsData, encoding:.utf8) //50
                    let lat = Int32(littleEndian: latData.withUnsafeBytes { $0.pointee })
                    let lon = Int32(littleEndian: lonData.withUnsafeBytes { $0.pointee })
                    let pA = UInt32(littleEndian: paData.withUnsafeBytes { $0.pointee })
                }
            }
        } else {
            print("Failed to open kCBAdvDataServiceData")
        }
    }