From c7eb5c430c89efae9ca31af72230a1eaed968743 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 25 Oct 2019 21:08:56 +0200 Subject: [PATCH] perform binary decoding on the server side --- htdocs/openwebrx.js | 12 +++--------- owrx/connection.py | 3 ++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 633a7d2..e3d0692 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -23,11 +23,6 @@ is_firefox = navigator.userAgent.indexOf("Firefox") >= 0; -function arrayBufferToString(buf) { - //http://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers - return String.fromCharCode.apply(null, new Uint8Array(buf)); -} - var bandwidth; var center_freq; var fft_size; @@ -1136,6 +1131,9 @@ function on_ws_recv(evt) { case "sdr_error": divlog(json['value'], true); break; + case 'secondary_demod': + secondary_demod_push_data(json['value']); + break; default: console.warn('received message of unknown type: ' + json['type']); } @@ -1186,10 +1184,6 @@ function on_ws_recv(evt) { secondary_demod_waterfall_add(waterfall_f32); } break; - case 4: - // secondary demod - secondary_demod_push_data(arrayBufferToString(data)); - break; default: console.warn('unknown type of binary message: ' + type) } diff --git a/owrx/connection.py b/owrx/connection.py index b4b827b..824d912 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -243,7 +243,8 @@ class OpenWebRxReceiverClient(Client): self.send(bytes([0x03]) + data) def write_secondary_demod(self, data): - self.send(bytes([0x04]) + data) + message = data.decode('ascii') + self.send({"type": "secondary_demod", "value": message}) def write_secondary_dsp_config(self, cfg): self.send({"type": "secondary_config", "value": cfg})