Teletonika FM1100 first sends the IMEI which you have to respond to by sending an acknowledgment packet 01 to. I can't figure out how i need to send that. It just keeps sending the IMEI because it does not get the 01 in the format it wants it i guess.
Here is a link to the Teletokina protocol documentation PDF http://bit.ly/1OrmI9P (Page 7, Server communication)
This is my code
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
I also tried it with client.write
and pack
in 4 different ways
...
client.write [0x01].pack('C')
client.write [0x00, 0x1].pack('C*')
client.write [0x01].pack('N')
client.write [0x00, 0x1].pack('N*')
...