blynkkk / blynk_Issues

6 stars 6 forks source link

Blynk.syncAll() not working #139

Open Peterkn2001 opened 3 years ago

Peterkn2001 commented 3 years ago

To replicate this issue, use the following code (ESP32 with static provisioning for simplicity of testing)

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "REDACTED"
#define BLYNK_DEVICE_NAME "REDACTED"
#include <BlynkSimpleEsp32_SSL.h>

char auth[] = "REDACTED";
char ssid[] = "REDACTED";
char pass[] = "REDACTED";

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
}

BLYNK_WRITE(V1)
{
  Serial.println("Blynk connected, processing syncAll...");
  Blynk.syncAll();

// Uncomment this code, and comment-out the syncAll code above and it works for pin V1
//  Serial.println("Blynk connected, processing syncVirtual(V1)...");
//  Blynk.syncVirtual(V1);

}

BLYNK_WRITE(V1)
{
  float pin_value = param.asFloat();
  Serial.println("BLYNK_WRITE(V1) triggered...");
  Serial.print("Value = ");
  Serial.println(pin_value);
  Serial.println(); 
}

Define a datastream for pin V1 and attach a slider widget to it in the web dashboard. (Note that this issue isn't limited to the slider widget, but there is another issue with the slider widget on the web dashboard, and I'll raise a separate issue about this (#140), but this setup will demonstrate that issue)

When the sketch is populated with the correct credentials and uploaded, it connects to Blynk and prints the "Blynk connected, processing syncAll..." message, but BLYNK_WRITE(V1) is not triggered. Moving the slider on the dashboard does trigger BLYNK_WRITE(V1).

If you then modify the BLYNK_WRITE(V1) callback and uncomment the Blynk.syncVirtual(V1) code BLYNK_WRITE(V1) is triggered on BLYNK_CONNECTED().

Pete.

doom369 commented 3 years ago

@Peterkn2001 now DS should be explicitly set as "sync" for SyncAll operation to work:

screenshot-raypak-qa blynk cc-2021 06 23-14_34_38

Right now this option is missing on the UI. We'll add it with the next deployment. This was done to avoid the hardware crash when syncAll invoked. For the devices with many datastreams it was often a problem and calling sync for the specific pin was not suitable as required a lot of calls.

Peterkn2001 commented 3 years ago

In that case, the documentation here will need updating:

https://docs.blynk.io/en/blynk.edgent/api/virtual-pins

Blynk.syncAll() Requests all stored on the server latest values for all widgets. All analog/digital/virtual pin values and states will be set to the latest stored value. Every virtual pin will generate BLYNK_WRITE() event.

and I'm not sure that the wording of the advanced option in your screenshot is very self-explanatory.

Will Blynk_syncAll cause BLYNK_WRITE_DEFAULT to trigger for any datastream that has this option turned on and doesn't have an explicit BLYNK_WRITE(Vpin) callback?

Pete.