update
This commit is contained in:
12
SARA/UDP/receiveUDP_downlink.py
Normal file
12
SARA/UDP/receiveUDP_downlink.py
Normal file
@@ -0,0 +1,12 @@
|
||||
'''
|
||||
____ _ ____ _
|
||||
/ ___| / \ | _ \ / \
|
||||
\___ \ / _ \ | |_) | / _ \
|
||||
___) / ___ \| _ < / ___ \
|
||||
|____/_/ \_\_| \_\/_/ \_\
|
||||
|
||||
Script to read UDP message
|
||||
|
||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/UDP/receiveUDP_downlink.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
|
||||
|
||||
|
||||
@@ -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('<p class="text-danger-emphasis">')
|
||||
print(response_SARA_2)
|
||||
print("</p>", 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('<p class="text-danger-emphasis">')
|
||||
print(response_SARA_2)
|
||||
print("</p>", 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('<p class="text-danger-emphasis">')
|
||||
print(response_SARA_2)
|
||||
print("</p>", end="")
|
||||
|
||||
#Close socket
|
||||
print("Close socket:")
|
||||
|
||||
Reference in New Issue
Block a user