Skip to content

Commit

Permalink
emscripten : add rx duration frames api getter (#100)
Browse files Browse the repository at this point in the history
* Add rxDurationFrames api getter

* Fixed comment

---------

Co-authored-by: Vittorio Palmisano <[email protected]>
  • Loading branch information
vpalmisano and Vittorio Palmisano authored Sep 8, 2023
1 parent c2716d8 commit bac95c8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
7 changes: 6 additions & 1 deletion bindings/javascript/emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ EMSCRIPTEN_BINDINGS(ggwave) {

int nActual = ggwave_encode(instance, data.data(), data.size(), protocolId, volume, result.data(), 0);

printf("n = %d, nActual = %d\n", n, nActual);
// printf("n = %d, nActual = %d\n", n, nActual);
return emscripten::val(emscripten::typed_memory_view(nActual, result.data()));
}));

Expand Down Expand Up @@ -128,4 +128,9 @@ EMSCRIPTEN_BINDINGS(ggwave) {
int freqStart) {
ggwave_txProtocolSetFreqStart(protocolId, freqStart);
}));

emscripten::function("rxDurationFrames", emscripten::optional_override(
[](ggwave_Instance instance) {
return ggwave_rxDurationFrames(instance);
}));
}
12 changes: 5 additions & 7 deletions bindings/javascript/ggwave.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions include/ggwave/ggwave.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ extern "C" {
ggwave_ProtocolId protocolId,
int freqStart);

// Return recvDuration_frames value for a rx protocol
GGWAVE_API int ggwave_rxDurationFrames(
ggwave_Instance instance);

#ifdef __cplusplus
}

Expand Down Expand Up @@ -736,6 +740,7 @@ class GGWave {
int rxFramesLeftToRecord() const;
int rxFramesToAnalyze() const;
int rxFramesLeftToAnalyze() const;
int rxDurationFrames() const;

bool rxStopReceiving();

Expand Down
7 changes: 7 additions & 0 deletions src/ggwave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ void ggwave_txProtocolSetFreqStart(
GGWave::Protocols::tx()[protocolId].freqStart = freqStart;
}

extern "C"
int ggwave_rxDurationFrames(ggwave_Instance id) {
GGWave * ggWave = (GGWave *) g_instances[id];
return ggWave->rxDurationFrames();
}

//
// C++ implementation
//
Expand Down Expand Up @@ -1255,6 +1261,7 @@ int GGWave::rxFramesToRecord() const { return m_rx.framesToRecord; }
int GGWave::rxFramesLeftToRecord() const { return m_rx.framesLeftToRecord; }
int GGWave::rxFramesToAnalyze() const { return m_rx.framesToAnalyze; }
int GGWave::rxFramesLeftToAnalyze() const { return m_rx.framesLeftToAnalyze; }
int GGWave::rxDurationFrames() const { return m_rx.recvDuration_frames; }

bool GGWave::rxStopReceiving() {
if (m_rx.receiving == false) {
Expand Down

0 comments on commit bac95c8

Please sign in to comment.