neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
933 stars 189 forks source link

need esp32 web menu example #315

Open LeandroLimaPRO opened 4 years ago

LeandroLimaPRO commented 4 years ago

will there be compatibility of the "MENU" websocket with esp32? I tried to perform a migration with ESP32 but without success.

neu-rah commented 4 years ago

yes, its the idea, but not tested it yet errors or libraries missing?

LeandroLimaPRO commented 4 years ago

I'm not a websocket ace, I'm quite a beginner to tell the truth, I made some changes:

CODE ARDUINO

/********************
Arduino generic menu system
XmlServer menu example
based on WebServer:
  https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer
  https://github.com/Links2004/arduinoWebSockets

Dec. 2016 Rui Azevedo - ruihfazevedo(@rrob@)gmail.com

menu on web browser served by esp8266 device
output: ESP8266WebServer -> Web browser
input: ESP8266WebSocket <- Web browser
format: xml, json

IMPORTANT!:
this requires the data folder to be stored on esp8266 spiff
Extra libraries should be present

arduinoWebSockets - https://github.com/Links2004/arduinoWebSockets
ESP8266WiFi - https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi
ESP8266WebServer - https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer

for development purposes some files are left external,
therefor requiring an external webserver to provide them (just for dev purposes)
i'm using nodejs http-server (https://www.npmjs.com/package/http-server)
to static serve content from the data folder. This allows me to quick change
the files without having to upload them to SPIFFS
also gateway ssid and password are stored on this code (bellow),
so don't forget to change it.

*/
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager

#include <menu.h>
#include <menuIO/esp8266Out.h>
#include <menuIO/xmlFmt.h>//to write a menu has html page
#include <menuIO/serialIn.h>
#include <menuIO/xmlFmt.h>//to write a menu has xml page
#include <menuIO/jsonFmt.h>//to write a menu has xml page
#ifndef ARDUINO_STREAMING
  #include <streamFlow.h>//https://github.com/neu-rah/streamFlow
#else
  #include <Streaming.h>//https://github.com/scottdky/Streaming
#endif
//#include <menuIO/jsFmt.h>//to send javascript thru web socket (live update)
#include <SPIFFS.h>
#include <Hash.h>

using namespace Menu;

#ifdef WEB_DEBUG
  // on debug mode I put aux files on external server to allow changes without SPIFF update
  // on this mode the browser MUST be instructed to accept cross domain files
  String xslt("http://neurux:8080/");
#else
  String xslt("");
#endif

menuOut& operator<<(menuOut& o,unsigned long int i) {
  o.print(i);
  return o;
}
menuOut& operator<<(menuOut& o,endlObj) {
  o.println();
  return o;
}

//this version numbers MUST be the same as data/1.2
#define CUR_VERSION "1.5"
#define APName "WebMenu"

int ledCtrl=LOW;
//on my esp12e led pin is 2
#define LEDPIN 2
//this is ok on other boards
// #define LEDPIN LED_BUILTIN
void updLed() {
  _trace(Serial<<"update led state!"<<endl);
  digitalWrite(LEDPIN,!ledCtrl);
}

#define ANALOG_PIN 4

// constexpr size_t wifiSSIDLen=64;
// constexpr size_t wifiPwdLen=32;
/* ---------------------------------------
 *  REMOVED - using WifiManager
#ifndef MENU_SSID
  #error "need to define WiFi SSID here"
  #define MENU_SSID "r-site.net"
#endif
#ifndef MENU_PASS
  #error "need to define WiFi password here"
  #define MENU_PASS ""
#endif

const char* ssid = MENU_SSID;
const char* password = MENU_PASS;
-------------------------------------------------*/
//const char* serverName="192.168.1.79";

#define HTTP_PORT 80
#define WS_PORT 81
#define USE_SERIAL Serial
ESP8266WebServer server(80);
WebSocketsServer webSocket(81);

#define MAX_DEPTH 2
idx_t web_tops[MAX_DEPTH];
PANELS(webPanels,{0,0,80,100});
xmlFmt<esp8266_WebServerStreamOut> serverOut(server,web_tops,webPanels);
jsonFmt<esp8266_WebServerStreamOut> jsonOut(server,web_tops,webPanels);
jsonFmt<esp8266BufferedOut> wsOut(web_tops,webPanels);

//menu action functions
result action1(eventMask event, navNode& nav, prompt &item) {
  Serial.println("action A called!");
  serverOut<<"This is action <b>A</b> web report "<<(millis()%1000)<<"<br/>";
  return proceed;
}
result action2(eventMask event, navNode& nav, prompt &item) {
  Serial.println("action B called!");
  serverOut<<"This is action <b>B</b> web report "<<(millis()%1000)<<"<br/>";
  return proceed;
}

void debugLedUpd() {
  _trace(Serial<<"debug led update! "<<ledCtrl<<endl);
}

TOGGLE(ledCtrl,setLed,"Led: ",updLed,(Menu::eventMask)(updateEvent|enterEvent),noStyle
  ,VALUE("Off",LOW,doNothing,noEvent)
  ,VALUE("On",HIGH,doNothing,noEvent)
);

int selTest=0;
SELECT(selTest,selMenu,"Select",doNothing,noEvent,noStyle
  ,VALUE("Zero",0,doNothing,noEvent)
  ,VALUE("One",1,doNothing,noEvent)
  ,VALUE("Two",2,doNothing,noEvent)
);

int chooseTest=-1;
CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,noStyle
  ,VALUE("First",1,doNothing,noEvent)
  ,VALUE("Second",2,doNothing,noEvent)
  ,VALUE("Third",3,doNothing,noEvent)
  ,VALUE("Last",-1,doNothing,noEvent)
);

int duty=50;//%
int timeOn=50;//ms
void updAnalog() {
  // analogWrite(ANALOG_PIN,map(timeOn,0,100,0,255/*PWMRANGE*/));
  analogWrite(ANALOG_PIN,map(duty,0,100,0,255/*PWMRANGE*/));
}

char* constMEM alphaNum MEMMODE=" 0123456789.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,\\|!\"#$%&/()=?~*^+-{}[]€";
char* constMEM alphaNumMask[] MEMMODE={alphaNum};
char name[]="                                                  ";

uint16_t year=2017;
uint16_t month=10;
uint16_t day=7;

//define a pad style menu (single line menu)
//here with a set of fields to enter a date in YYYY/MM/DD format
//altMENU(menu,birthDate,"Birth",doNothing,noEvent,noStyle,(systemStyles)(_asPad|Menu::_menuData|Menu::_canNav|_parentDraw)
PADMENU(birthDate,"Birth",doNothing,noEvent,noStyle
  ,FIELD(year,"","/",1900,3000,20,1,doNothing,noEvent,noStyle)
  ,FIELD(month,"","/",1,12,1,0,doNothing,noEvent,wrapStyle)
  ,FIELD(day,"","",1,31,1,0,doNothing,noEvent,wrapStyle)
);

//customizing a prompt look!
//by extending the prompt class
class altPrompt:public prompt {
public:
  // altPrompt(constMEM promptShadow& p):prompt(p) {}
  using prompt::prompt;
  Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t) override {
    return out.printRaw(F("special prompt!"),len);
  }
};

MENU(subMenu,"Sub-Menu",doNothing,noEvent,noStyle
  ,OP("Sub1",doNothing,noEvent)
  ,OP("Sub2",doNothing,noEvent)
  ,OP("Sub3",doNothing,noEvent)
  ,altOP(altPrompt,"",doNothing,noEvent)
  ,EXIT("<Back")
);

//the menu
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
  ,SUBMENU(setLed)
  ,OP("Action A",action1,enterEvent)
  ,OP("Action B",action2,enterEvent)
  ,FIELD(duty,"Duty","%",0,100,10,1, updAnalog, anyEvent, noStyle)
  // ,FIELD(timeOn,"On","ms",0,100,10,1, updAnalog, anyEvent, noStyle)
  ,EDIT("Name",name,alphaNumMask,doNothing,noEvent,noStyle)
  ,SUBMENU(birthDate)
  ,SUBMENU(selMenu)
  ,SUBMENU(chooseMenu)
  ,SUBMENU(subMenu)
  ,EXIT("Exit!")
);

result idle(menuOut& o,idleEvent e) {
  //if (e==idling)
  Serial.println("suspended");
  o<<"suspended..."<<endl<<"press [select]"<<endl<<"to continue"<<endl<<(millis()%1000);
  return quit;
}

template<typename T>//some utill to help us calculate array sizes (known at compile time)
constexpr inline size_t menuData_len(T& o) {return sizeof(o)/sizeof(decltype(o[0]));}

//serial menu navigation
MENU_OUTLIST(out,&serverOut);
serialIn serial(Serial);
NAVROOT(nav,mainMenu,MAX_DEPTH,serial,out);

//xml+http navigation control
noInput none;//web uses its own API
menuOut* web_outputs[]={&serverOut};
outputsList web_out(web_outputs,menuData_len(web_outputs));
navNode web_cursors[MAX_DEPTH];
navRoot webNav(mainMenu, web_cursors, MAX_DEPTH, none, web_out);

//json+http navigation control
menuOut* json_outputs[]={&jsonOut};
outputsList json_out(json_outputs,menuData_len(json_outputs));
navNode json_cursors[MAX_DEPTH];
navRoot jsonNav(mainMenu, json_cursors, MAX_DEPTH, none, json_out);

//websockets navigation control
menuOut* ws_outputs[]={&wsOut};
outputsList ws_out(ws_outputs,menuData_len(ws_outputs));
navNode ws_cursors[MAX_DEPTH];
navRoot wsNav(mainMenu, ws_cursors, MAX_DEPTH, none, ws_out);

//config myOptions('*','-',defaultNavCodes,false);

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
  switch(type) {
    case WStype_DISCONNECTED:
      //USE_SERIAL.printf("[%u] Disconnected!\n", num);
      break;
    case WStype_CONNECTED: {
        IPAddress ip = webSocket.remoteIP(num);
        //USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);
        webSocket.sendTXT(num, "console.log('ArduinoMenu Connected')");
      }
      break;
    case WStype_TEXT: {
        //USE_SERIAL.printf("[%u] get Text: %s\n", num, payload);
        // nav.async((const char*)payload);//this is slow!!!!!!!!
        __trace(Serial.printf("[%u] get Text: %s\n", num, payload));
        char*s=(char*)payload;
        _trace(Serial<<"serve websocket menu"<<endl);
        wsOut.response.remove(0);
        wsOut<<"{\"output\":\"";
        wsNav.async((const char*)payload);
        wsOut<<"\",\n\"menu\":";
        wsNav.doOutput();
        wsOut<<"\n}";
        webSocket.sendTXT(num,wsOut.response);
        // wsOut.response.remove(0);
        // jsonEnd();
      } break;
    case WStype_BIN: {
        USE_SERIAL<<"[WSc] get binary length:"<<length<<"[";
        for(int c=0;c<length;c++) {
          USE_SERIAL.print(*(char*)(payload+c),HEX);
          USE_SERIAL.write(',');
        }
        USE_SERIAL<<"]"<<endl;
        uint16_t id=*(uint16_t*) payload++;
        idx_t len=*((idx_t*)++payload);
        idx_t* pathBin=(idx_t*)++payload;
        const char* inp=(const char*)(payload+len);
        //Serial<<"id:"<<id<<endl;
        if (id==nav.active().hash()) {
          //Serial<<"id ok."<<endl;Serial.flush();
          //Serial<<"input:"<<inp<<endl;
          //StringStream inStr(inp);
          //while(inStr.available())
          nav.doInput(inp);
          webSocket.sendTXT(num, "binBusy=false;");//send javascript to unlock the state
        } //else Serial<<"id not ok!"<<endl;
        //Serial<<endl;
      }
      break;
    default:break;
  }
}

void pageStart() {
  _trace(Serial<<"pasgeStart!"<<endl);
  serverOut<<"HTTP/1.1 200 OK\r\n"
    <<"Content-Type: text/xml\r\n"
    <<"Connection: close\r\n"
    <<"Expires: 0\r\n"
    <<"\r\n";
  serverOut<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n"
    "<?xml-stylesheet type=\"text/xsl\" href=\"";
  serverOut<<xslt;
  serverOut<<CUR_VERSION"/device.xslt";
  serverOut<<"\"?>\r\n<menuLib"
    #ifdef WEB_DEBUG
      <<" debug=\"yes\""
    #endif
    <<" host=\"";
    serverOut.print(APName);
    serverOut<<"\">\r\n<sourceURL ver=\"" CUR_VERSION "/\">";
  if (server.hasHeader("host"))
    serverOut.print(server.header("host"));
  else
    serverOut.print(APName);
  serverOut<<"</sourceURL>";
}

void pageEnd() {
  serverOut<<"</menuLib>";
  server.client().stop();
}

void jsonStart() {
  _trace(Serial<<"jsonStart!"<<endl);
  serverOut<<"HTTP/1.1 200 OK\r\n"
    <<"Content-Type: application/json; charset=utf-8\r\n"
    <<"Connection: close\r\n"
    <<"Expires: 0\r\n"
    <<"\r\n";
}

void jsonEnd() {
  server.client().stop();
}

bool handleMenu(navRoot& nav){
  _trace(
    uint32_t free = system_get_free_heap_size();
    Serial.print(F("free memory:"));
    Serial.print(free);
    Serial.print(F(" handleMenu "));
    Serial.println(server.arg("at").c_str());
  );
  String at=server.arg("at");
  bool r;
  r=nav.async(server.hasArg("at")?at.c_str():"/");
  return r;
}

//redirect to version folder,
//this allows agressive caching with no need to cache reset on version change
auto mainPage= []() {
  _trace(Serial<<"serving main page from root!"<<endl);
  server.sendHeader("Location", CUR_VERSION "/index.html", true);
  server.send ( 302, "text/plain", "");
  if (server.hasArg("at"))
    nav.async(server.arg("at").c_str());
};

void setup(){
  //check your pins before activating this
  pinMode(LEDPIN,OUTPUT);
  updLed();
  // analogWriteRange(1023);
  pinMode(ANALOG_PIN,OUTPUT);
  updAnalog();
  //options=&myOptions;//menu options
  Serial.begin(115200);
  while(!Serial)
  //USE_SERIAL.setDebugOutput(true);
  Serial.println();
  Serial.println();
  Serial.println();

  // #ifndef MENU_DEBUG
    //do not allow web heads to exit, they wont be able to return (for now)
    //we should resume this heads on async requests!
    webNav.canExit=false;
    jsonNav.canExit=false;
    wsNav.canExit=false;
  // #endif

  for(uint8_t t = 4; t > 0; t--) {
      Serial.printf("[SETUP] BOOT WAIT %d...\n", t);
      Serial.flush();
      delay(1000);
  }

  // Serial.setDebugOutput(1);
  // Serial.setDebugOutput(0);
  // while(!Serial);
  // delay(10);
  // wifi_station_set_hostname((char*)serverName);
  Serial.println("");
  Serial.println("Arduino menu webserver example");

  SPIFFS.begin();

   WiFiManager wm;

    //reset settings - wipe credentials for testing
    //wm.resetSettings();

    // Automatically connect using saved credentials,
    // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
    // if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
    // then goes into a blocking loop awaiting configuration and will return success result

    bool res;
    // res = wm.autoConnect(); // auto generated AP name from chipid
     res = wm.autoConnect("AutoConnectAP"); // anonymous ap
    //res = wm.autoConnect("AutoConnectAP","password"); // password protected ap

    if(!res) {
        Serial.println("Failed to connect");
        // ESP.restart();
    } 
    else {
        //if you get here you have connected to the WiFi    
        Serial.println("connected...yeey :)");
   }
  webSocket.begin();
  Serial.println("");
  webSocket.onEvent(webSocketEvent);
  Serial.println("Connected.");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  webSocket.begin();

  nav.idleTask=idle;//point a function to be used when menu is suspended

  server.on("/",HTTP_GET,mainPage);

  //menu xml server over http
  server.on("/menu", HTTP_GET, []() {
    pageStart();
    serverOut<<"<output state=\""<<((int)&webNav.idleTask)<<"\"><![CDATA[";
    _trace(Serial<<"output count"<<webNav.out.cnt<<endl);
    handleMenu(webNav);//do navigation (read input) and produce output messages or reports
    serverOut<<"]]></output>";
    webNav.doOutput();
    pageEnd();
  });

  //menu json server over http
  server.on("/json", HTTP_GET, []() {
    _trace(Serial<<"json request!"<<endl);
    jsonStart();
    serverOut<<"{\"output\":\"";
    handleMenu(jsonNav);
    serverOut<<"\",\n\"menu\":";
    jsonNav.doOutput();
    serverOut<<"\n}";
    jsonEnd();
  });

  server.begin();
  Serial.println("HTTP server started");
  Serial.println("Serving ArduinoMenu example.");
  #ifdef MENU_DEBUG
    server.serveStatic("/", SPIFFS, "/","max-age=30");
  #else
    server.serveStatic("/", SPIFFS, "/","max-age=31536000");
  #endif
}

void loop(void){
  wsOut.response.remove(0);//clear websocket json buffer
  webSocket.loop();
  server.handleClient();
  delay(1);
}

DEBUG ARDUINO IDE:

Arduino: 1.8.12 (Windows 10), Placa:"ESP32 Dev Module, Disabled, Huge APP (3MB No OTA/1MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Debug"

WebMenu:245:34: error: 'WStype_t' has not been declared

 void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {

                                  ^

WebMenu:105:1: error: 'ESP8266WebServer' does not name a type

 ESP8266WebServer server(80);

 ^

WebMenu:106:1: error: 'WebSocketsServer' does not name a type

 WebSocketsServer webSocket(81);

 ^

WebMenu:111:1: error: 'xmlFmt' does not name a type

 xmlFmt<esp8266_WebServerStreamOut> serverOut(server,web_tops,webPanels);

 ^

WebMenu:112:1: error: 'jsonFmt' does not name a type

 jsonFmt<esp8266_WebServerStreamOut> jsonOut(server,web_tops,webPanels);

 ^

WebMenu:113:1: error: 'jsonFmt' does not name a type

 jsonFmt<esp8266BufferedOut> wsOut(web_tops,webPanels);

 ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'Menu::result action1(Menu::eventMask, Menu::navNode&, Menu::prompt&)':

WebMenu:118:3: error: 'serverOut' was not declared in this scope

   serverOut<<"This is action <b>A</b> web report "<<(millis()%1000)<<"<br/>";

   ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'Menu::result action2(Menu::eventMask, Menu::navNode&, Menu::prompt&)':

WebMenu:123:3: error: 'serverOut' was not declared in this scope

   serverOut<<"This is action <b>B</b> web report "<<(millis()%1000)<<"<br/>";

   ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'void updAnalog()':

WebMenu:155:59: error: 'analogWrite' was not declared in this scope

   analogWrite(ANALOG_PIN,map(duty,0,100,0,255/*PWMRANGE*/));

                                                           ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'Menu::result idle(Menu::menuOut&, Menu::idleEvent)':

WebMenu:212:4: error: no match for 'operator<<' (operand types are 'Menu::menuOut' and 'const char [13]')

   o<<"suspended..."<<endl<<"press [select]"<<endl<<"to continue"<<endl<<(millis()%1000);

    ^

In file included from C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino:41:0:

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:44:16: note: candidate: Stream& operator<<(Stream&, hex)

 inline Stream& operator<<(Stream& s,hex v) {return v.operator<<(s);}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:44:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:45:16: note: candidate: Stream& operator<<(Stream&, bin)

 inline Stream& operator<<(Stream& s,bin v) {return v.operator<<(s);}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:45:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:47:16: note: candidate: Stream& operator<<(Stream&, char)

 inline Stream& operator<<(Stream& s,char v) {s.print(v);return s;}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:47:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:48:16: note: candidate: Stream& operator<<(Stream&, int)

 inline Stream& operator<<(Stream& s,int v) {s.print(v);return s;}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:48:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:49:16: note: candidate: Stream& operator<<(Stream&, long int)

 inline Stream& operator<<(Stream& s,long v) {s.print(v);return s;}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:49:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:50:16: note: candidate: Stream& operator<<(Stream&, unsigned int)

 inline Stream& operator<<(Stream& s,unsigned int v) {s.print(v);return s;}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:50:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:51:16: note: candidate: Stream& operator<<(Stream&, long unsigned int)

 inline Stream& operator<<(Stream& s,unsigned long v) {s.print(v);return s;}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:51:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:52:16: note: candidate: Stream& operator<<(Stream&, double)

 inline Stream& operator<<(Stream& s,double v) {s.print(v);return s;}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:52:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:53:16: note: candidate: Stream& operator<<(Stream&, const char*)

 inline Stream& operator<<(Stream& s,const char* v) {s.print(v);return s;}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:53:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:55:16: note: candidate: Stream& operator<<(Stream&, const __FlashStringHelper*)

 inline Stream& operator<<(Stream& s,const __FlashStringHelper* v) {

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:55:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:88:16: note: candidate: Stream& operator<<(Stream&, endlObj&)

 inline Stream& operator<<(Stream &o,endlObj& v) {return v.operator<<(o);}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:88:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:89:16: note: candidate: Stream& operator<<(Stream&, tabObj&)

 inline Stream& operator<<(Stream &o,tabObj& v) {return v.operator<<(o);}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:89:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:90:16: note: candidate: Stream& operator<<(Stream&, thenObj&)

 inline Stream& operator<<(Stream &o,thenObj& v) {return v.operator<<(o);}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:90:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:91:16: note: candidate: Stream& operator<<(Stream&, dotObj&)

 inline Stream& operator<<(Stream &o,dotObj& v) {return v.operator<<(o);}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:91:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:92:16: note: candidate: Stream& operator<<(Stream&, dotlObj&)

 inline Stream& operator<<(Stream &o,dotlObj& v) {return v.operator<<(o);}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:92:16: note:   no known conversion for argument 1 from 'Menu::menuOut' to 'Stream&'

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:101:16: note: candidate: template<int N> Stream& operator<<(Stream&, tabs<N>&)

 inline Stream& operator<<(Stream& s,tabs<N>& v) {return v.operator<<(s);}

                ^

C:\Users\leo_l\Documents\Arduino\libraries\streamFlow-master\src/streamFlow.h:101:16: note:   template argument deduction/substitution failed:

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino:212:6: note:   cannot convert 'o' (type 'Menu::menuOut') to type 'Stream&'

   o<<"suspended..."<<endl<<"press [select]"<<endl<<"to continue"<<endl<<(millis()%1000);

      ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino:59:10: note: candidate: Menu::menuOut& operator<<(Menu::menuOut&, long unsigned int) <near match>

 menuOut& operator<<(menuOut& o,unsigned long int i) {

          ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino:59:10: note:   conversion of argument 2 would be ill-formed:

WebMenu:212:6: error: invalid conversion from 'const char*' to 'long unsigned int' [-fpermissive]

   o<<"suspended..."<<endl<<"press [select]"<<endl<<"to continue"<<endl<<(millis()%1000);

      ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino:63:10: note: candidate: Menu::menuOut& operator<<(Menu::menuOut&, endlObj)

 menuOut& operator<<(menuOut& o,endlObj) {

          ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino:63:10: note:   no known conversion for argument 2 from 'const char [13]' to 'endlObj'

In file included from C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/menuBase.h:31:0,

                 from C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/menuDefs.h:12,

                 from C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/menu.h:15,

                 from C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino:34:

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: At global scope:

WebMenu:220:19: error: 'serverOut' was not declared in this scope

 MENU_OUTLIST(out,&serverOut);

                   ^

C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/macros.h:71:53: note: in definition of macro 'MENU_OUTLIST'

   Menu::menuOut* constMEM _outputs_##id[] MEMMODE ={__VA_ARGS__};\

                                                     ^

WebMenu:226:26: error: 'serverOut' was not declared in this scope

 menuOut* web_outputs[]={&serverOut};

                          ^

WebMenu:232:27: error: 'jsonOut' was not declared in this scope

 menuOut* json_outputs[]={&jsonOut};

                           ^

WebMenu:238:25: error: 'wsOut' was not declared in this scope

 menuOut* ws_outputs[]={&wsOut};

                         ^

WebMenu:245:34: error: 'WStype_t' has not been declared

 void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {

                                  ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'void webSocketEvent(uint8_t, int, uint8_t*, size_t)':

WebMenu:247:10: error: 'WStype_DISCONNECTED' was not declared in this scope

     case WStype_DISCONNECTED:

          ^

WebMenu:250:10: error: 'WStype_CONNECTED' was not declared in this scope

     case WStype_CONNECTED: {

          ^

WebMenu:251:24: error: 'webSocket' was not declared in this scope

         IPAddress ip = webSocket.remoteIP(num);

                        ^

WebMenu:256:10: error: 'WStype_TEXT' was not declared in this scope

     case WStype_TEXT: {

          ^

WebMenu:262:9: error: 'wsOut' was not declared in this scope

         wsOut.response.remove(0);

         ^

WebMenu:264:15: error: 'class Menu::navRoot' has no member named 'async'

         wsNav.async((const char*)payload);

               ^

WebMenu:268:9: error: 'webSocket' was not declared in this scope

         webSocket.sendTXT(num,wsOut.response);

         ^

WebMenu:272:10: error: 'WStype_BIN' was not declared in this scope

     case WStype_BIN: {

          ^

WebMenu:289:26: error: no matching function for call to 'Menu::navRoot::doInput(const char*&)'

           nav.doInput(inp);

                          ^

In file included from C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/menuIo.h:178:0,

                 from C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/menuDefs.h:62,

                 from C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/menu.h:15,

                 from C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino:34:

C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/nav.h:121:14: note: candidate: void Menu::navRoot::doInput(Menu::menuIn&)

         void doInput(menuIn& in);

              ^

C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/nav.h:121:14: note:   no known conversion for argument 1 from 'const char*' to 'Menu::menuIn&'

C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/nav.h:128:21: note: candidate: void Menu::navRoot::doInput()

         inline void doInput() {doInput(in);}

                     ^

C:\Users\leo_l\Documents\Arduino\libraries\ArduinoMenu_library\src/nav.h:128:21: note:   candidate expects 0 arguments, 1 provided

WebMenu:290:11: error: 'webSocket' was not declared in this scope

           webSocket.sendTXT(num, "binBusy=false;");//send javascript to unlock the state

           ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'void pageStart()':

WebMenu:301:3: error: 'serverOut' was not declared in this scope

   serverOut<<"HTTP/1.1 200 OK\r\n"

   ^

WebMenu:317:7: error: 'server' was not declared in this scope

   if (server.hasHeader("host"))

       ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'void pageEnd()':

WebMenu:325:3: error: 'serverOut' was not declared in this scope

   serverOut<<"</menuLib>";

   ^

WebMenu:326:3: error: 'server' was not declared in this scope

   server.client().stop();

   ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'void jsonStart()':

WebMenu:331:3: error: 'serverOut' was not declared in this scope

   serverOut<<"HTTP/1.1 200 OK\r\n"

   ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'void jsonEnd()':

WebMenu:339:3: error: 'server' was not declared in this scope

   server.client().stop();

   ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'bool handleMenu(Menu::navRoot&)':

WebMenu:350:13: error: 'server' was not declared in this scope

   String at=server.arg("at");

             ^

WebMenu:352:9: error: 'class Menu::navRoot' has no member named 'async'

   r=nav.async(server.hasArg("at")?at.c_str():"/");

         ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In lambda function:

WebMenu:360:3: error: 'server' was not declared in this scope

   server.sendHeader("Location", CUR_VERSION "/index.html", true);

   ^

WebMenu:363:9: error: 'class Menu::navRoot' has no member named 'async'

     nav.async(server.arg("at").c_str());

         ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'void setup()':

WebMenu:428:3: error: 'webSocket' was not declared in this scope

   webSocket.begin();

   ^

WebMenu:439:3: error: 'server' was not declared in this scope

   server.on("/",HTTP_GET,mainPage);

   ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In lambda function:

WebMenu:444:5: error: 'serverOut' was not declared in this scope

     serverOut<<"<output state=\""<<((int)&webNav.idleTask)<<"\"><![CDATA[";

     ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In lambda function:

WebMenu:456:5: error: 'serverOut' was not declared in this scope

     serverOut<<"{\"output\":\"";

     ^

C:\Users\leo_l\AppData\Local\Temp\arduino_modified_sketch_426345\WebMenu.ino: In function 'void loop()':

WebMenu:475:3: error: 'wsOut' was not declared in this scope

   wsOut.response.remove(0);//clear websocket json buffer

   ^

WebMenu:476:3: error: 'webSocket' was not declared in this scope

   webSocket.loop();

   ^

WebMenu:477:3: error: 'server' was not declared in this scope

   server.handleClient();

   ^

Foram encontradas múltiplas bibliotecas para "WiFi.h"
Usado: C:\Users\leo_l\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
Não usado: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
'WStype_t' has not been declared

Este relatório teria mais informações com
"Mostrar a saida detalhada durante a compilação"
opção pode ser ativada em "Arquivo -> Preferências"

PS: I realized that you are Portuguese, can we communicate in Portuguese? My english is terrible

neu-rah commented 4 years ago

Thanks for the feedback. I gave a quick try with the original esp8266 example.. and there is a lot to change it seems, however wifimanager "ESP8266 WiFi Connection manager..." is also an esp8266 thing, so we first have to make menu work as is before going there

LeandroLimaPRO commented 4 years ago

Thanks for the quick return. The WifiManager lib being used is specific to ESP32. It is only replacing the manual entry of wifi "begin" data. I saw no interference in it. I look forward to returning to ESP32

Koxx3 commented 3 years ago

+1000 ;)

nagarjunredla commented 2 years ago

PR with ESP32 support (and updated example) #374