From 10dacbefb42a5baf25a7ca940ba41f982c322682 Mon Sep 17 00:00:00 2001 From: inmysocks Date: Thu, 22 Jan 2026 13:03:35 +0100 Subject: [PATCH] add a node version as a quick prototype --- .gitignore | 1 + node/cellularChunking.js | 10 +++++----- node/index.js | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 349002d..feb789e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ roost node/node_modules/ node/records/ +node/test_sender/alldata/ diff --git a/node/cellularChunking.js b/node/cellularChunking.js index 07b06a8..7031657 100644 --- a/node/cellularChunking.js +++ b/node/cellularChunking.js @@ -26,9 +26,9 @@ if(typeof message_handler !== 'function') { message_handler = () => {} } - console.log('received chunk: ', chunk) + //console.log('received chunk: ', chunk) const the_header = parse_chunk_header(chunk) - console.log('header: ', the_header) + //console.log('header: ', the_header) if(typeof the_header.message_id !== 'undefined') { // if this is a new message start a record for it if(!chunk_record[the_header.message_id]) { @@ -47,13 +47,13 @@ } // if this is a new chunk save it in chunk_records if(!chunk_record[the_header.message_id].chunks[the_header.chunk_index]) { - console.log('new chunk for existing message') + //console.log('new chunk for existing message') chunk_record[the_header.message_id].chunks[the_header.chunk_index] = chunk.slice(the_header.header_length, the_header.chunk_length+the_header.header_length) chunk_record[the_header.message_id].r_chunks = chunk_record[the_header.message_id].r_chunks + 1 } // if we have all the chunks reconstruct the message and pass it on for processing if(chunk_record[the_header.message_id].r_chunks === chunk_record[the_header.message_id].num_chunks) { - console.log('have all chunks') + //console.log('have all chunks') let reconstructed_message = Buffer.from([]) Object.keys(chunk_record[the_header.message_id].chunks).sort((a,b)=>a-b).forEach(function(thisChunkIndex) { reconstructed_message = Buffer.concat([reconstructed_message, chunk_record[the_header.message_id].chunks[thisChunkIndex]]) @@ -155,4 +155,4 @@ receive_chunk, parse_chunk_header } -})() \ No newline at end of file +})() diff --git a/node/index.js b/node/index.js index a4a9f9c..d910e62 100644 --- a/node/index.js +++ b/node/index.js @@ -93,7 +93,7 @@ function make_string_string_message( target, this_message_id, ); - console.log("message header: ", theHeader); + //console.log("message header: ", theHeader); theData = Buffer.alloc(key.length + value.length + 3); theData.write(key, 0); theData.writeUInt8(255, key.length); @@ -152,15 +152,15 @@ function sendFile(socket, rinfo, thisFilePath, fileList) { } function handleMessage(message, rinfo) { - console.log("store message: ", message); + //console.log("store message: ", message); // this is going to be for storing the new format for the data // this needs to be set up to handle different message types differently, or it could be done when the databuffer is storedu - console.log( - new Date().toISOString(), - " store data 2 route ", - Buffer.from(message, "hex").toString("hex"), - ); + //console.log( + // new Date().toISOString(), + // " store data 2 route ", + // Buffer.from(message, "hex").toString("hex"), + //); const parsed_data = message_parser.parse_messages({ data: message }); let settingsString = Buffer.from([]); //const seenIDs = [] @@ -172,7 +172,7 @@ function handleMessage(message, rinfo) { ) { return; } else { - console.log("parsed data: ", thisData); + //console.log("parsed data: ", thisData); } dataBuffer.push(thisData); if ( @@ -187,7 +187,7 @@ function handleMessage(message, rinfo) { }); if (settingsString.length > 0) { - console.log("settingsString: ", settingsString.toString("hex")); + //console.log("settingsString: ", settingsString.toString("hex")); message_id = message_id + 1; stream.write( "< " + @@ -201,9 +201,9 @@ function handleMessage(message, rinfo) { settingsString, message_id, ); - console.log("msg chunks: ", theRespChunks); + //console.log("msg chunks: ", theRespChunks); theRespChunks.forEach(function (thisChunk) { - console.log("thisChunk: ", thisChunk); + //console.log("thisChunk: ", thisChunk); socket.send(thisChunk, rinfo.port, rinfo.address, (err) => { if (err) { console.log(err); @@ -351,7 +351,7 @@ function storeType1Messages(msgs) { theseParams.push( msg.source.slice(4), msg.reporting_node || "000000000000", - settings[msg.source.slice(4)].temperature_site, + settings[msg.source.slice(4)]?.temperature_site || "Unknowable 1", msg.timestamp, msg.data["18_inch_temperature"] || 500000, msg.data["36_inch_temperature"] || 500000,