mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-07 15:55:35 +00:00
Mqtt-mbedtls (#960)
* Update package.json Update repo url for build * MQTT over TLS first build * MQTT TLS boot ok * Funcional version MQTT secure TLS * Add option for mqtt to use tls in web config * Versao funcional pendente otimizacao de rom * Versao funcional com verify certificate disabled * Adicao de informacoes para debug * Versao funcional com verificacao do certificado * Otimizacoes de rom e heap usage * Versao com webserver enable/disable * Versao boa para mqtt mbedtls boa uso * Invert CFG enable_web_server to disable_web_server * MQTT over TLS first build * MQTT TLS boot ok * Funcional version MQTT secure TLS * Add option for mqtt to use tls in web config * Versao funcional pendente otimizacao de rom * Versao funcional com verify certificate disabled * Adicao de informacoes para debug * Versao funcional com verificacao do certificado * Otimizacoes de rom e heap usage * Versao com webserver enable/disable * Versao boa para mqtt mbedtls boa uso * Invert CFG enable_web_server to disable_web_server * Same documentation * Rever submodulos configuration * Rever ignore submodules Rever ignore submodules * Fix for git actions * Fix build start_type_pub only in platform Beken * Fix build git w600 * Fix BL602 build * Remove format only changes * Delete src/driver/drv_ir.cpp Space changes only * Updates to pull request * Revert space only changes * Change cfg bool to byte and some documentation * Fix get initial time from compile time * Fix base64.c duplicate module * Fix base64.c duplicate module for git workflow * Fix strange behavior on BK7231n. Connection completed only in the second callback WIFI_STA_CONNECTED * MQTT-MBEDTLS default disable * Fix SERIOUS bug breaking all platforms except BK7231N (did you want to set g_bHasWiFiConnected in #else?) --------- Co-authored-by: Tester23 <85486843+openshwprojects@users.noreply.github.com>
This commit is contained in:
@ -19,6 +19,9 @@
|
||||
#include <time.h>
|
||||
#include "../driver/drv_ntp.h"
|
||||
#include "../driver/drv_local.h"
|
||||
#ifdef PLATFORM_BEKEN
|
||||
#include "start_type_pub.h"
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS
|
||||
// nothing
|
||||
@ -1073,6 +1076,14 @@ int http_fn_cfg_mqtt_set(http_request_t* request) {
|
||||
if (http_getArg(request->url, "port", tmpA, sizeof(tmpA))) {
|
||||
CFG_SetMQTTPort(atoi(tmpA));
|
||||
}
|
||||
|
||||
#if MQTT_USE_TLS
|
||||
CFG_SetMQTTUseTls(http_getArg(request->url, "mqtt_use_tls", tmpA, sizeof(tmpA)));
|
||||
CFG_SetMQTTVerifyTlsCert(http_getArg(request->url, "mqtt_verify_tls_cert", tmpA, sizeof(tmpA)));
|
||||
http_getArg(request->url, "mqtt_cert_file", tmpA, sizeof(tmpA));
|
||||
CFG_SetMQTTCertFile(tmpA);
|
||||
#endif
|
||||
|
||||
if (http_getArg(request->url, "user", tmpA, sizeof(tmpA))) {
|
||||
CFG_SetMQTTUserName(tmpA);
|
||||
}
|
||||
@ -1109,6 +1120,21 @@ int http_fn_cfg_mqtt(http_request_t* request) {
|
||||
|
||||
add_label_text_field(request, "Host", "host", CFG_GetMQTTHost(), "<form action=\"/cfg_mqtt_set\">");
|
||||
add_label_numeric_field(request, "Port", "port", CFG_GetMQTTPort(), "<br>");
|
||||
#if MQTT_USE_TLS
|
||||
hprintf255(request, "<input type=\"checkbox\" id=\"mqtt_use_tls\" name=\"mqtt_use_tls\" value=\"1\"");
|
||||
if (CFG_GetMQTTUseTls()) {
|
||||
hprintf255(request, " checked>");
|
||||
}
|
||||
hprintf255(request, "<label for=\"mqtt_use_tls\">Use TLS</label><br>");
|
||||
|
||||
hprintf255(request, "<input type=\"checkbox\" id=\"mqtt_verify_tls_cert\" name=\"mqtt_verify_tls_cert\" value=\"1\"");
|
||||
if (CFG_GetMQTTVerifyTlsCert()) {
|
||||
hprintf255(request, " checked>");
|
||||
}
|
||||
hprintf255(request, "<label for=\"mqtt_use_tls\">Verify TLS Certificate</label><br>");
|
||||
|
||||
add_label_text_field(request, "Certificate File (CA Root or Public Certificate PEM format)", "mqtt_cert_file", CFG_GetMQTTCertFile(), "<br>");
|
||||
#endif
|
||||
add_label_text_field(request, "Client Topic (Base Topic)", "client", CFG_GetMQTTClientId(), "<br><br>");
|
||||
add_label_text_field(request, "Group Topic (Secondary Topic to only receive cmnds)", "group", CFG_GetMQTTGroupTopic(), "<br>");
|
||||
add_label_text_field(request, "User", "user", CFG_GetMQTTUserName(), "<br>");
|
||||
@ -1178,6 +1204,15 @@ int http_fn_cfg_webapp(http_request_t* request) {
|
||||
http_setup(request, httpMimeTypeHTML);
|
||||
http_html_start(request, "Set Webapp");
|
||||
add_label_text_field(request, "URL of the Webapp", "url", CFG_GetWebappRoot(), "<form action=\"/cfg_webapp_set\">");
|
||||
|
||||
#if MQTT_USE_TLS
|
||||
hprintf255(request, "<input type=\"checkbox\" id=\"enable_web_server\" name=\"enable_web_server\" value=\"1\"");
|
||||
if (!CFG_GetDisableWebServer()) {
|
||||
hprintf255(request, " checked>");
|
||||
}
|
||||
hprintf255(request, "<label for=\"enable_web_server\">Web Server Enabled</label><br>");
|
||||
#endif
|
||||
|
||||
poststr(request, SUBMIT_AND_END_FORM);
|
||||
poststr(request, htmlFooterReturnToCfgOrMainPage);
|
||||
http_html_end(request);
|
||||
@ -1199,6 +1234,14 @@ int http_fn_cfg_webapp_set(http_request_t* request) {
|
||||
poststr(request, "Webapp url not set because you didn't specify the argument.");
|
||||
}
|
||||
|
||||
#if MQTT_USE_TLS
|
||||
CFG_SetDisableWebServer(!http_getArg(request->url, "enable_web_server", tmpA, sizeof(tmpA)));
|
||||
if (CFG_GetDisableWebServer()) {
|
||||
poststr(request, "<br>");
|
||||
poststr(request, "Webapp will be disabled on next boot!");
|
||||
}
|
||||
#endif
|
||||
|
||||
poststr(request, "<br>");
|
||||
poststr(request, htmlFooterReturnToCfgOrMainPage);
|
||||
http_html_end(request);
|
||||
|
||||
@ -55,6 +55,17 @@ void HTTPServer_Start()
|
||||
}
|
||||
}
|
||||
|
||||
void HTTPServer_Stop()
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
err = rtos_delete_thread(&g_http_thread);
|
||||
|
||||
if (err != kNoErr)
|
||||
{
|
||||
ADDLOG_ERROR(LOG_FEATURE_HTTP, "stop \"TCP_server\" thread failed with %i!\r\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
int sendfn(int fd, char* data, int len) {
|
||||
if (fd) {
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
|
||||
void HTTPServer_Start();
|
||||
void HTTPServer_Stop();
|
||||
Reference in New Issue
Block a user