1

I’m trying to send and receive UDP packets to my server. As far as sending the packet is concerned, it’s no problem. But when I try to receive a packet nothing ever arrives. In the photo you can see the complete setup of my BC68 quectel and on the right side sending UDP packet to the BC68 address and port (periodically every 1s). If I try to send just one packet at a time I still have the same problem.

Image

Am I doing something wrong or is there another problem?

Here is also the program I use to send data to BC68:

    import socket
    import time
    
    # Nastavení IP adresy a portu
    local_ip = "0.0.0.0"  # Poslouchá na všech rozhraních
    local_port = 60000    # Port pro příjem UDP paketů
    
    remote_ip = "10.234.160.111"  # IP adresa BC68
    remote_port = 1884   # Port BC68 pro odesílání zpráv
    
    hex_message = "DEADBEEF"  # Testovací zpráva v HEX
    message = bytes.fromhex(hex_message)  # Převod na binární data
    
    # Vytvoření UDP socketu
    udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    udp_socket.bind((local_ip, local_port))  # Svázání socketu pro příjem
    
    print(f"UDP server běží na {local_ip}:{local_port}, posílá data na {remote_ip}:{remote_port}")
    
    try:
        while True:
            # Odeslání UDP zprávy v HEX formátu
            udp_socket.sendto(message, (remote_ip, remote_port))
            print(f"✅ UDP paket odeslán (HEX): {hex_message} na {remote_ip}:{remote_port}")
    
            # Nastavení timeoutu pro příjem
            udp_socket.settimeout(1)  # Čeká max 1 sekundu na odpověď
    
            try:
                # Příjem UDP zprávy
                data, addr = udp_socket.recvfrom(1024)  # Přijme max 1024 bajtů
                hex_data = data.hex().upper()  # Převod na HEX
                ascii_data = data.decode(errors="ignore")  # Pokus o dekódování do ASCII
    
                print(f"📩 Přijatá zpráva od {addr}: HEX={hex_data} | ASCII={ascii_data}")
    
            except socket.timeout:
                print("⏳ Žádná odpověď nepřišla.")
    
            # Počkat jednu sekundu
            time.sleep(1)
    
    except KeyboardInterrupt:
        print("🛑 Program ukončen.")
    
    finally:
        udp_socket.close()

Here are also the rewritten steps on BC68:

AT+NRB
REBOOTING
B!Ä
Boot: Unsigned
Security B.. Verified
Protocol A.. Verified Apps A...... Verified
REBOOT_CAUSE_APPLICATION_AT
Neul OK

AT+QREGSWT=2
OK

AT+CFUN=1
OK

AT+CGDCONT=0, "IP", "iot.t-mobile.cz"
OK

AT+COPS=1,2,"23001"
OK 

AT+CSQ
+CSQ:29,99
OK

AT+CGPADDR
+CGPADDR: 0,10.234.160.111
OK

AT+NSOCR=DGRAM, 17, 1884,1
1
OK

AT+NSONMI=3
OK

AT+NSOST=1,158.196.109.146,60000,4,41686F6A
1,4
OK

AT+NSORF=1,512
OK
4
  • Please do not post critical information as images. Please type it in. Please provide the code you have written to set up the socket and listen on the server side. Commented Feb 11 at 22:17
  • there is no critical information on the photo but I edited it a bit anyway. The code is attached but even when I tried other methods to send UDP packet to BC68 it didn't work. Commented Feb 12 at 13:32
  • I think that it is possible that using '' will work better than '0.0.0.0' based on the doc in docs.python.org/3/library/socket.html#example. Commented Feb 12 at 13:38
  • I tried and no change. I'm still not getting any replies on BC68 Commented Feb 12 at 13:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.