卫星通信服务平台

This commit is contained in:
2026-05-19 17:12:10 +08:00
parent 098d2ff575
commit 2398f17070
5 changed files with 149 additions and 72 deletions

View File

@@ -21,14 +21,14 @@ module.exports = (app) => {
// 00000043010000000000000000000000000000000000000000 18 31353037365f32303236303330333135313835315f323832 00 0f 0102030405060708090a0b0c0d0e0f
let sn_value = value.slice(52, 100),
snBuffer = Buffer.from(sn_value, 'hex'),
snNumber = snBuffer.toString('ascii').split("_")[0],
snNumber = snBuffer.toString('ascii').split("_")[0].padStart(8, '0'),
msg_value = value.slice(104, value.length),
msgBuffer = Buffer.from(msg_value, 'hex'),
msgData = msgBuffer.toString('ascii');
console.log(msgData)
// socket接收消息后触发事件监听器,将消息发送给websocket客户端并存储在数据库中
shunt.socketEmitter().emit(snNumber, { msg_data: msgData, created_at: new Date() });
await app.curl('http://127.0.0.1:' + app.server.address().port + '/shortMsg', {
const shortMsg = await app.curl('http://127.0.0.1:' + app.server.address().port + '/shortMsg', {
dataType: 'json',
contentType: 'application/x-www-form-urlencoded',
method: 'POST',
@@ -40,6 +40,20 @@ module.exports = (app) => {
created_at: new Date()
},
});
if (shortMsg.data.code == 404) {
await app.curl('http://127.0.0.1:' + app.server.address().port + '/saveUnknown', {
dataType: 'json',
contentType: 'application/x-www-form-urlencoded',
method: 'POST',
timeout: 3000,
data: {
system_type: 1,
original_msg: value,
msg_data: msgData,
created_at: new Date()
},
});
}
});
socket.on('end', function (data) {
console.log(data);