Skip to content

Commit

Permalink
MockDroneID: add
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Mar 19, 2024
1 parent a25c8a3 commit c4b2e1a
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ExtLibs/MockDroneID/MockDroneID.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<NoWarn>1701;1702;NU1605</NoWarn>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Mavlink\MAVLink.csproj" />
</ItemGroup>

</Project>
108 changes: 108 additions & 0 deletions ExtLibs/MockDroneID/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace Mock
{
class Program
{
static void Main(string[] args)
{
var mavlinkudp = new UdpClient(14550);
var mavparse = new MAVLink.MavlinkParse();
var seqno = 0;
IPEndPoint ipEP = new IPEndPoint(IPAddress.Any, 0);


while (true)
{
while (mavlinkudp.Available > 0)
{
ipEP = new IPEndPoint(IPAddress.Any, 0);
try
{
var rawpacket = mavlinkudp.Receive(ref ipEP);

var packet = mavparse.ReadPacket(new MemoryStream(rawpacket));
Console.WriteLine(packet);
}
catch
{
continue;
}
}

if (ipEP.Address == IPAddress.Any)
{
Thread.Sleep(100);
continue;
}

var sendpacket = mavparse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.HEARTBEAT,
new MAVLink.mavlink_heartbeat_t()
{
autopilot = (byte)MAVLink.MAV_AUTOPILOT.ARDUPILOTMEGA,
base_mode = (byte)MAVLink.MAV_MODE_FLAG.CUSTOM_MODE_ENABLED,
system_status = (byte)MAVLink.MAV_STATE.ACTIVE,
type = (byte)MAVLink.MAV_TYPE.QUADROTOR
}, false, 1, 1, seqno++);
mavlinkudp.Send(sendpacket, sendpacket.Length, ipEP);


sendpacket = mavparse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.OPEN_DRONE_ID_BASIC_ID,
new MAVLink.mavlink_open_drone_id_basic_id_t()
{

}, false, 1, 1, seqno++);
mavlinkudp.Send(sendpacket, sendpacket.Length, ipEP);


sendpacket = mavparse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.OPEN_DRONE_ID_LOCATION,
new MAVLink.mavlink_open_drone_id_location_t()
{

}, false, 1, 1, seqno++);
mavlinkudp.Send(sendpacket, sendpacket.Length, ipEP);



sendpacket = mavparse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.OPEN_DRONE_ID_SELF_ID,
new MAVLink.mavlink_open_drone_id_self_id_t()
{

}, false, 1, 1, seqno++);
mavlinkudp.Send(sendpacket, sendpacket.Length, ipEP);

sendpacket = mavparse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.OPEN_DRONE_ID_SYSTEM,
new MAVLink.mavlink_open_drone_id_system_t()
{

}, false, 1, 1, seqno++);
mavlinkudp.Send(sendpacket, sendpacket.Length, ipEP);

sendpacket = mavparse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.OPEN_DRONE_ID_SYSTEM_UPDATE,
new MAVLink.mavlink_open_drone_id_system_update_t()
{

}, false, 1, 1, seqno++);
mavlinkudp.Send(sendpacket, sendpacket.Length, ipEP);

sendpacket = mavparse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.OPEN_DRONE_ID_OPERATOR_ID,
new MAVLink.mavlink_open_drone_id_operator_id_t()
{

}, false, 1, 1, seqno++);
mavlinkudp.Send(sendpacket, sendpacket.Length, ipEP);

Thread.Sleep(1000);
}
}
}

internal struct mavlink_vfr_hud_EDIT_t
{
}
}
7 changes: 7 additions & 0 deletions MissionPlanner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bulb", "ExtLibs\LEDBulb\Bul
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MissionPlannerTests", "MissionPlannerTests\MissionPlannerTests.csproj", "{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MockDroneID", "ExtLibs\MockDroneID\MockDroneID.csproj", "{6D39C141-733B-4C4A-87AB-974637952D1B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -550,6 +552,10 @@ Global
{AF81C41B-06E6-4CA5-9FD4-A4E7042F1107}.Release|Any CPU.Build.0 = Release|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B99EBF2-B964-4AAC-9EC5-76353610AAAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D39C141-733B-4C4A-87AB-974637952D1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D39C141-733B-4C4A-87AB-974637952D1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D39C141-733B-4C4A-87AB-974637952D1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D39C141-733B-4C4A-87AB-974637952D1B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -634,6 +640,7 @@ Global
{DED183CA-5591-4CE5-A89D-987035BAC553} = {9B3AC501-5FCB-4A2A-A628-BE0985DB2BD4}
{FBE658B3-684D-46E6-8668-50DEF0778538} = {9B3AC501-5FCB-4A2A-A628-BE0985DB2BD4}
{AF81C41B-06E6-4CA5-9FD4-A4E7042F1107} = {7E264F12-9EC3-4CDC-A187-6879C2B2BFCF}
{6D39C141-733B-4C4A-87AB-974637952D1B} = {0371886E-5A61-4626-B9E0-50A837ECE2DD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FD2C9507-1A09-4F5B-98AB-B6B194A4B260}
Expand Down

0 comments on commit c4b2e1a

Please sign in to comment.