×
固定報酬制
|
ワーカーと相談する
|
---|---|
納品完了日
|
2017年02月03日 |
掲載日
|
2017年01月29日 |
応募期限
|
2017年02月03日 |
応募した人 | 1 人 |
---|---|
契約した人 | 1 人 |
募集人数 | |
気になる!リスト | 4 人 |
ArduinoCore(ESP8266)で、ESP8266WebServerをSTOPした時にメモリ解放したいです。 理由は、HTTPSアクセスを定期的に実行したいのですが、メモリ不足で動きません。 一時的にWebサーバを停止し、メモリを解放して使いたいです。 Webサーバ、HTTPSアクセスここには動いていますが、同時に動かそうとすると メモリ領域が確保できず、reallocでNullPtrが返されセグメンテーションフォルトしています。 プログラム概要を添付と同じ内容ですが以下にも記載します。 (実際には他にもいろんな処理が動かしていますがメモリ消費は小さいので省略しています) #################################################################################### #include <ESP8266WiFi.h> #include <ESP8266WebServer.h> #include <WiFiClientSecure.h> const char *ssid = "xxxxxxx"; const char *password = "xxxxxx"; //////////////// ip-address //////////////// IPAddress ip(192, 168, 1, 250); IPAddress gateway(192, 168, 1, 1); IPAddress subnet(255, 255, 255, 0); ////////////////////////////////////////// ESP8266WebServer server ( 80 ); // 表示するHTMLを作成し送信 void handleRoot() { String htmlstr = "<html>\ <head>\ <title>ESP8266 Demo</title>\ </head>\ <body>\ <h1>Hello from ESP8266!</h1>\ </body>\ </html>"; // html 送信 server.send ( 200, "text/html", htmlstr ); } void setup ( void ) { WiFi.config( ip, gateway, subnet ); Serial.begin ( 115200 ); WiFi.begin ( ssid, password ); Serial.println ( "" ); // Wait for connection while ( WiFi.status() != WL_CONNECTED ) { delay ( 500 ); Serial.print ( "." ); } Serial.println ( "" ); Serial.print ( "Connected to " ); Serial.println ( ssid ); Serial.print ( "IP address: " ); Serial.println ( WiFi.localIP() ); // Webサーバ起動 httpServerStart (); Serial.println ( "HTTP server started" ); } void loop ( void ) { // 60秒に一度HTTPSアクセス。 if ( millis() % 60000 == 0 ) { // server.close(); server.stop(); // ★★★ここでWebサーバが利用していたメモリを解放したい // HTTPSアクセス WiFiClientSecure sslClient; String stringResponse = ""; if (sslClient.connect("server.com", 443)) { // ************************ HTTPSアクセス処理は省略 ************************* } // Webサーバ起動 httpServerStart (); } // http 受信処理 server.handleClient(); } // Webサーバ起動 void httpServerStart ( ) { server.on ( "/", handleRoot ); server.on ( "/inline", []() { server.send ( 200, "text/plain", "this works as well" ); } ); server.begin(); } #################################################################################### HTTPS処理を外していますので、プログラムは動かないです。 よろしくお願いします。 |
クラウドワーカー | 応募日時 |
---|---|
ProfessionalMind | 2017/01/29 21:55 |