Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Setting "#define USE_DYNAMIC_PARAMETERS false" on Blynk_WM_Template.ino results in compile error #16

Closed
ghost opened this issue Jun 27, 2020 · 13 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Jun 27, 2020

I can fix the template for my own use, but wanted to let you know:

using this option in the Blynk_WM_Template.ino file:
#define USE_DYNAMIC_PARAMETERS false
results in compile error

Compile Error log:
In function 'void updateDynamicParameters()':
working:456:98: error: 'controlVpinC' was not declared in this scope
Serial.print ( "\nupdateDynamicParameters has: \n controlVpinC/label = """ ); Serial.print ( controlVpinC ); Serial.print ( """/" ); Serial.print ( controlLabel );
^
working:456:153: error: 'controlLabel' was not declared in this scope
Serial.print ( "\nupdateDynamicParameters has: \n controlVpinC/label = """ ); Serial.print ( controlVpinC ); Serial.print ( """/" ); Serial.print ( controlLabel );
^
working:457:69: error: 'heartbeatVpinC' was not declared in this scope
Serial.print ( "\n heartbeatVpinC/label = """ ); Serial.print ( heartbeatVpinC ); Serial.print ( """/" ); Serial.print ( heartbeatLabel );
^
working:457:126: error: 'heartbeatLabel' was not declared in this scope
Serial.print ( "\n heartbeatVpinC/label = """ ); Serial.print ( heartbeatVpinC ); Serial.print ( """/" ); Serial.print ( heartbeatLabel );
^
working:458:67: error: 'displayVpinC' was not declared in this scope
Serial.print ( "\n displayVpinC/label = """ ); Serial.print ( displayVpinC ); Serial.print ( """/" ); Serial.print ( displayLabel );
^
working:458:122: error: 'displayLabel' was not declared in this scope
Serial.print ( "\n displayVpinC/label = """ ); Serial.print ( displayVpinC ); Serial.print ( """/" ); Serial.print ( displayLabel );
^
exit status 1
'controlVpinC' was not declared in this scope

@khoih-prog khoih-prog added the bug Something isn't working label Jun 27, 2020
@khoih-prog
Copy link
Owner

@kevinleberge

Again thanks for using the library and helping to locate the bugs. The library is getting better everyday thanks to contributing users like you.

For the record, the fix is as follows and will reflect in the release.

#if (USE_WM && USE_DYNAMIC_PARAMETERS)
// UPDATE DYNAMIC PARAMETERS 
//  1 - CONVERTS THE char INFO FROM THE CONFIG PORTAL OR COMPILER CONSTANTS TO THE int VALUES THEY NEED TO BE FOR USE IN A SKETCH
//  2 -   UPDATES BLYNK WITH OTHER DYNAMIC PARAMETERS (WIDGET LABELS) 
void updateDynamicParameters()
{
  ....
} // end updateDynamicParameters
#endif // (updateDynamicParameters not needed if NOT USE_WM)

// BLYNK_CONNECTED GETS CALLED WHEN CONNECTING TO BLYNK SERVERS
// GETS CALLED IMMEDIATELY ON FIRST CONNECT TO BLYNK SERVER, TOO
BLYNK_CONNECTED()
{
  Serial.println ( "\nBLYNK_CONNECTED..." );  

  #if (USE_WM && USE_DYNAMIC_PARAMETERS)
    // Convert the Config Portal (or compiler constant) Virtual Pin char values to Blynk-usable ints
    updateDynamicParameters();  
  #endif

} // end BLYNK_CONNECTED

@ghost
Copy link
Author

ghost commented Jun 27, 2020

I have absolutely no problem testing I am so grateful to be able to support this.

@khoih-prog
Copy link
Owner

@kevinleberge

There are more libraries in My Repository
You're very welcome to use, test and locate the bugs if you're interested.

The USE_DEFAULT_CONFIG_DATA bug is still present in many relating libraries and will be fixed gradually.

Regards,

@ghost
Copy link
Author

ghost commented Jun 27, 2020 via email

@khoih-prog
Copy link
Owner

@kevinleberge

Your help will be greatly welcome. You know there is so much a single guy can do.

Regards,

@ghost
Copy link
Author

ghost commented Jun 27, 2020

Hi, just wanted to share how I set my WM up. I hard coded the blynk-cloud.com server, port 80 and other fields as hidden input fields and updated the css.
image

@khoih-prog
Copy link
Owner

@kevinleberge

That's so nice. It'll be great if you can share with us how you can do that. Even post your new example here in this repository.

@thorathome
Copy link
Contributor

thorathome commented Jun 29, 2020

Hi @khoih-prog
Hi @kevinleberge

Here is my code and simple instructions for creating and using a couple of library files to free me from hard-coding credentials in my sketches.

For this first round with the .h library files, I have included the text for my two files.
@khoih-prog , may I ask that you post these in the right place? I'm also putting them on my own Github page.
After this initial placement, I can maintain them on the official WM repository as needed.

Thanks in advance.

MY_WIFI_CREDENTIALS.h
/* MY_WIFI_CREDENTIALS.h
 * 
 * Even if you use only one SSID/WiFiPassword, you may wish to keep it in a central place, out of your code. 
 * 
 * A simple way to manage SSIDs and WiFiPasswords you may wish to use...
 * * Put your WiFi credentials in a file you can #include in your Arduino sketches. 
 * * Use a simple label like MY_SSID and MY_WIFI_PASSWORD in your code.  
 * 
 * Here's how...
 * * Create a new folder called MY_WIFI_CREDENTIALS in the Arduino/libraries folder
 * * Create a new text file named MY_WIFI_CREDENTIALS.h 
 *   (Same as  as the folder. The .h is important.)
 * 
 * * Use this as a template.
 * * Edit in your own WiFi SSID(s) and WiFi Password(s)
 */ 


// #include "MY_WIFI_CREDENTIALS.h"   // #defines MY_WIFI_SSID AND MY_WIFI_PASSWORD

#define MY_WIFI_SSID "Serengeti"                       // network SSID (name)
#define MY_WIFI_PASSWORD "hey-this is secret 9897%%&"   // network password
/* Comment out the credentials you do not use as regularly...
#define MY_WIFI_SSID "Virus-Vault"                     // network SSID (name)
#define MY_WIFI_PASSWORD "TwoFourSixEight2468!"        // network password
#define MY_WIFI_SSID "MyAndroidPhone"                  // network SSID (name)
#define MY_WIFI_PASSWORD "AndroidPassword66$"          // network password
*/


/*
 * * With the library file in place, restart your Arduino IDE.
 * * In each Arduino sketch, add the line 
 *   #include "MY_WIFI_CREDENTIALS.h" // Use quotes " here.
 * * Write each sketch to use MY_SSID and MY_WIFI_PASSWORD throughout the sketch 
 * * Compile and go
 * 
 * This way, 
 * * All your WiFi credentials are in one place where you can keep track of them.
 * * You are not hard-coding passwords in your sketches.
 * * You Arduino code becomes more portable because all sketches use MY_WIFI_CREDENTIALS.
 * * If you ever have to publish your code, your WiFi Credentials are not visible to everyone.
 * * You will be happier in life.
 */

MY_BLYNK_CREDENTIALS.h

/* MY_BLYNK_CREDENTIALS.h
 * 
 * Since Blynk requires a different Blynk Authcode for every device on every Blynking panel,
 * I end up with a lot of Blynking Authcodes. 
 *
 * A simple way to manage all the Blynk Authcodes you will likely generate...
 * * Put them all in a library file you can #include in your Arduino sketches. 
 * * Name each of the Blynk Authcodes with a helpful name.
 * * Select the right Blynk Authcode in each sketch without having to hard-code it.
 * 
 * Here's how...
 * * Create a new folder called MY_BLYNK_CREDENTIALS in your Arduino/libraries folder
 * * Create a new text file named MY_BLYNK_CREDENTIALS.h 
 *   (Same as as the folder. The .h is important.)
 * 
 * * Use this as a template.
 * * Edit in your own Blynk Authcodes with descriptive names for each of your projects or devices
 */ 

#define MY_BLYNK_SERVER "blynk-cloud.com" // You may or may not need this depending on your code

// From my Blynk Panel 1 ( 3 devices )
#define MY_EXTERIOR_TEMP_AUTHCODE "wtxxxxxxxxxxxxxxxxxxxxxxxxxxxxBS"  // Use your real Blynk Authcode here

#define MY_AC_DEV_AUTHCODE        "fnyyyyyyyyyyyyyyyyyyyyyyyyyyyy7t"  // Use your real Blynk Authcode here

#define MY_BARO_AUTHCODE          "_YzzzzzzzzzzzzzzzzzzzzzzzzzzzzRP"  // Use your real Blynk Authcode here


//From my Blynk Panel 2 ( 2 devices ) 
#define MY_IFTTT_DEMO_AUTHCODE    "_cbbbbbbbbbbbbbbbbbbbbbbbbbbbbsi"  // Use your real Blynk Authcode here
#define MY_SONOFF_DEV_AUTHCODE    "HWcccccccccccccccccccccccccccc7K"  // Use your real Blynk Authcode here


//From my Blynk Panel 3 ( 1 device )
#define MY_REAL_SONOFF_AUTHCODE   "Geddddddddddddddddddddddddddddqc"  // Use your real Blynk Authcode here

/*
 * * Once this library file is in place, restart your Arduino IDE.
 * * In each Arduino sketch, add the line 
 *   #include "MY_BLYNK_AUTHCODES.h" // Use quotes " here.
 * * In all your sketches write something like 
 *   #define MY_BLYNK_AUTHCODE MY_BARO_AUTHCODE //from your .h file. 
 * * Write each sketch to use MY_BLYNK_AUTHCODE throughout the sketch 
 *   instead of a hard-coded Blynk Authcode. 
 * * Right after the #include "MY_BLYNK_AUTHCODES.h" statement, write a #define command to choose the
 *   correct Blynk Authcode. 
 * * Compile and go
 * 
 * This way, 
 * * All Blynk Authcodes are in one place where you can keep track of them.
 * * You are not hard-coding Blynk Authcodes in your sketches.
 * * You Arduino code becomes more portable because all sketches use MY_BLYNK_AUTHCODE. 
 * * If you ever have to publish your code, your Blynk Authcodes are not visible to everyone.
 * * You will be happier in life.
 */

@ghost
Copy link
Author

ghost commented Jun 29, 2020 via email

@khoih-prog
Copy link
Owner

Forgive my ignorance, why are you hard coding the data if the WM handles writing the details through a config portal to the eeprom?

No, your question is good one in normal use case, with USE_DEFAULT_CONFIG_DATA == false

I think @thorathome way to hardcode is just used in developing stage, with USE_DEFAULT_CONFIG_DATA == true, so that we don't have to use WM's Config Portal every time (CP) to enter the Credentials, and save us a lot of time to enter CP, copy and paste the info.

In normal use case, just use a dummy info is good enough. Credentials will get from CP, if necessary.

@thorathome
Copy link
Contributor

So true. So true @khoih-prog

Plus, Old Habits Die Hard! #OldHabitsDieHard @kevinleberge asks the right question. No need to hard-code any of this info in the code anymore.

@khoih-prog
Copy link
Owner

khoih-prog commented Jun 29, 2020

@thorathome

No need to hard-code any of this info in the code anymore.

Not absolutely necessary, but very helpful in many cases, especially with the latest USE_DEFAULT_CONFIG_DATA implementation

  1. For the first time, use hardcoded Credentials in those files to have Credentials loaded and saved in LittleFS/SPIFFS/EEPROM. This way will save us time to input them via CP, certainly with USE_DEFAULT_CONFIG_DATA == true

  2. Then with USE_DEFAULT_CONFIG_DATA == false, we don't need to use CP, yet having all the Credentials ready to work.

  3. Now, we can delete and use dummy Credentials files' info. Still keep the dummy files or get errors in compiling.

@khoih-prog
Copy link
Owner

@thorathome

Here is my code and simple instructions for creating and using a couple of library files to free me from hard-coding credentials in my sketches.

For this first round with the .h library files, I have included the text for my two files.
@khoih-prog , may I ask that you post these in the right place? I'm also putting them on my own Github page.
After this initial placement, I can maintain them on the official WM repository as needed.

Already updated

  1. MY_BLYNK_CREDENTIALS.h
  2. MY_WIFI_CREDENTIALS.h

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants