Skip to content

Commit 5000dd7

Browse files
authored
check for Inet and fallback to standard config
1 parent 381a557 commit 5000dd7

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

platform.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
python_exe = get_pythonexe_path()
3838
pm = ToolPackageManager()
3939

40+
def is_internet_available():
41+
"""Check if connected to Internet"""
42+
try:
43+
socket.create_connection(("8.8.8.8", 53), timeout=3)
44+
return True
45+
except OSError:
46+
return False
47+
4048
class Espressif32Platform(PlatformBase):
4149
def configure_default_packages(self, variables, targets):
4250
if not variables.get("board"):
@@ -128,11 +136,17 @@ def install_tool(TOOL, retry_count=0):
128136
if "arduino" in frameworks:
129137
self.packages["framework-arduinoespressif32"]["optional"] = False
130138
self.packages["framework-arduinoespressif32-libs"]["optional"] = False
131-
# use branch master
132-
URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/master/package/package_esp32_index.template.json"
133-
packjdata = requests.get(URL).json()
134-
dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url']
135-
self.packages["framework-arduinoespressif32-libs"]["version"] = dyn_lib_url
139+
if is_internet_available():
140+
try:
141+
# use branch master
142+
URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/master/package/package_esp32_index.template.json"
143+
packjdata = requests.get(URL, timeout=10).json()
144+
dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url']
145+
self.packages["framework-arduinoespressif32-libs"]["version"] = dyn_lib_url
146+
except (requests.RequestException, KeyError, IndexError) as e:
147+
print(f"Error loading latest Arduino ESP32 libs: {e}")
148+
else:
149+
print("No Internet connection - using local/standard configuration")
136150

137151
if variables.get("custom_sdkconfig") is not None or len(str(board_sdkconfig)) > 3:
138152
frameworks.append("espidf")

0 commit comments

Comments
 (0)