mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-04-17 11:26:00 +08:00
ggwave : big refactoring / renaming
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user