Skip to content

Instantly share code, notes, and snippets.

@ph1048
Created July 23, 2025 22:24
Show Gist options
  • Save ph1048/bc2ff3cae73f5dd3bc59d30b13e20b8d to your computer and use it in GitHub Desktop.
Save ph1048/bc2ff3cae73f5dd3bc59d30b13e20b8d to your computer and use it in GitHub Desktop.
Quectel RM520N AT via Ethernet client
import socket
import struct
import time
import threading
SERVER_IP = "192.168.225.1"
SERVER_PORT = 1555
BUFFER_SIZE = 2048 * 4
def main(argv):
# payload = 'AT'
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("Connecting...")
client_socket.connect((SERVER_IP, SERVER_PORT))
print("OK")
def reader():
while True:
hdr = client_socket.recv(3)
if len(hdr) < 3:
exit()
command_id, length = struct.unpack('>BH', hdr)
value = client_socket.recv(length)
value_str = value.decode('utf-8', errors='ignore')
print(command_id, value_str)
t = threading.Thread(target=reader, daemon=True)
t.start()
while True:
payload = input() + "\r\n"
msg = struct.pack(">BH", 0xA4, len(payload)) + payload.encode()
client_socket.send(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment