Skip to content

Commit

Permalink
switch data retrieval method from getting http response to storing it…
Browse files Browse the repository at this point in the history
… to an intermediate file
  • Loading branch information
ftylitak committed Apr 25, 2022
1 parent f3bbfb3 commit 35d3922
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
15 changes: 14 additions & 1 deletion insighioNode/apps/demo_console/ota.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,19 @@ def downloadDeviceConfigurationHTTP(client):
protocol_config.control_channel_id
)
if client.modem_based:
return client.modem_instance.http_get_with_auth_header(URL_base, URL_PATH + "?" + URL_QUERY_PARAMS, protocol_config.thing_token)
file = "tmpconfig"
file_downloaded = client.modem_instance.http_get_with_auth_header(URL_base, URL_PATH + "?" + URL_QUERY_PARAMS, protocol_config.thing_token, file)
if file_downloaded:
local_file_name = device_info.get_device_root_folder() + file
is_file_locally = client.modem_instance.get_file(file, local_file_name)
if is_file_locally:
client.modem_instance.delete_file(file)
configContent = utils.readFromFile(local_file_name)
logging.debug("config content: |" + configContent + "|")
if configContent.startswith('"') and configContent.endswith('"'):
configContent = configContent[1:-1]

return configContent
else:
from external.MicroWebCli import microWebCli
auth = MicroWebCli.AuthToken(protocol_config.thing_token)
Expand Down Expand Up @@ -231,5 +243,6 @@ def applyDeviceConfiguration(client, configurationParameters):
from www import configuration_handler
configuration_handler.apply_configuration(keyValueDict)
client.clear_control_message_config()
client.disconnect()
import machine
machine.reset()
12 changes: 6 additions & 6 deletions insighioNode/lib/networking/modem/modem_bg600.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def mqtt_connect(self, server_ip, server_port, username, password):
retry = 0
while retry < max_retries:
retry += 1
(mqtt_ready, _) = self.send_at_cmd('AT+QMTOPEN=0,"' + server_ip + '",' + str(server_port), 15000, "\\+QMTOPEN:\\s+0,0")
(mqtt_ready, _) = self.send_at_cmd('AT+QMTOPEN=0,"' + server_ip + '",' + str(server_port), 15000, r"\+QMTOPEN:\s+0,0")
if mqtt_ready:
break
utime.sleep_ms(1000)
Expand Down Expand Up @@ -400,8 +400,8 @@ def http_get_with_auth_header(self, url_base, url_request_route, auth_token, des
return None

response = None
(url_resp_received, lines) = self.send_at_cmd('AT+QHTTPREAD=120')
if url_resp_received and len(lines) > 1:
response = lines[1]
#(file_downloaded, _) = self.send_at_cmd('AT+QHTTPREADFILE="' + destination_file + '"', timeout_ms, r"\+QHTTPREADFILE:.*")
return response
# (url_resp_received, lines) = self.send_at_cmd('AT+QHTTPREAD=120')
# if url_resp_received and len(lines) > 1:
# response = lines[1]
(file_downloaded, _) = self.send_at_cmd('AT+QHTTPREADFILE="' + destination_file + '"', timeout_ms, r"\+QHTTPREADFILE:.*")
return file_downloaded

0 comments on commit 35d3922

Please sign in to comment.