mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-07 17:54:39 +08:00
c-api : add toggleRxProtocol() (#60)
This function allows to enable/disable Rx protocols during the decoding process. This is useful when the Tx/Rx protocol is known in advance.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
namespace {
|
||||
FILE * g_fptr = stderr;
|
||||
std::map<ggwave_Instance, GGWave *> g_instances;
|
||||
std::map<ggwave_Instance, GGWave::RxProtocols> g_rxProtocols;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -178,6 +179,27 @@ int ggwave_ndecode(
|
||||
return rxDataLength;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void ggwave_toggleRxProtocol(
|
||||
ggwave_Instance instance,
|
||||
ggwave_TxProtocolId rxProtocolId,
|
||||
int state) {
|
||||
// if never called - initialize with all available protocols
|
||||
if (g_rxProtocols.find(instance) == g_rxProtocols.end()) {
|
||||
g_rxProtocols[instance] = GGWave::getTxProtocols();
|
||||
}
|
||||
|
||||
if (state == 0) {
|
||||
// disable Rx protocol
|
||||
g_rxProtocols[instance].erase(rxProtocolId);
|
||||
} else if (state == 1) {
|
||||
// enable Rx protocol
|
||||
g_rxProtocols[instance][rxProtocolId] = GGWave::getTxProtocols().at(rxProtocolId);
|
||||
}
|
||||
|
||||
g_instances[instance]->setRxProtocols(g_rxProtocols[instance]);
|
||||
}
|
||||
|
||||
//
|
||||
// C++ implementation
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user