From 40422d437c3a010c2961b02d8830ed18bb075f1d Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 22 Jul 2022 16:57:01 +0300 Subject: [PATCH] js, examples : fix a few minor issues caused by the recent API changes --- bindings/javascript/README.md | 8 ++++++-- examples/arduino-rx-web/index-tmpl.html | 2 +- examples/buttons/index-tmpl.html | 4 ++-- examples/ggwave-js/index-tmpl.html | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bindings/javascript/README.md b/bindings/javascript/README.md index 0f52584..4a884d9 100644 --- a/bindings/javascript/README.md +++ b/bindings/javascript/README.md @@ -15,17 +15,21 @@ var factory = require('ggwave') factory().then(function(ggwave) { // create ggwave instance with default parameters var parameters = ggwave.getDefaultParameters(); + + parameters.operatingMode |= ggwave.GGWAVE_OPERATING_MODE_USE_DSS; + var instance = ggwave.init(parameters); + console.log('instance: ' + instance); var payload = 'hello js'; // generate audio waveform for string "hello js" - var waveform = ggwave.encode(instance, payload, ggwave.TxProtocolId.GGWAVE_TX_PROTOCOL_AUDIBLE_FAST, 10); + var waveform = ggwave.encode(instance, payload, ggwave.ProtocolId.GGWAVE_PROTOCOL_AUDIBLE_FAST, 10); // decode the audio waveform back to text var res = ggwave.decode(instance, waveform); - if (res != payload) { + if (new TextDecoder("utf-8").decode(res) != payload) { process.exit(1); } }); diff --git a/examples/arduino-rx-web/index-tmpl.html b/examples/arduino-rx-web/index-tmpl.html index 00599f2..f519354 100644 --- a/examples/arduino-rx-web/index-tmpl.html +++ b/examples/arduino-rx-web/index-tmpl.html @@ -123,7 +123,7 @@ } // generate audio waveform - var waveform = ggwave.encode(instance, payload, ggwave.TxProtocolId.GGWAVE_PROTOCOL_MT_FASTEST, 25) + var waveform = ggwave.encode(instance, payload, ggwave.ProtocolId.GGWAVE_PROTOCOL_MT_FASTEST, 25) // play audio var buf = convertTypedArray(waveform, Float32Array); diff --git a/examples/buttons/index-tmpl.html b/examples/buttons/index-tmpl.html index a04ea14..bb571bd 100644 --- a/examples/buttons/index-tmpl.html +++ b/examples/buttons/index-tmpl.html @@ -113,9 +113,9 @@ // generate audio waveform var waveform = null; if (document.getElementById("checkbox-fp").checked) { - waveform = ggwave_FluentPet.encode(instance, payload, ggwave_FluentPet.TxProtocolId.GGWAVE_PROTOCOL_DT_FAST, 25) + waveform = ggwave_FluentPet.encode(instance, payload, ggwave_FluentPet.ProtocolId.GGWAVE_PROTOCOL_DT_FAST, 25) } else { - waveform = ggwave.encode(instance, payload, ggwave.TxProtocolId.GGWAVE_PROTOCOL_DT_FAST, 25) + waveform = ggwave.encode(instance, payload, ggwave.ProtocolId.GGWAVE_PROTOCOL_DT_FAST, 25) } // play audio diff --git a/examples/ggwave-js/index-tmpl.html b/examples/ggwave-js/index-tmpl.html index 440f142..f2e37ee 100644 --- a/examples/ggwave-js/index-tmpl.html +++ b/examples/ggwave-js/index-tmpl.html @@ -87,7 +87,7 @@ captureStop.click(); // generate audio waveform - var waveform = ggwave.encode(instance, txData.value, ggwave.TxProtocolId.GGWAVE_TX_PROTOCOL_AUDIBLE_FAST, 10) + var waveform = ggwave.encode(instance, txData.value, ggwave.ProtocolId.GGWAVE_PROTOCOL_AUDIBLE_FAST, 10) // play audio var buf = convertTypedArray(waveform, Float32Array);