This commit is contained in:
Your Name
2025-01-15 17:25:45 +01:00
parent 376a143428
commit e2c522af13

View File

@@ -216,6 +216,8 @@ def read_complete_response(serial_connection, timeout=2, end_of_response_timeout
# Open and read the JSON file
try:
# Send the command to request data (e.g., data for 60 seconds)
print("SART LOOP")
print("Getting NPM values")
ser_NPM.write(b'\x81\x12\x6D')
# Read the response
@@ -242,6 +244,7 @@ try:
# Sonde BME280 connected
if bme_280_config:
print("Getting BME280 values")
#on récupère les infos du BME280 et on les ajoute au payload_csv
i2c = busio.I2C(board.SCL, board.SDA)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)
@@ -314,7 +317,7 @@ try:
print(f"No serial connection for {name}")
# Getting the LTE Signal
print("-> Getting signal <-")
print("-> Getting LTE signal <-")
ser_sara.write(b'AT+CSQ\r')
response2 = read_complete_response(ser_sara)
print("Response:")
@@ -349,7 +352,7 @@ try:
ser_sara.write(csv_string.encode())
response_SARA_2 = read_complete_response(ser_sara)
if need_to_log:
print("Write to memory:")
print("Write data to memory:")
print(response_SARA_2)
#3. Send to endpoint (with device ID)
@@ -357,12 +360,10 @@ try:
command= f'AT+UHTTPC=0,4,"/pro_4G/data.php?sensor_id={device_id}","server_response.txt","sensordata_csv.json",4\r'
ser_sara.write(command.encode('utf-8'))
print("Waiting for +UUHTTPCR response...")
response_received = False
while not response_received:
response_SARA_3 = read_complete_response(ser_sara, timeout=5)
print(response_SARA_3)
if "+UUHTTPCR" in response_SARA_3:
print("Received +UUHTTPCR response.")
response_received = True
# Les types de réponse