Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup() - Stack smashing protect failure! #7

Open
Shavo650 opened this issue Jun 6, 2024 · 0 comments
Open

lookup() - Stack smashing protect failure! #7

Shavo650 opened this issue Jun 6, 2024 · 0 comments

Comments

@Shavo650
Copy link

Shavo650 commented Jun 6, 2024

Hi. lookup() function keeps crashing. I loaded example sketch and have tried to use this library but after compilation and upload to my ESP32 i get this:

Starting...
.
IP address: 192.168.33.15

Stack smashing protect failure!


Backtrace: 0x40082371:0x3ffb2040 0x4008be1d:0x3ffb2060 0x40082382:0x3ffb2080 0x400d6dfb:0x3ffb20a0 0x400d70d3:0x3ffb2200 0x400d343a:0x3ffb2220 0x400d9f04:0x3ffb2290

This is my code:

#include <WiFi.h>
#include <ArduinoJson.h>
#include "yeelight.h"

#define LED 2

StaticJsonDocument<200> jsonBuffer;
Yeelight* yeelight;

void connectToWiFi(const char * ssid, const char * pwd);

void setup() {
  Serial.begin(115200);
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW);
  Serial.println("Starting...");

  connectToWifi("RandomSSID", "Stronkpassword");

  yeelight = new Yeelight();
  yeelight->lookup();
}

void loop() {
  if (yeelight->feedback()) {
    Serial.print("device: ");
    Serial.println(yeelight->getLocation());

    if (!yeelight->isPowered()) {
      digitalWrite(LED, HIGH);
      Serial.println(yeelight->sendCommand("set_power", "[\"on\", \"smooth\", 500]"));
      // Serial.println(yeelight->sendCommand("set_name", "[\"tv\"]"));
    }
    deserializeJson(jsonBuffer, yeelight->sendCommand("get_prop", "[\"power\", \"name\"]"));
    JsonObject root = jsonBuffer.as<JsonObject>();
    const char* state = root["result"][0];
    const char* name = root["result"][1];
    Serial.print("- power is: ");
    Serial.println(state);
    Serial.print("- name is: ");
    Serial.println(name);
  }
}

void connectToWifi(const char * ssid, const char * pwd)
{
  WiFi.begin(ssid, pwd);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }

  Serial.println("");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  
}

I already figured out that the problem is in the lookup() function. But i'm not sure how to fix it.

void Yeelight::lookup()
{
  #ifdef ESP32
    udp.beginMulticast(_ipMulti, 1982);
    udp.beginMulticastPacket();
  #else
    udp.beginMulticast(WiFi.localIP(), _ipMulti, 1982);
    udp.beginPacketMulticast(_ipMulti, 1982, WiFi.localIP());
  #endif
  udp.print("M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1982\r\nMAN: \"ssdp:discover\"\r\nST: wifi_bulb");
  udp.endPacket();
  udp.begin(1982);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant