ggwave : big refactoring / renaming

This commit is contained in:
Georgi Gerganov
2022-06-05 11:05:34 +03:00
parent 05f1b4750b
commit 7c5b614c16
26 changed files with 1097 additions and 834 deletions

View File

@@ -27,10 +27,10 @@ int main() {
const char * payload = "test";
char decoded[16];
int n = ggwave_encode(instance, payload, 4, GGWAVE_TX_PROTOCOL_AUDIBLE_FASTEST, 50, NULL, 1);
int n = ggwave_encode(instance, payload, 4, GGWAVE_PROTOCOL_AUDIBLE_FASTEST, 50, NULL, 1);
char waveform[n];
int ne = ggwave_encode(instance, payload, 4, GGWAVE_TX_PROTOCOL_AUDIBLE_FASTEST, 50, waveform, 0);
int ne = ggwave_encode(instance, payload, 4, GGWAVE_PROTOCOL_AUDIBLE_FASTEST, 50, waveform, 0);
CHECK(ne > 0);
// not enough output buffer size to store the decoded message
@@ -46,14 +46,26 @@ int main() {
CHECK(ret == 4);
// disable Rx protocol
ggwave_toggleRxProtocol(instance, GGWAVE_TX_PROTOCOL_AUDIBLE_FASTEST, 0);
ret = ggwave_ndecode(instance, waveform, ne, decoded, 4);
CHECK(ret == -1); // fail
{
ggwave_rxToggleProtocol(GGWAVE_PROTOCOL_AUDIBLE_FASTEST, 0);
ggwave_Instance instanceTmp = ggwave_init(parameters);
ret = ggwave_ndecode(instanceTmp, waveform, ne, decoded, 4);
CHECK(ret == -1); // fail
ggwave_free(instanceTmp);
}
// enable Rx protocol
ggwave_toggleRxProtocol(instance, GGWAVE_TX_PROTOCOL_AUDIBLE_FASTEST, 1);
ret = ggwave_ndecode(instance, waveform, ne, decoded, 4);
CHECK(ret == 4); // success
{
ggwave_rxToggleProtocol(GGWAVE_PROTOCOL_AUDIBLE_FASTEST, 1);
ggwave_Instance instanceTmp = ggwave_init(parameters);
ret = ggwave_ndecode(instanceTmp, waveform, ne, decoded, 4);
CHECK(ret == 4); // success
ggwave_free(instanceTmp);
}
decoded[ret] = 0; // null-terminate the received data
CHECK(strcmp(decoded, payload) == 0);