Skip to content

Commit

Permalink
wirbelscan: use hasJson to check for new setting
Browse files Browse the repository at this point in the history
  • Loading branch information
hannemann committed Mar 18, 2015
1 parent 045f1b8 commit a782de8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 21 deletions.
2 changes: 1 addition & 1 deletion API.html
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ <h2><a name="WirbelscanGetSetup">Retrieve the current setup of the Wirbelscan pl
<li>DVBC_QAM - AUTO = 0,QAM64 = 1, QAM128 = 2, QAM256 = 3, ALL = 4
<li>CountryId - the id according to country, found in country list, see wirbelscan_GetCountry
<li>SatId - the id according to satellite, found in list, see wirbelscan_GetSat
<li>scanflags - bitwise flag of wanted channels: TV = (1 << 0), RADIO = (1 << 1), FTA = (1 << 2), SCRAMBLED = (1 << 4), HDTV = (1 << 5)
<li>scanflags - bitwise flag of TV=1, RADIO=2, FTA=4, SCRAMBLED=8, HDTV=16 (default 31 -> TV + Radio, SD + HDTV, FTA + Scrambled)
<li>ATSC_type - VSB = 0, QAM = 1, both VSB+QAM = 2
</ul>
<br />
Expand Down
69 changes: 49 additions & 20 deletions wirbelscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,59 +191,88 @@ void WirbelscanResponder::replySetSetup(ostream& out,

wirbelscan->Service(getcmd.str().c_str(), &setupBuffer); // query buffer size.

if (q.hasBody("verbosity"))
// deactivated some sanity checks until it's clear which values are valid

if (q.hasJson("verbosity"))
{
setupBuffer.verbosity = q.getBodyAsInt("verbosity");
int verbosity = q.getBodyAsInt("verbosity");
if (verbosity >= 0 && verbosity < 6) {
setupBuffer.verbosity = verbosity;
}
}

if (q.hasBody("logFile"))
if (q.hasJson("logFile"))
{
setupBuffer.logFile = q.getBodyAsInt("logFile");
int logFile = q.getBodyAsInt("logFile");
if (logFile >= 0 && logFile < 3) {
setupBuffer.logFile = logFile;
}
}

if (q.hasBody("DVB_Type"))
if (q.hasJson("DVB_Type"))
{
setupBuffer.DVB_Type = q.getBodyAsInt("DVB_Type");
int dvbType = q.getBodyAsInt("DVB_Type");
//if ((dvbType >= 0 && dvbType < 6) || dvbType == 999) {
setupBuffer.DVB_Type = dvbType;
//}
}

if (q.hasBody("DVBT_Inversion"))
if (q.hasJson("DVBT_Inversion"))
{
setupBuffer.DVBT_Inversion = q.getBodyAsInt("DVBT_Inversion");
int dvbtInversion = q.getBodyAsInt("DVBT_Inversion");
if (dvbtInversion >= 0 && dvbtInversion < 2) {
setupBuffer.DVBT_Inversion = dvbtInversion;
}
}

if (q.hasBody("DVBC_Inversion"))
if (q.hasJson("DVBC_Inversion"))
{
setupBuffer.DVBC_Inversion = q.getBodyAsInt("DVBC_Inversion");
int dvbcInversion = q.getBodyAsInt("DVBC_Inversion");
if (dvbcInversion >= 0 && dvbcInversion < 2) {
setupBuffer.DVBC_Inversion = dvbcInversion;
}
}

if (q.hasBody("DVBC_Symbolrate"))
if (q.hasJson("DVBC_Symbolrate"))
{
setupBuffer.DVBC_Symbolrate = q.getBodyAsInt("DVBC_Symbolrate");
int dvbcSymbolrate = q.getBodyAsInt("DVBC_Symbolrate");
//if (dvbcSymbolrate >= 0 && dvbcSymbolrate < 16) {
setupBuffer.DVBC_Symbolrate = dvbcSymbolrate;
//}
}

if (q.hasBody("DVBC_QAM"))
if (q.hasJson("DVBC_QAM"))
{
setupBuffer.DVBC_QAM = q.getBodyAsInt("DVBC_QAM");
int dvbcQam = q.getBodyAsInt("DVBC_QAM");
//if (dvbcQam >= 0 && dvbcQam < 5) {
setupBuffer.DVBC_QAM = dvbcQam;
//}
}

if (q.hasBody("CountryId"))
if (q.hasJson("CountryId"))
{
setupBuffer.CountryId = q.getBodyAsInt("CountryId");
}

if (q.hasBody("SatId"))
if (q.hasJson("SatId"))
{
setupBuffer.SatId = q.getBodyAsInt("SatId");
}

if (q.hasBody("scanflags"))
if (q.hasJson("scanflags"))
{
setupBuffer.scanflags = q.getBodyAsInt("scanflags");
int scanFlags = q.getBodyAsInt("scanflags");
if (scanFlags >= 0 && scanFlags < 32) {
setupBuffer.scanflags = scanFlags;
}
}

if (q.hasBody("ATSC_type"))
if (q.hasJson("ATSC_type"))
{
setupBuffer.ATSC_type = q.getBodyAsInt("ATSC_type");
int atscType = q.getBodyAsInt("ATSC_type");
//if (atscType >= 0 && atscType < 3) {
setupBuffer.ATSC_type = atscType;
//}
}

std::stringstream setcmd;
Expand Down

0 comments on commit a782de8

Please sign in to comment.