mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-21 08:09:49 -05:00
try to wake device first when lookup fails
This commit is contained in:
1 parent
48b13b1c64
commit
91fd44d698
5 files changed
+36
-22
No files matched your search
@@ -27,7 +27,7 @@
|
||||
<ProductName>ColorControl</ProductName>
|
||||
<PublisherName>Maassoft</PublisherName>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.5.2.0</ApplicationVersion>
|
||||
<ApplicationVersion>1.5.3.0</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
|
||||
+28
-14
@@ -21,7 +21,7 @@ namespace ColorControl
|
||||
|
||||
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public string FriendlyScreenName { get; private set; }
|
||||
//public string FriendlyScreenName { get; private set; }
|
||||
|
||||
public List<PnpDev> Devices { get; private set; }
|
||||
public PnpDev SelectedDevice
|
||||
@@ -53,16 +53,16 @@ namespace ColorControl
|
||||
LoadConfig();
|
||||
LoadRemoteControlButtons();
|
||||
|
||||
foreach (var screen in Screen.AllScreens)
|
||||
{
|
||||
var name = screen.DeviceFriendlyName();
|
||||
if (name.Contains("LG"))
|
||||
{
|
||||
FriendlyScreenName = name;
|
||||
}
|
||||
}
|
||||
//foreach (var screen in Screen.AllScreens)
|
||||
//{
|
||||
// var name = screen.DeviceFriendlyName();
|
||||
// if (name.Contains("LG"))
|
||||
// {
|
||||
// FriendlyScreenName = name;
|
||||
// }
|
||||
//}
|
||||
|
||||
RefreshDevices();
|
||||
RefreshDevices(afterStartUp: true);
|
||||
}
|
||||
|
||||
~LgService()
|
||||
@@ -167,10 +167,23 @@ namespace ColorControl
|
||||
File.WriteAllText(_rcButtonsFilename, json);
|
||||
}
|
||||
|
||||
public async Task RefreshDevices(bool connect = true)
|
||||
public async Task RefreshDevices(bool connect = true, bool afterStartUp = false)
|
||||
{
|
||||
var devices = await Utils.GetPnpDevices(Config.DeviceSearchKey);
|
||||
SetDevices(devices);
|
||||
|
||||
if (afterStartUp && SelectedDevice == null && Config.PowerOnAfterStartup && !string.IsNullOrEmpty(Config.PreferredMacAddress))
|
||||
{
|
||||
Logger.Debug("No device has been found, trying to wake it first...");
|
||||
|
||||
WakeSelectedDevice(Config.PreferredMacAddress);
|
||||
|
||||
await Task.Delay(4000);
|
||||
await RefreshDevices();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (connect && SelectedDevice != null)
|
||||
{
|
||||
if (Config.PowerOnAfterStartup && _allowPowerOn)
|
||||
@@ -374,11 +387,12 @@ namespace ColorControl
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void WakeSelectedDevice()
|
||||
internal void WakeSelectedDevice(string macAddress = null)
|
||||
{
|
||||
if (SelectedDevice != null)
|
||||
macAddress = macAddress == null ? SelectedDevice?.MacAddress : macAddress;
|
||||
if (macAddress != null)
|
||||
{
|
||||
WOL.WakeFunction(SelectedDevice.MacAddress);
|
||||
WOL.WakeFunction(macAddress);
|
||||
_justWokeUp = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace ColorControl
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e);
|
||||
Logger.Error("Error initializing LgService: " + e.ToLogString());
|
||||
}
|
||||
|
||||
InitInfo();
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.5.2.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.2.0")]
|
||||
[assembly: AssemblyVersion("1.5.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.3.0")]
|
||||
@@ -236,10 +236,10 @@ namespace ColorControl
|
||||
object objValue;
|
||||
string value = null;
|
||||
|
||||
foreach (var key in device.Properties.Keys)
|
||||
{
|
||||
Debug.WriteLine(key);
|
||||
}
|
||||
//foreach (var key in device.Properties.Keys)
|
||||
//{
|
||||
// Debug.WriteLine(key);
|
||||
//}
|
||||
|
||||
if (device.Properties.TryGetValue(propertyName, out objValue))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user