|
37 | 37 | python_exe = get_pythonexe_path()
|
38 | 38 | pm = ToolPackageManager()
|
39 | 39 |
|
| 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 | + |
40 | 48 | class Espressif32Platform(PlatformBase):
|
41 | 49 | def configure_default_packages(self, variables, targets):
|
42 | 50 | if not variables.get("board"):
|
@@ -128,11 +136,17 @@ def install_tool(TOOL, retry_count=0):
|
128 | 136 | if "arduino" in frameworks:
|
129 | 137 | self.packages["framework-arduinoespressif32"]["optional"] = False
|
130 | 138 | 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") |
136 | 150 |
|
137 | 151 | if variables.get("custom_sdkconfig") is not None or len(str(board_sdkconfig)) > 3:
|
138 | 152 | frameworks.append("espidf")
|
|
0 commit comments