ESP32 coding error

Broady2067

Active Member
View Badges
Joined
Jun 21, 2023
Messages
157
Reaction score
90
Location
Sheffield. UK
Rating - 0%
0   0   0
First of all i would like to thanks all persons that have helped with my project so far @Ranjib @Sral.
I have been working on a project for some time and still have not solved the coding issues for a ESP32 PH module. I have the same error message over and over.
"Compilation error: 'ledcSetup' was not declared in this scope; did you mean 'ledc_stop'?"
As far as i can see all the libraries are installed in Arduino IDE except two which are TokenIterator and UrlTokenBindings libraries. Here is an example of the code.

#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <driver/ledc.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TokenIterator.h> // Custom library
#include <UrlTokenBindings.h> // Custom library

#define OUTLET_COUNT 6
#define INLET_COUNT 4
#define JACK_COUNT 4
#define ANALOG_INPUT_COUNT 2
#define PWM_FREQ 5000
#define PWM_RESOLUTION 8

const char *ssid = "SET_SSID";
const char *password = "SET_PASSWORD";

const int outletPins[OUTLET_COUNT] = { 5, 16, 17, 18, 19, 23 };
const int inletPins[INLET_COUNT] = { 1, 3, 14, 36 };
const int jackPins[JACK_COUNT] = { 12, 13, 14, 27 };
const int pwmChannels[JACK_COUNT] = { 0, 1, 2, 3 };
const int analogInputPins[ANALOG_INPUT_COUNT] = { 32, 33 };
const int oneWirePin = 4;

OneWire oneWire(oneWirePin);
DallasTemperature ds18b20(&oneWire);
AsyncWebServer server(80);

void setup() {
Serial.begin(115200);
for (int i = 0; i < OUTLET_COUNT; i++) {
pinMode(outletPins, OUTPUT);
}

for (int i = 0; i < INLET_COUNT; i++) {
pinMode(inletPins, INPUT);
}

for (int i = 0; i < JACK_COUNT; i++) {
ledcSetup(pwmChannels, PWM_FREQ, PWM_RESOLUTION);
ledcAttachPin(jackPins, pwmChannels);
}

for (int i = 0; i < ANALOG_INPUT_COUNT; i++) {
pinMode(analogInputPins, INPUT);
}
ds18b20.begin();

WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println(WiFi.localIP());
server.on("/outlets/*", HTTP_POST, switchOutlet);
server.on("/inlets/*", HTTP_GET, readInlet);
server.on("/jacks/*", HTTP_POST, setJackValue);
server.on("/analog_inputs/*", HTTP_GET, readAnalogInput);

server.begin();
}

void loop() {
}

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;
}

void switchOutlet(AsyncWebServerRequest *request) {
char path[] = "/outlets/:id/:action";
UrlTokenBindings bindings = parseURL(request, path);

int id = String(bindings.get("id")).toInt();
if (id < 0 || id >= OUTLET_COUNT) {
request->send(409, "text/plain", "invalid outlet pin id");
return;
}
String action = String(bindings.get("action"));
Serial.println("Outlet Pin:" + String(outletPins[id]) + ", Action:" + action);
if (action.equals("on")) {
digitalWrite(outletPins[id], HIGH);
request->send(200, "text/plain", "high");
} else if (action.equals("off")) {
digitalWrite(outletPins[id], LOW);
request->send(200, "text/plain", "low");
} else {
request->send(409, "text/plain", "unrecognized action");
}
}

void readInlet(AsyncWebServerRequest *request) {
char path[] = "/inlets/:id";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();
if (id < 0 || id >= INLET_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
int v = digitalRead(inletPins[id]);
Serial.println("Inlet pin:" + String(inletPins[id]) + " Value:" + String(v));
request->send(200, "text/plain", String(v));
}

void readAnalogInput(AsyncWebServerRequest *request) {
char path[] = "/analog_inputs/:id";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();

if (id < 0 || id >= ANALOG_INPUT_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
float value;
if (id == 0) {
ds18b20.requestTemperatures();
value = ds18b20.getTempCByIndex(0);
} else {
value = analogRead(analogInputPins[id]);
}
Serial.println("Analog Input pin:" + String(analogInputPins[id]) + " Value:" + String(value));
request->send(200, "text/plain", String(value));
}

void setJackValue(AsyncWebServerRequest *request) {
char path[] = "/jacks/:id/:value";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();
int dc = String(bindings.get("value")).toInt();
if (id < 0 || id >= JACK_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
if (dc > 255) {
dc = 255;
}
if (dc < 0) {
dc = 0;
}
Serial.println("PWM Pin" + String(jackPins[id]) + " DutyCycle:" + String(dc));
ledcWrite(pwmChannels[id], dc);
request->send(200, "text/plain", String(dc));
}

Any help will be much appreciated.
 
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
pro-mbTcpg8L.jpeg
pro-uNYwy17S.jpeg
 

Frank_Aaron

Community Member
View Badges
Joined
Oct 3, 2018
Messages
61
Reaction score
56
Location
St Louis MO
Rating - 0%
0   0   0
The error message Compilation error: 'ledcSetup' was not declared in this scope; did you mean 'ledc_stop'?' indicates that the function ledcSetup is not being recognized by the compiler. This could be due to several reasons, such as missing or incorrect library includes or issues with the Arduino IDE setup.

Here are a few steps to troubleshoot and fix this issue:

1. Ensure Proper Library Installation: Make sure you have installed the necessary libraries correctly. The ledcSetup function is part of the driver/ledc.h library, which should be included with the ESP32 Arduino core.


2. Check the ESP32 Board Setup: Ensure that you have the ESP32 board selected in the Arduino IDE. Go to Tools > Board and select an ESP32 board.


3. Update the ESP32 Core: Sometimes, updating the ESP32 core can resolve these kinds of issues. You can do this through the Board Manager in the Arduino IDE.

Make sure that you have the latest ESP32 libraries and board definitions installed. If the issue persists, try reinstalling the ESP32 board definitions from the Arduino IDE Board Manager.



#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <driver/ledc.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TokenIterator.h>
#include <UrlTokenBindings.h>

#define OUTLET_COUNT 6
#define INLET_COUNT 4
#define JACK_COUNT 4
#define ANALOG_INPUT_COUNT 2
#define PWM_FREQ 5000
#define PWM_RESOLUTION 8

const char *ssid = "SET_SSID";
const char *password = "SET_PASSWORD";

const int outletPins[OUTLET_COUNT] = { 5, 16, 17, 18, 19, 23 };
const int inletPins[INLET_COUNT] = { 1, 3, 14, 36 };
const int jackPins[JACK_COUNT] = { 12, 13, 14, 27 };
const int pwmChannels[JACK_COUNT] = { 0, 1, 2, 3 };
const int analogInputPins[ANALOG_INPUT_COUNT] = { 32, 33 };
const int oneWirePin = 4;

OneWire oneWire(oneWirePin);
DallasTemperature ds18b20(&oneWire);
AsyncWebServer server(80);

void setup() {
Serial.begin(115200);

for (int i = 0; i < OUTLET_COUNT; i++) {
pinMode(outletPins, OUTPUT);
}

for (int i = 0; i < INLET_COUNT; i++) {
pinMode(inletPins, INPUT);
}

for (int i = 0; i < JACK_COUNT; i++) {
ledcSetup(pwmChannels, PWM_FREQ, PWM_RESOLUTION);
ledcAttachPin(jackPins, pwmChannels);
}

for (int i = 0; i < ANALOG_INPUT_COUNT; i++) {
pinMode(analogInputPins, INPUT);
}

ds18b20.begin();

WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println(WiFi.localIP());

server.on("/outlets/*", HTTP_POST, switchOutlet);
server.on("/inlets/*", HTTP_GET, readInlet);
server.on("/jacks/*", HTTP_POST, setJackValue);
server.on("/analog_inputs/*", HTTP_GET, readAnalogInput);
server.begin();
}

void loop() {
}

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;
}

void switchOutlet(AsyncWebServerRequest *request) {
char path[] = "/outlets/:id/:action";
UrlTokenBindings bindings = parseURL(request, path);

int id = String(bindings.get("id")).toInt();
if (id < 0 || id >= OUTLET_COUNT) {
request->send(409, "text/plain", "invalid outlet pin id");
return;
}
String action = String(bindings.get("action"));
Serial.println("Outlet Pin:" + String(outletPins[id]) + ", Action:" + action);
if (action.equals("on")) {
digitalWrite(outletPins[id], HIGH);
request->send(200, "text/plain", "high");
} else if (action.equals("off")) {
digitalWrite(outletPins[id], LOW);
request->send(200, "text/plain", "low");
} else {
request->send(409, "text/plain", "unrecognized action");
}
}

void readInlet(AsyncWebServerRequest *request) {
char path[] = "/inlets/:id";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();
if (id < 0 || id >= INLET_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
int v = digitalRead(inletPins[id]);
Serial.println("Inlet pin:" + String(inletPins[id]) + " Value:" + String(v));
request->send(200, "text/plain", String(v));
}

void readAnalogInput(AsyncWebServerRequest *request) {
char path[] = "/analog_inputs/:id";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();

if (id < 0 || id >= ANALOG_INPUT_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
float value;
if (id == 0) {
ds18b20.requestTemperatures();
value = ds18b20.getTempCByIndex(0);
} else {
value = analogRead(analogInputPins[id]);
}
Serial.println("Analog Input pin:" + String(analogInputPins[id]) + " Value:" + String(value));
request->send(200, "text/plain", String(value));
}

void setJackValue(AsyncWebServerRequest *request) {
char path[] = "/jacks/:id/:value";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();
int dc = String(bindings.get("value")).toInt();
if (id < 0 || id >= JACK_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
if (dc > 255) {
dc = 255;
}
if (dc < 0) {
dc = 0;
}
Serial.println("PWM Pin" + String(jackPins[id]) + " DutyCycle:" + String(dc));
ledcWrite(pwmChannels[id], dc);
request->send(200, "text/plain", String(dc));
}
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
As Part of a version upgrade to Arduino version 3.0.0 ledcSetup and ledcAttachPin were merged into ledcAttach with the originals no longer working. You could try bool ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution); and see if that resolves your issue
 
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
As Part of a version upgrade to Arduino version 3.0.0 ledcSetup and ledcAttachPin were merged into ledcAttach with the originals no longer working. You could try bool ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution); and see if that resolves your issue
Thanks for the info. How do i upload this, in preferences then additional board preferences?
 
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
The error message Compilation error: 'ledcSetup' was not declared in this scope; did you mean 'ledc_stop'?' indicates that the function ledcSetup is not being recognized by the compiler. This could be due to several reasons, such as missing or incorrect library includes or issues with the Arduino IDE setup.

Here are a few steps to troubleshoot and fix this issue:

1. Ensure Proper Library Installation: Make sure you have installed the necessary libraries correctly. The ledcSetup function is part of the driver/ledc.h library, which should be included with the ESP32 Arduino core.


2. Check the ESP32 Board Setup: Ensure that you have the ESP32 board selected in the Arduino IDE. Go to Tools > Board and select an ESP32 board.


3. Update the ESP32 Core: Sometimes, updating the ESP32 core can resolve these kinds of issues. You can do this through the Board Manager in the Arduino IDE.

Make sure that you have the latest ESP32 libraries and board definitions installed. If the issue persists, try reinstalling the ESP32 board definitions from the Arduino IDE Board Manager.



#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <driver/ledc.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TokenIterator.h>
#include <UrlTokenBindings.h>

#define OUTLET_COUNT 6
#define INLET_COUNT 4
#define JACK_COUNT 4
#define ANALOG_INPUT_COUNT 2
#define PWM_FREQ 5000
#define PWM_RESOLUTION 8

const char *ssid = "SET_SSID";
const char *password = "SET_PASSWORD";

const int outletPins[OUTLET_COUNT] = { 5, 16, 17, 18, 19, 23 };
const int inletPins[INLET_COUNT] = { 1, 3, 14, 36 };
const int jackPins[JACK_COUNT] = { 12, 13, 14, 27 };
const int pwmChannels[JACK_COUNT] = { 0, 1, 2, 3 };
const int analogInputPins[ANALOG_INPUT_COUNT] = { 32, 33 };
const int oneWirePin = 4;

OneWire oneWire(oneWirePin);
DallasTemperature ds18b20(&oneWire);
AsyncWebServer server(80);

void setup() {
Serial.begin(115200);

for (int i = 0; i < OUTLET_COUNT; i++) {
pinMode(outletPins, OUTPUT);
}

for (int i = 0; i < INLET_COUNT; i++) {
pinMode(inletPins, INPUT);
}

for (int i = 0; i < JACK_COUNT; i++) {
ledcSetup(pwmChannels, PWM_FREQ, PWM_RESOLUTION);
ledcAttachPin(jackPins, pwmChannels);
}

for (int i = 0; i < ANALOG_INPUT_COUNT; i++) {
pinMode(analogInputPins, INPUT);
}

ds18b20.begin();

WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println(WiFi.localIP());

server.on("/outlets/*", HTTP_POST, switchOutlet);
server.on("/inlets/*", HTTP_GET, readInlet);
server.on("/jacks/*", HTTP_POST, setJackValue);
server.on("/analog_inputs/*", HTTP_GET, readAnalogInput);
server.begin();
}

void loop() {
}

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;
}

void switchOutlet(AsyncWebServerRequest *request) {
char path[] = "/outlets/:id/:action";
UrlTokenBindings bindings = parseURL(request, path);

int id = String(bindings.get("id")).toInt();
if (id < 0 || id >= OUTLET_COUNT) {
request->send(409, "text/plain", "invalid outlet pin id");
return;
}
String action = String(bindings.get("action"));
Serial.println("Outlet Pin:" + String(outletPins[id]) + ", Action:" + action);
if (action.equals("on")) {
digitalWrite(outletPins[id], HIGH);
request->send(200, "text/plain", "high");
} else if (action.equals("off")) {
digitalWrite(outletPins[id], LOW);
request->send(200, "text/plain", "low");
} else {
request->send(409, "text/plain", "unrecognized action");
}
}

void readInlet(AsyncWebServerRequest *request) {
char path[] = "/inlets/:id";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();
if (id < 0 || id >= INLET_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
int v = digitalRead(inletPins[id]);
Serial.println("Inlet pin:" + String(inletPins[id]) + " Value:" + String(v));
request->send(200, "text/plain", String(v));
}

void readAnalogInput(AsyncWebServerRequest *request) {
char path[] = "/analog_inputs/:id";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();

if (id < 0 || id >= ANALOG_INPUT_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
float value;
if (id == 0) {
ds18b20.requestTemperatures();
value = ds18b20.getTempCByIndex(0);
} else {
value = analogRead(analogInputPins[id]);
}
Serial.println("Analog Input pin:" + String(analogInputPins[id]) + " Value:" + String(value));
request->send(200, "text/plain", String(value));
}

void setJackValue(AsyncWebServerRequest *request) {
char path[] = "/jacks/:id/:value";
UrlTokenBindings bindings = parseURL(request, path);
int id = String(bindings.get("id")).toInt();
int dc = String(bindings.get("value")).toInt();
if (id < 0 || id >= JACK_COUNT) {
request->send(409, "text/plain", "invalid inlet pin id");
return;
}
if (dc > 255) {
dc = 255;
}
if (dc < 0) {
dc = 0;
}
Serial.println("PWM Pin" + String(jackPins[id]) + " DutyCycle:" + String(dc));
ledcWrite(pwmChannels[id], dc);
request->send(200, "text/plain", String(dc));
}
Thanks Frank ,i am in the process of trying to implement your suggestions.
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
Thanks for the info. How do i upload this, in preferences then additional board preferences?
Instead of:

for (int i = 0; i < JACK_COUNT; i++) {
ledcSetup(pwmChannels, PWM_FREQ, PWM_RESOLUTION);
ledcAttachPin(jackPins, pwmChannels);
}

try:

for (int i = 0; i < JACK_COUNT; i++) {
ledcAttach(jackPins, PWM_FREQ, PWM_RESOLUTION, pwmChannels);
}


Hope that works.


edit: html formatting is screwing with the code sample there should be jackPins{square braket}i{square bracket} and the same for pwm Channels.
 
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
Instead of:

for (int i = 0; i < JACK_COUNT; i++) {
ledcSetup(pwmChannels, PWM_FREQ, PWM_RESOLUTION);
ledcAttachPin(jackPins, pwmChannels);
}

try:

for (int i = 0; i < JACK_COUNT; i++) {
ledcAttach(jackPins, PWM_FREQ, PWM_RESOLUTION, pwmChannels);
}


Hope that works.


edit: html formatting is screwing with the code sample there should be jackPins{square braket}i{square bracket} and the same for pwm Channels.
Hi Robin,
just tried this and got this error.
Compilation error: invalid conversion from 'const int*' to 'uint8_t' {aka 'unsigned char'} [-fpermissive]
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
Ints are 2 bytes uint8_t is one. You can either change the declaration of the jackPins like this:

const uint8_t jackPins[JACK_COUNT] = { 12, 13, 14, 27 };

or typecast on the call.

ledcAttach(uint8_t(jackPins), PWM_FREQ, PWM_RESOLUTION, pwmChannels);

(don't forget the square brackets which I can't type here)

edit: Whoops don't think you need the channels i.e

ledcAttach(uint8_t(jackPins), PWM_FREQ, PWM_RESOLUTION);
 
Last edited:
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
Ints are 2 bytes uint8_t is one. You can either change the declaration of the jackPins like this:

const uint8_t jackPins[JACK_COUNT] = { 12, 13, 14, 27 };

or typecast on the call.

ledcAttach(uint8_t(jackPins), PWM_FREQ, PWM_RESOLUTION, pwmChannels);

(don't forget the square brackets which I can't type here)

edit: Whoops don't think you need the channels i.e

ledcAttach(uint8_t(jackPins), PWM_FREQ, PWM_RESOLUTION);
Which code am i using and where do the square brackets go?
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
It's cleaner if you change your declaration of jackPins.

const uint8_t jackPins[JACK_COUNT] = { 12, 13, 14, 27 };

then

for (int i = 0; i < JACK_COUNT; i++) {
ledcAttach(jackPins[*], PWM_FREQ, PWM_RESOLUTION);
}


but replace the asterisk with i
hopefully that should compile.
 
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
It's cleaner if you change your declaration of jackPins.

const uint8_t jackPins[JACK_COUNT] = { 12, 13, 14, 27 };

then

for (int i = 0; i < JACK_COUNT; i++) {
ledcAttach(jackPins[*], PWM_FREQ, PWM_RESOLUTION);
}


but replace the asterisk with i
hopefully that should compile.
is this instead of this
for (int i = 0; i < INLET_COUNT; i++) {
pinMode(inletPins, INPUT);
}
for (int i = 0; i < JACK_COUNT; i++) {
ledcAttach(jackPins, PWM_FREQ, PWM_RESOLUTION, pwmChannels);
}
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
is this instead of this
for (int i = 0; i < INLET_COUNT; i++) {
pinMode(inletPins, INPUT);
}
for (int i = 0; i < JACK_COUNT; i++) {
ledcAttach(jackPins, PWM_FREQ, PWM_RESOLUTION, pwmChannels);
}

No, that section is telling the ESP32 that your inlet pins are input.

Replace

for (int i = 0; i < JACK_COUNT; i++) {
ledcSetup(pwmChannels, PWM_FREQ, PWM_RESOLUTION);
ledcAttachPin(jackPins, pwmChannels);
}

with
for (int i = 0; i < JACK_COUNT; i++) {
ledcAttach(jackPins[*], PWM_FREQ, PWM_RESOLUTION);
}


but replace the asterisk in the above text with i

also replace

const int jackPins[JACK_COUNT] = { 12, 13, 14, 27 };
with

const uint8_t jackPins[JACK_COUNT] = { 12, 13, 14, 27 };
 
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
No, that section is telling the ESP32 that your inlet pins are input.

Replace

for (int i = 0; i < JACK_COUNT; i++) {
ledcSetup(pwmChannels, PWM_FREQ, PWM_RESOLUTION);
ledcAttachPin(jackPins, pwmChannels);
}

with
for (int i = 0; i < JACK_COUNT; i++) {
ledcAttach(jackPins[*], PWM_FREQ, PWM_RESOLUTION);
}


but replace the asterisk in the above text with i

also replace

const int jackPins[JACK_COUNT] = { 12, 13, 14, 27 };
with

const uint8_t jackPins[JACK_COUNT] = { 12, 13, 14, 27 };
new error
Compilation error: no matching function for call to 'UrlTokenBindings::UrlTokenBindings(TokenIterator&, TokenIterator&)'
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
That's a completely different issue so at least we're past the first problem :). It seems to be complaining about the constructor for UrlTokenBindings which would be these lines

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


I can't see anything wrong with code here so I we need to check that both the header files and libraries for TokenIterator and URLTokenBindings are correctly installed. Unfortunately as I have no access to your system I can't really guide you with that

EDIT: Thinking about it if you post a link to where you got this code from I'll have a look, download and try to burn it onto an ESP32, I have a couple lying around. At least I can try and reproduce your error.
 
Last edited:
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
That's a completely different issue so at least we're past the first problem :). It seems to be complaining about the constructor for UrlTokenBindings which would be these lines

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


I can't see anything wrong with code here so I we need to check that both the header files and libraries for TokenIterator and URLTokenBindings are correctly installed. Unfortunately as I have no access to your system I can't really guide you with that

EDIT: Thinking about it if you post a link to where you got this code from I'll have a look, download and try to burn it onto an ESP32, I have a couple lying around. At least I can try and reproduce your error.
I have tried to find the libraries and every time I try to install them I get errors.
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
Rating - 0%
0   0   0
Ahhh gotcha. Okay I've had a noodle around and the library you want is this one: https://github.com/sidoh/path_variable_handlers/releases/tag/v3.0.0

Download the Source code (zip) and just for compatibility rename the downloaded file to pathvariablehandlers.zip (some versions of the IDE don't like underscores and I don't know what version you have)

In the IDE go to the menu sketch->include library->Add .Zip library and install the library. If you get any errors let me know and let me know what version of the IDE you are running.

I have compiled the code snippet that was causing problems with this library and it compiles without 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
Ahhh gotcha. Okay I've had a noodle around and the library you want is this one: https://github.com/sidoh/path_variable_handlers/releases/tag/v3.0.0

Download the Source code (zip) and just for compatibility rename the downloaded file to pathvariablehandlers.zip (some versions of the IDE don't like underscores and I don't know what version you have)

In the IDE go to the menu sketch->include library->Add .Zip library and install the library. If you get any errors let me know and let me know what version of the IDE you are running.

I have compiled the code snippet that was causing problems with this library and it compiles without error.
Same error again.:loudly-crying-face: In an act of desperation i have removed all libraries and re-installed just the ones recommended in case i was getting conflicts somewhere.
Compilation error: no matching function for call to 'UrlTokenBindings::UrlTokenBindings(TokenIterator&, TokenIterator&)'
 

robinm

Active Member
View Badges
Joined
Feb 21, 2021
Messages
101
Reaction score
69
Location
Louth
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
 
Back
Top