fix handling of type 13 and type 17 messages.

main
inmysocks 2026-01-29 12:38:30 +01:00
parent 10dacbefb4
commit 671b68d70a
2 changed files with 87 additions and 30 deletions

View File

@ -32,7 +32,7 @@ function createPool() {
});
pool.getConnection(function (err, connection) {
if (err) {
console.log("error setting the database");
console.log("error setting the database: ", err);
} else {
connection.execute(
`SELECT
@ -53,7 +53,7 @@ function createPool() {
function (err2, results) {
if (err2) {
console.log(`Some other error getting node settings: ${err2}`);
connection.release();
//connection.release();
} else {
results.forEach(function (thisRow) {
settings[thisRow.node_id] = {
@ -381,7 +381,13 @@ function storeType1Messages(msgs) {
connection.execute(thisSQL, theseParams, function (err2, results) {
if (err2) {
console.log(`Some other error storing type 1 message: ${err2}`);
connection.release();
if(connection) {
try {
connection.release();
} catch (e) {
console.log('some error releasing connection: ', e)
}
}
} else {
connection.release();
// TODO: anything here?
@ -426,7 +432,13 @@ function storeType6Messages(msgs) {
connection.execute(thisSQL, theseParams, function (err2, results) {
if (err2) {
console.log(`Some other error storing type 6 message: ${err2}`);
connection.release();
if(connection) {
try {
connection.release();
} catch (e) {
console.log('some error releasing connection: ', e)
}
}
} else {
connection.release();
// TODO: anything here?
@ -466,8 +478,14 @@ function storeType13Messages(msgs) {
} else {
connection.execute(thisSQL, theseParams, function (err2, results) {
if (err2) {
console.log(`Some other error storing type 13 message: ${err}`);
connection.release();
console.log(`Some other error storing type 13 message: ${err2}`);
if(connection) {
try {
connection.release();
} catch (e) {
console.log('some error releasing connection: ', e)
}
}
} else {
connection.release();
// TODO: anything here?
@ -497,6 +515,9 @@ function storeType17Messages(msgs) {
);
});
});
if(n === 0) {
return // don't try to store anything if there is nothing to store
}
const thisSQL =
"INSERT IGNORE INTO datavis_noderssirecord (node_id,neighbor_id,collection_time,rssi,server_received_time) VALUES " +
"(?,?,?,?,?),".repeat(n).slice(0, -1) +
@ -508,7 +529,13 @@ function storeType17Messages(msgs) {
connection.execute(thisSQL, theseParams, function (err2, results) {
if (err2) {
console.log(`Some other error storing type 17 message: ${err2}`);
connection.release();
if(connection) {
try {
connection.release();
} catch (e) {
console.log('some error releasing connection: ', e)
}
}
} else {
connection.release();
// TODO: anything here?
@ -522,6 +549,9 @@ function storeType17Messages(msgs) {
}
function storeMessages() {
if(dataBuffer.length == 0) {
return
}
console.log("store messages!!");
try {
const type1Messages = dataBuffer.filter(function (thisMsg) {

View File

@ -307,27 +307,41 @@
}
const fileVersionManifestTypesDict = {
1: "boot_Version",
2: "program_Version",
3: "epaper_Version",
4: "mesh_version",
5: "bq27441_version",
6: "rtcmem_version",
7: "screen_version",
8: "message_parser_version",
9: "sht40_version",
10: "ssd1306_version",
11: "tmpxx_version",
12: "uqr_version",
13: "main_version",
14: "test_version",
15: "mc3470_version",
16: "settings_version",
17: "file_name_map_version",
18: "_walter_version",
19: "cellular_chunking_version",
20: "ds3231_version",
21: "walter_version",
1: 1,// "boot_Version",
2: 2,// "program_Version",
3: 3,// "epaper_Version",
4: 4,// "mesh_version",
5: 5,// "bq27441_version",
6: 6,// "rtcmem_version",
7: 7,// "screen_version",
8: 8,// "message_parser_version",
9: 9,// "sht40_version",
10: 10,// "ssd1306_version",
11: 11,// "tmpxx_version",
12: 12,// "uqr_version",
13: 13,// "main_version",
14: 14,// "test_version",
15: 15,// "mc3470_version",
16: 16,// "settings_version",
17: 17,// "file_name_map_version",
18: 18,// "rv3032_version",
19: 19,// "bme280_version",
20: 20,// "walter_version",
21: 21,// "_walter_version",
22: 22,// "cellular_chunking_version",
23: 23,// "base_mase_version",
24: 24,// "unknown_file_version",
25: 25,// "unknown_file_version",
26: 26,// "unknown_file_version",
27: 27,// "unknown_file_version",
28: 28,// "unknown_file_version",
29: 29,// "unknown_file_version",
30: 30,// "unknown_file_version",
31: 31,// "unknown_file_version",
32: 32,// "unknown_file_version",
33: 33,// "unknown_file_version",
34: 34,// "unknown_file_version",
35: 35// "unknown_file_version"
}
const fileVersionManifestConversionFunctions = {
@ -352,6 +366,20 @@
19: arrayToDecimal,
20: arrayToDecimal,
21: arrayToDecimal,
22: arrayToDecimal,
23: arrayToDecimal,
24: arrayToDecimal,
25: arrayToDecimal,
26: arrayToDecimal,
27: arrayToDecimal,
28: arrayToDecimal,
29: arrayToDecimal,
30: arrayToDecimal,
31: arrayToDecimal,
32: arrayToDecimal,
33: arrayToDecimal,
34: arrayToDecimal,
35: arrayToDecimal
}
const rssiDataTypesDict = {
@ -381,7 +409,6 @@
return '00:00:00'
}
}
// input is a 2 byte array representing minutes since midnight, convert it into hh:mm:ss time
function arrayToTime(input) {
@ -770,4 +797,4 @@
make_byte_string_message,
make_string_string_message
}
})()
})()