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
-
-
-