Skip to content

Commit 90439d1

Browse files
authored
Merge pull request #185 from kodi-pvr/user_setip_omega
[Omega] Allow user to set specific IP of hdhomerun unit
2 parents 77390b2 + b0e170f commit 90439d1

File tree

7 files changed

+78
-2
lines changed

7 files changed

+78
-2
lines changed

pvr.hdhomerun/addon.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<addon
33
id="pvr.hdhomerun"
4-
version="21.0.3"
4+
version="21.0.4"
55
name="HDHomeRun Client"
66
provider-name="Zoltan Csizmadia ([email protected])">
77
<requires>@ADDON_DEPENDS@</requires>

pvr.hdhomerun/changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v21.0.4
2+
- Add some help labels to some settings and group discovery related settings
3+
- Allow a user to specifically set IP address of HDHomerun device to search for if other discovery methods dont work.
4+
15
v21.0.3
26
- Fixed API URL (thanks mooninite!)
37

pvr.hdhomerun/resources/language/resource.language.en_gb/strings.po

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ msgctxt "Addon Description"
2424
msgid "HDHomeRun PVR Client"
2525
msgstr ""
2626

27+
#. label-category: general
2728
msgctxt "#32001"
2829
msgid "General"
2930
msgstr ""
@@ -44,6 +45,35 @@ msgctxt "#32005"
4445
msgid "Mark new show"
4546
msgstr ""
4647

48+
#. label: Device Discovery - http_discovery
4749
msgctxt "#32006"
4850
msgid "Use HTTP discovery"
4951
msgstr ""
52+
53+
#. label: Device Discovery - force_ip
54+
msgctxt "#32007"
55+
msgid "Set IP of device to use"
56+
msgstr ""
57+
58+
#. label-group: General - Device Discovery
59+
msgctxt "#32008"
60+
msgid "Device Discovery"
61+
msgstr ""
62+
63+
#empty strings from id 32009 to 320099
64+
65+
#. ############
66+
#. help info #
67+
#. ############
68+
69+
#. help info - General
70+
71+
#. help: Device Discovery - http_discovery
72+
msgctxt "#32100"
73+
msgid "This uses Silicondust web API to return HDHomeRun devices connected with the same internet IP address"
74+
msgstr ""
75+
76+
#. help: Device Discovery - force_ip
77+
msgctxt "#32101"
78+
msgid "When other discovery methods do not work, enter an [B]IPv4[/B] address of a HDHomeRun device to explicitly search only that IP. This works when Broadcast and HTTP discovery do not find devices due to LAN/WAN differences in Client/Tuner. Restart Addon by Disabling and Enabling when changed."
79+
msgstr ""

pvr.hdhomerun/resources/settings.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,21 @@
2323
<default>true</default>
2424
<control type="toggle"/>
2525
</setting>
26-
<setting id="http_discovery" type="boolean" label="32006">
26+
</group>
27+
<group id="2" label="32008">
28+
<setting id="http_discovery" type="boolean" label="32006" help="32100">
2729
<level>0</level>
2830
<default>false</default>
2931
<control type="toggle"/>
3032
</setting>
33+
<setting id="force_ip" type="string" label="32007" help="32101">
34+
<level>0</level>
35+
<default></default>
36+
<constraints>
37+
<allowempty>true</allowempty>
38+
</constraints>
39+
<control type="edit" format="string" />
40+
</setting>
3141
</group>
3242
</category>
3343
</section>

src/HDHomeRunTuners.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,28 @@ bool HDHomeRunTuners::Update(int nMode)
180180
nTunerCount = hdhomerun_discover_find_devices_custom_v2(
181181
0, HDHOMERUN_DEVICE_TYPE_TUNER, HDHOMERUN_DEVICE_ID_WILDCARD, foundDevices, 16);
182182

183+
// If neither HTTPDiscovery or normal broadcast discovery do not find a device, if a
184+
// user has entered an IP address in settings for a forced IP, do a search based on that
185+
// specific IP. We only accomodate IPv4 addresses currently.
186+
if (nTunerCount <= 0)
187+
{
188+
std::string strUserForcedIP = SettingsType::Get().GetForcedIP();
189+
if (!strUserForcedIP.empty())
190+
{
191+
unsigned char addressbuf[sizeof(struct in6_addr)];
192+
193+
int s = inet_pton(AF_INET, strUserForcedIP.c_str(), addressbuf);
194+
if (s > 0)
195+
{
196+
uint32_t ipaddress = (addressbuf[0] << 24) + (addressbuf[1] << 16) + (addressbuf[2] << 8) + addressbuf[3];
197+
nTunerCount = hdhomerun_discover_find_devices_custom_v2(
198+
ipaddress, HDHOMERUN_DEVICE_TYPE_TUNER, HDHOMERUN_DEVICE_ID_WILDCARD, foundDevices, 16);
199+
200+
KODI_LOG(ADDON_LOG_DEBUG, "Found %d HDHomeRun tuners on IP %s", nTunerCount, strUserForcedIP.c_str());
201+
}
202+
}
203+
}
204+
183205
if (nTunerCount <= 0)
184206
return false;
185207

src/Settings.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bool SettingsType::ReadSettings()
2222
bMarkNew = kodi::addon::GetSettingBoolean("mark_new", true);
2323
bDebug = kodi::addon::GetSettingBoolean("debug", false);
2424
bHttpDiscovery = kodi::addon::GetSettingBoolean("http_discovery", false);
25+
strForcedIP = kodi::addon::GetSettingString("force_ip", "");
2526

2627
return true;
2728
}
@@ -48,6 +49,11 @@ ADDON_STATUS SettingsType::SetSetting(const std::string& settingName,
4849
bHttpDiscovery = settingValue.GetBoolean();
4950
return ADDON_STATUS_NEED_RESTART;
5051
}
52+
else if (settingName == "force_ip")
53+
{
54+
strForcedIP = settingValue.GetString();
55+
return ADDON_STATUS_NEED_RESTART;
56+
}
5157

5258
return ADDON_STATUS_OK;
5359
}

src/Settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#pragma once
1111

12+
#include <string>
13+
1214
#include <kodi/AddonBase.h>
1315

1416
class ATTR_DLL_LOCAL SettingsType
@@ -24,6 +26,7 @@ class ATTR_DLL_LOCAL SettingsType
2426
bool GetDebug() const { return bDebug; }
2527
bool GetMarkNew() const { return bMarkNew; }
2628
bool GetHttpDiscovery() const { return bHttpDiscovery; }
29+
std::string GetForcedIP() const { return strForcedIP; }
2730

2831
private:
2932
SettingsType() = default;
@@ -33,4 +36,5 @@ class ATTR_DLL_LOCAL SettingsType
3336
bool bDebug = false;
3437
bool bMarkNew = false;
3538
bool bHttpDiscovery = false;
39+
std::string strForcedIP;
3640
};

0 commit comments

Comments
 (0)