Skip to content

Commit

Permalink
Added search via Zeroconf
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey004 committed Jun 20, 2023
1 parent 239cc56 commit 62e59e0
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Quest2-VRC.GUI/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 23 additions & 28 deletions Quest2-VRC.GUI/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ await Task.Run(() =>
{
try
{
var questip = materialTextBox1.Text;
if (ADB.StartADB(true, true, questip, false, materialCheckbox2.Checked))
var questip = "null";
materialTextBox1.Invoke(new Action(() => questip = materialTextBox1.Text));
if (ADB.StartADB(true, true, questip, true, materialCheckbox2.Checked))
{
materialLabel2.Invoke(new Action(() => materialLabel2.Text = "Status: ADB is running"));
Expand Down Expand Up @@ -174,7 +175,7 @@ await Task.Run(() =>
try
{
var questip = materialTextBox1.Text;
//questip += ":5555"; ;
if (ADB.StartADB(false, true, questip, true, materialCheckbox2.Checked))
{
materialLabel2.Invoke(new Action(() => materialLabel2.Text = "Status: Receive only"));
Expand Down Expand Up @@ -231,7 +232,7 @@ await Task.Run(() =>
try
{
var questip = materialTextBox1.Text;
//questip += ":5555";
if (ADB.StartADB(true, false, questip, true, materialCheckbox2.Checked))
{
materialLabel2.Invoke(new Action(() => materialLabel2.Text = "Status: Send only"));
Expand Down Expand Up @@ -314,39 +315,33 @@ private async void materialSwitch1_CheckedChanged(object sender, EventArgs e)
materialTextBox1.Enabled = false;
if (materialSwitch1.Checked)
{
MessageBox.Show("Connect your Quest to your computer and click \"OK\" to continue", "Restarting ADB in TCPIP mode", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (Check_Device.CheckDevice())
materialLabel2.Text = "Status: In TCPIP mode";
DialogResult dialogResult1 = MessageBox.Show("Do you want the program to find the IP address by old method or by using ZeroConf\nSearching through ZeroConf requires installing an additional program \"https://github.com/thedroidgeek/oculus-wireless-adb\"\nYes for ZeroConf, No for old method", "Restarting ADB in TCPIP mode", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult1 == DialogResult.Yes)
{
MessageBox.Show("Don't forget to wake up your device", "Restarting ADB in TCPIP mode", MessageBoxButtons.OK, MessageBoxIcon.Information);
materialTextBox1.Text = await ADB.GetZeroConfIP();
}
else if (dialogResult1 == DialogResult.No)
{
ADB.StartTCPIP();
await Task.Delay(3000);
materialLabel2.Text = "Status: In TCPIP mode";
MessageBox.Show("ADB restarted in TCPIP mode, ready to wireless conection", "Restarting ADB in TCPIP mode", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult dialogResult = MessageBox.Show("Do you want the program to find the IP address of the headset itself?", "Restarting ADB in TCPIP mode", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
MessageBox.Show("Do not forget to connect the device via USB", "Restarting ADB in TCPIP mode", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (Check_Device.CheckDevice())
{

ADB.StartTCPIP();
await Task.Delay(3000);
materialTextBox1.Text = ADB.GetIP();
}
else if (dialogResult == DialogResult.No)
else
{
MessageBox.Show("Input field is unlocked for manual entry", "Restarting ADB in TCPIP mode", MessageBoxButtons.OK, MessageBoxIcon.Information);
materialTextBox1.Enabled = true;

MessageBox.Show("Headset not connected", "Restarting ADB in TCPIP mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
materialSwitch1.Checked = false;
materialLabel2.Text = "Status: Headset not connected";
}

}
else
{
MessageBox.Show("Headset not connected", "Restarting ADB in TCPIP mode", MessageBoxButtons.OK, MessageBoxIcon.Error);
materialSwitch1.Checked = false;
materialLabel2.Text = "Status: Headset not connected";
}

}
else
{
materialTextBox1.Text = null;
}


}

private void materialButton5_Click(object sender, EventArgs e)
Expand Down
62 changes: 61 additions & 1 deletion Quest2-VRC.GUI/Form1.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
Expand Down
4 changes: 2 additions & 2 deletions Quest2-VRC.GUI/Quest2-VRC.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GitInfo" Version="2.3.0">
<PackageReference Include="GitInfo" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MaterialSkin.2" Version="2.3.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.2.1" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.3.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Quest2-VRC\Quest2-VRC.Core.csproj" />
Expand Down
24 changes: 24 additions & 0 deletions Quest2-VRC/Modules/ADB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Zeroconf;



Expand Down Expand Up @@ -145,6 +147,28 @@ public static string GetIP()

return deviceip;
}
public static async Task<string> GetZeroConfIP()
{
string deviceip = null;
var adbtls = await ZeroconfResolver.ResolveAsync("_adb-tls-connect._tcp.local.");
foreach (var headset in adbtls)
{
foreach (IService service in headset.Services.Values)
{
deviceip = headset.IPAddress + ":" + service.Port;
}
}
var secadb = await ZeroconfResolver.ResolveAsync("_adb_secure_connect._tcp.local");
foreach (var headset in secadb)
{
foreach (IService service in headset.Services.Values)
{
deviceip = headset.IPAddress + ":" + service.Port;
}
}

return await Task.FromResult(deviceip);
}
public static void StopADB()
{
if (!AdbServer.Instance.GetStatus().IsRunning)
Expand Down
3 changes: 2 additions & 1 deletion Quest2-VRC/Quest2-VRC.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AdvancedSharpAdbClient" Version="2.5.5" />
<PackageReference Include="AdvancedSharpAdbClient" Version="2.5.6" />
<PackageReference Include="Bespoke.Osc" Version="1.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OpenRGB.NET" Version="1.7.0" />
<PackageReference Include="System.Management" Version="7.0.1" />
<PackageReference Include="Zeroconf" Version="3.6.11" />
</ItemGroup>
<PropertyGroup>
<IsPublishable>False</IsPublishable>
Expand Down
2 changes: 1 addition & 1 deletion Quest2-VRC/Services/Sender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static async Task questwd(int Uport, bool wirlessmode, bool audioEnadled)
ConsoleOutputReceiver Wifi_Singal = new ConsoleOutputReceiver();
client.ExecuteRemoteCommand("dumpsys wifi | grep RSSI:", device, Wifi_Singal);
var Wifi_match = Regex.Match(Wifi_Singal.ToString(), @"RSSI: \S*\d+");
WifiRSSI = Wifi_match.ToString().Substring(6);
WifiRSSI = Wifi_match.ToString()[6..];
WifiInt = int.Parse(WifiRSSI);

}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

This program sending Quest 2 (As well as other headsets in the Quest line) battery information (Now also Wifi signal strength, especially for you, AirLink or VD users) to the VRChtat via the OSC protocol, also receive osc address to control OpenRGB

If you see a program with approximately the same functionality, it is either a fork or a copy, this program is the only one that uses ADB and OSC at the same time

OpenRGB functions tested only on MSI Mystic Light (AKA MSI-RGB)

Expand Down Expand Up @@ -68,6 +67,7 @@ And hope for the best that this program will work for you
- [MaterialSkin.2](https://github.com/leocb/MaterialSkin)
- [GitInfo](https://github.com/devlooped/GitInfo)
- [NetBeauty2](https://github.com/nulastudio/NetBeauty2)
- [ZeroConf](https://github.com/novotnyllc/Zeroconf)

Sending code based on modified source code from https://github.com/KaleidonKep99/VRChat_CS_OSCTest

Expand Down

0 comments on commit 62e59e0

Please sign in to comment.