diff --git a/CMakeLists.txt b/CMakeLists.txt index 7968270..c95a513 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2 -fstack-protector \ -fno-delete-null-pointer-checks -fwrapv -O0 -Wall -Wdouble-promotion \ -Wno-address-of-packed-member") -cmake_minimum_required(VERSION 2.6.3) +cmake_minimum_required(VERSION 2.8.12) option(BUILD_MAVLINK "Build with mavlink support" ON) option(BUILD_WIFI "Build with WiFi support" ON) diff --git a/README.md b/README.md index a0d6950..454a0c6 100644 --- a/README.md +++ b/README.md @@ -2,48 +2,57 @@ ## Open Drone ID Core C Library -This provides a function library for encoding and decoding (packing/unpacking) Open Drone ID messages as the format is defined in the ASTM Remote ID standard available [here](https://www.astm.org/Standards/F3411.htm). -The code is also compatible with the upcoming European ASD-STAN Direct Remote ID standard. -This latter standard has not yet been published, but some preliminary information can be found in this [white paper](https://asd-stan.org/wp-content/uploads/ASD-STAN_DRI_Introduction_to_the_European_digital_RID_UAS_Standard.pdf) and in the recording of this [webinar](https://www.cencenelec.eu/news/events/Pages/EV-2021-15.aspx). -An early draft of the standard is available [here](https://asd-stan.org/downloads/din-en-4709-0022021-02/). +This repository provides a C-code function library for encoding and decoding (packing/unpacking) Open Drone ID messages, as the format is defined in the ASTM F3411 Remote ID and the ASD-STAN prEN 4709-002 Direct Remote ID specifications. +See further details in the [specifications](#relevant-specifications) section below. -Please note that both standards have been updated during the first half of 2021 and the updated documents are not yet published (August 2021). -However, this implementation is already compliant with these updates. +Please note that both specifications have been updated during the first half of 2021 and the updated documents are not yet published (September 2021). +However, this implementation is already compliant with these updates. The opendroneid-core-c code is meant for implementations that will broadcast the Remote ID information via Bluetooth or WiFi. If you are looking for code related to Network Remoted ID (via the internet), please take a look at https://github.com/interuss and https://github.com/uastech/standards. -Work is ongoing by the IETF DRIP (Drone Remote ID Protocol) task force to define how security could be supported in the context of the ASTM Remote ID standard: +Work is ongoing by the IETF DRIP (Drone Remote ID Protocol) task force to define how security could be supported in the context of the ASTM Remote ID specification: https://datatracker.ietf.org/wg/drip/documents/ and https://github.com/ietf-wg-drip. MAVLink messages for drone ID are available at https://mavlink.io/en/messages/common.html#OPEN_DRONE_ID_BASIC_ID and documentation on how to use them is available at https://mavlink.io/en/services/opendroneid.html. ## Receiver examples +### Android For an example Android receiver application supporting Bluetooth and WiFi, see https://github.com/opendroneid/receiver-android. +### iOS +Currently there is no open source iOS receiver application for Apple devices. +However, reception of Bluetooth 4 Legacy Advertising drone ID signals have been demonstrated to work on iOS. +Apple currently does not expose suitable APIs to receive any other transmission method for drone ID signals than BT4 legacy advertising. I.e. current versions of iOS (up to and including 15) do not support receiving BT5 Long Range + Extended Advertising, Wi-Fi NaN nor Wi-Fi Beacon. + +### WireShark Examples on how to use the WireShark PC application to pick up and dissect open drone ID messages are available here: https://github.com/opendroneid/wireshark-dissector. ## Transmitter examples +### ESP32 An example library for transmitting Open Drone ID signals from ESP32 HW can be found at https://github.com/sxjack/uav_electronic_ids. The implementation supports simultaneous transmission via Bluetooth Legacy Advertising, WiFi NaN and WiFi Beacon. + Please note that the ESP32 HW only supports transmitting Bluetooth Legacy Advertising signals. Bluetooth Long Range and Extended Advertising are not supported. Please check if this is sufficient to comply with the rules that apply in the area in which you are flying. -The [ESP32-C3](https://www.espressif.com/en/news/ESP32_C3) and [ESP32-S3](https://www.espressif.com/en/news/ESP32_S3?position=0&list=_TQH0oNBtbw0KMnMbCVH3ol_jy3McAHwrsqIZcX6XjM) chips will both support Long Range and Extended Advertising but this has not yet been tested. +The [ESP32-C3](https://www.espressif.com/en/news/ESP32_C3) and [ESP32-S3](https://www.espressif.com/en/news/ESP32_S3) chips will both support Long Range and Extended Advertising but this has not yet been tested. +### Linux A WiFi NaN transmitter implementation for Linux is available [here](https://github.com/opendroneid/opendroneid-core-c/blob/master/wifi/sender/main.c). Better documentation is needed on what exact HW + SW environment this is functional. A description of some very preliminary experiments using bluez and hostapd to transmit BT4 and WiFi Beacon drone ID signals from a Linux PC or Raspberry Pi can be found [here](https://github.com/opendroneid/opendroneid-core-c/issues/42). Contributions to create fully functional transmitter implementations are very welcome. +### nRF and TI Bluetooth chipsets Transmitter implementations for Bluetooth 4 and 5, based on either the TI CC2640 or the nRF52480 SoCs are known to exists but so far none have been open sourced. Please open an issue if you have an implementation you are willing to share. A new repository under opendroneid can be made. ## How to Build -To build the library and the sample app: +To build the library and the sample app on Linux: ``` sudo apt-get install libgps-dev libnl-genl-3-dev @@ -159,5 +168,77 @@ https://mavlink.io/en/messages/common.html#OPEN_DRONE_ID_BASIC_ID The functions in `mav2odid.c` can be used to convert these MAVLink messages into suitable `opendroneid.h` data structures and back again. See the example usages in `test/test_mav2odid.c`. -Recommendations on how to utilize the MAVLink messages for internal distribution of Open Drone ID data of an Unmanned Aircraft System can be found here: +Recommendations on how to utilize the MAVLink messages for UAS internal distribution of Open Drone ID data of an Unmanned Aircraft System (UAS) can be found here: https://mavlink.io/en/services/opendroneid.html + + +## Relevant specifications + +### United States + +The ASTM F3411 Specification for Remote ID and Tracking has been defined to specify how Unmanned Aircraft (UA) or Unmanned Aircraft Systems (UAS) can publish their ID, location, altitude etc., either via direct broadcast (Bluetooth or Wi-Fi), or via an internet connection to a Remote ID server. + +Version 1.0 (F3411-19) of the specification is currently [available](https://www.astm.org/Standards/F3411.htm). +An updated version 1.1 (F3411-21?) is in the final stages of being finalized (September 2021). +It contains smaller changes/additions to make the message content etc. better suited to meet the [rule](https://www.regulations.gov/document/FAA-2019-1100-53264) defined by the [FAA](https://www.faa.gov/uas/getting_started/remote_id/) (Federal Aviation Administration) for [UAS flights](https://www.faa.gov/uas/commercial_operators/operations_over_people/) in the United States. +Additionally, a Means of Compliance document (MoC) is being drafted by the ASTM, containing further implementation requirements and test specifications. +Together, the two documents will allow manufacturers of UAS and remote ID broadcast modules/Add-ons (for retro-fit on UAs without built-in remote ID support) to implement remote ID support and create the necessary Declaration of Compliance (DoC) document, which must be submitted to the FAA for approval. + +### European Union + +To meet the European Commission Delegated Regulation [2019/945](https://eur-lex.europa.eu/eli/reg_del/2019/945/2020-08-09) and the Commission Implementing Regulation [2019/947](https://eur-lex.europa.eu/eli/reg_impl/2019/947/2021-08-05), ASD-STAN has developed the prEN 4709-002 Direct Remote Identification specification. +It specifies broadcast methods for Remote ID (Bluetooth and Wi-Fi) that are compliant with the ASTM F3411 specification. +See the summary [whitepaper](https://asd-stan.org/wp-content/uploads/ASD-STAN_DRI_Introduction_to_the_European_digital_RID_UAS_Standard.pdf) and the recording of this [webinar](https://www.cencenelec.eu/news-and-events/events/2021-02-09-european-workshop-on-uas-direct-remote-identification/). +The final version is not yet published (September 2021). +An earlier draft is available [here](https://asd-stan.org/downloads/din-en-4709-0022021-02/). +Be aware, that multiple changes were done after this draft version was made available and it should not be used as a reference for any implementations. + + + +### Comparison + +A comparison of some of the more detailed parts of each specification and rule is given in the table below. +If a field is left blank, nothing specific is mentioned in the particular document related to that part. + +The rules are what is defined by law and must be followed (the FAA rule in the United States and the EU rule in the European Union). +The ASTM Means of Compliance (MoC) document overrides certain parts of the ASTM specification to meet the FAA rule requirements. + +| | FAA rule | ASTM v1.1 | ASTM MoC | EU rule | ASD-STAN DRI | +| --- | --- | --- | --- | --- | --- | +| Serial ANSI/CTA-2063-A | M1 | M1 | M1 | M | M | +| Session ID | M1 | M1 | M1 | | O | +| UA dynamic position | M | M | | M | M | +| UA altitude WGS-84 | M | M | | | O | +| UA altitude AGL/Take-off | | O | | M | M | +| Timestamp | M | M | | M | M | +| Operational/Emergency status | M2 | O | M2 | M2 | M2 | +| Track direction | M | M | | M | M | +| Horizontal speed | M | M | | M | M | +| Vertical speed | M | M | | | O | +| Operator registration ID | | O | | M | M | +| EU Category & Class | | O | | | R | +| Operator dynamic position | M3 | O | M3 | M3 | M3 | +| Operator altitude WGS-84 | M | O | M | | O | +| Transmission interval4 (seconds) | 1 | 1 or 3 | 1 | | 1 or 3 | +| Transmission time | Take-off to shutdown | | Take-off to shutdown | | When airborne | +| BT4 Legacy Advertising | | M5 | M6, 7 | | O | +| BT5 Long Range | | O | M6, 7 | | M5 | +| Wi-Fi NaN 2.4 GHz | | M5 | | | M5 | +| Wi-Fi NaN 5 GHz | | O | | | M5 | +| Wi-Fi Beacon 2.4 GHz8 | | M5 | M7 | | M5 | +| Wi-Fi Beacon 5 GHz8 | | M5 | M7 | | M5 | + +M: Mandatory. O: Optional. R: Recommended + +1. Either the Serial Number or the Session ID must be transmitted. + Add-ons are not allowed to use Session ID. +2. Not required for Add-ons. +3. For Add-ons under EU rule: the Take-off location can be used instead. + For Add-ons under FAA rule: The Take-off location is required instead. +4. Concerns only the Basic ID, Location and System messages. + Location is always with 1 second intervals. + Basic ID and System intervals can be 3 seconds in the specifications. +5. Only one of the Mandatory broadcast methods is required. +6. Both BT4 and BT5 must be transmitted simultaneously. +7. Only Bluetooth (BT4 + BT5 simultaneously) or Wi-Fi Beacon (2.4 GHz or 5 GHz) are allowed. +8. If any other channel than Channel 6 on 2.4 GHz or Channel 149 on 5 GHz is used, a faster transmission rate of 5 Hz is required. diff --git a/libmav2odid/mav2odid.c b/libmav2odid/mav2odid.c index 86a930c..d6de9b2 100644 --- a/libmav2odid/mav2odid.c +++ b/libmav2odid/mav2odid.c @@ -307,7 +307,7 @@ static int m2o_authentication(mav2odid_t *m2o, mavlink_open_drone_id_authenticat int size = MAVLINK_MSG_OPEN_DRONE_ID_AUTHENTICATION_FIELD_AUTHENTICATION_DATA_LEN; if (authentication.DataPage == 0) { size = ODID_AUTH_PAGE_ZERO_DATA_SIZE; - authentication.LastPageIndex = mavAuthentication->page_count; + authentication.LastPageIndex = mavAuthentication->last_page_index; authentication.Length = mavAuthentication->length; authentication.Timestamp = mavAuthentication->timestamp; } @@ -364,6 +364,7 @@ static int m2o_system(mav2odid_t *m2o, mavlink_open_drone_id_system_t *mavSystem system.AreaFloor = mavSystem->area_floor; system.CategoryEU = (ODID_category_EU_t) mavSystem->category_eu; system.ClassEU = (ODID_class_EU_t) mavSystem->class_eu; + system.OperatorAltitudeGeo = mavSystem->operator_altitude_geo; if (encodeSystemMessage(&m2o->systemEnc, &system) != ODID_SUCCESS) return ODID_FAIL; @@ -556,7 +557,7 @@ void m2o_authentication2Mavlink(mavlink_open_drone_id_authentication_t *mavAuth, int size = ODID_AUTH_PAGE_ZERO_DATA_SIZE; if (Auth->DataPage == 0) { size = ODID_AUTH_PAGE_NONZERO_DATA_SIZE; - mavAuth->page_count = Auth->LastPageIndex; + mavAuth->last_page_index = Auth->LastPageIndex; mavAuth->length = Auth->Length; mavAuth->timestamp = Auth->Timestamp; } @@ -600,6 +601,7 @@ void m2o_system2Mavlink(mavlink_open_drone_id_system_t *mavSystem, mavSystem->area_floor = system->AreaFloor; mavSystem->category_eu = (ODID_category_EU_t) system->CategoryEU; mavSystem->class_eu = (ODID_class_EU_t) system->ClassEU; + mavSystem->operator_altitude_geo = system->OperatorAltitudeGeo; } /** diff --git a/mavlink_c_library_v2 b/mavlink_c_library_v2 index 4e10b28..6a6018b 160000 --- a/mavlink_c_library_v2 +++ b/mavlink_c_library_v2 @@ -1 +1 @@ -Subproject commit 4e10b2822e677e2f69015fb5b1be72069d481f91 +Subproject commit 6a6018b7d09898c0be55f474907578fc905e2c1f diff --git a/test/test_mav2odid.c b/test/test_mav2odid.c index 72a6647..616b40b 100644 --- a/test/test_mav2odid.c +++ b/test/test_mav2odid.c @@ -51,8 +51,8 @@ static void print_mavlink_auth(mavlink_open_drone_id_authentication_t *auth) int size = MAVLINK_MSG_OPEN_DRONE_ID_AUTHENTICATION_FIELD_AUTHENTICATION_DATA_LEN; if (auth->data_page == 0) { size = ODID_AUTH_PAGE_ZERO_DATA_SIZE; - printf("page_count: %d, length: %d, timestamp: %d, ", - auth->page_count, auth->length, auth->timestamp); + printf("last_page_index: %d, length: %d, timestamp: %d, ", + auth->last_page_index, auth->length, auth->timestamp); } printf("\n"); for (int i = 0; i < size; i++) @@ -75,12 +75,13 @@ static void print_mavlink_system(mavlink_open_drone_id_system_t *system) printf("Operator Location Type: %d, Classification Type: %d\n" "Lat/Lon: %d, %d degE7, \n" "Area Count, Radius: %d, %d, Ceiling, Floor: %.2f, %.2f m\n" - "Category EU: %d, Class EU: %d\n", + "Category EU: %d, Class EU: %d\n" + "Operator Altitude Geodetic: %.2f\n", system->operator_location_type, system->classification_type, system->operator_latitude, system->operator_longitude, system->area_count, system->area_radius, (double) system->area_ceiling, (double) system->area_floor, - system->category_eu, system->class_eu); + system->category_eu, system->class_eu, (double) system->operator_altitude_geo); } static void print_mavlink_operatorID(mavlink_open_drone_id_operator_id_t *operator_id) @@ -223,7 +224,7 @@ static void test_authentication(mav2odid_t *m2o, ODID_UAS_Data *uas_data) .data_page = 0, .authentication_type = MAV_ODID_AUTH_TYPE_UAS_ID_SIGNATURE, .authentication_data = "98765432101234567", - .page_count = 0, + .last_page_index = 0, .length = 17, .timestamp = 23000000 }; printf("\n\n---------------------Authentication---------------------\n\n"); @@ -294,7 +295,8 @@ static void test_system(mav2odid_t *m2o, ODID_UAS_Data *uas_data) .area_ceiling = 75.5f, .area_floor = 26.5f, .category_eu = MAV_ODID_CATEGORY_EU_CERTIFIED, - .class_eu = MAV_ODID_CLASS_EU_CLASS_5 }; + .class_eu = MAV_ODID_CLASS_EU_CLASS_5, + .operator_altitude_geo = 2.3f }; printf("\n\n------------------------System------------------------\n\n"); print_mavlink_system(&system);