From fe61b56b5bb81f59c3bb15666bdaff402367d21a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Jul 2025 16:38:41 +0100 Subject: [PATCH] update --- SARA/UDP/receiveUDP_downlink.py | 12 ++++++++++++ SARA/UDP/sendUDP_message.py | 3 +-- loop/SARA_send_data_v2.py | 17 +++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 SARA/UDP/receiveUDP_downlink.py diff --git a/SARA/UDP/receiveUDP_downlink.py b/SARA/UDP/receiveUDP_downlink.py new file mode 100644 index 0000000..38a0b59 --- /dev/null +++ b/SARA/UDP/receiveUDP_downlink.py @@ -0,0 +1,12 @@ +''' + ____ _ ____ _ + / ___| / \ | _ \ / \ + \___ \ / _ \ | |_) | / _ \ + ___) / ___ \| _ < / ___ \ + |____/_/ \_\_| \_\/_/ \_\ + +Script to read UDP message + +/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/UDP/receiveUDP_downlink.py + +''' \ No newline at end of file diff --git a/SARA/UDP/sendUDP_message.py b/SARA/UDP/sendUDP_message.py index 39e6461..fe660ea 100644 --- a/SARA/UDP/sendUDP_message.py +++ b/SARA/UDP/sendUDP_message.py @@ -5,8 +5,7 @@ ___) / ___ \| _ < / ___ \ |____/_/ \_\_| \_\/_/ \_\ -Script to set the PDP context for the SARA R5 - +Script to send UDP message /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/UDP/sendUDP_message.py diff --git a/loop/SARA_send_data_v2.py b/loop/SARA_send_data_v2.py index 16d44a7..83696c8 100755 --- a/loop/SARA_send_data_v2.py +++ b/loop/SARA_send_data_v2.py @@ -944,7 +944,7 @@ try: else: print("Failed to extract socket ID") - #Connect to UDP server + #Connect to UDP server (USOCO) print("Connect to server:") command = f'AT+USOCO={socket_id},"192.168.0.20",4242\r' ser_sara.write(command.encode('utf-8')) @@ -957,17 +957,30 @@ try: csv_udp_string = ','.join(str(value) if value is not None else '' for value in payload_udp) size_of_udp_string = len(csv_udp_string) - # 4. Write data and send + # 4. Write data and send (USOWR) print("Write data:") + print(csv_udp_string) command = f'AT+USOWR={socket_id},{size_of_udp_string}\r' ser_sara.write(command.encode('utf-8')) response_SARA_2 = read_complete_response(ser_sara, wait_for_lines=["@","OK", "+CME ERROR", "ERROR"], debug=False) + print('

') print(response_SARA_2) + print("

", end="") ser_sara.write(csv_udp_string.encode()) response_SARA_2 = read_complete_response(ser_sara, wait_for_lines=["@","OK", "+CME ERROR", "ERROR"], debug=False) + print('

') print(response_SARA_2) + print("

", end="") + #Read reply from server (USORD) + print("Read reply:") + command = f'AT+USORD=0,100\r' + ser_sara.write(command.encode('utf-8')) + response_SARA_2 = read_complete_response(ser_sara, wait_for_lines=["OK", "+CME ERROR", "ERROR"], debug=False) + print('

') + print(response_SARA_2) + print("

", end="") #Close socket print("Close socket:")