Merge pull request #2 from jjshoots/dev

Allow independent mac addr for each drone
This commit is contained in:
Jet
2023-06-22 22:31:35 +01:00
committed by GitHub
7 changed files with 16 additions and 21 deletions

View File

@@ -24,5 +24,4 @@ This spawns 16 different fake drones broadcasting RemoteID, with them all flying
## To-Do List
1. Set custom MAC address for each Remote ID instance.
2. Add GPS capability to automatically create IDs wherever the device is located.
1. Add GPS capability to automatically create IDs wherever the device is located.

View File

@@ -5,6 +5,7 @@
#include <ESP8266WiFi.h>
#include "spoofer.h"
// we are limited by how fast we can broadcast things
const int num_spoofers = 16;
static Spoofer spoofers[num_spoofers];
@@ -13,8 +14,8 @@ void setup() {
}
void loop() {
delay(50);
for (int i = 0; i < num_spoofers; i++) {
spoofers[i].update();
delay(10);
}
}
}

View File

@@ -68,12 +68,16 @@ ID_OpenDrone::ID_OpenDrone() {
#if ID_OD_WIFI
memset(WiFi_mac_addr,0,6);
// scrambled, not poached
for (int i = 0; i < 6; i++) {
WiFi_mac_addr[i] = (uint8_t) (rand() % 16);
}
memset(ssid,0,sizeof(ssid));
strcpy(ssid,"UAS_ID_OPEN");
beacon_interval = (BEACON_INTERVAL) ? BEACON_INTERVAL: 500;
beacon_interval = 10;
#if ID_OD_WIFI_BEACON
@@ -409,10 +413,8 @@ int ID_OpenDrone::transmit(struct UTM_data *utm_data) {
int i, status;
char text[128];
uint32_t msecs;
time_t secs = 0;
static int phase = 0;
static uint32_t last_msecs = 2000;
//
@@ -574,7 +576,6 @@ int ID_OpenDrone::transmit(struct UTM_data *utm_data) {
// Pack and transmit the WiFi data.
static uint8_t wifi_toggle = 1;
static uint32_t last_wifi = 0;
if ((msecs - last_wifi) >= beacon_interval) {
@@ -653,9 +654,7 @@ int ID_OpenDrone::transmit_wifi(struct UTM_data *utm_data,int prepacked) {
#if ID_OD_WIFI
int length = 0, wifi_status = 0;
uint32_t msecs;
uint64_t usecs = 0;
static uint32_t last_wifi = 0;
char text[128];
text[0] = 0;
@@ -833,9 +832,6 @@ int ID_OpenDrone::transmit_wifi(struct UTM_data *utm_data,int prepacked) {
*/
int ID_OpenDrone::transmit_ble(uint8_t *odid_msg,int length) {
uint32_t msecs;
static uint32_t last_ble;
msecs = millis();
ble_interval = msecs - last_ble;

View File

@@ -138,6 +138,7 @@ private:
char *UAS_operator;
uint8_t msg_counter[16];
uint16_t wifi_interval = 0, ble_interval = 0;
uint32_t last_ble = 0, last_wifi = 0, msecs = 0, last_msecs = 2000;
Stream *Debug_Serial = NULL;
char ssid[32];

View File

@@ -189,7 +189,8 @@ void init2(char *ssid,int ssid_length,uint8_t *WiFi_mac_addr,uint8_t wifi_channe
// esp_wifi_set_max_tx_power(78);
esp_wifi_get_max_tx_power(&wifi_power);
status = esp_read_mac(WiFi_mac_addr,ESP_MAC_WIFI_STA);
// no default mac addresses
// status = esp_read_mac(WiFi_mac_addr,ESP_MAC_WIFI_STA);
if (Debug_Serial) {

View File

@@ -66,8 +66,7 @@ void init2(char *ssid,int ssid_length,uint8_t *WiFi_mac_addr,uint8_t wifi_channe
softap_config wifi_config;
WiFi.mode(WIFI_OFF);
WiFi.macAddress(WiFi_mac_addr);
// WiFi.macAddress(WiFi_mac_addr);
WiFi.softAP(ssid,NULL,wifi_channel,false,0);
WiFi.setOutputPower(20.0);

View File

@@ -23,7 +23,7 @@ Spoofer::Spoofer() {
// define location
// 52° 24' 24.4404" -1° 29' 36.564"W
lat_d =
lat_d =
utm_data.latitude_d =
utm_data.base_latitude = 52.0 + (24.0 / 60.0) + (24.4404 / 3600.0);
long_d =
@@ -40,8 +40,6 @@ Spoofer::Spoofer() {
speed_m_x = ((float) speed_kn) * 0.514444 * 0.2; // Because we update every 200 ms.
utm_utils.calc_m_per_deg(lat_d,&m_deg_lat,&m_deg_long);
srand(micros());
}
void Spoofer::update() {
@@ -76,4 +74,4 @@ String Spoofer::getID() {
ID.concat(characters[(rand() % characters.length())]);
}
return ID;
}
}