Teletonika FM1100首先通过发送确认包01来发送您必须响应的IMEI。我无法弄清楚我是如何发送它的。它只是继续发送IMEI,因为它不会以我想要的格式获得01.
以下是Teletokina协议文档PDF http://bit.ly/1OrmI9P的链接(第7页,服务器通信)
这是我的代码
require 'socket' # Get sockets from stdlib
server = TCPServer.new 1337 # Socket to listen on port
loop do
Thread.new(server.accept) do |client|
client.print "\x00\x01" # also tried "\x01"
print "#{Time.now.strftime('%d/%m/%Y %H:%M')}: #{client.read} \n"
client.close
end
end
我还尝试了client.write
和pack
以4种不同的方式
...
client.write [0x01].pack('C')
client.write [0x00, 0x1].pack('C*')
client.write [0x01].pack('N')
client.write [0x00, 0x1].pack('N*')
...