Skip to content

Commit 0d6cd78

Browse files
committed
Check the platform used to set the auth flag in the platformio.ini. If the the platform isn't from espressif and an IP is select, it will display an error.
1 parent 2dc4bdf commit 0d6cd78

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

languages/en.lang

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ msgid "continue_button"
354354
msgstr "Continue"
355355

356356
msgid "ota_error_platform"
357-
msgstr "OTA Upload are only available for Espressif (ESP8266) platforms currently"
357+
msgstr "OTA Upload is only available for Espressif (ESP8266) platform."
358358

359359
msgid "select_library"
360360
msgstr "Select a Library"

libraries/preferences_bridge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_platform(self):
110110

111111
for board in boards:
112112
if(board['id'] == environment):
113-
return board['platform']
113+
return board['platform'].lower()
114114

115115
def get_ports_list(self):
116116
"""Ports List

libraries/project_check.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ def check_auth_ota(self):
227227
"""
228228
from ..libraries.configobj.configobj import ConfigObj
229229
from .tools import get_setting
230+
from re import search
231+
232+
ended = True
233+
234+
platform = self.get_platform()
235+
ip_device = search(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", self.port_id)
236+
237+
if('espressif' not in platform and ip_device is not None):
238+
return False
239+
240+
if('espressif' not in platform):
241+
return ended
230242

231243
auth = None
232244
ini_path = self.get_ini_path()
@@ -240,7 +252,7 @@ def check_auth_ota(self):
240252
auth = port[2]
241253
break
242254
except:
243-
return
255+
return anded
244256

245257
environment = 'env:{0}'.format(self.board_id)
246258
auth_pass = get_setting('auth_pass', None)
@@ -249,18 +261,19 @@ def check_auth_ota(self):
249261
if('upload_flags' in config[environment]):
250262
config[environment].pop('upload_flags')
251263
config.write()
252-
return None
264+
return ended
253265

254266

255267
if(auth == 'yes' and not auth_pass):
256268
self.window.run_command("deviot_set_password")
257269
save_setting('last_action', 3)
258-
return
270+
return ended
259271

260272
flag = {'upload_flags': '--auth={0}'.format(auth_pass)}
261273
config[environment].merge(flag)
262274

263275
config.write()
276+
return ended
264277

265278
def save_code_infile(self):
266279
"""Save Code

platformio/upload.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ def start_upload(self):
6262
else:
6363
cmd = ['run', '-t', 'upload', '--upload-port', self.port_id, '-e', self.board_id]
6464

65-
self.check_auth_ota()
65+
if(not self.check_auth_ota()):
66+
self.derror("ota_error_platform")
67+
save_setting('last_action', None)
68+
return
69+
6670
self.check_serial_monitor()
6771

6872
out = self.run_command(cmd)

0 commit comments

Comments
 (0)