0

I have a device that i want to send AT commands i am able to connect to the device with telnet or with a socket.

My issue is that i am unable to send the AT command or know how to receive it, i have found a few articles about this subject but they all talk about serial connection.

My question is what would be the proper way to send an AT commands if i am connected to the terminal by Telnet or a Socket and to receive the response

i have tried both socket.send("AT\n") and telnet.write(b"AT")

"AT" should just respond with "OK" status

Mike.G
  • 125
  • 5
  • 14

2 Answers2

1

Correct AT command handling is as follows:

You need to send the command line, then read and parse (framing) AT command responses until you receive a Final result code.

See this answer (or this, this or some of my other answers) for details on how the logic for reading and parsing should be.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
0

I am not sure if you tried this, but after [don't forget the .encode() and .decode() for send and recv]

s=socket.socket()
s.connect((host,port))
s.send("AT\n".encode())

You have to use

data=s.recv(1024).decode()
print(data)

To receive information. Then, you close the socket with

s.close()

Hope that helped!

Evgeny
  • 153
  • 16