diff --git a/pvr.hdhomerun/resources/language/resource.language.en_gb/strings.po b/pvr.hdhomerun/resources/language/resource.language.en_gb/strings.po
index 7ecddfa..70f9db8 100644
--- a/pvr.hdhomerun/resources/language/resource.language.en_gb/strings.po
+++ b/pvr.hdhomerun/resources/language/resource.language.en_gb/strings.po
@@ -47,3 +47,7 @@ msgstr ""
msgctxt "#32006"
msgid "Use HTTP discovery"
msgstr ""
+
+msgctxt "#32007"
+msgid "Set IP of device to use"
+msgstr ""
diff --git a/pvr.hdhomerun/resources/settings.xml b/pvr.hdhomerun/resources/settings.xml
index a11c85a..4128ecf 100644
--- a/pvr.hdhomerun/resources/settings.xml
+++ b/pvr.hdhomerun/resources/settings.xml
@@ -28,6 +28,14 @@
false
+
+ 0
+
+
+ true
+
+
+
diff --git a/src/HDHomeRunTuners.cpp b/src/HDHomeRunTuners.cpp
index 0e1f1ff..c9213bc 100644
--- a/src/HDHomeRunTuners.cpp
+++ b/src/HDHomeRunTuners.cpp
@@ -180,6 +180,28 @@ bool HDHomeRunTuners::Update(int nMode)
nTunerCount = hdhomerun_discover_find_devices_custom_v2(
0, HDHOMERUN_DEVICE_TYPE_TUNER, HDHOMERUN_DEVICE_ID_WILDCARD, foundDevices, 16);
+ // If neither HTTPDiscovery or normal broadcast discovery do not find a device, if a
+ // user has entered an IP address in settings for a forced IP, do a search based on that
+ // specific IP. We only accomodate IPv4 addresses currently.
+ if (nTunerCount <= 0)
+ {
+ std::string strUserForcedIP = SettingsType::Get().GetForcedIP();
+ if (!strUserForcedIP.empty())
+ {
+ unsigned char addressbuf[sizeof(struct in6_addr)];
+
+ int s = inet_pton(AF_INET, strUserForcedIP.c_str(), addressbuf);
+ if (s > 0)
+ {
+ uint32_t ipaddress = (addressbuf[0] << 24) + (addressbuf[1] << 16) + (addressbuf[2] << 8) + addressbuf[3];
+ nTunerCount = hdhomerun_discover_find_devices_custom_v2(
+ ipaddress, HDHOMERUN_DEVICE_TYPE_TUNER, HDHOMERUN_DEVICE_ID_WILDCARD, foundDevices, 16);
+
+ KODI_LOG(ADDON_LOG_DEBUG, "Found %d HDHomeRun tuners on IP %s", nTunerCount, strUserForcedIP.c_str());
+ }
+ }
+ }
+
if (nTunerCount <= 0)
return false;
diff --git a/src/Settings.cpp b/src/Settings.cpp
index bc40590..98c6951 100644
--- a/src/Settings.cpp
+++ b/src/Settings.cpp
@@ -22,6 +22,7 @@ bool SettingsType::ReadSettings()
bMarkNew = kodi::addon::GetSettingBoolean("mark_new", true);
bDebug = kodi::addon::GetSettingBoolean("debug", false);
bHttpDiscovery = kodi::addon::GetSettingBoolean("http_discovery", false);
+ strForcedIP = kodi::addon::GetSettingString("force_ip", "");
return true;
}
@@ -48,6 +49,11 @@ ADDON_STATUS SettingsType::SetSetting(const std::string& settingName,
bHttpDiscovery = settingValue.GetBoolean();
return ADDON_STATUS_NEED_RESTART;
}
+ else if (settingName == "force_ip")
+ {
+ strForcedIP = settingValue.GetString();
+ return ADDON_STATUS_NEED_RESTART;
+ }
return ADDON_STATUS_OK;
}
diff --git a/src/Settings.h b/src/Settings.h
index 636ff15..2d0f495 100644
--- a/src/Settings.h
+++ b/src/Settings.h
@@ -9,6 +9,8 @@
#pragma once
+#include
+
#include
class ATTR_DLL_LOCAL SettingsType
@@ -24,6 +26,7 @@ class ATTR_DLL_LOCAL SettingsType
bool GetDebug() const { return bDebug; }
bool GetMarkNew() const { return bMarkNew; }
bool GetHttpDiscovery() const { return bHttpDiscovery; }
+ std::string GetForcedIP() const { return strForcedIP; }
private:
SettingsType() = default;
@@ -33,4 +36,5 @@ class ATTR_DLL_LOCAL SettingsType
bool bDebug = false;
bool bMarkNew = false;
bool bHttpDiscovery = false;
+ std::string strForcedIP;
};