Skip to content

Commit

Permalink
OpenDroneID library
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Oct 31, 2023
1 parent d61cdf8 commit 5b2cce0
Show file tree
Hide file tree
Showing 23 changed files with 6,047 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Radio|FLARM AIR V6|<p align="center">![](https://github.com/lyusupov/SoftRF/raw/
&nbsp;|<p align="center">1090&nbsp;ES<br>ADS-B</p>|||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)<sup>5</sup></p>||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)<sup>5</sup></p>
&nbsp;|<p align="center">FANET+</p>||||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>|<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)<sup>3</sup></p>
&nbsp;|<p align="center">APRS</p>|||||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)<sup>6</sup></p>
&nbsp;|<p align="center">Remote ID</p>|||||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_yellow_32.png)
Data|FLARM NMEA|<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>|<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>|<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>
&nbsp;|Garmin GDL90|||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>
&nbsp;|<p align="center">MAVLINK</p>|<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>|<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>|||<p align="center">![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/check-mark_32.png)</p>
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SoftRF/src/platform/ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ struct rst_info {
#define ENABLE_RECORDER
#define USE_SA8X8
/* Experimental */
//#define ENABLE_REMOTE_ID
#define ENABLE_REMOTE_ID
#endif /* CONFIG_IDF_TARGET_ESP32S3 */

#if defined(USE_USB_HOST)
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SoftRF/src/platform/nRF52.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ struct rst_info {
//#define EXCLUDE_IMU
#define USE_OGN_ENCRYPTION
#define ENABLE_PROL
//#define ENABLE_REMOTE_ID
#define ENABLE_REMOTE_ID

/* FTD-012 data port protocol version 8 and 9 */
#define PFLAA_EXT1_FMT ",%d,%d,%d"
Expand Down
11 changes: 0 additions & 11 deletions software/firmware/source/SoftRF/src/protocol/radio/RemoteID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ bool rid_enabled() {

size_t rid_encode(void *pkt, ufo_t *this_aircraft) {

uint32_t id = this_aircraft->addr & 0x00FFFFFF;

#if !defined(SOFTRF_ADDRESS)
uint8_t addr_type = ADDR_TYPE_ANONYMOUS;
#else
uint8_t addr_type = id == SOFTRF_ADDRESS ? ADDR_TYPE_ICAO : ADDR_TYPE_ANONYMOUS;
#endif

uint8_t acft_type = this_aircraft->aircraft_type > AIRCRAFT_TYPE_STATIC ?
AIRCRAFT_TYPE_UNKNOWN : this_aircraft->aircraft_type;

utm_data.latitude_d = (double) this_aircraft->latitude;
utm_data.longitude_d = (double) this_aircraft->longitude;
utm_data.alt_msl_m = (float) this_aircraft->altitude;
Expand Down
4 changes: 2 additions & 2 deletions software/firmware/source/SoftRF/src/protocol/radio/RemoteID.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#ifndef PROTOCOL_RID_H
#define PROTOCOL_RID_H

#define RID_TX_INTERVAL_MIN 900 /* in ms */
#define RID_TX_INTERVAL_MAX 1100
#define RID_TX_INTERVAL_MIN 490 /* in ms */
#define RID_TX_INTERVAL_MAX 510

typedef struct {

Expand Down
16 changes: 16 additions & 0 deletions software/firmware/source/libraries/OpenDroneID/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ID Open
An Arduino/ESP32 class to act as a wrapper around opendroneid.

Supports BLE 4, WiFi NAN and WiFi beacon.

Runs on a cheap ESP32 dev board.

Needs opendroneid.c, opendroneid.h, odid_wifi.h and wifi.c from [opendroneid](https://github.com/opendroneid/opendroneid-core-c/tree/master/libopendroneid) to be copied into the id_open directory.

Last tested with opendroneid release 2.0.

If you are thinking of using this to make remote IDs for use in the US or EU, there are problems.
* It looks like both of these jurisdictions are going to require IDs to transmit ANSI/CTA serial numbers. (See the table at the bottom of [this page](https://github.com/opendroneid/opendroneid-core-c/).)
* The FAA are requiring remote IDs to be tamper resistant (see their [acceptance of the ASTM Means of Compliance](https://www.federalregister.gov/documents/2022/08/11/2022-16997/accepted-means-of-compliance-remote-identification-of-unmanned-aircraft) ). I don't see how this can be done with an open source, home built ID.

There is a report of an ESP32 that will not simultaneously do WiFi and Bluetooth remote ID (see issue #18). If your ESP32 goes into a reboot loop when both are enabled, try one or the other. This may be related to the ESP IDF version.
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
/* -*- tab-width: 2; mode: c; -*-
*
* Points around the BMFA's Buckminster flying centre.
*
*/

#pragma GCC diagnostic warning "-Wunused-variable"

#include <Arduino.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>

#include "id_open.h"

#define WAYPOINTS 6

static ID_OpenDrone squitter;
static UTM_Utilities utm_utils;

static struct UTM_parameters utm_parameters;
static struct UTM_data utm_data;

static int speed_kn = 40, waypoint = 0;
static float z = 100.0;
static double deg2rad = 0.0, m_deg_lat = 0.0, m_deg_long = 0.0;
static double latitude[WAYPOINTS], longitude[WAYPOINTS];

void setup() {

char text[64];
double lat_d, long_d;
time_t time_2;
struct tm clock_tm;
struct timeval tv = {0,0};
struct timezone utc = {0,0};

//

Serial.begin(115200);
Serial.print("\nSerial\n\n\r");

// Do not use Serial1 if using an ESP32.
#if defined(ARDUINO_ARCH_RP2040)
Serial1.begin(115200);
Serial1.print("\nSerial1\n\n\r");
#endif

#if 0
Serial2.begin(115200);
Serial2.print("\nSerial2\n\n\r");
#endif

deg2rad = (4.0 * atan(1.0)) / 180.0;

//

memset(&clock_tm,0,sizeof(struct tm));

clock_tm.tm_hour = 10;
clock_tm.tm_mday = 27;
clock_tm.tm_mon = 11;
clock_tm.tm_year = 122;

tv.tv_sec =
time_2 = mktime(&clock_tm);

settimeofday(&tv,&utc);

delay(500);

Serial.print(ctime(&time_2));

//

memset(&utm_parameters,0,sizeof(utm_parameters));

#if 0
strcpy(utm_parameters.UAS_operator,"GBR-OP-1234ABCDEFGH");
#elif defined(ARDUINO_ARCH_ESP32)
strcpy(utm_parameters.UAS_operator,"GBR-OP-ESP32");
#elif defined(ARDUINO_ARCH_ESP8266)
strcpy(utm_parameters.UAS_operator,"GBR-OP-ESP8266");
#elif defined(ARDUINO_ARCH_RP2040)
strcpy(utm_parameters.UAS_operator,"GBR-OP-PICOW");
#else
strcpy(utm_parameters.UAS_operator,"GBR-OP-UNKNOWN");
#endif

utm_parameters.region = 1;
utm_parameters.EU_category = 1;
utm_parameters.EU_class = 5;

squitter.init(&utm_parameters);

memset(&utm_data,0,sizeof(utm_data));

//

latitude[0] = 52.0 + (46.0 / 60.0) + (49.27 / 3600.0);
longitude[0] = 0.0 - (42.0 / 60.0) - (27.73 / 3600.0);

latitude[1] = 52.0 + (46.0 / 60.0) + (51.91 / 3600.0);
longitude[1] = 0.0 - (42.0 / 60.0) - (20.74 / 3600.0);

latitude[2] = 52.0 + (46.0 / 60.0) + (48.80 / 3600.0);
longitude[2] = 0.0 - (42.0 / 60.0) - (33.52 / 3600.0);

latitude[3] = 52.0 + (46.0 / 60.0) + (50.89 / 3600.0);
longitude[3] = 0.0 - (42.0 / 60.0) - (36.58 / 3600.0);

latitude[4] = 52.0 + (46.0 / 60.0) + (54.11 / 3600.0);
longitude[4] = 0.0 - (42.0 / 60.0) - (29.52 / 3600.0);

latitude[5] = 52.0 + (46.0 / 60.0) + (55.54 / 3600.0);
longitude[5] = 0.0 - (42.0 / 60.0) - (20.00 / 3600.0);

//

utm_data.latitude_d = latitude[1];
utm_data.longitude_d = longitude[1];

lat_d =
utm_data.base_latitude = latitude[0];
long_d =
utm_data.base_longitude = longitude[0];

utm_data.base_alt_m = 137.0;

utm_data.alt_msl_m = utm_data.base_alt_m + z;
utm_data.alt_agl_m = z;

utm_data.speed_kn = speed_kn;
utm_data.satellites = 12;
utm_data.base_valid = 1;

//

utm_utils.calc_m_per_deg(lat_d,&m_deg_lat,&m_deg_long);

//

Serial.print("\r\n");

sprintf(text,"%d degrees/radian\r\n",(int) (1.0 / deg2rad));
Serial.print(text);

sprintf(text,"%d m per degree latitude\r\n",(int) m_deg_lat);
Serial.print(text);

sprintf(text,"%d m per degree longitude\r\n",(int) m_deg_long);
Serial.print(text);

Serial.print("\r\n");

//

srand(micros());

return;
}

//

void loop() {

char text[64], lat_s[16], long_s[16];
uint32_t msecs;
time_t time_2;
struct tm *gmt;
static uint32_t last_update = 0, last_waypoint = 0;

msecs = millis();

if ((msecs - last_waypoint) > 9999) {

last_waypoint = msecs;

utm_data.latitude_d = latitude[waypoint];
utm_data.longitude_d = longitude[waypoint];

dtostrf(utm_data.latitude_d,10,7,lat_s);
dtostrf(utm_data.longitude_d,10,7,long_s);

#if 1
sprintf(text,"%d,%s,%s,%d,%d\r\n",
waypoint,lat_s,long_s,utm_data.heading,utm_data.speed_kn);
Serial.print(text);
#endif

if (++waypoint >= WAYPOINTS) {
waypoint = 1;
}
}

if ((msecs - last_update) > 24) {
last_update = msecs;
time(&time_2);

gmt = gmtime(&time_2);

utm_data.seconds = gmt->tm_sec;
utm_data.minutes = gmt->tm_min;
utm_data.hours = gmt->tm_hour;

squitter.transmit(&utm_data);
}

return;
}

//
Loading

0 comments on commit 5b2cce0

Please sign in to comment.