ESP32 coding error

OP
OP
Broady2067

Broady2067

Active Member
View Badges
Joined
Jun 21, 2023
Messages
157
Reaction score
90
Location
Sheffield. UK
Rating - 0%
0   0   0
Weird, it compiles perfectly on my system. What version of the IDE are you running? It gives you the version number in the title bar.

In the meantime try this:

Create a brand new sketch name it what you want and copy & paste the below in.

#include <ESPAsyncWebServer.h>
#include <TokenIterator.h>
#include <UrlTokenBindings.h>

void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}

UrlTokenBindings parseURL(AsyncWebServerRequest *request, char templatePath[]) {
char urlBuffer[30];
request->url().toCharArray(urlBuffer, 30);
int urlLength = request->url().length();
auto templateIterator = std::make_shared<TokenIterator>(templatePath, strlen(templatePath), '/');
auto pathIterator = std::make_shared<TokenIterator>(urlBuffer, urlLength, '/');
UrlTokenBindings bindings(templateIterator, pathIterator);
return bindings;
}

See whether that compiles for you
2.3.2
 
OP
OP
Broady2067

Broady2067

Active Member
View Badges
Joined
Jun 21, 2023
Messages
157
Reaction score
90
Location
Sheffield. UK
Rating - 0%
0   0   0
Weird, it compiles perfectly on my system. What version of the IDE are you running? It gives you the version number in the title bar.

In the meantime try this:

Create a brand new sketch name it what you want and copy & paste the below in.

#include <ESPAsyncWebServer.h>
#include <TokenIterator.h>
#include <UrlTokenBindings.h>

void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}

UrlTokenBindings parseURL(AsyncWebServerRequest *request, char templatePath[]) {
char urlBuffer[30];
request->url().toCharArray(urlBuffer, 30);
int urlLength = request->url().length();
auto templateIterator = std::make_shared<TokenIterator>(templatePath, strlen(templatePath), '/');
auto pathIterator = std::make_shared<TokenIterator>(urlBuffer, urlLength, '/');
UrlTokenBindings bindings(templateIterator, pathIterator);
return bindings;
}

See whether that compiles for you
Compilation error: exit status 1
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
Let's take this step by step.

Go to File->Examples and Find PathVariableHandlers from that select Simple which will create a new sketch. If you can't find PathVariableHandlers then the library is not installed. In that case repeat the instructions I gave for downloading and installing the library. If it still doesn't show up in examples let me know.

In the sketch created in the last step go to the board selection dialog (the box next to the compile, upload, debug buttons) select Arduino and then attempt to compile. If it doesn't compile successfully let me know the error message.

If that worked go to the sketch created yesterday with just the code snippet I posted in. In the board selection dialog select ESP32 Dev Module and attempt to compile. If it doesn't compile successfully let me know the error message.

If that worked go to your sketch that we've been working on and ensure you have the right board for your target board selected in the dialog box (If you don't know what your target is other than an ESP32 then ESP32 Dev Module is a good choice. As before if it doesn't compile successfully let me know the error message.
 
OP
OP
Broady2067

Broady2067

Active Member
View Badges
Joined
Jun 21, 2023
Messages
157
Reaction score
90
Location
Sheffield. UK
Rating - 0%
0   0   0
Let's take this step by step.

Go to File->Examples and Find PathVariableHandlers from that select Simple which will create a new sketch. If you can't find PathVariableHandlers then the library is not installed. In that case repeat the instructions I gave for downloading and installing the library. If it still doesn't show up in examples let me know.

In the sketch created in the last step go to the board selection dialog (the box next to the compile, upload, debug buttons) select Arduino and then attempt to compile. If it doesn't compile successfully let me know the error message.

If that worked go to the sketch created yesterday with just the code snippet I posted in. In the board selection dialog select ESP32 Dev Module and attempt to compile. If it doesn't compile successfully let me know the error message.

If that worked go to your sketch that we've been working on and ensure you have the right board for your target board selected in the dialog box (If you don't know what your target is other than an ESP32 then ESP32 Dev Module is a good choice. As before if it doesn't compile successfully let me know the error message.
I had to select Arduino nano ESP32 and that ran fine.
Second part after i selected ESP32 Dev Module came up with an error.
Compilation error: exit status 1
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
So the example sketch compiled fine with Arduino nano ESP32, this is good it means that the library is working. It's also interesting because that fails on my system. Can you go to Preferences and copy the contents of the additional boards manager URLs and post it. I can then compare against where my board definitions are coming from.
 
OP
OP
Broady2067

Broady2067

Active Member
View Badges
Joined
Jun 21, 2023
Messages
157
Reaction score
90
Location
Sheffield. UK
Rating - 0%
0   0   0
So the example sketch compiled fine with Arduino nano ESP32, this is good it means that the library is working. It's also interesting because that fails on my system. Can you go to Preferences and copy the contents of the additional boards manager URLs and post it. I can then compare against where my board definitions are coming from.
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
Sorry for taking a while to respond, had a busy weekend. I've added the board definitions to a clean install of the Arduino IDE, downloaded the required libraries and the code compiles fine for the Arduino nano ESP32 so I'm not sure where your error is coming from. The only thing I did notice was that I went to the Reef-pi / esp-32 github page and had a look at the code there and it's incorrect and will not compile. It has:

TokenIterator templateIterator(templatePath, strlen(templatePath), '/');
TokenIterator pathIterator(urlBuffer, urlLength, '/');


Whereas the code should be:

auto templateIterator = std::make_shared<TokenIterator>(templatePath, strlen(templatePath), '/');
auto pathIterator = std::make_shared<TokenIterator>(urlBuffer, urlLength, '/');


But the code you shared earlier is correct so I'm not sure where you got the correction from but it's right.

The only thing I can suggest is start with a clean install of the IDE, download the required libraries and try again.
 
OP
OP
Broady2067

Broady2067

Active Member
View Badges
Joined
Jun 21, 2023
Messages
157
Reaction score
90
Location
Sheffield. UK
Rating - 0%
0   0   0
Sorry for taking a while to respond, had a busy weekend. I've added the board definitions to a clean install of the Arduino IDE, downloaded the required libraries and the code compiles fine for the Arduino nano ESP32 so I'm not sure where your error is coming from. The only thing I did notice was that I went to the Reef-pi / esp-32 github page and had a look at the code there and it's incorrect and will not compile. It has:

TokenIterator templateIterator(templatePath, strlen(templatePath), '/');
TokenIterator pathIterator(urlBuffer, urlLength, '/');

Whereas the code should be:

auto templateIterator = std::make_shared<TokenIterator>(templatePath, strlen(templatePath), '/');
auto pathIterator = std::make_shared<TokenIterator>(urlBuffer, urlLength, '/');


But the code you shared earlier is correct so I'm not sure where you got the correction from but it's right.

The only thing I can suggest is start with a clean install of the IDE, download the required libraries and try again.
Thanks Robin. i have done fresh install and just adding the relevant libraries.
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
dang.. What is the error message you are getting and which Path Variable Handler library did you install? The one I found?
 
Back
Top