opendroneid / receiver-android

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

UTM UUID is handled as a string instead of binary data #8

Closed realflight1 closed 2 years ago

realflight1 commented 4 years ago

The getUasIdAsString method of the Identification class handles all IDs as strings, but according to the ASTM remote ID standard (under BASIC ID MESSAGE 5.4.5.6) UAS ID Type 3 (UTM UUID) should be handled as a 128-bit UUID - binary encoded with network byte order.

friissoren commented 4 years ago

You are correct. That is something that is not properly handled in the receiver implementation at the moment. Based on the value of IdTypeEnum, it should handle the uasId either as ASCII or binary data. If you have a good suggestions on how to correct this, please upload a Pull Request.

gabrielcox commented 4 years ago

Here's one method/suggestion (courtesy stack overflow) :

import java.nio.ByteBuffer;
import java.util.UUID;
public static UUID getUUIDFromBytes(byte[] bytes) {
    ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
    Long high = byteBuffer.getLong();
    Long low = byteBuffer.getLong();

    return new UUID(high, low);
}

This will return a UUID object. The .toString() method will return the "common looking" UUID string in the 4-2-2-2-6 format.