Skip to content

check for Inet before trying to fetch newest develop Arduino #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import socket
import contextlib
import requests
import json
Expand All @@ -37,6 +38,14 @@
python_exe = get_pythonexe_path()
pm = ToolPackageManager()

def is_internet_available():
"""Check if connected to Internet"""
try:
with socket.create_connection(("8.8.8.8", 53), timeout=3):
return True
except OSError:
return False

class Espressif32Platform(PlatformBase):
def configure_default_packages(self, variables, targets):
if not variables.get("board"):
Expand Down Expand Up @@ -128,11 +137,22 @@ def install_tool(TOOL, retry_count=0):
if "arduino" in frameworks:
self.packages["framework-arduinoespressif32"]["optional"] = False
self.packages["framework-arduinoespressif32-libs"]["optional"] = False
# use branch master
URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/master/package/package_esp32_index.template.json"
packjdata = requests.get(URL).json()
dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url']
self.packages["framework-arduinoespressif32-libs"]["version"] = dyn_lib_url
if is_internet_available():
try:
# use branch master
URL = (
"https://raw.githubusercontent.com/espressif/arduino-esp32/master/"
"package/package_esp32_index.template.json"
)
response = requests.get(URL, timeout=10)
response.raise_for_status()
packjdata = response.json()
dyn_lib_url = packjdata['packages'][0]['tools'][0]['systems'][0]['url']
self.packages["framework-arduinoespressif32-libs"]["version"] = dyn_lib_url
except (requests.RequestException, ValueError, KeyError, IndexError) as e:
print(f"Error loading latest Arduino ESP32 libs: {e}")
else:
print("No Internet connection - using local/standard configuration")

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