当前位置: 首页 > news >正文

百度站长工具添加不了站点wordpress 发送邮件 名称

百度站长工具添加不了站点,wordpress 发送邮件 名称,网站市场做烂了,《高性能网站建设指南因为使用云服务有时候不可靠,那么离线控制就很重要。本文使用webserver实现本地网页控制。这样不需要再单独开发APP,有浏览器就可以控制。本文所有测试是靠ESP32。8266未测试。使用USE_8266控制。 核心代码如下: html.h #pragma onceconst…

因为使用云服务有时候不可靠,那么离线控制就很重要。本文使用webserver实现本地网页控制。这样不需要再单独开发APP,有浏览器就可以控制。本文所有测试是靠ESP32。8266未测试。使用USE_8266控制。

核心代码如下:

html.h

#pragma onceconst char *AutoConfigHTML = u8R"esp_html(<!DOCTYPE html>
<html><head><meta charset="UTF8"><title>智能控制台</title>
</head><body style="font-size: 30px"><style>.inputText {height: 38px;font-size: 30px;line-height: 30px;padding-left: 15px;border-radius: 10px;background-color: #dff1f7;border: 2;}.inputText:focus {outline: none;background-color: #d6e4eb;}.buttonText {height: 38px;font-size: 30px;line-height: 30px;padding-left: 15px;border-radius: 10px;background-color: #FE5E08;border: none;}.buttonText:focus {outline: none;background-color: #FE5E08;}.buttonText:disabled {background-color: #c9c7c6;}</style><center><form><input id="btn_test" type="button" class="buttonText" value="点我测试" onclick="config(this)"/><br/><label id="recvtxt"/></form></center><script language="javascript">function config(sender) {var xmlhttp = new XMLHttpRequest();xmlhttp.onreadystatechange = function () {if (xmlhttp.readyState == 4) {if (xmlhttp.status == 200) {document.getElementById("recvtxt").innerText = "设置成功";                        }else {document.getElementById("recvtxt").innerText = "设置失败";document.getElementById("btnsendconfig").disabled = false;}}}xmlhttp.ontimeout = function () {window.location.href = "about:blank";window.close();}xmlhttp.open("GET", "/Ctrl?btn_name=" + sender.id, true);xmlhttp.timeout = 5000;xmlhttp.send();document.getElementById("btnsendconfig").disabled = true;}</script>
</body></html>
)esp_html";

webctrl.h


#include <atomic>
#include <thread>
#include <functional>
#include "html.h"#ifndef AUTOCFGSSID
#define AUTOCFGSSID "ESP_WIFI"
#endif
#ifndef AUTOCFGPSW
#define AUTOCFGPSW "12345678"
#endif#ifdef USE_8266
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
using TagWebSERVER = ESP8266WebServer;
#else
#include <WiFi.h>
#include <WebServer.h>
using TagWebSERVER = WebServer;
#endifusing FunWebServerCallback = std::function<bool(const char *)>;class CWebControl
{protected:void HandleHtmlRoot(){m_ControlWebServer.send(200, "text/html", AutoConfigHTML);}void HandleHtmlContrl(){if (m_WebServerCallback){bool bRet=m_WebServerCallback(m_ControlWebServer.arg("btn_name").c_str());m_ControlWebServer.send(bRet?200:500, "text/html", m_ControlWebServer.arg("btn_name").c_str());}}public:CWebControl() : m_bRun(false){}void Init(){WiFi.mode(WIFI_AP_STA); // 双模式WiFi.setAutoReconnect(true);IPAddress ip, gateway, subnet;ip.fromString("192.168.2.1");gateway.fromString("192.168.2.1");subnet.fromString("255.255.255.0");WiFi.softAPConfig(ip, gateway, subnet);WiFi.softAP(AUTOCFGSSID, AUTOCFGPSW);m_ControlWebServer.on("/", std::bind(&CWebControl::HandleHtmlRoot, this));m_ControlWebServer.on("/Ctrl", HTTP_GET, std::bind(&CWebControl::HandleHtmlContrl, this));}~CWebControl(){Stop();}void Stop(){m_bRun = false;m_ControlWebServer.close();if (m_LoopThread.joinable()){m_LoopThread.join();}}void SetCallBack(FunWebServerCallback callback){m_WebServerCallback = callback;}void Run(){Stop();m_bRun = true;m_ControlWebServer.begin(80);m_LoopThread = std::thread(std::bind([&]{while (m_bRun){m_ControlWebServer.handleClient();} }));}private:std::thread m_LoopThread;TagWebSERVER m_ControlWebServer;std::atomic_bool m_bRun;FunWebServerCallback m_WebServerCallback;
};

调用方法如下

// 这里定义热点名和密码,定义一定要在#include "webCtrl.h"前面
//连接如下热点 在浏览器访问 192.168.2.1 即可打开控制页面。当然IP地址可以在webCtrl.h修改成你想要的。
//#define AUTOCFGSSID "ESP_WIFI"
//#define AUTOCFGPSW "12345678"// 如果使用8266取消下行注释
// #define USE_8266
#include "webCtrl.h"// 我这里使用的是ESP32 s3.当然其它型号也是代码通用。因为这里我的板子有一颗RGB。使用它测试。请根据需要修改
#ifndef USE_8266
#include "RGB.h"
RGB rgb(1, 48);//注意我买的板子是48脚。你的板子未必是
#endifCWebControl g_WebControl;bool WebCtrlCallBack(const char *name)
{// btn_test这里需要修改HTML对应ID。我这里使用btn_test。添加按钮根据ID区分即可。if (strcmp(name, "btn_test") == 0){
#ifndef USE_8266static bool trunOn = false;rgb.showRGB(trunOn = !trunOn, 0, 255, 100);
#endif}return true;
}void setup()
{// put your setup code here, to run once:g_WebControl.Init();g_WebControl.SetCallBack(std::bind(WebCtrlCallBack, std::placeholders::_1));g_WebControl.Run();#ifndef USE_8266rgb.begin(50);
#endif
}void loop()
{// put your main code here, to run repeatedly:
}

工程代码下载:

【免费】esp32使用网页实现本地控制资源-CSDN文库

http://www.yayakq.cn/news/930440/

相关文章:

  • 网站建设分什么行业wordpress 当前位置 插件
  • 专业做网站建设 昆山郑州影视公司
  • 永久免费网站空间创新创业大赛项目计划书
  • asp.net网站开发代码做网站需要自己上传产品吗
  • 北京新闻媒体网站seo评测
  • 重庆做网站怎么做呀做网站都需要哪些知识
  • 网站栏目相关内容在哪采集啊青海省住房和城乡建设厅网站
  • 保定网站设计多少钱网站怎么算抄袭
  • 二类电商用网站怎么做H5页面鄂州做网站的公司
  • 网站推广前景怎么样中疾控新冠最新消息
  • 怎样免费注册网站域名沈阳餐饮网站建设
  • asp.net 企业官网网站 源码 多风格 多模板 多皮肤做招商类型的网站
  • 网上做任务挣钱的网站公司免费网站域名注册
  • 汕尾营销网站建设海口网络公司网站建设
  • 怎么做公司网站seo电影免费在线观看
  • 鄱阳电商网站建设常见的o2o平台有哪些
  • 手机网站cms 下载自适应网站开发工具
  • 武安专业做网站access数据库创建网站
  • 中国企业网官方网站下载专门做问卷调查的一个网站
  • 简述网站建设的流程做成一个页面北京响应式网站建设推荐
  • 网站 用户体验的重要性企业网站源码进一品资源网
  • 进入福建省建设干部培训中心网站常规做网站要在工信部认证吗
  • 网站建设的策划书优化核心系列网站
  • 罗湖网站建设的公司哪家好网页效果
  • jsp开源网站优秀网站h5案例分享
  • 广州产品网站设计主机做网站服务器怎么设置
  • 苏州市建设培训网站安全员C类查询设计说明书格式
  • 中国住建部和城乡建设部官网网站建设和网络优化
  • 校园类网站模板免费下载wordpress 不能发布文章
  • 学习前端的网站js获取网站广告点击量怎么做