-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from asv-soft/feat/air-talk
Add audio and radio mavlink interfaces
- Loading branch information
Showing
71 changed files
with
2,550 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
"src\Asv.Mavlink.Shell\bin\Debug\net7.0\Asv.Mavlink.Shell.exe" gen -t=asv_gbs.xml -i=src/Asv.Mavlink/Protocol/Dialects -o=src/Asv.Mavlink/Protocol/Messages -e=cs src/Asv.Mavlink.Shell/Resources/csharp.tpl | ||
"src\Asv.Mavlink.Shell\bin\Debug\net7.0\Asv.Mavlink.Shell.exe" gen -t=asv_sdr.xml -i=src/Asv.Mavlink/Protocol/Dialects -o=src/Asv.Mavlink/Protocol/Messages -e=cs src/Asv.Mavlink.Shell/Resources/csharp.tpl | ||
"src\Asv.Mavlink.Shell\bin\Debug\net7.0\Asv.Mavlink.Shell.exe" gen -t=asv_audio.xml -i=src/Asv.Mavlink/Protocol/Dialects -o=src/Asv.Mavlink/Protocol/Messages -e=cs src/Asv.Mavlink.Shell/Resources/csharp.tpl | ||
"src\Asv.Mavlink.Shell\bin\Debug\net7.0\Asv.Mavlink.Shell.exe" gen -t=asv_radio.xml -i=src/Asv.Mavlink/Protocol/Dialects -o=src/Asv.Mavlink/Protocol/Messages -e=cs src/Asv.Mavlink.Shell/Resources/csharp.tpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/Asv.Mavlink.Test/Microservices/AsvAudio/AsvAudioTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using DynamicData; | ||
using DynamicData.Binding; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Asv.Mavlink.Test; | ||
|
||
public class AsvAudioTest | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
|
||
public AsvAudioTest(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
} | ||
|
||
|
||
[Theory] | ||
[InlineData(1)] | ||
[InlineData(16)] | ||
[InlineData(127)] | ||
[InlineData(AsvAudioHelper.MaxPacketStreamData)] | ||
[InlineData(AsvAudioHelper.MaxPacketStreamData + 1)] | ||
[InlineData(256)] | ||
[InlineData(1024)] | ||
[InlineData(byte.MaxValue * AsvAudioHelper.MaxPacketStreamData)] | ||
public async Task All_devices_send_status(int dataLength) | ||
{ | ||
var link = new VirtualMavlinkConnection(); | ||
var rawPart = new RawCodecFactoryPart(); | ||
var factory = new CompositeAudioCodecFactory(new []{rawPart}); | ||
var device1 = new AudioService(factory, link.Client, new MavlinkIdentity(1,1), new PacketSequenceCalculator(), TimeSpan.FromSeconds(5),TimeSpan.FromSeconds(1)); | ||
var device2 = new AudioService(factory, link.Server, new MavlinkIdentity(2,2), new PacketSequenceCalculator(), TimeSpan.FromSeconds(5),TimeSpan.FromSeconds(1)); | ||
|
||
device1.GoOnline("device1", RawCodecFactoryPart.Raw8KHz16BitMono, true, true); | ||
device2.GoOnline("device2", RawCodecFactoryPart.Raw8KHz16BitMono, true, true); | ||
|
||
await Task.Delay(2000); | ||
|
||
using var subscribe1 = device1.Devices.BindToObservableList(out var device1List).Subscribe(); | ||
using var subscribe2 = device2.Devices.BindToObservableList(out var device2List).Subscribe(); | ||
|
||
Assert.Equal(1, device1List.Count); | ||
Assert.Equal(1, device2List.Count); | ||
var audio1 = device1List.Items.First(); | ||
var audio2 = device2List.Items.First(); | ||
|
||
var tcs = new TaskCompletionSource(); | ||
var cancel = new CancellationTokenSource(); | ||
cancel.CancelAfter(TimeSpan.FromSeconds(10)); | ||
await using var c1 = cancel.Token.Register(()=>tcs.TrySetCanceled(), false); | ||
|
||
var data = new byte[dataLength]; | ||
Random.Shared.NextBytes(data); | ||
|
||
device2.OnReceiveAudio += (device, bytes, dataSize) => | ||
{ | ||
Assert.Equal(data.Length, dataSize); | ||
for (var i = 0; i < dataSize; i++) | ||
{ | ||
Assert.Equal(data[i], bytes[i]); | ||
} | ||
tcs.SetResult(); | ||
}; | ||
|
||
await audio1.SendAudio(data, data.Length, default); | ||
await tcs.Task; | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.