2015-11-16 23:49:54 -05:00
|
|
|
#include "ModemSQAM.h"
|
2015-11-18 21:09:51 -05:00
|
|
|
|
2015-11-28 23:03:07 -05:00
|
|
|
ModemSQAM::ModemSQAM() : ModemDigital() {
|
2015-11-18 21:09:51 -05:00
|
|
|
demodSQAM32 = modem_create(LIQUID_MODEM_SQAM32);
|
|
|
|
demodSQAM128 = modem_create(LIQUID_MODEM_SQAM128);
|
2015-11-23 20:03:47 -05:00
|
|
|
demodSQAM = demodSQAM32;
|
|
|
|
cons = 32;
|
2015-11-18 21:09:51 -05:00
|
|
|
}
|
|
|
|
|
2016-07-24 15:25:17 -04:00
|
|
|
ModemBase *ModemSQAM::factory() {
|
2015-11-18 21:09:51 -05:00
|
|
|
return new ModemSQAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
ModemSQAM::~ModemSQAM() {
|
|
|
|
modem_destroy(demodSQAM32);
|
|
|
|
modem_destroy(demodSQAM128);
|
|
|
|
}
|
|
|
|
|
2015-11-18 23:40:30 -05:00
|
|
|
std::string ModemSQAM::getName() {
|
|
|
|
return "SQAM";
|
|
|
|
}
|
|
|
|
|
2015-11-23 20:03:47 -05:00
|
|
|
ModemArgInfoList ModemSQAM::getSettings() {
|
|
|
|
ModemArgInfoList args;
|
|
|
|
|
|
|
|
ModemArgInfo consArg;
|
|
|
|
consArg.key = "cons";
|
|
|
|
consArg.name = "Constellation";
|
|
|
|
consArg.description = "Modem Constellation Pattern";
|
|
|
|
consArg.value = std::to_string(cons);
|
|
|
|
consArg.type = ModemArgInfo::STRING;
|
|
|
|
std::vector<std::string> consOpts;
|
|
|
|
consOpts.push_back("32");
|
|
|
|
consOpts.push_back("128");
|
|
|
|
consArg.options = consOpts;
|
|
|
|
args.push_back(consArg);
|
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModemSQAM::writeSetting(std::string setting, std::string value) {
|
|
|
|
if (setting == "cons") {
|
|
|
|
int newCons = std::stoi(value);
|
|
|
|
updateDemodulatorCons(newCons);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ModemSQAM::readSetting(std::string setting) {
|
|
|
|
if (setting == "cons") {
|
|
|
|
return std::to_string(cons);
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-11-18 22:57:31 -05:00
|
|
|
void ModemSQAM::updateDemodulatorCons(int cons) {
|
2015-11-23 20:03:47 -05:00
|
|
|
this->cons = cons;
|
|
|
|
switch (cons) {
|
|
|
|
case 32:
|
|
|
|
demodSQAM = demodSQAM32;
|
|
|
|
break;
|
|
|
|
case 128:
|
|
|
|
demodSQAM = demodSQAM128;
|
|
|
|
break;
|
2015-11-18 21:31:59 -05:00
|
|
|
}
|
2015-11-18 22:57:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ModemSQAM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
|
|
|
ModemKitDigital *dkit = (ModemKitDigital *)kit;
|
|
|
|
|
|
|
|
digitalStart(dkit, demodSQAM, input);
|
2015-11-18 21:31:59 -05:00
|
|
|
|
2016-02-04 18:05:33 -05:00
|
|
|
for (size_t i = 0, bufSize = input->data.size(); i < bufSize; i++) {
|
2015-11-18 21:31:59 -05:00
|
|
|
modem_demodulate(demodSQAM, input->data[i], &demodOutputDataDigital[i]);
|
|
|
|
}
|
|
|
|
updateDemodulatorLock(demodSQAM, 0.005f);
|
2015-11-18 22:57:31 -05:00
|
|
|
|
|
|
|
digitalFinish(dkit, demodSQAM);
|
2016-02-04 18:05:33 -05:00
|
|
|
}
|