### Build Examples Source: https://github.com/tuupola/librid/blob/master/README.md Commands to configure and build the library examples using CMake. ```bash $ mkdir build && cd build $ cmake -DRID_BUILD_EXAMPLES=ON .. $ make ``` -------------------------------- ### Installation Procedures Source: https://github.com/tuupola/librid/blob/master/README.md Various commands for building and installing the library as static or shared binaries. ```bash $ mkdir build && cd build $ cmake .. $ make $ sudo make install ``` ```bash $ cmake -DCMAKE_INSTALL_PREFIX=/opt/librid .. $ make $ make install ``` ```bash $ cmake -DBUILD_SHARED_LIBS=ON .. $ make $ sudo make install ``` -------------------------------- ### Run MAVLink Example Source: https://github.com/tuupola/librid/blob/master/examples/mavlink/README.md Commands to execute the project, optionally specifying the MAVLink library directory. ```bash $ make run $ make MAVLINK_DIR=/path/to/c_library_v2 run ``` -------------------------------- ### Run Librid Self ID Example Source: https://github.com/tuupola/librid/blob/master/examples/self_id/README.md Executes the self ID example using the make build system. ```bash $ make run ``` -------------------------------- ### Start Bluetooth Scanning with bluetoothctl Source: https://github.com/tuupola/librid/blob/master/examples/cli/README.md Initiate Bluetooth scanning using the bluetoothctl utility. Ensure Bluetooth is powered on before starting the scan. ```bash $ bluetoothctl [bluetoothctl]> power on [bluetoothctl]> scan le ``` -------------------------------- ### Prettified JSON output example Source: https://github.com/tuupola/librid/blob/master/examples/json/README.md An example of the structured JSON output after being processed by jq. ```json { "protocol_version": 2, "message_type": 15, "message_count": 4, "messages": [ { "protocol_version": 2, "message_type": 0, "id_type": 1, "ua_type": 2, "uas_id": "1ABCD2345EF678XYZ" }, { "protocol_version": 2, "message_type": 1, "latitude": 60.169857, "longitude": 24.938379, ... }, { "protocol_version": 2, "message_type": 3, "description_type": 0, "description": "Survey drone" }, { "protocol_version": 2, "message_type": 5, "id_type": 0, "operator_id": "FIN87astrdge12k8" } ] } ``` -------------------------------- ### MAVLink Example Output Source: https://github.com/tuupola/librid/blob/master/examples/mavlink/README.md Expected console output showing the conversion between Remote ID and MAVLink formats. ```text === Remote ID to MAVLink ======================= Remote ID Basic ID (25 bytes): 02 12 31 41 42 43 44 32 33 34 35 45 46 36 37 38 58 59 5a 00 00 00 00 00 00 ID type: RID_ID_TYPE_SERIAL_NUMBER UA type: RID_UA_TYPE_HELICOPTER_OR_MULTIROTOR UAS ID: 1ABCD2345EF678XYZ MAVLink Basic ID (41 bytes): Message ID: 12900 96 1e fd 29 00 00 00 01 01 64 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 31 41 42 43 44 === MAVLink to Remote ID ======================= Remote ID Basic ID (25 bytes): 02 12 31 41 42 43 44 32 33 34 35 45 46 36 37 38 58 59 5a 00 00 00 00 00 00 ID type: RID_ID_TYPE_SERIAL_NUMBER UA type: RID_UA_TYPE_HELICOPTER_OR_MULTIROTOR UAS ID: 1ABCD2345EF678XYZ ``` -------------------------------- ### Authentication Output Format Source: https://github.com/tuupola/librid/blob/master/examples/auth/README.md Displays the expected console output after running the authentication example, including verification status, page data, and signature bytes. ```text Signature verified. Page count: 4 Length: 64 bytes Auth type: 1 Timestamp: 189014400 Public key: 7b cc 86 f8 50 b0 c1 12 c4 40 e0 2e 97 d5 7d dd cd d1 36 c1 3e 74 82 e7 72 fa 7a 20 df d1 96 2c Page 0: 22 10 03 40 80 21 44 0b 76 50 50 49 3c 2c da ee 4a ea 66 58 11 80 21 14 6d Page 1: 22 11 50 a1 11 82 df ef 9b fa 54 ce 06 23 92 95 a6 4e 06 72 44 a1 fd 1c 81 Page 2: 22 12 a2 36 2c 1c ff ab 24 d9 07 1c 00 2a ab ef 85 79 81 96 b8 ef db 30 0c Page 3: 22 13 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Retrieved signature: 76 50 50 49 3c 2c da ee 4a ea 66 58 11 80 21 14 6d 50 a1 11 82 df ef 9b fa 54 ce 06 23 92 95 a6 4e 06 72 44 a1 fd 1c 81 a2 36 2c 1c ff ab 24 d9 07 1c 00 2a ab ef 85 79 81 96 b8 ef db 30 0c 07 ``` -------------------------------- ### Building librid with CMake Source: https://context7.com/tuupola/librid/llms.txt Provides various shell commands for building, testing, and installing the library using CMake. ```bash # Build static library (default) mkdir build && cd build cmake .. make sudo make install # Build shared library cmake -DBUILD_SHARED_LIBS=ON .. make sudo make install # Build with examples cmake -DRID_BUILD_EXAMPLES=ON .. make # Build and run tests cmake -DRID_BUILD_TESTS=ON .. make ctest # Install to custom location cmake -DCMAKE_INSTALL_PREFIX=/opt/librid .. make make install # Uninstall cd build sudo make uninstall ``` -------------------------------- ### Uninstall Library Source: https://github.com/tuupola/librid/blob/master/README.md Command to remove the installed library files. ```bash $ cd build $ sudo make uninstall ``` -------------------------------- ### Librid JSON Output Example Source: https://github.com/tuupola/librid/blob/master/examples/cli/README.md Example of the JSON output produced by the librid CLI when decoding a standard Remote ID message. ```json { "protocol_version": 2, "message_type": 1, "latitude": 65.634037, "longitude": 25.255144, "geodetic_altitude": 120.500000, "pressure_altitude": -1000.000000, "height": 50.000000, "height_type": 0, "speed": 15.500000, "vertical_speed": 2.000000, "track_direction": 45, "operational_status": 2, "horizontal_accuracy": 10, "vertical_accuracy": 4, "speed_accuracy": 3, "baro_altitude_accuracy": 0, "timestamp": 12345, "timestamp_accuracy": 1 } ``` -------------------------------- ### Operator ID Output Example Source: https://github.com/tuupola/librid/blob/master/examples/operator_id/README.md This is the expected output after running the operator ID command. It displays the raw hexadecimal data followed by the decoded Operator ID and its type. ```text 52 00 46 49 4e 38 37 61 73 74 72 64 67 65 31 32 6b 38 00 00 00 00 00 00 00 Operator ID: FIN87astrdge12k8 ID type: 0 ``` -------------------------------- ### Librid Validation Output Source: https://github.com/tuupola/librid/blob/master/examples/validate/README.md Example output from the Librid validation process, showing results for valid and invalid serial numbers and UTM UUIDs. ```text Valid Serial Number: RID_SUCCESS Invalid Serial Number: RID_ERROR_INVALID_CHARACTER Valid UTM UUID: RID_SUCCESS Invalid UTM UUID: RID_ERROR_INVALID_UUID_VERSION ``` -------------------------------- ### Librid JSON Output for Bluetooth Scanner Source: https://github.com/tuupola/librid/blob/master/examples/cli/README.md Example of the JSON output from librid when decoding aggregated Bluetooth Remote ID messages captured via tshark. ```json { "counter": 216, "protocol_version": 2, "message_type": 15, "message_count": 4, "messages": [ { "protocol_version": 2, "message_type": 0, "id_type": 1, "ua_type": 0, "uas_id": "1596A303716531B" }, { "protocol_version": 2, "message_type": 1, "latitude": 65.634037, "longitude": 25.255144, "geodetic_altitude": 102.500000, "pressure_altitude": 104.500000, "height": -0.500000, "height_type": 0, "speed": 0.000000, "vertical_speed": 0.000000, "track_direction": 74, "operational_status": 2, "horizontal_accuracy": 10, "vertical_accuracy": 5, "speed_accuracy": 4, "baro_altitude_accuracy": 0, "timestamp": 13880, "timestamp_accuracy": 0 }, { "protocol_version": 2, "message_type": 4, "operator_location_type": 0, "classification_type": 1, "ua_classification_category": 1, "ua_classification_class": 0, "operator_latitude": 65.634037, "operator_longitude": 25.255144, "operator_altitude": 107.500000, "area_count": 1, "area_radius": 0, "area_ceiling": -1000.000000, "area_floor": -1000.000000, "timestamp": 225282188 }, { "protocol_version": 2, "message_type": 5, "id_type": 0, "operator_id": "FIN87astrdge12k8" } ] } ``` -------------------------------- ### Build and Run Tests Source: https://github.com/tuupola/librid/blob/master/README.md Commands to configure, build, and execute the test suite. ```bash $ mkdir build && cd build $ cmake -DRID_BUILD_TESTS=ON .. $ make $ ctest ``` -------------------------------- ### Initialize and Manage Message Packs Source: https://github.com/tuupola/librid/blob/master/README.md Demonstrates how to initialize a message pack, add, replace, and delete messages, and convert the pack to JSON. ```c rid_message_pack_t pack; rid_basic_id_t basic_id; rid_location_t location; char json[1024]; rid_message_pack_init(&pack); rid_message_pack_add_message(&pack, &basic_id); rid_message_pack_add_message(&pack, &location); rid_message_pack_replace_message_at(&pack, 0, &basic_id); rid_message_pack_delete_message_at(&pack, 1); rid_message_pack_validate(&pack); uint8_t count = rid_message_pack_get_message_count(&pack); size_t size = rid_message_pack_get_size(&pack); const void *message = rid_message_pack_get_message_at(&pack, 0); rid_message_pack_to_json(&pack, json, sizeof(json)); ``` -------------------------------- ### Build and Run Librid CLI Source: https://github.com/tuupola/librid/blob/master/examples/cli/README.md Build the project using make and then run the librid CLI tool with a hex string or by piping from a file. ```bash $ make $ ./rid $ ./rid < file.hex ``` -------------------------------- ### Create and Manage Message Pack Source: https://context7.com/tuupola/librid/llms.txt Demonstrates creating a message pack, adding multiple message types, validating the pack, querying its properties, and modifying its contents by replacing or deleting messages. Ensure the pack does not exceed its capacity of 9 messages, each up to 25 bytes. ```c #include #include "rid/rid.h" int main(void) { rid_message_pack_t pack; rid_basic_id_t basic_id; rid_location_t location; rid_self_id_t self_id; char json[1024]; /* Initialize all messages */ rid_message_pack_init(&pack); rid_basic_id_init(&basic_id); rid_location_init(&location); rid_self_id_init(&self_id); /* Configure messages */ rid_basic_id_set_type(&basic_id, RID_ID_TYPE_SERIAL_NUMBER); rid_basic_id_set_uas_id(&basic_id, "1ABCD2345EF678XYZ"); rid_location_set_latitude(&location, 62.683472); rid_location_set_longitude(&location, 21.974944); rid_location_set_operational_status(&location, RID_OPERATIONAL_STATUS_AIRBORNE); rid_self_id_set_description(&self_id, "Test flight"); /* Add messages to pack */ rid_message_pack_add_message(&pack, &basic_id); rid_message_pack_add_message(&pack, &location); rid_message_pack_add_message(&pack, &self_id); /* Validate the message pack */ int result = rid_message_pack_validate(&pack); if (result != RID_SUCCESS) { printf("Validation failed: %s\n", rid_error_to_string(result)); return 1; } /* Query pack info */ uint8_t count = rid_message_pack_get_message_count(&pack); size_t size = rid_message_pack_get_size(&pack); printf("Message count: %u\n", count); printf("Pack size: %zu bytes\n", size); /* Iterate through messages */ for (uint8_t i = 0; i < count; i++) { const rid_message_t *msg = rid_message_pack_get_message_at(&pack, i); if (msg) { printf("Message %u: %s\n", i, rid_message_type_to_string(rid_message_get_type(msg))); } } /* Modify pack: replace message at index 0 */ rid_basic_id_set_uas_id(&basic_id, "NEWID12345"); rid_message_pack_replace_message_at(&pack, 0, &basic_id); /* Delete message at index 2 */ rid_message_pack_delete_message_at(&pack, 2); /* Export as JSON */ rid_message_pack_to_json(&pack, json, sizeof(json)); printf("JSON: %s\n", json); return 0; } /* Output: Message count: 3 Pack size: 78 bytes Message 0: RID_MESSAGE_TYPE_BASIC_ID Message 1: RID_MESSAGE_TYPE_LOCATION Message 2: RID_MESSAGE_TYPE_SELF_ID */ ``` -------------------------------- ### Initialize and Configure System Message (C) Source: https://context7.com/tuupola/librid/llms.txt Initializes a System message, sets operator location, drone classification, coordinates, area details, and timestamp. It then validates the message and prints its details and JSON representation. Ensure all values are within their specified ranges. ```c #include #include "rid/system.h" int main(void) { rid_system_t system; char json[512]; /* Initialize and configure System message */ rid_system_init(&system); rid_system_set_operator_location_type(&system, RID_OPERATOR_LOCATION_TYPE_TAKEOFF); rid_system_set_classification_type(&system, RID_CLASSIFICATION_TYPE_EUROPEAN_UNION); rid_system_set_ua_classification_category(&system, RID_UA_CLASSIFICATION_CATEGORY_OPEN); rid_system_set_ua_classification_class(&system, RID_UA_CLASSIFICATION_CLASS_1); rid_system_set_operator_latitude(&system, 60.2870324); rid_system_set_operator_longitude(&system, 24.5397187); rid_system_set_operator_altitude(&system, 50.0f); rid_system_set_area_count(&system, 1); rid_system_set_area_radius(&system, 100); rid_system_set_area_ceiling(&system, 120.0f); rid_system_set_area_floor(&system, 0.0f); rid_system_set_unixtime(&system, 1234567890); /* Validate the message */ int result = rid_system_validate(&system); if (result != RID_SUCCESS) { printf("Validation failed: %s\n", rid_error_to_string(result)); return 1; } /* Read back values */ printf("Op Location: %s\n", rid_operator_location_type_to_string( rid_system_get_operator_location_type(&system))); printf("Class Type: %s\n", rid_classification_type_to_string( rid_system_get_classification_type(&system))); printf("UA Category: %s\n", rid_ua_classification_category_to_string( rid_system_get_ua_classification_category(&system))); printf("UA Class: %s\n", rid_ua_classification_class_to_string( rid_system_get_ua_classification_class(&system))); printf("Op Lat: %.6f\n", rid_system_get_operator_latitude(&system)); printf("Op Lon: %.6f\n", rid_system_get_operator_longitude(&system)); printf("Area Radius: %u m\n", rid_system_get_area_radius(&system)); /* Export as JSON */ rid_system_to_json(&system, json, sizeof(json)); printf("JSON: %s\n", json); return 0; } /* Output: Op Location: RID_OPERATOR_LOCATION_TYPE_TAKEOFF Class Type: RID_CLASSIFICATION_TYPE_EUROPEAN_UNION UA Category: RID_UA_CLASSIFICATION_CATEGORY_OPEN UA Class: RID_UA_CLASSIFICATION_CLASS_1 Op Lat: 60.287032 Op Lon: 24.539719 Area Radius: 100 m */ ``` -------------------------------- ### Initialize and Use Basic ID Message (C) Source: https://context7.com/tuupola/librid/llms.txt Demonstrates initializing, configuring, validating, and exporting a Basic ID Remote ID message. Ensure the necessary headers are included and the library functions are available. ```c #include #include "rid/basic_id.h" int main(void) { rid_basic_id_t basic_id; char uas_id[21]; char json[255]; /* Initialize and configure Basic ID message */ 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"); /* Validate the message */ int result = rid_basic_id_validate(&basic_id); if (result != RID_SUCCESS) { printf("Validation failed: %s\n", rid_error_to_string(result)); return 1; } /* Read back values */ rid_basic_id_type_t id_type = rid_basic_id_get_type(&basic_id); rid_ua_type_t ua_type = rid_basic_id_get_ua_type(&basic_id); rid_basic_id_get_uas_id(&basic_id, uas_id, sizeof(uas_id)); printf("ID Type: %s\n", rid_basic_id_type_to_string(id_type)); printf("UA Type: %s\n", rid_ua_type_to_string(ua_type)); printf("UAS ID: %s\n", uas_id); /* Export as JSON */ rid_basic_id_to_json(&basic_id, json, sizeof(json)); printf("JSON: %s\n", json); return 0; } /* Output: ID Type: RID_ID_TYPE_SERIAL_NUMBER UA Type: RID_UA_TYPE_HELICOPTER_OR_MULTIROTOR UAS ID: 1ABCD2345EF678XYZ */ ``` -------------------------------- ### Manage Authentication Data (0x02) Source: https://github.com/tuupola/librid/blob/master/README.md Initializes and validates authentication data for verifying UA identity. Ensure the signature buffer is correctly sized before retrieval. ```c rid_auth_t auth; uint8_t signature[64]; uint8_t retrieved[64]; char json[512]; rid_auth_init(&auth); rid_auth_set_type(&auth, RID_AUTH_TYPE_UAS_ID_SIGNATURE); rid_auth_set_timestamp(&auth, 3600); rid_auth_set_unixtime(&auth, (uint32_t)time(NULL)); rid_auth_set_signature(&auth, signature, sizeof(signature)); rid_auth_validate(&auth); rid_auth_type_t auth_type = rid_auth_get_type(&auth); uint32_t timestamp = rid_auth_get_timestamp(&auth); uint32_t unixtime = rid_auth_get_unixtime(&auth); uint8_t page_count = rid_auth_get_page_count(&auth); uint8_t length = rid_auth_get_length(&auth); rid_auth_get_signature(&auth, retrieved, sizeof(retrieved)); const char *auth_type_string = rid_auth_type_to_string(auth_type); rid_auth_to_json(&auth, json, sizeof(json)); ``` -------------------------------- ### Initialize and Configure Self ID Message (C) Source: https://context7.com/tuupola/librid/llms.txt Initializes a Self ID message, sets a text description, validates the message, and prints its details and JSON representation. Ensure the description fits within the buffer size. ```c #include #include "rid/self_id.h" int main(void) { rid_self_id_t self_id; char description[24]; char json[256]; /* Initialize and configure Self ID message */ rid_self_id_init(&self_id); rid_self_id_set_description_type(&self_id, RID_DESCRIPTION_TYPE_TEXT); rid_self_id_set_description(&self_id, "Drone delivery test"); /* Validate the message */ int result = rid_self_id_validate(&self_id); if (result != RID_SUCCESS) { printf("Validation failed: %s\n", rid_error_to_string(result)); return 1; } /* Read back values */ rid_description_type_t desc_type = rid_self_id_get_description_type(&self_id); rid_self_id_get_description(&self_id, description, sizeof(description)); printf("Type: %s\n", rid_description_type_to_string(desc_type)); printf("Description: %s\n", description); /* Export as JSON */ rid_self_id_to_json(&self_id, json, sizeof(json)); printf("JSON: %s\n", json); return 0; } /* Output: Type: RID_DESCRIPTION_TYPE_TEXT Description: Drone delivery test */ ``` -------------------------------- ### Generic Message Handling in C Source: https://context7.com/tuupola/librid/llms.txt Demonstrates how to use generic functions to detect message types, validate messages, and export them to JSON regardless of the specific message structure. ```c #include #include "rid/message.h" #include "rid/basic_id.h" #include "rid/location.h" int main(void) { rid_basic_id_t basic_id; rid_location_t location; char json[512]; rid_basic_id_init(&basic_id); rid_location_init(&location); /* Generic message type detection */ rid_message_type_t type1 = rid_message_get_type(&basic_id); rid_message_type_t type2 = rid_message_get_type(&location); printf("Type 1: %s\n", rid_message_type_to_string(type1)); printf("Type 2: %s\n", rid_message_type_to_string(type2)); /* Generic protocol version detection */ rid_protocol_version_t ver = rid_message_get_protocol_version(&basic_id); printf("Protocol: %s\n", rid_protocol_version_to_string(ver)); /* Generic validation (dispatches to type-specific validator) */ int result = rid_message_validate(&basic_id); printf("Validation: %s\n", rid_error_to_string(result)); /* Generic JSON export (dispatches to type-specific serializer) */ rid_message_to_json(&basic_id, json, sizeof(json)); printf("JSON: %s\n", json); return 0; } ``` -------------------------------- ### Initialize and Set Location Message in C Source: https://github.com/tuupola/librid/blob/master/README.md Shows how to initialize a Location message and populate its fields including operational status, height type, coordinates, altitudes, speed, direction, and timestamps. Validation and JSON conversion are also included. ```c rid_location_t location; char json[512]; rid_location_init(&location); rid_location_set_operational_status(&location, RID_OPERATIONAL_STATUS_AIRBORNE); rid_location_set_height_type(&location, RID_HEIGHT_TYPE_ABOVE_TAKEOFF); rid_location_set_latitude(&location, 62.683472); rid_location_set_longitude(&location, 21.974944); rid_location_set_geodetic_altitude(&location, 120.5f); rid_location_set_pressure_altitude(&location, 101.3f); rid_location_set_height(&location, 50.0f); rid_location_set_speed(&location, 15.5f); rid_location_set_vertical_speed(&location, 2.0f); rid_location_set_track_direction(&location, 45); rid_location_set_timestamp(&location, 12345); rid_location_set_unixtime(&location, 1234567890); rid_location_set_horizontal_accuracy(&location, RID_HORIZONTAL_ACCURACY_1M); rid_location_set_vertical_accuracy(&location, RID_VERTICAL_ACCURACY_10M); rid_location_set_speed_accuracy(&location, RID_SPEED_ACCURACY_1MS); rid_location_set_baro_altitude_accuracy(&location, RID_VERTICAL_ACCURACY_3M); rid_location_set_timestamp_accuracy(&location, RID_TIMESTAMP_ACCURACY_0_1S); rid_location_validate(&location); rid_height_type_t height_type = rid_location_get_height_type(&location); rid_operational_status_t status = rid_location_get_operational_status(&location); uint16_t direction = rid_location_get_track_direction(&location); float speed = rid_location_get_speed(&location); float vspeed = rid_location_get_vertical_speed(&location); double latitude = rid_location_get_latitude(&location); double longitude = rid_location_get_longitude(&location); float pressure_altitude = rid_location_get_pressure_altitude(&location); float geodetic_altitude = rid_location_get_geodetic_altitude(&location); float height = rid_location_get_height(&location); rid_horizontal_accuracy_t h_accuracy = rid_location_get_horizontal_accuracy(&location); rid_vertical_accuracy_t v_accuracy = rid_location_get_vertical_accuracy(&location); rid_speed_accuracy_t s_accuracy = rid_location_get_speed_accuracy(&location); rid_vertical_accuracy_t baro_accuracy = rid_location_get_baro_altitude_accuracy(&location); uint16_t timestamp = rid_location_get_timestamp(&location); rid_timestamp_accuracy_t ts_accuracy = rid_location_get_timestamp_accuracy(&location); const char *height_type_string = rid_height_type_to_string(height_type); const char *status_string = rid_operational_status_to_string(status); const char *horizontal_accuracy_string = rid_horizontal_accuracy_to_string(h_accuracy); const char *vertical_accuracy_string = rid_vertical_accuracy_to_string(v_accuracy); const char *speed_accuracy_string = rid_speed_accuracy_to_string(s_accuracy); const char *timestamp_accuracy_string = rid_timestamp_accuracy_to_string(ts_accuracy); rid_location_to_json(&location, json, sizeof(json)); ``` -------------------------------- ### Initialize and Configure Auth Message Source: https://context7.com/tuupola/librid/llms.txt Initializes an Auth message, sets the authentication type, timestamp, and signature, validates the message, and exports it to JSON. A placeholder signature is used; replace with actual cryptographic signature in production. ```c #include #include #include #include "rid/auth.h" int main(void) { rid_auth_t auth; uint8_t signature[64]; /* Ed25519 signature size */ uint8_t retrieved[64]; char json[512]; /* Create a sample signature (in practice, use crypto library) */ memset(signature, 0xAB, sizeof(signature)); /* Initialize and configure Auth message */ rid_auth_init(&auth); rid_auth_set_type(&auth, RID_AUTH_TYPE_UAS_ID_SIGNATURE); rid_auth_set_unixtime(&auth, (uint32_t)time(NULL)); rid_auth_set_signature(&auth, signature, sizeof(signature)); /* Validate the message */ int result = rid_auth_validate(&auth); if (result != RID_SUCCESS) { printf("Validation failed: %s\n", rid_error_to_string(result)); return 1; } /* Read back values */ rid_auth_type_t auth_type = rid_auth_get_type(&auth); uint32_t timestamp = rid_auth_get_timestamp(&auth); uint8_t page_count = rid_auth_get_page_count(&auth); uint8_t length = rid_auth_get_length(&auth); rid_auth_get_signature(&auth, retrieved, sizeof(retrieved)); printf("Auth Type: %s\n", rid_auth_type_to_string(auth_type)); printf("Timestamp: %u (seconds since 2019-01-01)\n", timestamp); printf("Page Count: %u\n", page_count); printf("Sig Length: %u bytes\n", length); /* Export as JSON */ rid_auth_to_json(&auth, json, sizeof(json)); printf("JSON: %s\n", json); return 0; } /* Output: Auth Type: RID_AUTH_TYPE_UAS_ID_SIGNATURE Timestamp: Page Count: 4 Sig Length: 64 bytes */ ``` -------------------------------- ### Format JSON output with jq Source: https://github.com/tuupola/librid/blob/master/examples/json/README.md Pipe the output of the make command into jq to prettify the JSON structure. ```bash $ make run | jq . ``` -------------------------------- ### Initialize and Configure Location Message Source: https://context7.com/tuupola/librid/llms.txt Initializes a Location message, sets various parameters including status, altitude, position, speed, and accuracy, validates the message, and exports it to JSON. Ensure all required fields are set before validation. ```c #include #include "rid/location.h" int main(void) { rid_location_t location; char json[512]; /* Initialize and configure Location message */ rid_location_init(&location); rid_location_set_operational_status(&location, RID_OPERATIONAL_STATUS_AIRBORNE); rid_location_set_height_type(&location, RID_HEIGHT_TYPE_ABOVE_TAKEOFF); rid_location_set_latitude(&location, 62.683472); rid_location_set_longitude(&location, 21.974944); rid_location_set_geodetic_altitude(&location, 120.5f); rid_location_set_pressure_altitude(&location, 101.3f); rid_location_set_height(&location, 50.0f); rid_location_set_speed(&location, 15.5f); rid_location_set_vertical_speed(&location, 2.0f); rid_location_set_track_direction(&location, 45); rid_location_set_timestamp(&location, 12345); rid_location_set_horizontal_accuracy(&location, RID_HORIZONTAL_ACCURACY_10M); rid_location_set_vertical_accuracy(&location, RID_VERTICAL_ACCURACY_10M); rid_location_set_speed_accuracy(&location, RID_SPEED_ACCURACY_1MS); rid_location_set_baro_altitude_accuracy(&location, RID_VERTICAL_ACCURACY_3M); rid_location_set_timestamp_accuracy(&location, RID_TIMESTAMP_ACCURACY_0_1S); /* Validate the message */ int result = rid_location_validate(&location); if (result != RID_SUCCESS) { printf("Validation failed: %s\n", rid_error_to_string(result)); return 1; } /* Read back values */ printf("Status: %s\n", rid_operational_status_to_string( rid_location_get_operational_status(&location))); printf("Latitude: %.6f\n", rid_location_get_latitude(&location)); printf("Longitude: %.6f\n", rid_location_get_longitude(&location)); printf("Altitude: %.1f m\n", (double)rid_location_get_geodetic_altitude(&location)); printf("Speed: %.1f m/s\n", (double)rid_location_get_speed(&location)); printf("Direction: %u deg\n", rid_location_get_track_direction(&location)); printf("H Accuracy: %s\n", rid_horizontal_accuracy_to_string( rid_location_get_horizontal_accuracy(&location))); /* Export as JSON */ rid_location_to_json(&location, json, sizeof(json)); printf("JSON: %s\n", json); return 0; } /* Output: Status: RID_OPERATIONAL_STATUS_AIRBORNE Latitude: 62.683472 Longitude: 21.974944 Altitude: 120.5 m Speed: 15.5 m/s Direction: 45 deg H Accuracy: RID_HORIZONTAL_ACCURACY_10M */ ``` -------------------------------- ### Initialize and Set Basic ID Message in C Source: https://github.com/tuupola/librid/blob/master/README.md Demonstrates initializing a Basic ID message structure and setting its identification type, UAS type, and UAS ID. Use the provided setter functions instead of direct struct member access. ```c rid_basic_id_t basic_id; char uas_id[21]; char json[255]; 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"); rid_basic_id_validate(&basic_id); rid_basic_id_type_t id_type = rid_basic_id_get_type(&basic_id); rid_ua_type_t ua_type = rid_basic_id_get_ua_type(&basic_id); rid_basic_id_get_uas_id(&basic_id, uas_id, sizeof(uas_id)); const char *id_type_string = rid_basic_id_type_to_string(id_type); const char *ua_type_string = rid_ua_type_to_string(ua_type); rid_basic_id_to_json(&basic_id, json, sizeof(json)); ``` -------------------------------- ### Accessing Transport Constants in C Source: https://context7.com/tuupola/librid/llms.txt Shows how to retrieve ASTM F3411 transport payload limits and iterate through transport type enumerations. ```c #include #include "rid/transport.h" int main(void) { /* Transport payload limits */ printf("Bluetooth Legacy max payload: %d bytes\n", RID_TRANSPORT_BLUETOOTH_LEGACY_MAX_PAYLOAD); printf("Bluetooth Long Range max payload: %d bytes\n", RID_TRANSPORT_BLUETOOTH_LONG_RANGE_MAX_PAYLOAD); printf("Wi-Fi NAN max payload: %d bytes\n", RID_TRANSPORT_WIFI_NAN_MAX_PAYLOAD); printf("Wi-Fi Beacon max payload: %d bytes\n", RID_TRANSPORT_WIFI_BEACON_MAX_PAYLOAD); /* Transport type enumeration */ for (int i = 0; i <= RID_TRANSPORT_MAX; i++) { printf("Transport %d: %s\n", i, rid_transport_to_string(i)); } return 0; } ``` -------------------------------- ### Manage Self ID (0x03) Source: https://github.com/tuupola/librid/blob/master/README.md Configures operator identity or flight purpose descriptions. Note that the description buffer must accommodate the string length. ```c rid_self_id_t self_id; char description[24]; char json[256]; rid_self_id_init(&self_id); rid_self_id_set_description_type(&self_id, RID_DESCRIPTION_TYPE_TEXT); rid_self_id_set_description(&self_id, "Drone delivery test"); rid_self_id_validate(&self_id); rid_description_type_t description_type = rid_self_id_get_description_type(&self_id); rid_self_id_get_description(&self_id, description, sizeof(description)); const char *description_type_string = rid_description_type_to_string(desc_type); rid_self_id_to_json(&self_id, json, sizeof(json)); ``` -------------------------------- ### Configure CMake for Test Runner Source: https://github.com/tuupola/librid/blob/master/tests/CMakeLists.txt Defines the test_runner executable, sets include directories, compiler options, and links the rid library. ```cmake add_executable(test_runner unit.c test_message.c test_basic_id.c test_operator_id.c test_location.c test_self_id.c test_system.c test_message_pack.c test_auth_page.c test_auth.c test_transport.c ) target_include_directories(test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_options(test_runner PRIVATE -Werror=double-promotion) target_link_libraries(test_runner rid) add_test(NAME unit_tests COMMAND test_runner) ``` -------------------------------- ### Decode Bluetooth Data with btmon and grep Source: https://github.com/tuupola/librid/blob/master/examples/cli/README.md Use btmon to capture Bluetooth traffic, grep to filter for relevant Remote ID data (UUID 0xfffa), extract the hex data, and pipe it to the librid CLI for decoding. ```bash $ sudo btmon | grep -i -A 1 "0xfffa" | grep -oP '^\s+Data: \K[0-9a-f]+' | ./rid | jq ``` -------------------------------- ### Manage System Information (0x04) Source: https://github.com/tuupola/librid/blob/master/README.md Handles remote pilot location, operating area, and aircraft classification data. Requires precise coordinate and altitude inputs. ```c rid_system_t system; char json[512]; rid_system_init(&system); rid_system_set_operator_location_type(&system, RID_OPERATOR_LOCATION_TYPE_TAKEOFF); rid_system_set_classification_type(&system, RID_CLASSIFICATION_TYPE_EUROPEAN_UNION); rid_system_set_ua_classification_category(&system, RID_UA_CLASSIFICATION_CATEGORY_OPEN); rid_system_set_ua_classification_class(&system, RID_UA_CLASSIFICATION_CLASS_1); rid_system_set_operator_latitude(&system, 60.2870324); rid_system_set_operator_longitude(&system, 24.5397187); rid_system_set_operator_altitude(&system, 50.0f); rid_system_set_area_count(&system, 1); rid_system_set_area_radius(&system, 100); rid_system_set_area_ceiling(&system, 120.0f); rid_system_set_area_floor(&system, 0.0f); rid_system_set_timestamp(&system, 3600); rid_system_set_unixtime(&system, 1234567890); rid_system_validate(&system); rid_operator_location_type_t operator_location_type = rid_system_get_operator_location_type(&system); rid_classification_type_t classification_type = rid_system_get_classification_type(&system); rid_ua_classification_category_t ua_category = rid_system_get_ua_classification_category(&system); rid_ua_classification_class_t ua_class = rid_system_get_ua_classification_class(&system); double operator_latitude = rid_system_get_operator_latitude(&system); double operator_longitude = rid_system_get_operator_longitude(&system); float operator_altitude = rid_system_get_operator_altitude(&system); uint16_t area_count = rid_system_get_area_count(&system); uint16_t area_radius = rid_system_get_area_radius(&system); float area_ceiling = rid_system_get_area_ceiling(&system); float area_floor = rid_system_get_area_floor(&system); uint32_t timestamp = rid_system_get_timestamp(&system); uint32_t unixtime = rid_system_get_unixtime(&system); const char *operator_location_type_string = rid_operator_location_type_to_string(operator_location_type); const char *classification_type_string = rid_classification_type_to_string(classification_type); const char *ua_category_string = rid_ua_classification_category_to_string(ua_category); const char *ua_class_string = rid_ua_classification_class_to_string(ua_class); rid_system_to_json(&system, json, sizeof(json)); ``` -------------------------------- ### Librid System Output Source: https://github.com/tuupola/librid/blob/master/examples/system/README.md Displays the raw hexadecimal output and the parsed protocol data fields. ```text 42 04 34 12 ef 23 c3 76 a0 0e 01 00 0a c0 08 d0 07 12 34 08 10 0e 00 00 00 Protocol version: 2 Message type: 4 Operator loc type: 0 Classification: 1 Operator latitude: 60.287032 Operator longitude: 24.539719 Area count: 1 Area radius: 100 m Area ceiling: 120.0 m Area floor: 0.0 m UA class: 2 UA category: 1 Operator altitude: 50.0 m Timestamp: 3600 Unixtime: 1546304400 ``` -------------------------------- ### Librid Auth Page Output Source: https://github.com/tuupola/librid/blob/master/examples/auth_page/README.md The output displays data for multiple pages, including hexadecimal byte sequences, authentication types, page indices, lengths, and timestamps. This data represents the raw output from the authentication process. ```text Page 0: 22 30 02 38 80 86 48 0b 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 Auth type: 3 Last page index: 2 Length: 56 Timestamp: 189302400 Page 1: 22 31 05 00 03 82 01 0f 00 30 82 01 0a 02 82 01 01 00 bb 6a 8c 7e 5f 2a 9b Auth type: 3 Page number: 1 Page 2: 22 32 c5 7b 99 3a 1d 03 66 81 f4 9e 2c 87 ab 4f e0 12 00 00 00 00 00 00 00 Auth type: 3 Page number: 2 ``` -------------------------------- ### Create and Validate Operator ID Message Source: https://context7.com/tuupola/librid/llms.txt Initializes, configures, and validates an Operator ID message. Ensure the ID string is correctly formatted and within the allowed length. ```c #include #include "rid/operator_id.h" int main(void) { rid_operator_id_t operator_id; char id[21]; char json[256]; /* Initialize and configure Operator ID message */ rid_operator_id_init(&operator_id); rid_operator_id_set_type(&operator_id, RID_ID_TYPE_OPERATOR_ID); rid_operator_id_set(&operator_id, "FIN87astrdge12k8"); /* Validate the message */ int result = rid_operator_id_validate(&operator_id); if (result != RID_SUCCESS) { printf("Validation failed: %s\n", rid_error_to_string(result)); return 1; } /* Read back values */ rid_operator_id_type_t id_type = rid_operator_id_get_type(&operator_id); rid_operator_id_get(&operator_id, id, sizeof(id)); printf("ID Type: %s\n", rid_operator_id_type_to_string(id_type)); printf("Operator ID: %s\n", id); /* Export as JSON */ rid_operator_id_to_json(&operator_id, json, sizeof(json)); printf("JSON: %s\n", json); return 0; } /* Output: ID Type: RID_ID_TYPE_OPERATOR_ID Operator ID: FIN87astrdge12k8 */ ``` -------------------------------- ### Decode Hex String to JSON Source: https://github.com/tuupola/librid/blob/master/examples/cli/README.md Pipe a hex-encoded Remote ID message to the ./rid command and then pipe the output to jq for pretty-printing the JSON. ```bash $ ./rid 12202d3e0420bd5c25401c190d0000c10834084a0339300100 | jq ``` ```bash $ echo "12202d3e0420bd5c25401c190d0000c10834084a0339300100" | ./rid | jq ``` -------------------------------- ### Librid JSON output format Source: https://github.com/tuupola/librid/blob/master/examples/json/README.md The raw JSON structure returned by the *_to_json() functions. ```json {"protocol_version": 2, "message_type": 15, "message_count": 4, "messages": [...]} ``` -------------------------------- ### Capture and Decode with tshark using stdbuf Source: https://github.com/tuupola/librid/blob/master/examples/cli/README.md Use stdbuf to manage output buffering for tshark when capturing Bluetooth Remote ID data. This can help prevent data loss or delays in the stream piped to the librid CLI. ```bash $ stdbuf -oL tshark -i bluetooth-monitor \ -Y "btcommon.eir_ad.entry.uuid_16 == 0xfffa" \ -T fields -e btcommon.eir_ad.entry.service_data | \ ./rid | jq ``` -------------------------------- ### Capture and Decode Bluetooth Remote ID Data with tshark Source: https://github.com/tuupola/librid/blob/master/examples/cli/README.md Capture Bluetooth LE advertising data containing Remote ID service data using tshark, filter for the specific UUID, and pipe the output to the librid CLI for decoding. ```bash $ tshark -q -l -i bluetooth-monitor \ -Y "btcommon.eir_ad.entry.uuid_16 == 0xfffa" \ -T fields -e btcommon.eir_ad.entry.service_data | \ ./rid | jq ``` -------------------------------- ### Librid Self ID Output Source: https://github.com/tuupola/librid/blob/master/examples/self_id/README.md Displays the hexadecimal output and metadata for the drone delivery test. ```text 32 00 44 72 6f 6e 65 20 64 65 6c 69 76 65 72 79 20 74 65 73 74 00 00 00 00 Description: Drone delivery test Type: 0 ``` -------------------------------- ### Manage Operator ID (0x05) Source: https://github.com/tuupola/librid/blob/master/README.md Registers CAA-issued operator or pilot IDs. Ensure the ID buffer is large enough for the registration string. ```c rid_operator_id_t operator_id; char id[21]; char json[256]; rid_operator_id_init(&operator_id); rid_operator_id_set_type(&operator_id, RID_ID_TYPE_OPERATOR_ID); rid_operator_id_set(&operator_id, "FIN87astrdge12k8"); rid_operator_id_validate(&operator_id); rid_operator_id_type_t id_type = rid_operator_id_get_type(&operator_id); rid_operator_id_get(&operator_id, id, sizeof(id)); const char *id_type_string = rid_operator_id_type_to_string(id_type); rid_operator_id_to_json(&operator_id, json, sizeof(json)); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.