update
This commit is contained in:
@@ -211,20 +211,18 @@ config_file = '/var/www/nebuleair_pro_4g/config.json'
|
|||||||
config = load_config(config_file)
|
config = load_config(config_file)
|
||||||
device_latitude_raw = config.get('latitude_raw', 0)
|
device_latitude_raw = config.get('latitude_raw', 0)
|
||||||
device_longitude_raw = config.get('longitude_raw', 0)
|
device_longitude_raw = config.get('longitude_raw', 0)
|
||||||
|
|
||||||
baudrate = config.get('SaraR4_baudrate', 115200) #baudrate du sara R4
|
baudrate = config.get('SaraR4_baudrate', 115200) #baudrate du sara R4
|
||||||
device_id = config.get('deviceID', '').upper() #device ID en maj
|
device_id = config.get('deviceID', '').upper() #device ID en maj
|
||||||
bme_280_config = config.get('BME280/get_data_v2.py', False) #présence du BME280
|
bme_280_config = config.get('BME280/get_data_v2.py', False) #présence du BME280
|
||||||
envea_cairsens= config.get('envea/read_value_v2.py', False)
|
envea_cairsens= config.get('envea/read_value_v2.py', False)
|
||||||
mppt_charger= config.get('MPPT/read.py', False)
|
mppt_charger= config.get('MPPT/read.py', False)
|
||||||
wind_meter= config.get('windMeter/read.py', False)
|
wind_meter= config.get('windMeter/read.py', False)
|
||||||
|
|
||||||
send_aircarto = config.get('send_aircarto', True) #envoi sur AirCarto (data.nebuleair.fr)
|
send_aircarto = config.get('send_aircarto', True) #envoi sur AirCarto (data.nebuleair.fr)
|
||||||
send_uSpot = config.get('send_uSpot', False) #envoi sur MicroSpot ()
|
send_uSpot = config.get('send_uSpot', False) #envoi sur MicroSpot ()
|
||||||
reset_uSpot_url = False
|
reset_uSpot_url = False
|
||||||
selected_networkID = int(config.get('SARA_R4_neworkID', 0))
|
selected_networkID = int(config.get('SARA_R4_neworkID', 0))
|
||||||
npm_5channel = config.get('NextPM_5channels', False) #5 canaux du NPM
|
npm_5channel = config.get('NextPM_5channels', False) #5 canaux du NPM
|
||||||
|
modem_version=config.get('modem_version', "")
|
||||||
modem_config_mode = config.get('modem_config_mode', False) #modem 4G en mode configuration
|
modem_config_mode = config.get('modem_config_mode', False) #modem 4G en mode configuration
|
||||||
|
|
||||||
#update device id in the payload json
|
#update device id in the payload json
|
||||||
@@ -316,6 +314,7 @@ try:
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
print('<h3>START LOOP</h3>')
|
print('<h3>START LOOP</h3>')
|
||||||
|
print(f'Modem version: {modem_version}')
|
||||||
|
|
||||||
#Local timestamp
|
#Local timestamp
|
||||||
#ATTENTION:
|
#ATTENTION:
|
||||||
@@ -638,6 +637,8 @@ try:
|
|||||||
parts = http_response.split(',')
|
parts = http_response.split(',')
|
||||||
|
|
||||||
# 2.1 code 0 (HTTP failed) ⛔⛔⛔
|
# 2.1 code 0 (HTTP failed) ⛔⛔⛔
|
||||||
|
# -> GET error code
|
||||||
|
# -> reboot module
|
||||||
if len(parts) == 3 and parts[-1] == '0': # The third value indicates success
|
if len(parts) == 3 and parts[-1] == '0': # The third value indicates success
|
||||||
print("*****")
|
print("*****")
|
||||||
print('<span style="color: red;font-weight: bold;">⛔ATTENTION: HTTP operation failed</span>')
|
print('<span style="color: red;font-weight: bold;">⛔ATTENTION: HTTP operation failed</span>')
|
||||||
@@ -668,7 +669,7 @@ try:
|
|||||||
elif error_code == 11:
|
elif error_code == 11:
|
||||||
print('<p class="text-danger">Error 11: Server connection error</p>')
|
print('<p class="text-danger">Error 11: Server connection error</p>')
|
||||||
elif error_code == 22:
|
elif error_code == 22:
|
||||||
print('<p class="text-danger">Error 22: PSD or CSD connection not established</p>')
|
print('<p class="text-danger">⚠️Error 22: PSD or CSD connection not established (SARA-R5 need to reset PDP conection)⚠️</p>')
|
||||||
elif error_code == 73:
|
elif error_code == 73:
|
||||||
print('<p class="text-danger">Error 73: Secure socket connect error</p>')
|
print('<p class="text-danger">Error 73: Secure socket connect error</p>')
|
||||||
else:
|
else:
|
||||||
@@ -685,7 +686,7 @@ try:
|
|||||||
response_SARA_9r = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=True)
|
response_SARA_9r = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=True)
|
||||||
print('<p class="text-danger-emphasis">')
|
print('<p class="text-danger-emphasis">')
|
||||||
print(response_SARA_9r)
|
print(response_SARA_9r)
|
||||||
print("</p>")
|
print("</p>", end="")
|
||||||
|
|
||||||
reset_uSpot_url = True
|
reset_uSpot_url = True
|
||||||
|
|
||||||
@@ -701,6 +702,41 @@ try:
|
|||||||
print(responseResetHTTP2_profile)
|
print(responseResetHTTP2_profile)
|
||||||
print("</p>", end="")
|
print("</p>", end="")
|
||||||
|
|
||||||
|
#si on a un sara r5 il faut également reset la connection PDP
|
||||||
|
if modem_version == "SARA-R500":
|
||||||
|
print("⚠️Need to reset PDP connection")
|
||||||
|
# 2. Activate PDP context 1
|
||||||
|
print('➡️Activate PDP context 1')
|
||||||
|
command = f'AT+CGACT=1,1\r'
|
||||||
|
ser_sara.write(command.encode('utf-8'))
|
||||||
|
response_SARA_2dpd = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||||
|
print(response_SARA_2dpd, end="")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# 2. Set the PDP type
|
||||||
|
print('➡️Set the PDP type to IPv4 referring to the outputof the +CGDCONT read command')
|
||||||
|
command = f'AT+UPSD=0,0,0\r'
|
||||||
|
ser_sara.write(command.encode('utf-8'))
|
||||||
|
response_SARA_31dpd = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||||
|
print(response_SARA_31dpd, end="")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# 2. Profile #0 is mapped on CID=1.
|
||||||
|
print('➡️Profile #0 is mapped on CID=1.')
|
||||||
|
command = f'AT+UPSD=0,100,1\r'
|
||||||
|
ser_sara.write(command.encode('utf-8'))
|
||||||
|
response_SARA_32dpd = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||||
|
print(response_SARA_32dpd, end="")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# 2. Set the PDP type
|
||||||
|
print('➡️Activate the PSD profile #0: the IPv4 address is already assigned by the network.')
|
||||||
|
command = f'AT+UPSDA=0,3\r'
|
||||||
|
ser_sara.write(command.encode('utf-8'))
|
||||||
|
response_SARA_33dpd = read_complete_response(ser_sara, wait_for_lines=["OK","+UUPSDA"])
|
||||||
|
print(response_SARA_33dpd, end="")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
# 2.2 code 1 (✅✅HHTP / UUHTTPCR succeded✅✅)
|
# 2.2 code 1 (✅✅HHTP / UUHTTPCR succeded✅✅)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user