完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我不是新手也不是高级...我的问题是我无法将长度为 700 的字符串发送到我的手机。
当然,最大长度在200左右也是可以的。 说明: 是用rs485连线的本地wifi。该线路以名称“LO1”或“GE1”来称呼它。当被前者调用时,它将请求从应用程序传递到线路,而当被后者调用时,它会保存所谓的 。 然后也许应用程序通过 wifi http 调用它并请求报告或开关上的开/关。对于前者,它应该传递保存的海量数据(现在不能!?),而对于后者,它等待直到它被名称'LO1'调用并发送应用程序请求。就这样。 这是我的代码: 代码:全选#include String request_onWiFi; String request_fromApp; const char *ssid = "Greenhouse"; const char *password = "784951623"; WiFiServer server(80); const char *myRRID = "GE1"; //for receive const char *myTtiD = "LO1"; //for response String myTID = "LO1"; //for transmit String myRID = "GE1"; //for receive String falseID = "GE1HM1"; //for receive String r1ID; String r2ID; String safetyID; String responseData; String appData; String rData; int led; int n; byte mac[6]; unsigned long firstmillis; unsigned long secondmillis; int ledPin = D3; void setup() { IPAddress ip(192, 168, 4, 1); // IPAddress gateway(192, 168, 0, 1); // IPAddress subnet(255, 255, 255, 0); WiFi.mode(WIFI_AP); // u can remove the password if you want the AP to be open. WiFi.softAP(ssid, password); server.begin(); Serial.begin(115200); // WiFi.config(ip, gateway, subnet); // IPAddress myIP = WiFi.softAPIP(); // WiFi.macAddress(mac); pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); } int value = 0; void App_request_onWiFi() { WiFiClient client = server.available(); if (!client) { return; } //Read what the browser has sent into a String class //and print the request to the monitor //if u want just first line, use readStringUntil('r') //instead of readString() request_onWiFi = client.readString(); int untill1 = request_onWiFi.indexOf("s/"); int untill2 = request_onWiFi.indexOf("/e"); //Serial.println(sign); request_fromApp += request_onWiFi.substring(untill1 + 2, untill2); request_fromApp += (","); // Serial.println(request_fromApp); // Handle the Request String content; if (request_fromApp.indexOf("RP") != -1) { content = responseData; // Serial.print("content :"); // Serial.println(content); } else { content = "OK"; } // Respond to it client.flush(); //clear previous info in the stream String response = "HTTP/1.1 200 OKrnContent-Type: text/htmlrnrn"; //rnrn"; response += content; // response += "n"; client.print(response); // Send the response to the client delay(1); } void feedback() { digitalWrite(LED_BUILTIN, LOW); delay(100); digitalWrite(LED_BUILTIN, HIGH); } void loop() { if (Serial.available()) { firstmillis = millis(); rData = ""; char chars; while (Serial.available()) { chars = Serial.read(); delayMicroseconds(68); rData = rData + chars; } // rData=Serial.readString(); // Serial.println(rData); int until1 = rData.indexOf("LO1"); r1ID = rData.substring(until1, until1 + 3); int until2 = rData.indexOf("GE1"); r2ID = rData.substring(until2, until2 + 3); int until3 = rData.indexOf("GE1HM1"); safetyID = rData.substring(until3, until3 + 6); // Serial.println(r1ID); // Serial.print("r2ID : "); // Serial.println(r2ID); if (until1 <= 4 ) { if (r1ID == myTID) { secondmillis = millis(); if ((secondmillis - firstmillis) < 90) { String news; news = "UUUU"; news += myTID; news += ","; news += request_fromApp; Serial.print(news); request_fromApp = ""; news = ""; } } } if (safetyID != falseID) { if (until2 <= 4 ) { if (r2ID == myRID) { responseData = rData; int untilsemi = responseData.indexOf(";"); int untiltag = responseData.indexOf("#"); responseData = responseData.substring(untilsemi + 1, untiltag); // Serial.print("responseData :"); // Serial.println(responseData); } } } } App_request_onWiFi(); |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
1042 浏览 1 评论
562浏览 6评论
470浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
454浏览 5评论
456浏览 4评论
428浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-5 05:59 , Processed in 0.821479 second(s), Total 73, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号