From a9a2e03791b85d8dcfa7aabcdf1fa2faa21871ca Mon Sep 17 00:00:00 2001 From: Irene-Maxine <114802521+Irene-Maxine@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=A9=E8=81=94=E7=BD=91mq?= =?UTF-8?q?tt=E4=BD=BF=E7=94=A8=E6=8E=88=E6=9D=83=E7=A0=81=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=9D=97+=E8=B0=83=E6=95=B4=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=97=B6=E9=97=B4=E5=9D=97=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default_src/micropython/generators/iot.js | 12 ++++++-- .../micropython_esp32/template.xml | 28 +++++++++---------- .../micropython_esp32c2/template.xml | 28 +++++++++---------- .../micropython_esp32c3/template.xml | 28 +++++++++---------- .../micropython_esp32s2/template.xml | 28 +++++++++---------- .../micropython_esp32s3/template.xml | 28 +++++++++---------- 6 files changed, 80 insertions(+), 72 deletions(-) diff --git a/boards/default_src/micropython/generators/iot.js b/boards/default_src/micropython/generators/iot.js index f26aba2a..09bd2360 100644 --- a/boards/default_src/micropython/generators/iot.js +++ b/boards/default_src/micropython/generators/iot.js @@ -168,8 +168,16 @@ export const IOT_EMQX_INIT_AND_CONNECT_BY_SHARE_CODE = function (_, generator) { // var socket_pool = 'socketpool.SocketPool(wifi.radio)' // var ssl_context = 'ssl.create_default_context()' var code = 'sk = analyse_sharekey(\'https://' + server.substring(1, server.length - 1) + '/mixio-php/sharekey.php?sk=' + share_code + '\')\n' + - 'MQTT_USR_PRJ = sk[0]+\'/\'+sk[1]+\'/\'\n' + - 'mqtt_client = mixiot.init_MQTT_client(' + server.substring(0,server.indexOf(':')) + ', sk[0], sk[2]' + ', MQTT_USR_PRJ)\n'; + 'MQTT_USR_PRJ = sk[0]+\'/\'+sk[1]+\'/\'\n'; + + // 根据server是否包含":"来生成不同的mqtt_client代码 + if (server.indexOf(':') !== -1) { + // 包含":",使用server.substring(1, server.indexOf(':')) + code += 'mqtt_client = mixiot.init_MQTT_client(' + server.substring(1, server.indexOf(':')) + ', sk[0], sk[2]' + ', MQTT_USR_PRJ)\n'; + } else { + // 不包含":",使用完整的server(去掉首尾的引号) + code += 'mqtt_client = mixiot.init_MQTT_client(' + server.substring(1, server.length - 1) + ', sk[0], sk[2]' + ', MQTT_USR_PRJ)\n'; + } return code; } diff --git a/boards/default_src/micropython_esp32/template.xml b/boards/default_src/micropython_esp32/template.xml index 06b3ec1a..2079e6a5 100644 --- a/boards/default_src/micropython_esp32/template.xml +++ b/boards/default_src/micropython_esp32/template.xml @@ -156,6 +156,20 @@ + + + + + + 500 + + + + + 0 + + + @@ -275,20 +289,6 @@ - - - - - - 500 - - - - - 0 - - - diff --git a/boards/default_src/micropython_esp32c2/template.xml b/boards/default_src/micropython_esp32c2/template.xml index e203810c..154537c2 100644 --- a/boards/default_src/micropython_esp32c2/template.xml +++ b/boards/default_src/micropython_esp32c2/template.xml @@ -131,6 +131,20 @@ + + + + + + 500 + + + + + 0 + + + @@ -250,20 +264,6 @@ - - - - - - 500 - - - - - 0 - - - diff --git a/boards/default_src/micropython_esp32c3/template.xml b/boards/default_src/micropython_esp32c3/template.xml index e0c83e6f..8be7eb76 100644 --- a/boards/default_src/micropython_esp32c3/template.xml +++ b/boards/default_src/micropython_esp32c3/template.xml @@ -131,6 +131,20 @@ + + + + + + 500 + + + + + 0 + + + @@ -250,20 +264,6 @@ - - - - - - 500 - - - - - 0 - - - diff --git a/boards/default_src/micropython_esp32s2/template.xml b/boards/default_src/micropython_esp32s2/template.xml index ebd662bb..1f24abe6 100644 --- a/boards/default_src/micropython_esp32s2/template.xml +++ b/boards/default_src/micropython_esp32s2/template.xml @@ -156,6 +156,20 @@ + + + + + + 500 + + + + + 0 + + + @@ -275,20 +289,6 @@ - - - - - - 500 - - - - - 0 - - - diff --git a/boards/default_src/micropython_esp32s3/template.xml b/boards/default_src/micropython_esp32s3/template.xml index 22126ee8..9f51b8ff 100644 --- a/boards/default_src/micropython_esp32s3/template.xml +++ b/boards/default_src/micropython_esp32s3/template.xml @@ -156,6 +156,20 @@ + + + + + + 500 + + + + + 0 + + + @@ -275,20 +289,6 @@ - - - - - - 500 - - - - - 0 - - -