Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to set specific IP of hdhomerun unit #144

Open
wants to merge 3 commits into
base: Nexus
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pvr.hdhomerun/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hdhomerun"
version="20.4.0"
version="20.5.0"
name="HDHomeRun Client"
provider-name="Zoltan Csizmadia ([email protected])">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
4 changes: 4 additions & 0 deletions pvr.hdhomerun/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v20.5.0
- Add some help labels to some settings and group discovery related settings
- Allow a user to specifically set IP address of HDHomerun device to search for if other discovery methods dont work.

v20.4.0
- Kodi inputstream API update to version 3.2.0
- Kodi PVR API update to version 8.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ msgctxt "Addon Description"
msgid "HDHomeRun PVR Client"
msgstr ""

#. label-category: general
msgctxt "#32001"
msgid "General"
msgstr ""
Expand All @@ -44,6 +45,35 @@ msgctxt "#32005"
msgid "Mark new show"
msgstr ""

#. label: Device Discovery - http_discovery
msgctxt "#32006"
msgid "Use HTTP discovery"
msgstr ""

#. label: Device Discovery - force_ip
msgctxt "#32007"
msgid "Set IP of device to use"
msgstr ""

#. label-group: General - Device Discovery
msgctxt "#32008"
msgid "Device Discovery"
msgstr ""

#empty strings from id 32009 to 320099

#. ############
#. help info #
#. ############

#. help info - General

#. help: Device Discovery - http_discovery
msgctxt "#32100"
msgid "This uses Silicondust web API to return HDHomeRun devices connected with the same internet IP address"
msgstr ""

#. help: Device Discovery - force_ip
msgctxt "#32101"
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."
msgstr ""
12 changes: 11 additions & 1 deletion pvr.hdhomerun/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@
<default>true</default>
<control type="toggle"/>
</setting>
<setting id="http_discovery" type="boolean" label="32006">
</group>
<group id="2" label="32008">
<setting id="http_discovery" type="boolean" label="32006" help="32100">
<level>0</level>
<default>false</default>
<control type="toggle"/>
</setting>
<setting id="force_ip" type="string" label="32007" help="32101">
<level>0</level>
<default></default>
<constraints>
<allowempty>true</allowempty>
</constraints>
<control type="edit" format="string" />
</setting>
</group>
</category>
</section>
Expand Down
22 changes: 22 additions & 0 deletions src/HDHomeRunTuners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
4 changes: 4 additions & 0 deletions src/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#pragma once

#include <string>

#include <kodi/AddonBase.h>

class ATTR_DLL_LOCAL SettingsType
Expand All @@ -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;
Expand All @@ -33,4 +36,5 @@ class ATTR_DLL_LOCAL SettingsType
bool bDebug = false;
bool bMarkNew = false;
bool bHttpDiscovery = false;
std::string strForcedIP;
};