perform binary decoding on the server side

This commit is contained in:
Jakob Ketterl 2019-10-25 21:08:56 +02:00
parent 70e2a99274
commit c7eb5c430c
2 changed files with 5 additions and 10 deletions

View File

@ -23,11 +23,6 @@
is_firefox = navigator.userAgent.indexOf("Firefox") >= 0; 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 bandwidth;
var center_freq; var center_freq;
var fft_size; var fft_size;
@ -1136,6 +1131,9 @@ function on_ws_recv(evt) {
case "sdr_error": case "sdr_error":
divlog(json['value'], true); divlog(json['value'], true);
break; break;
case 'secondary_demod':
secondary_demod_push_data(json['value']);
break;
default: default:
console.warn('received message of unknown type: ' + json['type']); console.warn('received message of unknown type: ' + json['type']);
} }
@ -1186,10 +1184,6 @@ function on_ws_recv(evt) {
secondary_demod_waterfall_add(waterfall_f32); secondary_demod_waterfall_add(waterfall_f32);
} }
break; break;
case 4:
// secondary demod
secondary_demod_push_data(arrayBufferToString(data));
break;
default: default:
console.warn('unknown type of binary message: ' + type) console.warn('unknown type of binary message: ' + type)
} }

View File

@ -243,7 +243,8 @@ class OpenWebRxReceiverClient(Client):
self.send(bytes([0x03]) + data) self.send(bytes([0x03]) + data)
def write_secondary_demod(self, 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): def write_secondary_dsp_config(self, cfg):
self.send({"type": "secondary_config", "value": cfg}) self.send({"type": "secondary_config", "value": cfg})