ItKindaWorks / ESPHelper

A library to make using WiFi & MQTT on the ESP8266 easy.
GNU General Public License v3.0
327 stars 67 forks source link

Installation Instructions for PlatformIO #38

Closed mansdahlstrom1 closed 8 months ago

mansdahlstrom1 commented 4 years ago

Would be really nice if there was installation instructions for PlatformIO. I've setup a project for the Adafruit Feather Huzzah32 to play around with and was able to find most dependencies for ESPHelper. But i cannot get it to work properly.

Note: Also downgraded ArduinoJson to version 6.14.1.

see my paltformio.inifile

[env:featheresp32]
platform = espressif32
board = featheresp32
framework = arduino
monitor_speed = 115200
lib_deps = 
    itkindaworks/ESPHelper@^1.7.4
    knolleary/PubSubClient@^2.8
    bblanchon/ArduinoJson@6.14.1 

I'm not sure i've installed installed metro correctly. What i did was to download the latest version here : https://github.com/thomasfredericks/Metro-Arduino-Wiring/archive/master.zip. And added the folder to lib folder in my project. So once that was done it seemed to be working for me, no errors saying it can't find Metro.h.

Screenshot 2020-10-24 at 16 14 27

But even after this. I'm stuck with the same errors mentioned in this issue https://github.com/ItKindaWorks/ESPHelper/issues/35.

Posting them here too: (All errors seems to be located in the ShardedData.h header file)


compilation terminated.
*** [.pio/build/featheresp32/libdb3/ESPHelper/ESPHelperWebConfig.cpp.o] Error 1
In file included from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.h:44:0,
                 from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.cpp:23:
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
  const char* pass;
              ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error:   'int netInfo::mqttPort' [-Werror=reorder]
  int mqttPort;
      ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:57:2: error:   when initialized here [-Werror=reorder]
  netInfo(const char* _name,
  ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
  int mqttPort;
      ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:42:14: error:   'const char* netInfo::mqttUser' [-Werror=reorder]
  const char* mqttUser;
              ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:57:2: error:   when initialized here [-Werror=reorder]
  netInfo(const char* _name,
  ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
  const char* pass;
              ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error:   'int netInfo::mqttPort' [-Werror=reorder]
  int mqttPort;
      ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:76:3: error:   when initialized here [-Werror=reorder]
   netInfo(const char* _mqttHost,
   ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
  int mqttPort;
      ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:42:14: error:   'const char* netInfo::mqttUser' [-Werror=reorder]
  const char* mqttUser;
              ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:76:3: error:   when initialized here [-Werror=reorder]
   netInfo(const char* _mqttHost,
   ^
In file included from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.h:44:0,
                 from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.h:27,
                 from .pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp:22:
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
  const char* pass;
              ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error:   'int netInfo::mqttPort' [-Werror=reorder]
  int mqttPort;
      ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:57:2: error:   when initialized here [-Werror=reorder]
  netInfo(const char* _name,
  ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
  int mqttPort;
      ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:42:14: error:   'const char* netInfo::mqttUser' [-Werror=reorder]
  const char* mqttUser;
              ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:57:2: error:   when initialized here [-Werror=reorder]
  netInfo(const char* _name,
  ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h: In constructor 'netInfo::netInfo(const char*, const char*, const char*, const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:46:14: error: 'netInfo::pass' will be initialized after [-Werror=reorder]
  const char* pass;
              ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error:   'int netInfo::mqttPort' [-Werror=reorder]
  int mqttPort;
      ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:76:3: error:   when initialized here [-Werror=reorder]
   netInfo(const char* _mqttHost,
   ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:44:6: error: 'netInfo::mqttPort' will be initialized after [-Werror=reorder]
  int mqttPort;
      ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:42:14: error:   'const char* netInfo::mqttUser' [-Werror=reorder]
  const char* mqttUser;
              ^
.pio/libdeps/featheresp32/ESPHelper/src/sharedData.h:76:3: error:   when initialized here [-Werror=reorder]
   netInfo(const char* _mqttHost,
   ^
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.cpp: In member function 'void ESPHelper::setMQTTCallback(std::function<void(char*, unsigned char*, unsigned int)>)':
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelper.cpp:832:16: error: cannot convert 'std::function<void(char*, unsigned char*, unsigned int)>' to 'void (*)(char*, uint8_t*, unsigned int) {aka void (*)(char*, unsigned char*, unsigned int)}' in assignment
  _mqttCallback = callback;
                ^
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp: In member function 'bool ESPHelperFS::addKey(const char*, const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp:329:19: warning: comparison with string literal results in unspecified behaviour [-Waddress]
   if(_filename != ""){
                   ^
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp: In member function 'String ESPHelperFS::loadKey(const char*)':
.pio/libdeps/featheresp32/ESPHelper/src/ESPHelperFS.cpp:397:19: warning: comparison with string literal results in unspecified behaviour [-Waddress]
   if(_filename != ""){
                   ^
cc1plus: some warnings being treated as errors
*** [.pio/build/featheresp32/libdb3/ESPHelper/ESPHelper.cpp.o] Error 1
cc1plus: some warnings being treated as errors
*** [.pio/build/featheresp32/libdb3/ESPHelper/ESPHelperFS.cpp.o] Error 1
jeffeb3 commented 4 years ago

YMMV, but I was just trying to do the same thing.

This is where I ended up:

[platformio]
default_envs = thermespy32
src_dir = src

[env:thermespy32]
platform = espressif32
board = lolin32
framework = arduino
lib_deps =
  ESPHelper
  ArduinoJson
  PubSubClient
  https://github.com/thomasfredericks/Metro-Arduino-Wiring.git
  WebServer

This isn't the example code from here or anything. I may not be using enough of the library to exercise all the includes.

jeffeb3 commented 4 years ago

I ended up getting frustrated with Metro. So I published it to platformio's registry. Here's the lib_deps that is working for me:

lib_deps =
  ESPHelper
  ArduinoJson
  PubSubClient
  Metro-Arduino-Wiring
  WebServer

The next step is to probably put these dependencies into the ESPHelper's library.json, so we (as users) just have to add ESPHelper, and it will figure out all this for us.

ItKindaWorks commented 8 months ago

Many years too late but this has all been sorted. The library now properly compiles with PIO with all dependencies accounted for.