IotWebConf
IotWebConf copied to clipboard
Error compiling for wemos D1 mini
Hi, I am getting this error compiling a sketch for a wemos D1 mini.
What could be the cause of the problem?
This is the code:
IotWebConf iotWebConf(thingName.c_str(), &dnsServer, &server, wifiInitialApPassword, "JamesOGorman");
IotWebConfParameter mqttServerParam = IotWebConfParameter("MQTT server", "mqttServer", mqttServer, sizeof(mqttServer) );
IotWebConfParameter mqttUserNameParam = IotWebConfParameter("MQTT username", "mqttUser", mqttUserName, sizeof(mqttUserName));
IotWebConfParameter mqttUserPasswordParam = IotWebConfParameter("MQTT password", "mqttPass", mqttUserPassword, sizeof(mqttUserPassword), "password");
IotWebConfParameter mqttTopicParam = IotWebConfParameter("MQTT Topic", "mqttTopic", mqttTopicPrefix, sizeof(mqttTopicPrefix));
And this is error:
notifier_wemos:124: error: 'IotWebConfParameter' does not name a type
IotWebConfParameter mqttServerParam = IotWebConfParameter("MQTT server", "mqttServer", mqttServer, sizeof(mqttServer) );
^
notifier_wemos:125: error: 'IotWebConfParameter' does not name a type
IotWebConfParameter mqttUserNameParam = IotWebConfParameter("MQTT username", "mqttUser", mqttUserName, sizeof(mqttUserName));
^
notifier_wemos:126: error: 'IotWebConfParameter' does not name a type
IotWebConfParameter mqttUserPasswordParam = IotWebConfParameter("MQTT password", "mqttPass", mqttUserPassword, sizeof(mqttUserPassword), "password");
^
notifier_wemos:127: error: 'IotWebConfParameter' does not name a type
IotWebConfParameter mqttTopicParam = IotWebConfParameter("MQTT Topic", "mqttTopic", mqttTopicPrefix, sizeof(mqttTopicPrefix));
^
C:\Users\usuario\AppData\Local\Temp\arduino_modified_sketch_306604\notifier_wemos.ino: In function 'void setup()':
notifier_wemos:144: error: 'class iotwebconf::IotWebConf' has no member named 'addParameter'
iotWebConf.addParameter(&mqttServerParam);
^
notifier_wemos:144: error: 'mqttServerParam' was not declared in this scope
iotWebConf.addParameter(&mqttServerParam);
^
notifier_wemos:145: error: 'class iotwebconf::IotWebConf' has no member named 'addParameter'
iotWebConf.addParameter(&mqttUserNameParam);
^
notifier_wemos:145: error: 'mqttUserNameParam' was not declared in this scope
iotWebConf.addParameter(&mqttUserNameParam);
^
notifier_wemos:146: error: 'class iotwebconf::IotWebConf' has no member named 'addParameter'
iotWebConf.addParameter(&mqttUserPasswordParam);
^
notifier_wemos:146: error: 'mqttUserPasswordParam' was not declared in this scope
iotWebConf.addParameter(&mqttUserPasswordParam);
^
notifier_wemos:147: error: 'class iotwebconf::IotWebConf' has no member named 'addParameter'
iotWebConf.addParameter(&mqttTopicParam);
^
notifier_wemos:147: error: 'mqttTopicParam' was not declared in this scope
iotWebConf.addParameter(&mqttTopicParam);
^
notifier_wemos:149: error: no matching function for call to 'iotwebconf::IotWebConf::setFormValidator(boolean (*)())'
iotWebConf.setFormValidator(&formValidator);
^
C:\Users\usuario\AppData\Local\Temp\arduino_modified_sketch_306604\notifier_wemos.ino:149:45: note: candidate is:
In file included from C:\Users\usuario\AppData\Local\Temp\arduino_modified_sketch_306604\notifier_wemos.ino:76:0:
C:\Users\usuario\Documents\Arduino\libraries\IotWebConf-master\src/IotWebConf.h:301:8: note: void iotwebconf::IotWebConf::setFormValidator(std::function<bool(iotwebconf::WebRequestWrapper*)>)
void setFormValidator(std::function<bool(WebRequestWrapper* webRequestWrapper)> func);
^
C:\Users\usuario\Documents\Arduino\libraries\IotWebConf-master\src/IotWebConf.h:301:8: note: no known conversion for argument 1 from 'boolean (*)() {aka bool (*)()}' to 'std::function<bool(iotwebconf::WebRequestWrapper*)>'
C:\Users\usuario\AppData\Local\Temp\arduino_modified_sketch_306604\notifier_wemos.ino: In function 'void wifiConnected()':
notifier_wemos:407: error: 'class PubSubClient' has no member named 'setBufferSize'
mqttClient.setBufferSize(MQTT_MSG_SIZE);
^
C:\Users\usuario\AppData\Local\Temp\arduino_modified_sketch_306604\notifier_wemos.ino: In function 'boolean formValidator()':
notifier_wemos:414: error: 'mqttServerParam' was not declared in this scope
int l = server.arg(mqttServerParam.getId()).length();
You might want to use an older code with a newer IotWebConf version (3.x.x). Now, with 3.0.0 namespaces are introduced. In short the name IotWebConfParameter were renamed to iotwebconf::Parameter.
For older codes (like yours) there is a helper header file #include <IotWebConfUsing.h>
, that creates aliases, so you can still use IotWebConfParameter.
Also check the Namespaces
section of the migration guide:
https://github.com/prampec/IotWebConf/blob/master/doc/MigrationGuide-v3.0.0.md#namespaces
(This issue still valid however, as examples are still using the "old" format via the aliases.