sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
Other
234 stars 124 forks source link

Hello Boris, let's talk again #219

Closed jamsyogendra closed 3 years ago

jamsyogendra commented 3 years ago

My code was stack, here is the decoding result.

Decoding stack results

0x401007de: puts(char const*) at C:\Users\jamsa\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\libc_replacements.cpp line 117
0x4020aeac: __assert_func(char const*, int, char const*, char const*) at C:\Users\jamsa\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_postmortem.cpp line 275
0x4020b3b9: __attachInterruptFunctionalArg(uint8_t, voidFuncPtrArg, void*, int, bool) at C:\Users\jamsa\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_wiring_digital.cpp line 201
0x40209c88: String::~String() at C:\Users\jamsa\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\WString.cpp line 125
0x4020b468: __attachInterrupt(uint8_t, voidFuncPtr, int) at C:\Users\jamsa\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_wiring_digital.cpp line 236
0x402091d1: dimmerLamp::ext_int_init() at C:\Users\jamsa\OneDrive\Documents\Arduino\libraries\RBDDimmer-master\src\esp8266\RBDmcuESP8266.cpp line 62
0x4020920a: dimmerLamp::begin(DIMMER_MODE_typedef, ON_OFF_typedef) at C:\Users\jamsa\OneDrive\Documents\Arduino\libraries\RBDDimmer-master\src\esp8266\RBDmcuESP8266.cpp line 71
0x40202698: setup() at C:\Users\jamsa\OneDrive\Desktop\project sinric pro\sinricpro2relay - Copy\sinricpro2relay/sinricpro2relay.ino line 95
0x4020aa4c: loop_wrapper() at C:\Users\jamsa\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 194

Can you help, I hope you remember!

jamsyogendra commented 3 years ago
`#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <SinricPro.h>
#include <SinricProSwitch.h>
#include <SinricProDimSwitch.h>
#include <RBDdimmer.h>

#define SSID          ".................."                                              // WiFi SSID
#define PASS          "....................."                                              // WiFi Password

#define APPKEY        ""                                              // SinricPro AppKey
#define APPSECRET     ""        // SinricPro AppSecret

#define RELAY1_ID         ""                                              // SinricPro deviceId for relay1
#define RELAY2_ID         ""                                              // SinricPro deviceId for relay2
#define DIMSWITCH_ID      ""    // Should look like "5dc1564130xxxxxxxxxxxxxx"

#define RELAY1_PIN  D3                                                // PIN relay1 is connected to
#define RELAY2_PIN  D6                                                // PIN relay2 is connected to
#define outputPin  D1 
#define zerocross  D7 // for boards with CHANGEBLE input pins

SinricProSwitch &relay1       = SinricPro[RELAY1_ID];                 // declare SinricPro device for relay1 and add the device to SinricProSDK
SinricProSwitch &relay2       = SinricPro[RELAY2_ID];                 // declare SinricPro device for relay2 and add the device to SinricProSD
SinricProDimSwitch &myDimSwitch = SinricPro[DIMSWITCH_ID];

dimmerLamp dimmer(outputPin, zerocross);

int outVal = 0;
int dim_val = 0;

// callback for onPowerState (relay1)
bool onPowerStateRelay1(const String& deviceId, bool &state) {
  digitalWrite(RELAY1_PIN, state);                                    // turn RELAY1_PIN on/off (depending on state parameter)
  Serial.printf("[Relay1]: turn %s\r\n", state ? "on" : "off");       // just some output on serial monitor
  return true;
}

// callback for onPowerState (relay2)
bool onPowerStateRelay2(const String& deviceId, bool &state) {
  digitalWrite(RELAY2_PIN, state);                                    // turn RELAY1_PIN on/off (depending on state parameter)
  Serial.printf("[Relay2]: turn %s\r\n", state ? "on" : "off");       // just some output on serial monitor
  return true;
}

bool onPowerLevel(const String &deviceId, int &powerLevel) {
   dim_val = map(outVal, 45, 100, 45, 100); // mapped the value for dimmer
   dimmer.setPower(dim_val); // Set dimmer power
  return true;
}

void setupPins() {
  pinMode(RELAY1_PIN, OUTPUT);                                        // initialize RELAY1_PIN as OUTPUT
  pinMode(RELAY2_PIN, OUTPUT);                                        // initialize RELAY2_PIN as OUTPUT
}

// setup part for connecting to WiFi (just to keep setup() nice and clean)
void setupWiFi() {
  Serial.printf("[WiFi]: Connecting to %s", SSID);                    // print to which WiFi we are trying to connect to
  WiFi.begin(SSID, PASS);                                             // start connecting to WiFi
  while (WiFi.status() != WL_CONNECTED) {                             // wait until WiFi has been connected
    Serial.printf(".");                                               //    meanwhile print a dot
    delay(250);                                                       //    every 250ms  
  }
  Serial.printf("connected\r\n");                                     // print to serial that we are connected to wifi now
}

// setup part for SinricProSDK (just to keep setup() nice and clean)
void setupSinricPro() {
  relay1.onPowerState(onPowerStateRelay1);                            // assign onPowerStateRelay1 callback function to relay1 device
  relay2.onPowerState(onPowerStateRelay2);                            // assign onPowerStateRelay2 callback function to relay2 device
  myDimSwitch.onPowerLevel(onPowerLevel);

  SinricPro.onConnected([]() {                                        // instead of writing a full callback function we use a lambda function which get called when ESP is connected to SinricPro
    Serial.printf("[SinricPro]: Connected\r\n");                      // and this function does: output to serial "[SinricPro]: Connected"
  });

  SinricPro.onDisconnected([]() {                                     // instead of writing a full callback function we use a lambda function which get called when ESP is disconnected from SinricPro
    Serial.printf("[SinricPro]: Disconnected\r\n");                   // and this function does: output to serial "[SinricPro]: Disconnected"
  });

  SinricPro.begin(APPKEY, APPSECRET);                                 // initialize SinricProSDK with APPKEY and APPSECRET
}

void setup() {
  Serial.begin(115200);                                               // initialize Serial to baudrate 115200
  Serial.println();                                                   // print a single line (to get rid of the junk)
  setupPins();                                                        // call setupPin function
  setupWiFi();                                                        // call setupWiFi function
  setupSinricPro();                                                   // call setupSinricPro function
  dimmer.begin(NORMAL_MODE, ON);
}

void loop() {
  SinricPro.handle();                                                 // do the magic...
  dimmer.setPower(dim_val);
}`
sivar2311 commented 3 years ago

It looks like the rbdimmer library is still buggy. Check the issues in the RobotDyn repository. A lot of people complain about this problem on the ESP8266.

jamsyogendra commented 3 years ago

Can we edit or modify rbd lib according to our needs

sivar2311 commented 3 years ago

Surely you can edit the library. Unfortunately, I cannot help you with that. Check the solutions that have already been worked out in the RobotDyn repository or contact RobotDyn directly.

jamsyogendra commented 3 years ago

We have decoding results it lock like if we can edit same line in cpp or header file we can sure we can run our code

sivar2311 commented 3 years ago

The error is in the RBDimmer library. I can't help you with that. Please contact RobotDyn.

jamsyogendra commented 3 years ago

Sure but I don't think they help me already so many issues already there

jamsyogendra commented 3 years ago

But thanks again sir