News

moodlite - Coming soon


invalid use of member function

Goldenfaeron · 868

Goldenfaeron

  • Newbie
  • *
    • Posts: 1
    • Likes: +0/-0
    • View Profile
on: July 17, 2019, 11:37:30 AM
When I want to upload the program the first time (step 7. at https://github.com/spigotx/Moodlite/wiki/First-setup-of-Moodlite ) there are some errors:

Code: [Select]
Arduino: 1.8.10 Hourly Build 2019/07/16 11:33 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

WARNUNG: Bibliothek Timezone behauptet auf (avr) Architektur(en) ausgeführt werden zu können und ist möglicherweise inkompatibel mit Ihrem derzeitigen Board, welches auf (esp8266) Architektur(en) ausgeführt wird.
In file included from C:\Users\-------\Documents\Zimmereinrichtung\Moodlite\Arduino\Moodlite\Moodlite.ino:31:0:

C:\Users\-------\Documents\Arduino\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.002.010

 #    pragma message "FastLED version 3.002.010"

                     ^

In file included from C:\Users\-------\Documents\Arduino\libraries\FastLED/FastLED.h:65:0,

                 from C:\Users\-------\Documents\Zimmereinrichtung\Moodlite\Arduino\Moodlite\Moodlite.ino:31:

C:\Users\-------\Documents\Arduino\libraries\FastLED/fastspi.h:115:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output

 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"

                       ^

C:\Users\-------\-------\-------\Moodlite\Arduino\Moodlite\Moodlite.ino: In member function 'String& ByteString::copy(const void*, unsigned int)':

Moodlite:419:9: error: invalid use of member function (did you forget the '()' ?)

     len = length;

         ^

Moodlite:420:30: error: cannot convert 'String::buffer' from type 'const char* (String::)()const' to type 'void*'

   memcpy(buffer, data, length);

                              ^

Moodlite:421:16: error: invalid types '<unresolved overloaded function type>[unsigned int]' for array subscript

   buffer[length] = 0;

                ^

exit status 1
invalid use of member function (did you forget the '()' ?)


------ = my full name  ;)

What is wrong with the code?

Thanks for answers.

Tobi



Tim

  • Newbie
  • *
    • Posts: 3
    • Likes: +0/-0
    • View Profile
Reply #1 on: September 19, 2019, 10:34:21 AM
Hi
i have the same errors. I used different version from Arduino but still not compiling. I printed all the stuff and now i can not use it. please help us!



Tim

  • Newbie
  • *
    • Posts: 3
    • Likes: +0/-0
    • View Profile
Reply #2 on: September 19, 2019, 12:57:55 PM
HI.
I think i solved the issue:

add this two lines to the String& copy function line 414:

Code: [Select]
char* buffer;
size_t len = length;

it looks like that now:

Code: [Select]
String& copy(const void *data, unsigned int length) {
if (!reserve(length)) {
invalidate();
return (*this);
}
    char* buffer;
size_t len = length;
memcpy(buffer, data, length);
buffer[length] = 0;
return (*this);
}
};

After that i has an error from FastLed. If you has this too, then you need to change the following file:

File: /platforms/esp/8266/led_sysdefs_esp8266.h
Line: 15
Change to: //typedef uint8_t boolean;

I hope the two changes have no impact on the logic of the program



spigot

  • Global Moderator
  • Full Member
  • *****
    • Posts: 113
    • Likes: +25/-0
  • There's no place like 127.0.0.1
    • View Profile
Reply #3 on: September 28, 2019, 12:58:10 PM
Hi.

You can completely remove this part:

Code: [Select]
class ByteString : public String {
public:
ByteString(void *data, size_t len) :
String() {
copy(data, len);
}

ByteString() :
String() {
}

String& copy(const void *data, unsigned int length) {
if (!reserve(length)) {
invalidate();
return (*this);
}
len = length;
memcpy(buffer, data, length);
buffer[length] = 0;
return (*this);
}
};

// Asynchronous TCP Client to retrieve data/time
struct AsyncHTTPClient {
AsyncClient *aClient = NULL;

bool         initialized = false;
String       protocol;
String       base64Authorization;
String       host;
int          port;
String       uri;
String       request;

ByteString   response;
int          statusCode;
void(*onSuccess)();
void(*onFail)(String);

void initialize(String url) {
// check for : (http: or https:
int index = url.indexOf(':');

if (index < 0) {
initialized = false; // This is not a URLs
}

protocol = url.substring(0, index);
DEBUGLN(protocol);
url.remove(0, (index + 3)); // remove http:// or https://

index = url.indexOf('/');
String hostPart = url.substring(0, index);
DEBUGLN(hostPart);
url.remove(0, index); // remove hostPart part

// get Authorization
index = hostPart.indexOf('@');

if (index >= 0) {
// auth info
String auth = hostPart.substring(0, index);
hostPart.remove(0, index + 1);                // remove auth part including @
base64Authorization = base64::encode(auth);
}

// get port
port = 80; //Default
index = hostPart.indexOf(':');
if (index >= 0) {
host = hostPart.substring(0, index); // hostname
host.remove(0, (index + 1));         // remove hostname + :
DEBUGLN(host);
port = host.toInt();                 // get port
DEBUGLN(port);
}
else {
host = hostPart;
DEBUGLN(host);
}
uri = url;
if (protocol != "http") {
initialized = false;
}

DEBUGLN(initialized);
request = "GET " + uri + " HTTP/1.1\r\nHost: " + host + "\r\n\r\n";

DEBUGLN(request);
initialized = true;
}

int getStatusCode() {
return (statusCode);
}

String getBody() {
if (statusCode == 200) {
int bodyStart = response.indexOf("\r\n\r\n") + 4;
return (response.substring(bodyStart));
}
else {
return ("");
}
}

static void clientError(void *arg, AsyncClient *client, int error) {
DEBUGLN("Connect Error");
AsyncHTTPClient *self = (AsyncHTTPClient *)arg;
self->onFail("Connection error");
self->aClient = NULL;
delete client;
}

static void clientDisconnect(void *arg, AsyncClient *client) {
DEBUGLN("Disconnected");
AsyncHTTPClient *self = (AsyncHTTPClient *)arg;
self->aClient = NULL;
delete client;
}

static void clientData(void *arg, AsyncClient *client, void *data, size_t len) {
DEBUGLN("Got response");

AsyncHTTPClient *self = (AsyncHTTPClient *)arg;
self->response = ByteString(data, len);
String status = self->response.substring(9, 12);
self->statusCode = atoi(status.c_str());
DEBUGLN(status.c_str());

if (self->statusCode == 200) {
self->onSuccess();
}
else {
self->onFail("Failed with code " + status);
}
}

static void clientConnect(void *arg, AsyncClient *client) {
DEBUGLN("Connected");

AsyncHTTPClient *self = (AsyncHTTPClient *)arg;

self->response.copy("", 0);
self->statusCode = -1;

// Clear oneError handler
self->aClient->onError(NULL, NULL);

// Set disconnect handler
client->onDisconnect(clientDisconnect, self);

client->onData(clientData, self);

//send the request
client->write(self->request.c_str());
}

void makeRequest(void(*success)(), void(*fail)(String msg)) {
onFail = fail;

if (!initialized) {
fail("Not initialized");
return;
}

if (aClient) {           //client already exists
fail("Call taking forever");
return;
}

aClient = new AsyncClient();

if (!aClient) {           //could not allocate client
fail("Out of memory");
return;
}

onSuccess = success;

aClient->onError(clientError, this);

aClient->onConnect(clientConnect, this);

if (!aClient->connect(host.c_str(), port)) {
DEBUGLN("Connect Fail");
fail("Connection failed");
AsyncClient *client = aClient;
aClient = NULL;
delete client;
}
}
};

AsyncHTTPClient httpClient;


It's no longer needed



Tim

  • Newbie
  • *
    • Posts: 3
    • Likes: +0/-0
    • View Profile
Reply #4 on: October 28, 2019, 09:41:54 AM
OK thats cool. but now i have this error:

Code: [Select]
exit status 1
'fullColor' was not declared in this scope

 at the line 364
Code: [Select]
SimplePatternList gPatterns = { &fullColor, &standard, &confetti, &sinelon, &juggle, &bpm, &kitt, &plasma, &blendwave, &inoise8_fire, &rainbow_beat, &rainbow, &rainbowWithGlitter };

any help?



zonochromatica

  • Newbie
  • *
    • Posts: 3
    • Likes: +0/-0
    • View Profile
Reply #5 on: January 16, 2020, 01:35:02 AM
bump!!!



nicksears

  • Newbie
  • *
    • Posts: 5
    • Likes: +0/-0
    • View Profile
Reply #6 on: January 20, 2020, 07:43:29 PM
use arduino 1.8.8, this fixed it for me. Also make sure you''re using the exact versions of the libraries mentioned...



SimonSplat

  • Newbie
  • *
    • Posts: 7
    • Likes: +0/-0
    • View Profile
Reply #7 on: January 21, 2020, 01:52:53 PM
I made sure all the libraries were the same version as the instruction and then overwrote the contents of the Mooodlite.no arduino tab back to original and it seemed to fix it.



nicksears

  • Newbie
  • *
    • Posts: 5
    • Likes: +0/-0
    • View Profile
Reply #8 on: January 22, 2020, 06:10:07 AM
Do you get it to work COMPLETELY and if so would you mind sharing your setup? (zip file of libraries and source code?)

I have an ESP-12E (https://www.amazon.com/dp/B081CSJV2V/) and am using Arduino 1.8.8 on win10x64 with ESP board package 2.4.2 (Anything above this number gives compile errors I can't get around)

I've installed all the libraries

via library manager:
PubSubClient
Timezone
FastLED (3.2.8)

via zip file:
ESPAsyncWebServer
ESPAsyncTCP
Timer
Time
AsyncTCP (not sure if it's used)

I've used different versions of these from this page (https://github.com/spigotx/Moodlite/wiki/Preparing-Arduino-IDE)

as well as official sources, and versions from the github (https://github.com/spigotx/Moodlite)

I can get it to compile and upload with no errors (just some warnings that are supposedly ok) and upload spiffs (skipped over that but no errors there).

I can even (usually) connect to the access point (sometimes "Moodlite", sometimes "ESP_1234") and give it my own wifi credentials and have it connect, but here's where it starts to get hairy:


Sometimes (and I haven't tracked down exactly when) after connecting to it over my wifi - it will load the settings page with the default number of LEDs and I'll get some kind of initial light (the first 9 leds), but not always. Sometimes it will pretend to save the new number and do nothing. I think it has something to do with resetting EEPROM, when I upload with the erase eeprom lines uncommented and reupload commented, it seems to work better (page loads faster and saves my new led numbers)

I think I get some (glitchy) function out of it when I can change the numbers. The lights are always on, but they flicker when I select a preset, and flicker more rapidly the second I select a new preset, but nothing intelligible.

Can someone explain what erasing "All flash contents" vs just sketch will do? the tutorials always say just pick "sketch", but that never worked for me until I erased all and/or erased eeprom.

Oh and on top of it all, I'm using 12V WS2811, rather than WS2812B, so I have some in the mail just to check, but it's weird that the first 9 light up fine...
« Last Edit: January 22, 2020, 04:22:42 PM by nicksears »



SimonSplat

  • Newbie
  • *
    • Posts: 7
    • Likes: +0/-0
    • View Profile
Reply #9 on: January 22, 2020, 11:42:51 AM
Hi! No, I've not got it working completely yet and I agree that it seems to be a writing/reading to/from the EEPROM that's the issue. I am trying to debug it so will keep you all posted. The infuriating thing is that on another NodeMCU Moodlite that I built for a friend it worked! Grrr...

Sometimes reflashing the EEPROM and SPIFFS a few times (this is what I did on my friends system) kicks it into working but this isn't a reliable solution.

The LED flickering, in my experience, is generally due to a power supply issue in that it't not pumping out enough to reliably fire the LEDs. Not sure it will stop it working beyond 9 LEDs though, make sure the connections are ok of course!



 


SMF spam blocked by CleanTalk