Teltonika TST100 GPRS 命令未通过 TCP 发送
我有一个 teltonika tcp 服务器,可以解析数据,它工作正常,但我无法发送 gprs 命令,我不知道为什么或我做错了什么。以下是他们的网站文档:
首先,Teltonika设备打开GPRS会话并发送AVL数据 到服务器(请参阅设备协议)。所有记录发送完毕后 设备收到正确发送的数据阵列确认,然后 GPRS 可以将十六进制命令发送到设备。 ACK(确认 来自服务器的 IMEI)是一个一字节常量 0x01。的认可 从设备发送的每个数据数组都是四个字节整数 - 一个数字 收到的记录数。
这是应该有效的 getinfo 十六进制示例 第 1 个示例:通过 GPRS Codec12 发送 getinfo SMS 命令
十六进制流中的服务器请求: 000000000000000F0C010500000007676574696E666F0100004312
这是我的nodejs tcp服务器
const net = require('net');
const Parser = require('teltonika-parser-ex');
const binutils = require('binutils64');
const { parse } = require('path');
let server = net.createServer((c) => {
console.log("client connected");
c.on('end', () => {
console.log("client disconnected");
});
c.on('data', (data) => {
let buffer = data;
console.log(buffer);
let parser = new Parser(buffer);
if (parser.isImei) {
c.write(Buffer.alloc(1, 1)); // send ACK for IMEI
} else {
let avl = parser.getAvl();
console.log("parseRec", avl?.records?.map(({ gps, timestamp }) => {
return { gps, timestamp }
}
)
)
let writer = new binutils.BinaryWriter();
writer.WriteInt32(avl.number_of_data);
let response = writer.ByteBuffer;
c.write(response); // send ACK for AVL DATA
// console.log(test);
c.write("000000000000000F0C010500000007676574696E666F0100004312"); // SEND GETINFO command that is not working
}
});
});
server.listen(1574, '0.0.0.0', () => {
console.log("Server started");
});
最后一个c.write("000000000000000F0C010500000007676574696E666F0100004312");应该发送 getinfo 命令,我应该得到答案,但我什么也没得到。
i have a teltonika tcp server that parses data it works ok but i'm not able to send gprs command and i don't know why or what i do wrong. Here is from their website documentation:
First, the Teltonika device opens the GPRS session and sends AVL data
to the server (refer device protocols). Once all records are sent and
correct sent data array acknowledgment is received by device then GPRS
commands in Hex can be sent to the device. The ACK (acknowledge of
IMEI from server) is a one-byte constant 0x01. The acknowledgment of
each data array send from the device is four bytes integer – a number
of received records.this is the getinfo hex example that should work
1'st example: Sending getinfo SMS command via GPRS Codec12Server request in hexadecimal stream:
000000000000000F0C010500000007676574696E666F0100004312
here is my nodejs tcp server
const net = require('net');
const Parser = require('teltonika-parser-ex');
const binutils = require('binutils64');
const { parse } = require('path');
let server = net.createServer((c) => {
console.log("client connected");
c.on('end', () => {
console.log("client disconnected");
});
c.on('data', (data) => {
let buffer = data;
console.log(buffer);
let parser = new Parser(buffer);
if (parser.isImei) {
c.write(Buffer.alloc(1, 1)); // send ACK for IMEI
} else {
let avl = parser.getAvl();
console.log("parseRec", avl?.records?.map(({ gps, timestamp }) => {
return { gps, timestamp }
}
)
)
let writer = new binutils.BinaryWriter();
writer.WriteInt32(avl.number_of_data);
let response = writer.ByteBuffer;
c.write(response); // send ACK for AVL DATA
// console.log(test);
c.write("000000000000000F0C010500000007676574696E666F0100004312"); // SEND GETINFO command that is not working
}
});
});
server.listen(1574, '0.0.0.0', () => {
console.log("Server started");
});
the last c.write("000000000000000F0C010500000007676574696E666F0100004312"); should send the getinfo command and i should get an answer but i don't get nothing back.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好发送“no_of_avl_data”的十六进制值。检查下面的完整代码。
It would be best if you will send the HEX value of "no_of_avl_data". Check the full code below.
我设法让它工作,我必须将它转换为十六进制缓冲区。看来我正在发送一个字符串。这是我必须修改的内容,以防其他人遇到我的问题:
i managed to make it work, i had to convert it to a buffer in hex. It seems i was sending a string. Here is what i had to modify in case someone else has my problem: