Multi character constant

Hiya. I'm getting this multi character constant error with a vision I guess. I did some searching prior to and couldn't find my issue exactly.

**chatgpt got me to edit the file avision_web.cpp but to no effect

/home/varg/Arduino/libraries/AVision_ESP8266/src/avision_web.cpp: In member function 'String AVision::web::_REQUEST(String)':
/home/varg/Arduino/libraries/AVision_ESP8266/src/avision_web.cpp:26:1: error: control reaches end of non-void function [-Werror=return-type]
   26 | }
      | ^
cc1plus: some warnings being treated as errors
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <AVision_ESP8266.h>
#include <sha256.h>
#include <thinx.h>
#include <THiNXLib.h>
#include <thinx_root_ca.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char* ssid = "";
const char* password = "";
String url = "";

const int buttonPin = D2; // GPIO2
bool buttonState = HIGH;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  Serial.begin(115200);

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
}

String AVision::web::_REQUEST(String name) {
    // ... [rest of the function code]

    return ""; // Add this line to ensure a value is always returned
}

void loop() {
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW) { // Button is pressed
    if (WiFi.status() == WL_CONNECTED) {
      HTTPClient http;
      WiFiClient client; // Create an instance of WiFiClient
      http.begin(client, url); // Use the url variable directly
      int httpCode = http.GET();
      http.end();
    }
    delay(1000); // Debounce delay
  }
}

Do you mean this "multi character constant'? The error message is quite clear: a value must be returned from the function. Check the library code.

chatgpt got me to edit the file avision_web.cpp but to no effect

Ask the bot what you did wrong.

the line referenced isnt in that .cpp file to edit as suggested. i edited a line that was almost the same... to no effect.
chatbot returns the same answer as before. edit the file.

Line references can be misleading with code formatting errors. Check for unmatched braces or parentheses, misplaced ";", etc.

will do thanks. strange that theyd release a module with errors though no? or that it wouldn't be configured appropriately.

String AVision::web::_REQUEST(String name) {
    // ... [rest of the function code]

Please post the rest of that function code.

Does the module have examples?

Tom.. :grinning: :+1: :coffee: :australia:

Tom has a good point. Always check that the library example compiles, if there is one.

From the library file avision_web.cpp.
The compiler is correct, in the situation where the if statement is never true, then no return statement will be executed.

16 
 17 String web::_REQUEST(String name)
 18 {
 19     for (uint8_t i = 0; i < server->args(); i++)
 20     {
 21         if (server->argName(i) == name)
 22         {
 23             return server->arg(i);
 24         }
 25     }
 26 }
 27 

In reference to the "multi character constant", check your code for improper use of single quotes, a multi-character constant is where you have more than a single character enclosed in single quotes instead of double quotes. That in itself is not an error, but the situation in which you are using it may be.

You should never post in the Uncategorized section.
It says so in the description of the section. Therefore I have moved your post here.

You might want to look at this How to get the best out of this forum before you proceed any further.

The fix here is the right idea, but "" is not a "String", and I'm not sure "return" will convert it for you, so you'll probably get a new compile error.

You probably want something like:

String defResponse = "";

String web::_REQUEST(String name)
{
     for (uint8_t i = 0; i < server->args(); i++)
     {
         if (server->argName(i) == name)
         {
             return server->arg(i);
         }
     }
    return defResponse;
 }

The "" is not a String but a char*. You have to return a String object or NULL. I'd try return(name); which is an existing String object.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.