From 5623b632c73b947ff36bf7a9dfa6379f7b78a63f Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 12 Apr 2025 16:03:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dota=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TC1/http_server/app_httpd.c | 14 +- TC1/http_server/web/index.html | 3 +- TC1/http_server/web_data.c | 227 +++++++++++++++-------------- TC1/mqtt_server/user_mqtt_client.c | 36 ++++- TC1/mqtt_server/user_mqtt_client.h | 2 + TC1/ota_server/ota_server.c | 2 +- 6 files changed, 155 insertions(+), 129 deletions(-) diff --git a/TC1/http_server/app_httpd.c b/TC1/http_server/app_httpd.c index 9d56cc9..b79c56a 100644 --- a/TC1/http_server/app_httpd.c +++ b/TC1/http_server/app_httpd.c @@ -103,17 +103,6 @@ static int HttpGetIndexPage(httpd_request_t *req) { return err; } -static int HttpGetDemoPage(httpd_request_t *req) { - OSStatus err = kNoErr; - err = httpd_send_all_header(req, HTTP_RES_200, sizeof(web_index_html), HTTP_CONTENT_HTML_ZIP); - require_noerr_action(err, exit, http_log("ERROR: Unable to send http demo headers.")); - - err = httpd_send_body(req->sock, web_index_html, sizeof(web_index_html)); - require_noerr_action(err, exit, http_log("ERROR: Unable to send http demo body.")); - exit: - return err; -} - static int HttpGetAssets(httpd_request_t *req) { OSStatus err = kNoErr; @@ -150,7 +139,7 @@ static int HttpGetAssets(httpd_request_t *req) { static int HttpGetTc1Status(httpd_request_t *req) { char *sockets = GetSocketStatus(); char *short_click_config = GetButtonClickConfig(); - char *tc1_status = malloc(1024); + char *tc1_status = malloc(1500); char *socket_names = malloc(512); sprintf(socket_names, "%s,%s,%s,%s,%s,%s", user_config->socket_names[0], @@ -608,7 +597,6 @@ static int OtaStart(httpd_request_t *req) { const struct httpd_wsgi_call g_app_handlers[] = { {"/", HTTPD_HDR_DEFORT, 0, HttpGetIndexPage, NULL, NULL, NULL}, - {"/demo", HTTPD_HDR_DEFORT, 0, HttpGetDemoPage, NULL, NULL, NULL}, {"/assets", HTTPD_HDR_ADD_SERVER | HTTPD_HDR_ADD_CONN_CLOSE, APP_HTTP_FLAGS_NO_EXACT_MATCH, HttpGetAssets, NULL, NULL, NULL}, {"/socket", HTTPD_HDR_DEFORT, 0, NULL, HttpSetSocketStatus, NULL, NULL}, diff --git a/TC1/http_server/web/index.html b/TC1/http_server/web/index.html index abd1969..0a50590 100644 --- a/TC1/http_server/web/index.html +++ b/TC1/http_server/web/index.html @@ -1305,7 +1305,7 @@ componentHandler.upgradeDom(); switch_lables[i+3].MaterialSwitch.off(); } } - window.setTimeout(GetPowerRecord, 3000); + window.powerTimeout= window.setTimeout(GetPowerRecord, 3000); }, power_idx.toString()); } $(document).ready(function(){ @@ -1485,6 +1485,7 @@ HttpPost("/shortClickEvent", function (re) { var protocol = window.location.protocol; var baseUrl = protocol+"//"+window.location.host; +clearTimeout(window.powerTimeout); HttpPost("/ota", function (re) { OtaStatus(); }, ota_url); diff --git a/TC1/http_server/web_data.c b/TC1/http_server/web_data.c index d0a3021..43f4a88 100644 --- a/TC1/http_server/web_data.c +++ b/TC1/http_server/web_data.c @@ -1,5 +1,5 @@ const unsigned char js_pack[0xd2be] = { -0x1f,0x8b,0x08,0x00,0x3b,0x32,0xe0,0x67,0x02,0xff,0xd4,0xbd,0xfb,0x72,0xdb,0x46, +0x1f,0x8b,0x08,0x00,0xb9,0xf8,0xf9,0x67,0x02,0xff,0xd4,0xbd,0xfb,0x72,0xdb,0x46, 0xd2,0x38,0xfa,0xff,0x56,0xed,0x3b,0x88,0x48,0x96,0x01,0xc4,0x21,0x45,0xca,0xb1, 0x13,0x83,0x1e,0xb1,0x1c,0xdb,0x49,0xbc,0x5f,0x9c,0x64,0xe3,0x5c,0x97,0x62,0x52, 0xb8,0x92,0xa0,0x48,0x82,0xe2,0xc5,0x12,0x23,0x72,0xdf,0xe7,0xf7,0x1a,0xe7,0xc9, @@ -3372,7 +3372,7 @@ const unsigned char js_pack[0xd2be] = { 0x02,0x0f,0xb7,0x98,0x0c,0x59,0x7f,0x97,0xf2,0x25,0x55,0x7c,0x45,0xad,0x25,0x8e, 0x0f,0x58,0x4f,0xcc,0x9f,0x00,0x32,0xd2,0xf4,0xa5,0xf0,0xee,0x02,0x00}; const unsigned char css_pack[0x6217] = { -0x1f,0x8b,0x08,0x00,0x3b,0x32,0xe0,0x67,0x02,0xff,0xed,0xbd,0x79,0x73,0xdb,0xc8, +0x1f,0x8b,0x08,0x00,0xb9,0xf8,0xf9,0x67,0x02,0xff,0xed,0xbd,0x79,0x73,0xdb,0xc8, 0xf5,0x28,0xfa,0x7f,0xaa,0xf2,0x1d,0x70,0x9d,0x9a,0x1a,0x6b,0x42,0xc8,0xd8,0x49, 0x4a,0x95,0x54,0xbc,0x8f,0x26,0x96,0x9c,0x78,0x19,0x8f,0x9d,0x5f,0x9e,0x0b,0x04, 0x9a,0x24,0x24,0x90,0x60,0x00,0x50,0x1b,0x4b,0xb7,0xee,0x07,0xb9,0xef,0xcb,0xbd, @@ -4942,8 +4942,8 @@ const unsigned char css_pack[0x6217] = { 0x34,0x4a,0x61,0x0f,0x9e,0x4c,0x71,0xf7,0x2d,0x84,0xeb,0x52,0x24,0xf6,0xd5,0x25, 0xe6,0x54,0x09,0x49,0xbc,0xd0,0xc2,0x1c,0x55,0x23,0x76,0x55,0x21,0xff,0x3f,0x3f, 0xef,0x85,0xce,0x3d,0xbc,0x02,0x00}; -const unsigned char web_index_html[0x3465] = { -0x1f,0x8b,0x08,0x00,0x3b,0x32,0xe0,0x67,0x02,0xff,0xed,0x7d,0x6d,0x93,0xdb,0xc6, +const unsigned char web_index_html[0x3477] = { +0x1f,0x8b,0x08,0x00,0xb9,0xf8,0xf9,0x67,0x02,0xff,0xed,0x7d,0x6d,0x93,0xdb,0xc6, 0x91,0xf0,0xf7,0xab,0xca,0x7f,0x18,0xc3,0xaa,0x90,0xbc,0x25,0x40,0x02,0x7c,0x59, 0x72,0xdf,0x52,0xca,0xda,0xc9,0xfa,0xb9,0x95,0xe5,0xcb,0xea,0x94,0xe7,0x4e,0x71, 0xd1,0x58,0x02,0xbb,0x84,0x05,0x12,0x34,0x00,0xee,0x6a,0x6d,0xab,0x4a,0x4a,0xce, @@ -5673,112 +5673,113 @@ const unsigned char web_index_html[0x3465] = { 0x88,0x99,0x00,0x71,0x65,0x3a,0x88,0x2b,0x7b,0x43,0x7c,0x68,0xe7,0x06,0xc3,0x7f, 0xc4,0xc6,0x8d,0xe8,0xd6,0x0d,0x3e,0x7b,0xea,0xce,0x8d,0x7d,0xdb,0xbb,0x31,0x7a, 0xf7,0x06,0xc3,0x2d,0x69,0xf3,0xc6,0xd0,0xf6,0x8d,0x78,0x56,0x2e,0xe7,0x1d,0xef, -0xdf,0xb8,0xf3,0x9d,0x07,0x07,0x3b,0x3f,0xa6,0xb1,0xf3,0xe3,0x7e,0xdc,0xbf,0x31, -0xd2,0x1f,0xc5,0x99,0xb6,0x79,0x52,0x8a,0x3a,0xa4,0xf2,0xa1,0xad,0x09,0xca,0x67, -0xcd,0xb5,0x8d,0xce,0x66,0x18,0x49,0x70,0x7a,0xfc,0x91,0x1b,0x41,0x53,0xe2,0x36, -0x74,0x30,0x15,0x8a,0xcd,0x7a,0xa2,0x33,0x21,0xee,0xac,0xa0,0xf8,0x2a,0x21,0x8d, -0xa8,0xda,0xd6,0xf5,0x93,0x1a,0x0d,0xf4,0x1f,0xbb,0x52,0x88,0x7c,0x8b,0xf9,0xc8, -0x79,0x10,0xde,0x6a,0x9f,0xb7,0xf0,0xf6,0xd0,0xb0,0xff,0x3a,0xa8,0x93,0xed,0x5e, -0x4e,0x5f,0xb0,0x49,0xde,0x7b,0x92,0x56,0x34,0xba,0x06,0x75,0x3a,0x36,0x41,0xe4, -0xa7,0x20,0x5c,0xc4,0x71,0xd2,0x2a,0x87,0xcb,0xce,0x58,0x4a,0x9d,0x7e,0x44,0x23, -0x8d,0x23,0x71,0x79,0x2c,0x14,0x18,0x83,0x00,0x7f,0xc6,0xcb,0x10,0x8d,0x1f,0xf6, -0x3f,0x96,0xd7,0x4a,0x78,0x47,0xbb,0x60,0xf2,0x3b,0x76,0x50,0x4d,0xca,0xbb,0x2f, -0x3e,0xd8,0x7d,0xf9,0x6a,0x0a,0xcc,0x30,0x5e,0x39,0x1a,0x39,0x68,0x2f,0xf9,0x21, -0xcb,0x11,0xcc,0x83,0x80,0xc2,0xc0,0x88,0xb5,0x3a,0x8e,0x65,0xea,0x92,0x69,0x6d, -0xc6,0x66,0x4d,0x94,0x00,0x40,0x24,0x67,0xd4,0xd4,0x0a,0xa5,0x84,0x66,0xf2,0x4d, -0xe6,0x3b,0x8e,0x9c,0xe4,0x65,0x77,0x6c,0xc0,0x64,0xd2,0x68,0xc0,0xa3,0x91,0x34, -0x10,0xf0,0x68,0xc4,0xe8,0x18,0x63,0x24,0x8b,0x35,0x45,0x0f,0x07,0x85,0x89,0xc3, -0x46,0xd7,0x66,0xdf,0x77,0x46,0xdf,0x07,0xc5,0x2e,0xa5,0x40,0x2c,0x4a,0x36,0x28, -0x1f,0x84,0xcb,0x8e,0xd9,0x2e,0x30,0x0e,0x7e,0x36,0x3b,0x0c,0x72,0x71,0x51,0x96, -0x9f,0x7f,0x7e,0x38,0x7d,0xa1,0x96,0xfb,0x01,0x97,0x9d,0x99,0x3f,0x3f,0x10,0x40, -0xd4,0x84,0x39,0x3c,0x7e,0x4b,0xc8,0xcd,0x09,0xa2,0x30,0xb6,0x4a,0x98,0xf4,0xaf, -0x5a,0x56,0x17,0x07,0xad,0x10,0x9a,0xa7,0x05,0x46,0x16,0x4e,0x0a,0xd6,0x7d,0x44, -0x37,0xc3,0x7e,0x19,0xa1,0x30,0x0d,0xd9,0x75,0xd5,0x76,0x17,0x41,0x26,0xc4,0xed, -0x46,0x59,0x36,0x42,0x36,0xc6,0xc6,0xd2,0x8e,0x0d,0x10,0x41,0x54,0xb4,0x06,0xd5, -0x40,0x23,0x62,0x69,0xc7,0x9c,0xb7,0xc3,0x93,0xcd,0xf0,0xf5,0x3a,0x1b,0x9a,0xc2, -0xe7,0xa6,0x0a,0x9a,0xaf,0x38,0xc7,0x47,0xfe,0x90,0xcc,0xcd,0x4f,0x2f,0xb2,0x2e, -0x9f,0x99,0xe7,0x72,0xc9,0xb1,0x5c,0x83,0xab,0x97,0xfa,0xaf,0xbc,0x7f,0xf3,0xd3, -0x33,0x91,0x5c,0x4a,0x72,0xae,0x6b,0x2f,0x45,0x72,0x95,0x52,0x60,0x9d,0x8f,0xe4, -0x2a,0x27,0xe6,0xea,0xbf,0xf1,0x46,0x24,0x57,0x25,0xa5,0xc6,0xd7,0x22,0xb9,0xaa, -0xc9,0xb0,0x5e,0xf8,0x30,0x92,0x6b,0x36,0x31,0xd7,0xe0,0xca,0xbb,0x19,0x5e,0x63, -0x61,0xce,0x5a,0x42,0xce,0x77,0xfe,0x90,0x89,0xf2,0x22,0xe2,0xd8,0x0e,0x06,0x94, -0x51,0x0e,0x2d,0x6e,0xd4,0x99,0x8f,0x15,0xa5,0xbd,0x7f,0x5c,0x51,0x36,0x95,0x0f, -0xbc,0x95,0x01,0x38,0x3f,0x3e,0x85,0x08,0xf4,0x83,0x91,0xf8,0x55,0x86,0xc0,0xd8, -0xf4,0xb2,0x61,0xd1,0x30,0x9b,0x5c,0x9c,0xc3,0x63,0x83,0x8a,0x7e,0xa6,0x61,0x48, -0x63,0x0f,0x02,0xe1,0x4b,0x46,0x80,0x27,0x96,0xf4,0x0f,0x30,0x12,0x86,0x86,0xd2, -0xc3,0x9a,0x96,0x38,0x94,0x7a,0x27,0x96,0x61,0x9f,0x88,0x22,0x17,0x71,0x98,0x43, -0xcd,0x7e,0x8e,0x10,0x89,0x48,0x0e,0xe6,0x97,0x1b,0x4d,0x57,0xe7,0xa4,0x8b,0x36, -0x15,0xf3,0xb0,0xc7,0xca,0x13,0xd4,0x6c,0x63,0xca,0xb3,0x8d,0xb5,0xcc,0xf4,0x8f, -0x06,0x28,0x9d,0x4c,0x88,0x05,0x48,0xb5,0x73,0x38,0x7f,0x0c,0xba,0x90,0x7c,0x91, -0x50,0xe9,0x4a,0xdb,0x31,0xaa,0xce,0x8c,0x36,0x35,0x94,0x43,0x46,0x1c,0x5b,0x59, -0x61,0x94,0x8d,0x38,0xd7,0xfd,0xe1,0x64,0x91,0x1d,0x2a,0x64,0x5b,0xbd,0x8e,0x16, -0xf2,0xc5,0x07,0xee,0xbb,0x27,0xf8,0x50,0x54,0xae,0x28,0x37,0x28,0xd1,0xb1,0xf9, -0xb1,0x8e,0x8b,0x6b,0x5e,0x61,0x6e,0x4a,0x19,0xb8,0x70,0x51,0x66,0xd1,0x80,0xab, -0xb6,0x16,0x05,0xc3,0xfc,0xfa,0xcc,0x3b,0xca,0xee,0xa1,0xb4,0x7f,0x0b,0xb4,0x4a, -0x0e,0x36,0x1c,0x67,0x4a,0x71,0xb1,0x22,0xc3,0x11,0x31,0x6c,0x71,0x22,0x6a,0x55, -0x8c,0x5e,0x25,0x4e,0xdc,0x4d,0xc6,0x42,0xec,0xda,0x5a,0x64,0x49,0x78,0x8c,0xa5, -0x7d,0x28,0x9b,0xe9,0x99,0x27,0xe8,0x27,0x31,0xd9,0x61,0x2e,0xec,0x03,0xf4,0x4f, -0xb2,0xe3,0x5e,0xf8,0xfd,0x75,0x68,0x2e,0x67,0xe8,0x32,0x54,0x26,0x1f,0x07,0xf1, -0x30,0x57,0x36,0x43,0x83,0x61,0x37,0x37,0x75,0x98,0xcb,0x31,0xeb,0x9a,0x4e,0xe2, -0x4e,0x07,0x97,0x60,0x0f,0x60,0xa4,0x0c,0x85,0xce,0xb2,0x0f,0x1b,0xe3,0xc1,0x76, -0x1f,0x2e,0x7c,0x3e,0x5c,0x67,0x42,0x60,0x6c,0xf7,0x07,0x1d,0x40,0x1b,0x5d,0xfc, -0xf2,0x23,0xbd,0x67,0x9f,0xfc,0xcc,0x78,0xb3,0xf0,0x20,0x40,0x2e,0x53,0xcc,0xfc, -0x00,0x77,0x44,0xf5,0xcf,0x5d,0x1f,0xfc,0x09,0x1d,0xb9,0x99,0xb9,0x8c,0xf7,0xb9, -0xe2,0xf7,0x5e,0xc5,0x47,0x0e,0xd7,0x43,0x43,0x87,0x01,0x46,0xf6,0x78,0xca,0xd4, -0xf0,0x5a,0x84,0x49,0xd0,0xf0,0x8e,0xce,0x14,0x9c,0xbe,0x99,0x0d,0x8f,0x46,0x7c, -0x83,0xe3,0xa4,0x21,0x0f,0xde,0x9a,0x31,0x3f,0xa8,0x47,0x76,0x26,0xa2,0x08,0x84, -0x53,0x8a,0x75,0xee,0x55,0x52,0x7f,0x48,0xde,0x30,0x19,0xb5,0xad,0x79,0x9f,0x2f, -0x13,0x1b,0xef,0x39,0x80,0x06,0x44,0xe1,0x37,0x3b,0x79,0x90,0x39,0x97,0x85,0xd5, -0xd9,0x7c,0xc2,0x66,0x6b,0xad,0xa9,0x5a,0x91,0x97,0xf7,0x24,0xa5,0x4a,0xb7,0x12, -0x8d,0x02,0xe0,0x6d,0x60,0x4d,0x05,0xc0,0x38,0x6f,0xd9,0x8d,0x70,0xe9,0x3e,0xfd, -0xb4,0xa9,0x44,0x59,0xe1,0xc0,0xe2,0xc6,0xac,0xec,0x43,0x14,0xa7,0xe7,0x9f,0x7f, -0x28,0x0e,0x1a,0x99,0xc0,0xc5,0x58,0xdf,0xba,0xfa,0x09,0x3b,0x6e,0xf2,0xf6,0x99, -0xf3,0xb7,0xdf,0xfe,0x8c,0xf2,0x31,0x50,0x27,0x49,0x5b,0x73,0xc6,0xb1,0x6d,0x82, -0xc0,0x3e,0x3e,0xc4,0xfb,0x93,0xff,0x1d,0x7c,0x02,0x93,0x98,0xb7,0xd8,0x0e,0xb0, -0x9b,0xd7,0xfe,0xfd,0xe6,0xf5,0x8f,0x23,0x5e,0xb8,0x21,0x21,0x4a,0x0c,0xe1,0xa3, -0x3b,0x95,0xe3,0x4d,0x3d,0x4d,0x0e,0x3d,0x47,0xc9,0x80,0x37,0x01,0xa3,0x87,0xb6, -0xc3,0x07,0x4d,0x18,0xde,0x1b,0x37,0xc4,0x97,0x7c,0x00,0xc6,0x37,0x4a,0xf7,0x93, -0x34,0xcc,0xa8,0xdf,0x1f,0xd2,0x88,0x72,0x2a,0x51,0x02,0xc4,0x59,0xdf,0x3e,0xea, -0x4f,0x91,0xb2,0x74,0xfb,0xad,0xb7,0xed,0x22,0x1f,0xee,0x8d,0x44,0xab,0x9d,0xb6, -0x82,0xc5,0x0d,0x82,0xcd,0x8e,0xe3,0xa4,0x3f,0xc6,0xd2,0x42,0x9e,0x87,0x35,0x23, -0x66,0x72,0xb8,0xdf,0x72,0x9e,0x6d,0x1e,0xf4,0xf6,0x01,0x01,0x21,0xc4,0xd0,0xd3, -0x9c,0x26,0xf8,0xd0,0x0a,0x0a,0xea,0xb4,0x48,0xad,0x8f,0xa7,0x72,0x81,0x89,0xc6, -0x6d,0xbd,0x9c,0x9f,0x14,0x06,0x2d,0xcb,0xc1,0x10,0x65,0xa6,0xed,0x38,0xf7,0xca, -0xde,0x11,0x89,0x50,0x64,0x7e,0x32,0x18,0x71,0x44,0x28,0x4d,0x7c,0xcd,0xcb,0x47, -0xfe,0xe3,0xd6,0x45,0xba,0x49,0x9c,0x72,0x7b,0xb2,0x40,0x01,0x14,0x22,0x46,0x19, -0xb6,0xe7,0x6c,0x48,0x88,0x98,0x74,0x50,0x9e,0x61,0x27,0xa1,0x95,0x33,0x59,0x18, -0x0e,0x86,0x8d,0xcc,0x46,0x83,0x09,0x68,0xcc,0x5d,0x84,0x47,0x8f,0x32,0x1b,0xa7, -0x20,0xcc,0x04,0x99,0x26,0x43,0xf6,0x11,0xda,0xff,0xa8,0x32,0xd4,0xa8,0x11,0x4c, -0x8e,0xfe,0xc3,0x43,0x11,0x89,0x4f,0x37,0x66,0x42,0x7c,0x86,0xce,0xf0,0xe5,0xdd, -0x7c,0x11,0x07,0xe0,0xd1,0x63,0x87,0x13,0x4f,0xd3,0x0d,0xbf,0x8a,0x1d,0x3b,0x0a, -0x94,0x7d,0x09,0x7c,0x94,0x72,0xf6,0x3f,0x16,0x9e,0xa4,0xe4,0xe9,0xb9,0xa3,0xf8, -0x35,0xe8,0x20,0x06,0xd0,0xb4,0x9a,0x54,0x5c,0x24,0xff,0x55,0x24,0xff,0x3a,0x4c, -0xdd,0xfe,0x89,0x56,0xe7,0xbf,0x9e,0x11,0x0a,0x40,0xd5,0x78,0xe1,0x16,0x08,0x48, -0xb2,0xa9,0x09,0xd8,0x8c,0x92,0x13,0xd6,0x4e,0xb7,0xe7,0x44,0x49,0xe9,0xb5,0x21, -0xe1,0xe8,0xe8,0xf0,0x93,0xda,0xa3,0x4e,0x76,0x0e,0x73,0x05,0x3e,0xf9,0x30,0x69, -0x78,0xdb,0x08,0xb5,0x56,0x82,0xad,0xb6,0xde,0x16,0x5b,0x2d,0x93,0xec,0x67,0xa5, -0xdb,0x5b,0x7d,0xff,0xf4,0x13,0xde,0xa7,0xbb,0xd1,0xe5,0xec,0xdf,0x67,0x8b,0x43, -0x71,0x30,0x31,0xbe,0xd2,0xf6,0x46,0x19,0x7b,0x0f,0x39,0xc3,0x6c,0x9f,0x31,0x8c, -0xa1,0x38,0xe9,0x76,0x93,0x59,0x15,0xa1,0x26,0x8d,0x98,0xfd,0x85,0x42,0xd4,0x1b, -0xc9,0x05,0x1a,0x85,0xf9,0xf9,0x02,0x1c,0x13,0x46,0x52,0xd0,0xab,0x79,0x68,0x2d, -0xd6,0x43,0x68,0x61,0xc8,0x65,0x19,0xb4,0xd7,0xd6,0xf1,0x43,0x74,0xd9,0xdc,0xa4, -0xf1,0xaa,0x01,0x43,0x46,0xc5,0xaa,0x86,0x7d,0x35,0xd2,0x79,0xd9,0xe1,0xf9,0x43, -0x47,0xde,0xb1,0xaf,0x87,0x8f,0x3c,0xf0,0xce,0xfb,0xc0,0x38,0xef,0xb3,0x80,0xe7, -0x06,0x7e,0x1e,0x3a,0xb1,0x58,0xf4,0x6c,0x3a,0xef,0x0b,0xe7,0xfc,0x06,0x9b,0xc8, -0x76,0x01,0xef,0x43,0xe1,0x49,0x4e,0x74,0xd3,0x1a,0x19,0xdf,0xe5,0x21,0x16,0x71, -0xa0,0xd9,0xfc,0xaa,0x9e,0x87,0x65,0x18,0x40,0x51,0xcc,0xc7,0xd2,0x56,0x74,0x63, -0xb3,0xe5,0xa6,0xd3,0x91,0xff,0x92,0x79,0x8c,0x90,0x11,0xe2,0xde,0xfc,0xf4,0x42, -0xff,0xad,0xff,0xb9,0xfd,0xd6,0xf5,0xdd,0x97,0xcf,0x0d,0xb7,0x91,0x0b,0x1a,0x4d, -0x6c,0x27,0x8d,0x89,0x65,0x27,0x38,0x15,0x68,0xe0,0xe9,0xc8,0x73,0xfa,0xf8,0xd3, -0x9f,0x52,0x99,0xc6,0x05,0xb1,0x86,0x04,0x09,0x12,0xd3,0x48,0x96,0xd0,0x7c,0x1e, -0xf7,0xf9,0x84,0xf3,0x54,0xf0,0xeb,0x9c,0xc1,0xc2,0x12,0xdd,0xc7,0xb0,0x48,0x23, -0xf3,0xec,0x76,0x56,0xd8,0x7d,0xfb,0x23,0x18,0x4c,0x6e,0xfd,0xfe,0x2c,0x3b,0xf2, -0xa8,0x7f,0xf9,0xca,0xd7,0x37,0xc2,0xe3,0x89,0xa8,0x55,0xb7,0xb8,0x88,0xab,0x35, -0xde,0x04,0x8a,0xe7,0x2d,0xd6,0x8c,0xb0,0xd9,0xb7,0x20,0xb2,0xb9,0x14,0xdf,0x1b, -0x67,0x7a,0xc5,0x0a,0x24,0x86,0x85,0x79,0x5f,0x13,0x9d,0xd8,0x16,0x60,0x88,0x47, -0xc7,0x7f,0x01,0x7a,0x9e,0x90,0xbe,0x05,0x26,0x39,0x48,0x98,0xdb,0x38,0xfa,0x90, -0x97,0xf6,0xfc,0xf3,0xde,0xcd,0xe2,0x62,0x31,0x5c,0x99,0xf3,0xd3,0xe4,0xf8,0x1e, -0xcd,0x78,0x0c,0xf5,0x44,0xf2,0x92,0x6c,0xdb,0x80,0xb4,0x0e,0x2e,0xbc,0x7b,0xfb, -0x77,0xaf,0x80,0xb4,0x46,0xce,0x80,0xc2,0x63,0x02,0x3c,0x84,0xc3,0xea,0xf9,0x8f, -0x9d,0x14,0xbc,0xb3,0x69,0x16,0x0a,0xe8,0xa6,0x86,0x9b,0xff,0x0f,0x2f,0x54,0x56, -0x8a,0x5c,0x10,0x01,0x00}; +0xdf,0xb8,0xf3,0x9d,0x07,0x07,0x3b,0x3f,0xa6,0xb1,0xf3,0xe3,0x7e,0xdc,0xbf,0x11, +0xf1,0x46,0x51,0xa1,0xf4,0xfc,0x51,0x8b,0x29,0x3e,0x2a,0xce,0xdc,0xcd,0x93,0x52, +0xd4,0x49,0x95,0x0f,0xed,0x4f,0x50,0x48,0x6b,0xae,0x6d,0x74,0x36,0xc3,0xe8,0x82, +0xd3,0xe3,0x8f,0xe1,0x08,0x9a,0x17,0xb7,0xab,0x83,0xe9,0x51,0x6c,0x26,0x14,0x9d, +0x1d,0x71,0xe7,0x07,0xc5,0x57,0x0e,0x69,0x94,0xd5,0xb6,0xae,0x9f,0xd4,0x68,0xf0, +0xff,0xd8,0xd5,0x43,0xe4,0x65,0xcc,0x6f,0xce,0x83,0xf0,0x56,0x00,0xbd,0xc5,0xb8, +0x87,0x86,0x7d,0xda,0x41,0x9d,0x6c,0x47,0x73,0xfa,0x22,0x4e,0xf2,0x7e,0x94,0xb4, +0xa2,0xd1,0x75,0xa9,0xd3,0xb1,0x49,0x23,0x3f,0x2d,0xe1,0xa2,0x90,0x93,0x56,0x3e, +0x5c,0x76,0xee,0x52,0xea,0x94,0x24,0x1a,0x7d,0x1c,0x89,0xd5,0x63,0xe1,0xc1,0x18, +0x18,0xf8,0x33,0x5e,0xae,0x68,0x4c,0xb1,0xff,0x01,0xbd,0x56,0xc2,0x3b,0xda,0x2d, +0x93,0xdf,0xb1,0xc3,0x6b,0x52,0xde,0x7d,0xf1,0xc1,0xee,0xcb,0x57,0x53,0x60,0x86, +0x31,0xcc,0xd1,0x68,0x42,0x7b,0xc9,0x0f,0x63,0x8e,0x60,0x1e,0x04,0x19,0x06,0x86, +0xad,0xd5,0x71,0x2c,0x53,0x97,0x4c,0x6b,0x33,0x36,0x93,0xa2,0x04,0x00,0x22,0x39, +0xa3,0xa6,0x5b,0x28,0x25,0x34,0x93,0x6f,0x46,0xdf,0x71,0x34,0x25,0x2f,0xbb,0x63, +0x83,0x28,0x93,0x46,0x08,0x1e,0x8d,0xa4,0xc1,0x81,0x47,0x23,0x46,0xc7,0x18,0x23, +0x59,0xfc,0x29,0x7a,0x3d,0x28,0x4c,0x1c,0x4a,0xba,0x36,0xfb,0xe6,0x33,0xfa,0x43, +0x28,0x76,0x29,0x05,0x62,0x91,0xb3,0x41,0xf9,0x20,0x84,0x76,0xcc,0x16,0x82,0x71, +0xf0,0xb3,0xd9,0x61,0x90,0x8b,0x8b,0xb2,0xfc,0xfc,0xf3,0xc3,0xe9,0x0b,0xb5,0xdc, +0x0f,0xb8,0xec,0xcc,0x24,0xfa,0x81,0x00,0xa2,0x26,0xcc,0xe1,0x91,0x5c,0x42,0x6e, +0x4e,0x10,0x85,0xb1,0x55,0x6e,0xea,0xee,0xaa,0x65,0x75,0x71,0x20,0x0b,0xa1,0x79, +0x5a,0x60,0x64,0xe1,0xa4,0x00,0xde,0x47,0x74,0x33,0xec,0x97,0x11,0x0a,0xd3,0x30, +0x5e,0x57,0x6d,0x77,0x11,0x64,0x42,0x2c,0x6f,0x94,0x65,0x23,0x64,0x63,0x6c,0x7c, +0xed,0xd8,0xa0,0x11,0x44,0x45,0x6b,0x50,0x0d,0x34,0x22,0xbe,0x76,0xcc,0x19,0x3c, +0x3c,0xd9,0x0c,0x5f,0xaf,0xb3,0xe1,0x2a,0x7c,0x6e,0xaa,0xa0,0xf9,0x8a,0x73,0x7c, +0x34,0x10,0xc9,0xdc,0xfc,0xf4,0x22,0xeb,0xf2,0x99,0x79,0x2e,0x97,0x1c,0xcb,0x35, +0xb8,0x7a,0xa9,0xff,0xca,0xfb,0x37,0x3f,0x3d,0x13,0xc9,0xa5,0x24,0xe7,0xba,0xf6, +0x52,0x24,0x57,0x29,0x05,0xd6,0xf9,0x48,0xae,0x72,0x62,0xae,0xfe,0x1b,0x6f,0x44, +0x72,0x55,0x52,0x6a,0x7c,0x2d,0x92,0xab,0x9a,0x0c,0xeb,0x85,0x0f,0x23,0xb9,0x66, +0x13,0x73,0x0d,0xae,0xbc,0x9b,0xe1,0x35,0x16,0xe6,0xac,0x25,0xe4,0x7c,0xe7,0x0f, +0x99,0x28,0x2f,0x22,0xce,0xee,0x60,0x40,0x19,0xe5,0xe4,0xe2,0x46,0x9d,0xf9,0x58, +0x51,0xda,0xfb,0xc7,0x15,0x65,0xd3,0xfb,0xc0,0x83,0x19,0x80,0xf3,0x63,0x56,0x88, +0x40,0x3f,0x22,0x89,0x5f,0x6a,0x08,0x0c,0x50,0x2f,0x1b,0x16,0x0d,0xb3,0xc9,0xc5, +0x39,0x3c,0x4a,0xa8,0xe8,0x67,0x1a,0x86,0x34,0xf6,0x70,0x10,0xbe,0x64,0x04,0x78, +0x62,0x49,0xff,0x50,0x23,0x61,0x68,0x28,0x3d,0xac,0x69,0x89,0x43,0xa9,0x77,0x8a, +0x19,0xf6,0x89,0x28,0x72,0x11,0x27,0x3a,0xd4,0xec,0xe7,0x08,0x91,0x88,0xe4,0x60, +0xbe,0xba,0xd1,0x74,0x75,0x4e,0xba,0x68,0x53,0x31,0xaf,0x7b,0xac,0x3c,0x41,0xcd, +0x36,0xa6,0x3c,0xdb,0x6c,0xcb,0xa6,0x03,0xd1,0xa0,0xa5,0x93,0x09,0xf1,0x01,0xa9, +0x76,0x0e,0xe7,0xa3,0x41,0xb7,0x92,0x2f,0x12,0x2a,0x5d,0x7d,0x3b,0x46,0xd5,0x99, +0xd1,0xa6,0xc6,0x73,0xc8,0x88,0x63,0x2b,0x2b,0x8c,0xb2,0x11,0x87,0xbb,0x3f,0x9c, +0x2c,0xb2,0x83,0x86,0x6c,0xab,0xd7,0xd1,0x42,0xbe,0xf8,0xc0,0x7d,0x97,0x05,0x1f, +0x9e,0xca,0x15,0xe5,0x06,0x25,0x3a,0x36,0x3f,0xd6,0x71,0x71,0x1d,0x2c,0xcc,0x4d, +0x29,0x03,0x17,0x2e,0xf2,0x2c,0x1a,0x84,0xd5,0xd6,0xa2,0x60,0x98,0xaf,0x9f,0x79, +0x4c,0xd9,0x3d,0x94,0xf6,0x6f,0x81,0x56,0xc9,0x01,0x88,0xe3,0x4c,0x29,0x2e,0x7e, +0x64,0x38,0x4a,0x86,0x2d,0x58,0x44,0xad,0x8a,0xd1,0x2b,0xc7,0x89,0x3b,0xcc,0x58, +0xd8,0x5d,0x5b,0x8b,0x2c,0x13,0x8f,0xb1,0xb4,0x0f,0x65,0x33,0x3d,0xf3,0x04,0xfd, +0x4c,0x26,0x3b,0xe0,0x85,0x7d,0x94,0xfe,0x49,0x76,0x04,0x0c,0xbf,0xe7,0x0e,0xcd, +0xe5,0x0c,0x5d,0x9a,0xca,0xe4,0xe3,0x20,0x1e,0xe6,0xca,0x66,0x68,0x80,0xec,0xe6, +0xa6,0x0e,0xf3,0x3b,0x66,0x5d,0xd3,0x89,0xdd,0xe9,0xe0,0x12,0xec,0x0b,0x8c,0x94, +0xa1,0xd0,0x59,0xf6,0x61,0x63,0x3c,0xd8,0x02,0xc4,0x85,0xd4,0x87,0x6b,0x4f,0x08, +0x8c,0xed,0x08,0xa1,0x03,0x68,0xa3,0x8b,0x5f,0x83,0xa4,0xf7,0xec,0x33,0xa0,0x19, +0x6f,0x66,0x1e,0x04,0xcd,0x65,0x8a,0x99,0x1f,0xe0,0x2e,0xa9,0xfe,0xb9,0xeb,0x83, +0x3f,0xa1,0x73,0x37,0x33,0x97,0xf1,0x3e,0x61,0xfc,0xde,0xab,0xf8,0xc8,0xe1,0x7a, +0x68,0xe8,0x80,0xc0,0xc8,0xbe,0x4f,0x99,0x1a,0x5e,0x8b,0x30,0x09,0x1a,0xde,0xe5, +0x99,0x82,0xd3,0x37,0xb3,0x09,0xd2,0x88,0x6f,0x7a,0x9c,0x34,0x0c,0xc2,0x5b,0x47, +0xe6,0x07,0xf5,0xc8,0x6e,0x45,0x14,0x81,0x70,0x4a,0xb1,0xce,0xbd,0x4a,0xea,0x0f, +0xc9,0x9b,0x28,0xa3,0xb6,0x35,0xef,0x07,0x66,0x62,0xe3,0x3d,0x07,0xd0,0x80,0x28, +0xfc,0x06,0x28,0x0f,0x32,0xe7,0xc6,0xb0,0x3a,0x9b,0x4f,0xd8,0x6c,0xfd,0x35,0x55, +0x2b,0xf2,0xf2,0x9e,0xa4,0x54,0xe9,0xf6,0xa2,0x51,0x00,0xbc,0x4d,0xad,0xa9,0x00, +0x18,0xe7,0x2d,0xbb,0x11,0x2e,0xe7,0xa7,0x9f,0x40,0x95,0x28,0x2b,0x1c,0x58,0xdc, +0xac,0x95,0x7d,0x88,0xe2,0xf4,0xfc,0xf3,0x0f,0xc5,0x41,0x23,0x13,0xb8,0xb8,0xeb, +0x5b,0x57,0x3f,0x61,0x47,0x50,0xde,0x3e,0x73,0xfe,0xf6,0xdb,0x9f,0x51,0x3e,0x06, +0xea,0x24,0x69,0xbb,0xce,0x38,0xb6,0x4d,0x10,0xec,0xc7,0x87,0x7d,0x7f,0xf2,0xbf, +0x83,0x4f,0x60,0x12,0xf3,0x16,0xdb,0x15,0x76,0xf3,0xda,0xbf,0xdf,0xbc,0xfe,0x71, +0xc4,0x33,0x37,0x24,0x44,0x89,0x61,0x7d,0x74,0xf7,0x72,0xbc,0xa9,0xa7,0xc9,0xa1, +0xe7,0x28,0x19,0xf0,0x26,0x60,0xf4,0xd0,0x16,0xf9,0xa0,0x09,0xc3,0xfb,0xe5,0x86, +0xf8,0x92,0x0f,0xc0,0xf8,0x46,0xe9,0x7e,0x92,0x86,0x19,0xf5,0xfb,0x43,0x1a,0x51, +0x4e,0x25,0x4a,0x80,0x38,0xeb,0xdb,0x47,0xfd,0x29,0x52,0x96,0x6e,0xc9,0xf5,0xb6, +0x62,0xe4,0xc3,0xfd,0x92,0x68,0xb5,0xd3,0x56,0xb0,0x58,0x42,0xb0,0xd9,0x71,0x9c, +0xf4,0xc7,0x58,0x5a,0xc8,0xf3,0xba,0x66,0xc4,0x4c,0x0e,0xf7,0x60,0xce,0xb3,0x0d, +0x85,0xde,0xde,0x20,0x20,0x84,0x18,0x7a,0x9f,0xd3,0x04,0x1f,0x5a,0x41,0x41,0x9d, +0x16,0xa9,0xf5,0xf1,0x54,0x2e,0x30,0xd1,0xb8,0xed,0x98,0xf3,0x93,0xc2,0xa0,0x65, +0x39,0x18,0xa2,0xcc,0xb4,0x1d,0xe7,0x5e,0xd9,0x3b,0x22,0x11,0x8a,0xcc,0x4f,0x06, +0x23,0x8e,0x08,0xa5,0x89,0xaf,0x79,0xf9,0xdd,0x00,0xb8,0x9d,0x91,0x6e,0x1c,0xa7, +0xdc,0x9e,0x2c,0x78,0x00,0x85,0x88,0x51,0x86,0xed,0x43,0x1b,0x12,0x22,0x26,0x1d, +0x94,0x67,0xd8,0x49,0x68,0xe5,0x4c,0x16,0x86,0x03,0x64,0x23,0xb3,0xd1,0x60,0x02, +0x1a,0x73,0x17,0xe1,0x71,0xa4,0xcc,0xc6,0x29,0x08,0x33,0x41,0xa6,0xc9,0x90,0x7d, +0x84,0xf6,0x3f,0xaa,0x0c,0x35,0x6a,0x04,0x93,0xa3,0xff,0xf0,0x50,0x44,0xe2,0xd3, +0x8d,0x99,0x10,0x9f,0xa1,0x73,0x7d,0x79,0x37,0x5f,0xc4,0x01,0x78,0xf4,0xd8,0xe1, +0xc4,0x13,0x76,0xc3,0x2f,0x65,0xc7,0x8e,0x07,0x65,0x5f,0x07,0x1f,0xa5,0x9c,0xfd, +0x0f,0x88,0x27,0x29,0x79,0x7a,0x16,0x29,0x7e,0x21,0x3a,0x88,0x0b,0x34,0xad,0x26, +0x15,0x17,0xc9,0x7f,0x15,0xc9,0xbf,0x0e,0x53,0xb7,0x7f,0xa2,0xd5,0xf9,0xaf,0x67, +0x84,0x02,0x50,0x35,0x5e,0xb8,0x05,0x02,0x42,0xd5,0x7e,0xe4,0xc0,0xb1,0x04,0x1f, +0x6d,0xe2,0xfe,0x2b,0xc0,0x78,0x94,0x2c,0x31,0x5a,0xb8,0x3d,0x27,0x4a,0x6e,0xaf, +0x9d,0x09,0x47,0x4e,0x87,0x9f,0xe2,0x1e,0x75,0x22,0x74,0x98,0x2b,0xf0,0xe5,0x87, +0x49,0xc3,0xdb,0x4d,0xa8,0x45,0x13,0x6c,0xd1,0xf5,0xb6,0xe6,0x6a,0x99,0x64,0x5f, +0x2c,0xdd,0x16,0xeb,0xfb,0xb5,0x9f,0xf0,0x3e,0xf9,0x8d,0x6e,0x69,0xff,0x3e,0x5b, +0x1c,0x8a,0x9f,0x89,0xf1,0x9e,0xb6,0x37,0xca,0xfc,0x7d,0xe7,0x5e,0xdc,0xe5,0x3a, +0x86,0x31,0x14,0x27,0xdd,0x6e,0x32,0xcb,0x23,0xd4,0xb6,0x91,0xa9,0x41,0xa1,0x10, +0xf5,0x58,0x72,0x01,0x4a,0x61,0x7e,0xbe,0x00,0xc7,0x84,0x91,0x14,0xf4,0x6a,0x1e, +0x5a,0xc3,0xf5,0x10,0x5a,0x18,0x72,0x6b,0x06,0xed,0xb5,0x75,0xfc,0x80,0x5d,0x36, +0x37,0x69,0x9c,0x6b,0xc0,0x90,0x51,0x31,0xae,0x61,0x7f,0x8e,0x74,0x70,0x76,0xe8, +0xfe,0xd0,0x51,0x79,0xec,0xab,0xe3,0x23,0x0f,0xca,0xf3,0x3e,0x4c,0xce,0xfb,0x35, +0xe0,0xb9,0x81,0x9f,0x95,0x4e,0x2c,0x16,0x3d,0xd3,0xce,0xfb,0x32,0x3a,0xbf,0x31, +0x27,0xb2,0xcd,0xc0,0xfb,0xc0,0x78,0x92,0xa3,0xdd,0xb4,0x46,0xc6,0x85,0x79,0x88, +0x45,0x9c,0x6c,0x36,0xbf,0x1a,0xe8,0x61,0x19,0x06,0x5e,0x14,0xf3,0xb1,0xb4,0x15, +0xdd,0xd8,0x6c,0xb9,0xe9,0x74,0xe4,0xbf,0x80,0x1e,0x23,0x64,0x84,0xb8,0x37,0x3f, +0xbd,0xd0,0x7f,0xeb,0x7f,0x6e,0xbf,0x75,0x7d,0xf7,0xe5,0x73,0xc3,0x6d,0xe4,0x82, +0x4d,0x13,0xdb,0x49,0x63,0x69,0xd9,0xc9,0x4f,0x05,0x1a,0xb0,0x3a,0xf2,0x7c,0x3f, +0xfe,0xd4,0xa8,0x54,0xa6,0x71,0xc1,0xaf,0x21,0x41,0x82,0xc4,0x34,0x92,0x25,0x34, +0x9f,0xc7,0x7d,0x3e,0xe1,0x1c,0x16,0xfc,0xaa,0x67,0xb0,0xf8,0x44,0xf7,0x3f,0x2c, +0xd2,0x88,0x3e,0xbb,0x9d,0x15,0x76,0xdf,0xfe,0x08,0x06,0x9c,0x5b,0xbf,0x3f,0xcb, +0x8e,0x4a,0xea,0x5f,0xbe,0xf2,0xf5,0x8d,0xf0,0x58,0x23,0x6a,0xf9,0x2d,0x2e,0xe2, +0x8a,0x8e,0x37,0xc9,0xe2,0x79,0x8b,0x35,0x23,0x6c,0xf6,0x0d,0x89,0x6c,0x2e,0xc5, +0x3f,0xc7,0x99,0x67,0xb1,0x02,0x89,0xe1,0x64,0xde,0x57,0x48,0x27,0xb6,0x17,0x18, +0xe2,0x51,0x1b,0x41,0x80,0x9e,0x27,0xa4,0x6f,0x9d,0x49,0x0e,0x2e,0xe6,0x36,0x9c, +0x3e,0xe4,0xa5,0x3d,0xff,0xbc,0x77,0xb3,0xb8,0x58,0x0c,0x57,0xef,0xfc,0x34,0x39, +0xbe,0xb7,0x33,0x1e,0x7b,0x3d,0x91,0xbc,0x24,0xdb,0x3f,0x20,0xad,0x83,0x0b,0xef, +0xde,0xfe,0xdd,0x2b,0x20,0xad,0x91,0xb3,0xa3,0xf0,0x78,0x01,0x0f,0xe1,0xb0,0x7a, +0xfe,0x23,0x29,0x05,0xef,0x4c,0x9b,0x85,0x02,0xba,0xb2,0xe1,0xe6,0xff,0x03,0x8c, +0x92,0xa8,0xc1,0x94,0x10,0x01,0x00}; diff --git a/TC1/mqtt_server/user_mqtt_client.c b/TC1/mqtt_server/user_mqtt_client.c index 00db224..7db7a37 100644 --- a/TC1/mqtt_server/user_mqtt_client.c +++ b/TC1/mqtt_server/user_mqtt_client.c @@ -77,6 +77,7 @@ void UserMqttTimerFunc(void *arg) { UserMqttHassAutoLed(); UserMqttHassAutoTotalSocket(); UserMqttHassAutoChildLock(); + UserMqttHassAutoRebootButton(); break; case 1: case 2: @@ -422,6 +423,8 @@ void ProcessHaCmd(char *cmd) { childLockEnabled = on; UserMqttSendChildLockState(); mico_system_context_update(sys_config); + }else if (strcmp(cmd, "reboot") == 0) { + MicoSystemReboot(); // 立即重启设备 } } @@ -530,7 +533,7 @@ void UserMqttHassAuto(char socket_id) { socket_id--; char *send_buf = NULL; char *topic_buf = NULL; - send_buf = (char *) malloc(800); + send_buf = (char *) malloc(600); topic_buf = (char *) malloc(64); if (send_buf != NULL && topic_buf != NULL) { sprintf(topic_buf, "homeassistant/switch/%s/socket_%d/config", str_mac, socket_id); @@ -542,6 +545,7 @@ void UserMqttHassAuto(char socket_id) { "\"cmd_t\":\"device/ztc1/set\"," "\"pl_on\":\"set socket %s %d 1\"," "\"pl_off\":\"set socket %s %d 0\"," + "\"device_class\":\"outlet\"," "\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"%s\"," @@ -558,6 +562,33 @@ void UserMqttHassAuto(char socket_id) { free(topic_buf); } +void UserMqttHassAutoRebootButton(void) { + char *send_buf = NULL; + char *topic_buf = NULL; + send_buf = (char *) malloc(600); + topic_buf = (char *) malloc(64); + if (send_buf != NULL && topic_buf != NULL) { + // 重启按钮配置 + sprintf(topic_buf, "homeassistant/button/%s/reboot/config", str_mac); + sprintf(send_buf, + "{\"name\":\"重启设备\"," + "\"uniq_id\":\"tc1_%s_reboot\"," + "\"object_id\":\"tc1_%s_reboot\"," + "\"cmd_t\":\"device/ztc1/set\"," + "\"pl_prs\":\"reboot\"," + "\"device_class\":\"outlet\"," + "\"device\":{" + "\"identifiers\":[\"tc1_%s\"]," + "\"name\":\"%s\"," + "\"model\":\"TC1\"," + "\"manufacturer\":\"PHICOMM\"}}", + str_mac,str_mac,str_mac, sys_config->micoSystemConfig.name); + UserMqttSendTopic(topic_buf, send_buf, 1); + } + if (send_buf) free(send_buf); + if (topic_buf) free(topic_buf); +} + void UserMqttHassAutoLed(void) { char *send_buf = NULL; char *topic_buf = NULL; @@ -573,6 +604,7 @@ void UserMqttHassAutoLed(void) { "\"cmd_t\":\"device/ztc1/set\"," "\"pl_on\":\"set led %s 1\"," "\"pl_off\":\"set led %s 0\"," + "\"device_class\":\"outlet\"," "\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"%s\"," @@ -602,6 +634,7 @@ void UserMqttHassAutoChildLock(void) { "\"cmd_t\":\"device/ztc1/set\"," "\"pl_on\":\"set childLock %s 1\"," "\"pl_off\":\"set childLock %s 0\"," + "\"device_class\":\"outlet\"," "\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"%s\"," @@ -631,6 +664,7 @@ void UserMqttHassAutoTotalSocket(void) { "\"cmd_t\":\"device/ztc1/set\"," "\"pl_on\":\"set total_socket %s 1\"," "\"pl_off\":\"set total_socket %s 0\"," + "\"device_class\":\"outlet\"," "\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"%s\"," diff --git a/TC1/mqtt_server/user_mqtt_client.h b/TC1/mqtt_server/user_mqtt_client.h index 29ade30..d384d07 100644 --- a/TC1/mqtt_server/user_mqtt_client.h +++ b/TC1/mqtt_server/user_mqtt_client.h @@ -49,4 +49,6 @@ extern void UserMqttHassAutoTotalSocket(void); extern void registerMqttEvents(void); +extern void UserMqttHassAutoRebootButton(void); + #endif diff --git a/TC1/ota_server/ota_server.c b/TC1/ota_server/ota_server.c index 43f17a1..fa9d8d5 100644 --- a/TC1/ota_server/ota_server.c +++ b/TC1/ota_server/ota_server.c @@ -257,7 +257,7 @@ static void OtaServerThread(mico_thread_arg_t arg) InitMd5(&md5); } - httpHeader = HTTPHeaderCreateWithCallback(1024, OnReceivedData, NULL, NULL); + httpHeader = HTTPHeaderCreateWithCallback(512, OnReceivedData, NULL, NULL); require_action(httpHeader, DELETE, OtaServerProgressSet(OTA_FAIL)); while (1)