Closed al3xsh closed 3 years ago
Hi @al3xsh , I did not get the "functional" error yet. Maybe you could compile after install the "ArduinoSTL" library .
Hi @hirotakaster,
Thanks for such a rapid reply!
I have tried installing ArduinoSTL from the libraries manager, then installing CoAP simple library, and then compiling the default coapserver example and I still get a message about missing
I have Coap simple library version 1.3.19 installed and ArduinoSTL version 1.1.0 installed.
Any other ideas?
Regards,
Alex
It may not be an essential solution, but try to compile after install c++ to your Linux(apt install c++ or apt install g++).
Hi,
Thanks for the reply - I already have g++ installed (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)).
I realised I wasn't including Arduino STL in the coaptest.ino code, so I've added #include
Arduino: 1.8.13 (Linux), Board: "Arduino Uno"
In file included from /tmp/arduino_modified_sketch_663275/coaptest.ino:8:0:
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:133:14: error: 'function' in namespace 'std' does not name a template type
typedef std::function<void(CoapPacket &, IPAddress, int)> CoapCallback;
^~~~~~~~
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:138:9: error: 'CoapCallback' does not name a type
CoapCallback c[COAP_MAX_CALLBACK];
^~~~~~~~~~~~
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:146:18: error: 'CoapCallback' has not been declared
void add(CoapCallback call, String url) {
^~~~~~~~~~~~
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:160:9: error: 'CoapCallback' does not name a type
CoapCallback find(String url) {
^~~~~~~~~~~~
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h: In constructor 'CoapUri::CoapUri()':
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:143:17: error: 'c' was not declared in this scope
c[i] = NULL;
^
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h: In member function 'void CoapUri::add(int, String)':
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:148:21: error: 'c' was not declared in this scope
if (c[i] != NULL && u[i].equals(url)) {
^
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:153:21: error: 'c' was not declared in this scope
if (c[i] == NULL) {
^
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h: At global scope:
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:170:9: error: 'CoapCallback' does not name a type
CoapCallback resp;
^~~~~~~~~~~~
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:183:23: error: 'CoapCallback' has not been declared
void response(CoapCallback c) { resp = c; }
^~~~~~~~~~~~
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:185:21: error: 'CoapCallback' has not been declared
void server(CoapCallback c, String url) { uri.add(c, url); }
^~~~~~~~~~~~
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h: In member function 'void Coap::response(int)':
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:183:41: error: 'resp' was not declared in this scope
void response(CoapCallback c) { resp = c; }
^~~~
/home/alex/Dropbox/code/teaching/arduino_sketchbook/libraries/CoAP_simple_library/coap-simple.h:183:41: note: suggested alternative: 'frexp'
void response(CoapCallback c) { resp = c; }
^~~~
frexp
exit status 1
Error compiling for board Arduino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Any ideas?
Regards,
Alex
So looking into it a bit more - it seems ArduinoSTL doesn't yet support C++11 std::function.
https://github.com/mike-matera/ArduinoSTL/issues/45
I was wondering - have you had this library working with the Arduino Uno, or is it designed with the ESP8266 / ESP32 in mind?
It looks to me like this pull request:
might be the issue?
Regards,
Alex
Hi @hirotakaster ,
Last one from me :)
That was it - I reverted
typedef std::function<void(CoapPacket &, IPAddress, int)> CoapCallback;
to
typedef void (*CoapCallback)(CoapPacket &, IPAddress, int);
and the example now compiles for me.
I'll test that everything works properly when I get the chance, but it compiles with no errors so - for the moment at least - I'm happy!
Have a good weekend.
Regards,
Alex
p.s. if you're interested, once I've tested it I can send you a pull request with the fix.
Hi @al3xsh , Oh, nice!! yes, this PR is hit to your error. https://github.com/hirotakaster/CoAP-simple-library/pull/18 So I think it's good for callback implementation to don't have to use ArduinoSTL.
Probably just this change.
typedef void (*CoapCallback)(CoapPacket &, IPAddress, int);
If you okay, please send me pull request, I will merge it.
Hi @hirotakaster,
I've made the changes and added them to this pull request:
https://github.com/hirotakaster/CoAP-simple-library/pull/21
I also changed the COAP_BUF_MAX_SIZE
to 128 so it works out of the box with the Arduino Uno - though this might be a bit small for some applications (?).
Regards,
Alex
Hi @al3xsh , Thank you, I checked on Arduino Uno/ESP32 Dev/ESP8266, it works well.
update and release https://github.com/hirotakaster/CoAP-simple-library/tree/1.3.20 You could use this version from Arduino library manager, thank you for your issue&pull request.
Hi,
I'm trying to use your library with the Arduino Uno and I get the error message:
Any ideas?
I feel like I must be missing something really obvious! :+1:
Regards,
Alex