Open Drone ID Core C Library

repository·master·Indexed 43 days ago

https://github.com/opendroneid/opendroneid-core-c

A C library for encoding and decoding Open Drone ID messages. It implements standards for broadcasting Remote ID information via Bluetooth or Wi-Fi, including ASTM F3411, ASD-STAN prEN 4709-002, and the broadcast mode of the GB 46750-2025 standard for Civil Unmanned Aircraft System Operational Identification.

Tokens
4.6K
Snippets
6
Records
18
Agent score
57%

What's inside Open Drone ID

  1. Overview of GB 46750-2025 Broadcast Remote ID Protocol

    master

    The opendroneid-core-c library implements the broadcast mode (广播模式) of the GB 46750-2025 standard for Civil Unmanned Aircraft System Operational Identification.

    Key Characteristics

    • Protocol Independence: This implementation is independent of ASTM F3411 and uses its own wire format, field set, and transmission rules.
    • Compliance Scope: This library covers broadcast mode only. Full compliance with GB 46750-2025 requires both broadcast mode (§5.2) and network mode (§5.3). Manufacturers must implement network mode and meet hardware/firmware requirements (e.g., transmission interval $\le$ 1s, antenna placement, 10s shutdown grace period) separately.
    • Supported RF Methods:
      • Bluetooth 5.0 and above
      • Wi-Fi (2.4 GHz / 5.8 GHz)
  2. Understand Remote ID regional specifications and compliance

    master

    The opendroneid-core-c library supports multiple regional Remote ID standards. Developers should choose the implementation based on the target operating region:

    United States

    Follows ASTM F3411 (v1.0 and v1.1) and the ASTM F3586 Means of Compliance (MoC). The FAA accepts the F3586 MoC as an acceptable means of demonstrating compliance. Key requirements include mandatory transmission of UA dynamic position, track direction, and horizontal speed.

    European Union

    Complies with ASD-STAN prEN 4709-002 Direct Remote Identification, which is designed to meet EU Commission Regulations 2019/945 and 2019/947. It is compatible with ASTM F3411 v1.1.

    Japan

    Requires broadcast Remote ID. Key characteristics include:

    • Mandatory use of both Serial Number and a Civil Aviation Authority provisioned ID.
    • Mandatory transmission of two Basic ID messages.
    • Mandatory Authentication messages (signatures).
    • Bluetooth 5 Long Range is a mandatory transmit method.

    China

    Uses the GB 46750-2025 standard, which is an independent protocol and is not wire-compatible with ASTM F3411.

    • It requires both a 20-character serial number and an 8-character real-name registration ID (UIN).
    • Mandatory operator/GCS location and GNSS accuracy levels.
    • Implementation is found in the libopendroneidcn/ repository.
  3. Understand differences between GB 46750-2025 and ASTM F3411

    master

    GB 46750-2025 is not wire-compatible with ASTM F3411. If you are building a receiver or transmitter, you must implement the specific protocol requirements for the target standard.

    Key architectural differences include:

    • Wire Format: ASTM F3411 uses 6 message types with 25-byte fixed lengths. GB 46750-2025 uses a single variable-length packet with a flag-bitmask chain.
    • Identity: ASTM F3411 uses either a Serial Number or Session ID. GB 46750-2025 requires both the Serial Number (SN) and the Unique Identification Number (UIN/registration ID).
    • Operator Location: Optional in ASTM F3411, but mandatory in GB 46750-2025 (including GCS position, type, and altitude).
    • Accuracy Reporting: GB 46750-2025 defines 4 specific accuracy levels (horizontal, vertical, speed, and timestamp).
    • Broadcast Transport: ASTM F3411 supports BT4, BT5, Wi-Fi NaN, and Wi-Fi Beacon. GB 46750-2025 supports Bluetooth 5.0+ and Wi-Fi (2.4 GHz / 5.8 GHz).
    • Coordinate Systems: ASTM F3411 uses WGS-84 only. GB 46750-2025 supports both WGS-84 and CGCS2000.
    • Drone Classification: GB 46750-2025 mandates drone classification (Micro to Large).
  4. Protocol versions for ASTM F3411 and ASD-STAN

    master

    The Remote ID protocol version is transmitted in the header of each message. The following versions are supported:

    Changes in Version 2 compared to Version 1:

    • New enum values: ODID_STATUS_REMOTE_ID_SYSTEM_FAILURE, ODID_DESC_TYPE_EMERGENCY, and ODID_DESC_TYPE_EXTENDED_STATUS.
    • New Timestamp field in the System message.
  5. GB 46750-2025 Packet Format Structure

    master

    GB 46750-2025 broadcast-mode RID packets use a flag-bitmask chain structure rather than TLV tags. The packet is composed of a header, a variable-length flag region, and a data region.

    Packet Layout

    OffsetFieldSizeDescription
    0Type1 byteAlways 0xFF
    1Version1 byteBits 7–5: Major version (001 for V1). Bits 4–0: Sub-version (0–31).
    2DataLen1 byteByte count of data content items (1–200), excluding flags.
    3...Flags1–3 bytesVariable-length flag bytes chained via bit 0.
    3+N...DataN bytesConcatenated field values in ascending field-ID order.

    Flag Chain Rules

    • Content Flags: Bits 1–7 of each flag byte signal the presence of specific fields.
    • Extension Flag: Bit 0 (LSB, 0x01) of a flag byte indicates if the chain continues. 1 means the next byte is also a flag byte; 0 means the flag region has ended.
    • Data Mapping: Omitted fields (where the flag bit is 0) consume zero bytes in the data region.
    ┌──────────┬──────────┬──────────┬───────────────────┬──────────────────────┐
    │  Type    │ Version  │ DataLen  │   Flag Bytes      │     Data             │
    │  1 byte  │ 1 byte   │ 1 byte   │   1–3 bytes       │   N bytes (≤200)     │
    │  0xFF    │          │  1–200   │                   │                      │
    └──────────┴──────────┴──────────┴───────────────────┴──────────────────────┘
  6. How Open Drone ID data encoding and decoding works

    master

    The SDK operates using two distinct types of data structures: nominal (non-encoded) structures and encoded structures.

    1. Nominal Data (*_data): These are the human-readable/logical representations of the information (e.g., ODID_BasicID_data). You populate these structures with the actual information you want to transmit.
    2. Encoded Data (*_encoded): These are the serialized formats ready for transmission (e.g., ODID_BasicID_encoded).

    Workflow for Transmitters: Populate a *_data structure $\rightarrow$ Call an encode* function $\rightarrow$ Transmit the resulting *_encoded data over a broadcast method (Bluetooth, Wi-Fi, etc.).

    Workflow for Receivers: Receive *_encoded data $\rightarrow$ Call a decode* function $\rightarrow$ Access the information via the resulting *_data structure.

    // Example workflow logic
    ODID_BasicID_data myData = { ... };
    ODID_BasicID_encoded myEncoded;
    
    // Encoding for transmission
    int status = encodeBasicIDMessage(&myEncoded, &myData);
    
    // Decoding after reception
    ODID_BasicID_data receivedData;
    status = decodeBasicIDMessage(&receivedData, &myEncoded);
  7. Implement China's GB 46750-2025 Remote ID protocol

    master

    For compliance with China's national standard (effective 2026-05-01), do not use the standard opendroneid-core-c ASTM-based implementation as it is not wire-compatible. Instead, use the libopendroneidcn/ library.

    Key Protocol Differences for GB 46750-2025:

    • Wire Format: Uses a flag-bitmask chain instead of fixed 25-byte message types.
    • Mandatory IDs: Requires both a 20-character serial number and an 8-character real-name registration ID (UIN).
    • Mandatory Data: Operator/GCS location (position, altitude, type) and GNSS accuracy levels (horizontal, vertical, speed, and timestamp) are required.
    • Transmission: Uses Bluetooth 5.0+ and Wi-Fi (2.4 GHz / 5.8 GHz).
    • Coordinate Systems: Supports both WGS-84 and CGCS2000.
  8. Run tests for opendroneid-core-c

    master

    After building, you can run the provided test systems to check for regressions. Two types of simple test systems are available:

    1. test/odidtest: A sample application that performs a test encode/decode and then continuously generates sample messages.
    2. ctest .: Runs the CTest suite.

    Successful builds will produce libopendroneid/libopendroneid.so, the test/odidtest sample application, and the test/unit_odid_wifi_beacon test.

    test/odidtest
    ctest .
  9. Build the opendroneid-core-c library on Linux

    master

    To build the library, sample applications, and unit tests on a Linux system, ensure you have the necessary dependencies installed, initialize submodules, and use CMake.

    Dependencies:

    • libgps-dev
    • libnl-genl-3-dev
    • libgtest-dev
    • cmake

    Build Steps:

    1. Install dependencies via apt-get.
    2. Initialize git submodules.
    3. Create a build directory and run cmake and make.
    sudo apt-get install libgps-dev libnl-genl-3-dev libgtest-dev cmake
    git submodule update --init
    mkdir build && cd build
    cmake ../.
    make -j
  10. Configure MAVLink and Wi-Fi build options

    master

    The build process includes support for MAVLink and Wi-Fi NaN by default. You can toggle these features using CMake flags.

    • MAVLink: To disable MAVLink support, use -DBUILD_MAVLINK=off. Note that enabling it requires mavlink_c_library_v2 to be installed in the respective folder.
    • Wi-Fi NaN: To disable the Wi-Fi NaN example implementation, use -DBUILD_WIFI=off. Enabling it requires libgps, libnl-3, and libnl-genl-3.
    # Disable MAVLink
    cmake -DBUILD_MAVLINK=off .
    
    # Disable Wi-Fi
    cmake -DBUILD_WIFI=off .