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

校园网站建设方案模板天津建设工程信息网电脑版登录

校园网站建设方案模板,天津建设工程信息网电脑版登录,做旅游攻略的网站代码,为网站做seo需要什么因为使用云服务有时候不可靠#xff0c;那么离线控制就很重要。本文使用webserver实现本地网页控制。这样不需要再单独开发APP#xff0c;有浏览器就可以控制。本文所有测试是靠ESP32。8266未测试。使用USE_8266控制。 核心代码如下#xff1a; html.h #pragma onceconst…因为使用云服务有时候不可靠那么离线控制就很重要。本文使用webserver实现本地网页控制。这样不需要再单独开发APP有浏览器就可以控制。本文所有测试是靠ESP32。8266未测试。使用USE_8266控制。 核心代码如下 html.h #pragma onceconst char *AutoConfigHTML u8Resp_html(!DOCTYPE html htmlheadmeta charsetUTF8title智能控制台/title /headbody stylefont-size: 30pxstyle.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;}/stylecenterforminput idbtn_test typebutton classbuttonText value点我测试 onclickconfig(this)/br/label idrecvtxt//form/centerscript languagejavascriptfunction 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::functionbool(const char *);class CWebControl {protected:void HandleHtmlRoot(){m_ControlWebServer.send(200, text/html, AutoConfigHTML);}void HandleHtmlContrl(){if (m_WebServerCallback){bool bRetm_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.dnsts.com.cn/news/124137.html

相关文章:

  • asp.net mvc 企业网站牡丹江
  • 企业营销类专业网站c2c网站的特点
  • 昆明cms模板建站wordpress局域网自定义域名
  • 有什么建筑网站新冠三阳最新消息
  • 游戏网站网页设计网站建设帮助中心
  • 用jsp sqlserver做的购物网站安徽省住房和城乡建设厅网站
  • 泉州网站搭建建英文产品网站
  • 超链接网站建设seo优化6个实用技巧
  • 输入一组基因做网络图的网站app制作软件排名
  • 定机票最便宜网站建设浙江的健康码小程序叫什么
  • 代做ansys网站小程序商店网址
  • 房产网站制作wordpress 维文版
  • 国外网页设计欣赏网站网站建设类有哪些岗位
  • 视频网站自己怎么做的做水军那些网站好
  • 微擎微网站开发wordpress数据库怎么连接
  • 淄博网站建设优化运营熊掌号wordpress.org密码
  • 做外汇网站卖判刑多少年网站服务器类型
  • 网页制作模板的淘宝网站代码udacity 移动网站开发
  • 临颍网站建设网络服务遇到问题请检查网络状况或稍后再试吧
  • 微信辅助做任务网站小型商城网站
  • 响应式网站开发asp南宁本地有几家网站开发
  • 花生壳做网站wordpress评论页面
  • 南宁网站建站推广推广网络推广
  • 淮南装饰公司网站建设陷在泥里无法前进 企业解决方案
  • 专业模板网站制作价格wordpress默认图像不显示
  • 网站怎么做订单wordpress ueditor 代码 转义
  • 朱腾鹏个人网站seo网站源码
  • 代做网站公司有哪些视频网站做app开发的
  • 企业网站推广短平快珠海柏泰教育官方网站建设
  • 胶南网站建设公司酒水食品做的好网站