Basic Id

include/rid/basic_id.h Basic ID message handling per ASTM F3411-22a.

Example usage:

rid_basic_id_t basic_id;

rid_basic_id_init(&basic_id);
rid_basic_id_set_type(&basic_id, RID_ID_TYPE_SERIAL_NUMBER);
rid_basic_id_set_ua_type(&basic_id, RID_UA_TYPE_HELICOPTER_OR_MULTIROTOR);
rid_basic_id_set_uas_id(&basic_id, "1ABCD2345EF678XYZ", strlen("1ABCD2345EF678XYZ"));

hexdump(&basic_id, sizeof(basic_id));

char uas_id[RID_UAS_ID_SIZE + 1];
rid_basic_id_get_uas_id(&basic_id, uas_id, sizeof(uas_id));
rid_ua_type_t ua_type = rid_basic_id_get_ua_type(&basic_id);
rid_basic_id_type_t id_type = rid_basic_id_get_type(&basic_id);

printf("UAS ID:  %s\n", uas_id);
printf("UA type: %d\n", ua_type);
printf("ID type: %d\n", id_type);

Structures and Types

Type Name
struct rid_basic_id_t
Basic ID message structure per ASTM F3411-22a.
enum rid_basic_id_type_t
Basic ID type classification per ASTM F3411-22a.
enum rid_ua_type_t
Unmanned Aircraft type classification per ASTM F3411-22a.

Functions

Type Name
rid_basic_id_type_t rid_basic_id_get_type (const rid_basic_id_t *message)
Get the ID type from a Basic ID message.
rid_ua_type_t rid_basic_id_get_ua_type (const rid_basic_id_t *message)
Get the Unmanned Aircraft type from a Basic ID message.
int rid_basic_id_get_uas_id (const rid_basic_id_t *message, void *buffer, size_t buffer_size)
Get the Unmanned Aircraft System ID from a Basic ID message.
int rid_basic_id_init (rid_basic_id_t *message)
Initialize a Basic ID message structure.
int rid_basic_id_set_type (rid_basic_id_t *message, rid_basic_id_type_t type)
Set the ID type for a Basic ID message.
int rid_basic_id_set_ua_type (rid_basic_id_t *message, rid_ua_type_t type)
Set the Unmanned Aircraft type for a Basic ID message.
int rid_basic_id_set_uas_id (rid_basic_id_t *message, const void *uas_id, size_t uas_id_size)
Set the Unmanned Aircraft System ID for a Basic ID message.
int rid_basic_id_to_json (const rid_basic_id_t *message, char *buffer, size_t buffer_size, size_t *needed_size)
Format a Basic ID message as a JSON string.
const char * rid_basic_id_type_to_string (rid_basic_id_type_t type)
Convert ID type to string representation.
int rid_basic_id_validate (const rid_basic_id_t *message)
Validate a Basic ID message structure.
const char * rid_ua_type_to_string (rid_ua_type_t type)
Convert Unmanned Aircraft type to string representation.

Macros

Type Name
define RID_UAS_ID_SIZE 20
UAS ID field size in bytes per ASTM F3411-22a.
define RID_UAS_ID_UUID_SIZE 16
RFC4122 UUID size in bytes.

Structures and Types Documentation

struct rid_basic_id_t

Basic ID message structure per ASTM F3411-22a.

Variables:

  • uint8_t id_type

  • uint8_t message_type

  • uint8_t protocol_version

  • char reserved

  • uint8_t ua_type

  • char uas_id

enum rid_basic_id_type_t

Basic ID type classification per ASTM F3411-22a.

enum rid_basic_id_type_t {
    RID_ID_TYPE_NONE = 0,
    RID_ID_TYPE_SERIAL_NUMBER = 1,
    RID_ID_TYPE_CAA_REGISTRATION_ID = 2,
    RID_ID_TYPE_UTM_ASSIGNED_UUID = 3,
    RID_ID_TYPE_SPECIFIC_SESSION_ID = 4,
    RID_ID_TYPE_MAX = 15
};

enum rid_ua_type_t

Unmanned Aircraft type classification per ASTM F3411-22a.

enum rid_ua_type_t {
    RID_UA_TYPE_NONE = 0,
    RID_UA_TYPE_AEROPLANE_OR_FIXED_WING = 1,
    RID_UA_TYPE_HELICOPTER_OR_MULTIROTOR = 2,
    RID_UA_TYPE_GYROPLANE = 3,
    RID_UA_TYPE_HYBRID_LIFT = 4,
    RID_UA_TYPE_ORNITHOPTER = 5,
    RID_UA_TYPE_GLIDER = 6,
    RID_UA_TYPE_KITE = 7,
    RID_UA_TYPE_FREE_BALLOON = 8,
    RID_UA_TYPE_CAPTIVE_BALLOON = 9,
    RID_UA_TYPE_AIRSHIP = 10,
    RID_UA_TYPE_FREE_FALL_PARACHUTE = 11,
    RID_UA_TYPE_ROCKET = 12,
    RID_UA_TYPE_TETHERED_POWERED_AIRCRAFT = 13,
    RID_UA_TYPE_GROUND_OBSTACLE = 14,
    RID_UA_TYPE_OTHER = 15,
    RID_UA_TYPE_MAX = 15
};

Functions Documentation

function rid_basic_id_get_type

Get the ID type from a Basic ID message.

rid_basic_id_type_t rid_basic_id_get_type (
    const rid_basic_id_t *message
) 

Parameters:

  • message Pointer to the Basic ID message structure.

Returns:

The ID type or RID_ID_TYPE_NONE if message is NULL.

function rid_basic_id_get_ua_type

Get the Unmanned Aircraft type from a Basic ID message.

rid_ua_type_t rid_basic_id_get_ua_type (
    const rid_basic_id_t *message
) 

Parameters:

  • message Pointer to the Basic ID message structure.

Returns:

The UA type or RID_UA_TYPE_NONE if message is NULL.

function rid_basic_id_get_uas_id

Get the Unmanned Aircraft System ID from a Basic ID message.

int rid_basic_id_get_uas_id (
    const rid_basic_id_t *message,
    void *buffer,
    size_t buffer_size
) 

Copies RID_UAS_ID_SIZE bytes to the provided buffer. String callers should pass a buffer of RID_UAS_ID_SIZE + 1 to get a null-terminated C string.

Parameters:

  • message Pointer to the Basic ID message structure.
  • buffer Buffer to store the UAS ID.
  • buffer_size Size of the buffer. Must be at least RID_UAS_ID_SIZE.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message or buffer is NULL.
  • RID_ERROR_BUFFER_TOO_SMALL if buffer_size is insufficient.

function rid_basic_id_init

Initialize a Basic ID message structure.

int rid_basic_id_init (
    rid_basic_id_t *message
) 

Sets protocol version to RID_PROTOCOL_VERSION_2 and message type to RID_MESSAGE_TYPE_BASIC_ID. All other fields are zeroed.

Parameters:

  • message Pointer to the Basic ID message structure to initialize.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.

function rid_basic_id_set_type

Set the ID type for a Basic ID message.

int rid_basic_id_set_type (
    rid_basic_id_t *message,
    rid_basic_id_type_t type
) 

Parameters:

  • message Pointer to the Basic ID message structure.
  • type The ID type to set.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_OUT_OF_RANGE if type exceeds RID_ID_TYPE_MAX.

function rid_basic_id_set_ua_type

Set the Unmanned Aircraft type for a Basic ID message.

int rid_basic_id_set_ua_type (
    rid_basic_id_t *message,
    rid_ua_type_t type
) 

Parameters:

  • message Pointer to the Basic ID message structure.
  • type The UA type to set.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_OUT_OF_RANGE if type exceeds RID_UA_TYPE_MAX.

function rid_basic_id_set_uas_id

Set the Unmanned Aircraft System ID for a Basic ID message.

int rid_basic_id_set_uas_id (
    rid_basic_id_t *message,
    const void *uas_id,
    size_t uas_id_size
) 

Copies uas_id_size bytes and zero-pads the remainder.

Parameters:

  • message Pointer to the Basic ID message structure.
  • uas_id The UAS ID bytes to set.
  • uas_id_size Number of bytes in the uas_id.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message or uas_id is NULL.
  • RID_ERROR_BUFFER_TOO_LARGE if uas_id_size exceeds RID_UAS_ID_SIZE.

function rid_basic_id_to_json

Format a Basic ID message as a JSON string.

int rid_basic_id_to_json (
    const rid_basic_id_t *message,
    char *buffer,
    size_t buffer_size,
    size_t *needed_size
) 

Parameters:

  • message Pointer to the Basic ID message structure.
  • buffer Buffer to store the JSON string or NULL.
  • buffer_size Size of the buffer.
  • needed_size Receives the required buffer size. Can be NULL.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL or if both buffer and needed_size are NULL.
  • RID_ERROR_BUFFER_TOO_SMALL if buffer is too small.

function rid_basic_id_type_to_string

Convert ID type to string representation.

const char * rid_basic_id_type_to_string (
    rid_basic_id_type_t type
) 

Parameters:

  • type The ID type to convert.

Returns:

String representation of the ID type. Returns "UNKNOWN" for invalid values.

function rid_basic_id_validate

Validate a Basic ID message structure.

int rid_basic_id_validate (
    const rid_basic_id_t *message
) 

Checks that all fields contain valid encoded values according to ASTM F3411-22a. Reserved values are considered valid.

Parameters:

  • message Pointer to the Basic ID message structure to validate.

Return value:

  • RID_SUCCESS if all fields are valid.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_INVALID_PROTOCOL_VERSION if protocol version is invalid.
  • RID_ERROR_UNKNOWN_MESSAGE_TYPE if message type is not BASIC_ID.
  • RID_ERROR_INVALID_CAA_REGISTRATION_ID if Registration ID contains invalid characters.
  • RID_ERROR_INVALID_SERIAL_NUMBER if Serial Number contains invalid characters.
  • RID_ERROR_INVALID_UUID_VERSION if UTM UUID version is not 1-5.
  • RID_ERROR_INVALID_UUID_VARIANT if UTM UUID variant is not RFC4122.
  • RID_ERROR_INVALID_UUID_PADDING if UTM UUID padding bytes are non-zero.

function rid_ua_type_to_string

Convert Unmanned Aircraft type to string representation.

const char * rid_ua_type_to_string (
    rid_ua_type_t type
) 

Parameters:

  • type The UA type to convert.

Returns:

String representation of the UA type. Returns "UNKNOWN" for invalid values.

Macros Documentation

define RID_UAS_ID_SIZE

UAS ID field size in bytes per ASTM F3411-22a.

#define RID_UAS_ID_SIZE 20

define RID_UAS_ID_UUID_SIZE

RFC4122 UUID size in bytes.

#define RID_UAS_ID_UUID_SIZE 16