FFTS and DAT are now correctly received at the browser

This commit is contained in:
ha7ilm 2017-05-05 19:45:30 +02:00
parent 50748ec042
commit 71d92c6767
2 changed files with 12 additions and 9 deletions

View File

@ -1137,14 +1137,15 @@ function on_ws_recv(evt)
if(!(evt.data instanceof ArrayBuffer)) { divlog("on_ws_recv(): Not ArrayBuffer received...",1); return; } if(!(evt.data instanceof ArrayBuffer)) { divlog("on_ws_recv(): Not ArrayBuffer received...",1); return; }
// //
debug_ws_data_received+=evt.data.byteLength/1000; debug_ws_data_received+=evt.data.byteLength/1000;
firstChars=getFirstChars(evt.data,3); first4Chars=getFirstChars(evt.data,4);
if(firstChars=="CLI") first3Chars=first4Chars.slice(0,3);
if(first3Chars=="CLI")
{ {
var stringData=arrayBufferToString(evt.data); var stringData=arrayBufferToString(evt.data);
if(stringData.substring(0,16)=="CLIENT DE SERVER") divlog("Server acknowledged WebSocket connection."); if(stringData.substring(0,16)=="CLIENT DE SERVER") divlog("Server acknowledged WebSocket connection.");
} }
if(firstChars=="AUD") if(first3Chars=="AUD")
{ {
var audio_data; var audio_data;
if(audio_compression=="adpcm") audio_data=new Uint8Array(evt.data,4) if(audio_compression=="adpcm") audio_data=new Uint8Array(evt.data,4)
@ -1154,9 +1155,10 @@ function on_ws_recv(evt)
audio_buffer_all_size_debug+=audio_data.length; audio_buffer_all_size_debug+=audio_data.length;
if(!ios && (audio_initialized==0 && audio_prepared_buffers.length>audio_buffering_fill_to)) audio_init() if(!ios && (audio_initialized==0 && audio_prepared_buffers.length>audio_buffering_fill_to)) audio_init()
} }
else if(firstChars=="FFT") else if(first3Chars=="FFT")
{ {
//alert("Yupee! Doing FFT"); //alert("Yupee! Doing FFT");
if(first4Chars=="FFTS") console.log("FFTS");
if(fft_compression=="none") waterfall_add_queue(new Float32Array(evt.data,4)); if(fft_compression=="none") waterfall_add_queue(new Float32Array(evt.data,4));
else if(fft_compression="adpcm") else if(fft_compression="adpcm")
{ {
@ -1165,15 +1167,15 @@ function on_ws_recv(evt)
var waterfall_i16=fft_codec.decode(new Uint8Array(evt.data,4)); var waterfall_i16=fft_codec.decode(new Uint8Array(evt.data,4));
var waterfall_f32=new Float32Array(waterfall_i16.length-COMPRESS_FFT_PAD_N); var waterfall_f32=new Float32Array(waterfall_i16.length-COMPRESS_FFT_PAD_N);
for(var i=0;i<waterfall_i16.length;i++) waterfall_f32[i]=waterfall_i16[i+COMPRESS_FFT_PAD_N]/100; for(var i=0;i<waterfall_i16.length;i++) waterfall_f32[i]=waterfall_i16[i+COMPRESS_FFT_PAD_N]/100;
if(evt.data[3]=="S") { secondary_demod_waterfall_add_queue(waterfall_f32); console.log("FFTS"); } if(first4Chars=="FFTS");// secondary_demod_waterfall_add_queue(waterfall_f32); //TODO digimodes
else waterfall_add_queue(waterfall_f32); else waterfall_add_queue(waterfall_f32);
} }
} }
else if(firstChars=="DAT") else if(first3Chars=="DAT")
{ {
console.log("DAT"); console.log("DAT");
} }
else if(firstChars=="MSG") else if(first3Chars=="MSG")
{ {
/*try /*try
{*/ {*/

View File

@ -522,13 +522,14 @@ class WebRXHandler(BaseHTTPRequestHandler):
try: try:
secondary_spectrum_data=dsp.read_secondary_fft(dsp.get_secondary_fft_bytes_to_read()) secondary_spectrum_data=dsp.read_secondary_fft(dsp.get_secondary_fft_bytes_to_read())
if len(secondary_spectrum_data) == 0: break if len(secondary_spectrum_data) == 0: break
rxws.send(self, "FFTS", secondary_spectrum_data) print "len(secondary_spectrum_data)", len(secondary_spectrum_data) #TODO digimodes
rxws.send(self, secondary_spectrum_data, "FFTS")
except: break except: break
while True: while True:
try: try:
secondary_demod_data=dsp.read_secondary_demod(1) secondary_demod_data=dsp.read_secondary_demod(1)
if len(secondary_demod_data) == 0: break if len(secondary_demod_data) == 0: break
rxws.send(self, "DAT ", secondary_demod_data) rxws.send(self, secondary_demod_data, "DAT ")
except: break except: break
# ========= process commands ========= # ========= process commands =========