Help with get data from terminal widget

hello all!!

i’m new to Blynk and i’m trying to get data from the terminal widget. my problem is that i already get some data and now i want to get new data.
my code:
` BLYNK_WRITE(V1)
{

if(mypassword == param.asStr())
{
mypassword="";
char c;
for(int i=0;i<8;i++)
{
c = char(random(120));
mypassword+=c;
}
terminal.println("my new password is: "+mypassword);
Serial.println("my new password is: "+mypassword);
}

if(String(“node”) == param.asStr()){
terminal.println("please enter my new node_address: ");
delay(5000);
// Ensure everything is sent
terminal.flush();
tmp1 = param.asStr();
Serial.println(“my tmp1:”);
Serial.println(tmp1);
node_address = (uint16_t) tmp1.toInt();
Serial.println(“my node_address:”);
Serial.println(node_address);
}
// Ensure everything is sent
terminal.flush();
} `

now, when i want to enter the second if i need to write “node”, and after i enter the loop i want him to get a number (i know about param.asInt, this is one of my tests) . how i can change the value of param??

the delay was set for enter new data in the terminal but his not get the new data in param(despite i’m use terminal.flush)…

what can i do?

Can you post your entire sketch? I think I know what you want to achieve, but I’d like to be sure.

The delay will cause problems. I think you have to solve this in a different manner. You can use the following structure too:

if(something == somethingOne)
{
  doThis();
}
else if(something == somethingTwo)
{
  doThat();
}
else
{
  doSomethingDefault();
}

I think that logic would work better and it probably will work without delay toom which is better.

thank you for your replay!

i dont think your code will help because i want him to enter some loop with the terminal and then enter new data…

my entire code:
`/**************************************************************

  • Blynk is a platform with iOS and Android apps to control
  • Arduino, Raspberry Pi and the likes over the Internet.
  • You can easily build graphic interfaces for all your
  • projects by simply dragging and dropping widgets.
  • Downloads, docs, tutorials: http://www.blynk.cc
  • Blynk community: http://community.blynk.cc
  • Social networks: http://www.fb.com/blynkapp
  •                           http://twitter.com/blynk_app
    
  • Blynk library is licensed under MIT license
  • This example code is in public domain.

  • This example runs directly on ESP8266 chip.
  • You need to install this for ESP8266 development:
  • https://github.com/esp8266/Arduino
  • Please be sure to select hte right ESP8266 module
  • in the Tools -> Board menu!
  • Change WiFi ssid, pass, and Blynk auth token to run :slight_smile:

**************************************************************/

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “xxxxxxxxxxxxxxxxx”;
int led = 13;
int state = 0;
int past_state = 1;
String mypassword = “0000”;
uint16_t node_address = 02;
String tmp = “7”;
String tmp1 = “9”;
// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);

void setup()
{
pinMode(led,OUTPUT);
digitalWrite(led,HIGH);
delay(2000);
digitalWrite(led,LOW);
Serial.begin(9600);
Blynk.begin(auth, “shtainer”, “yoav1234”);

while (Blynk.connect() == false) {
// Wait until connected

}
// This will print Blynk Software version to the Terminal Widget when
// your hardware gets connected to Blynk Server
terminal.println(F(“Blynk v” BLYNK_VERSION “: Device started”));
terminal.println("-------------");
//terminal.println(“Type ‘Marco’ and get a reply, or type”);
//terminal.println(“anything else and get it printed back.”);
terminal.flush();
}

// You can send commands from Terminal to your hardware. Just use
// the same Virtual Pin as your Terminal Widget
BLYNK_WRITE(V1)
{

// // if you type “Marco” into Terminal Widget - it will respond: “Polo:”
// if (String(“Marco”) == param.asStr()) {
// terminal.println(“You said: ‘Marco’”) ;
// terminal.println(“I said: ‘Polo’”) ;
// } else {
//
// // Send it back
// terminal.print(“You said:”);
// terminal.write(param.getBuffer(), param.getLength());
// terminal.println();
// }
if(mypassword == param.asStr())
{
mypassword="";
char c;
for(int i=0;i<8;i++)
{
c = char(random(120));
mypassword+=c;
}
terminal.println("my new password is: "+mypassword);
Serial.println("my new password is: "+mypassword);
}

if(String(“node”) == param.asStr()){
terminal.println("please enter my new node_address: ");
delay(5000);
// Ensure everything is sent
terminal.flush();
tmp1 = param.asStr();
Serial.println(“my tmp1:”);
Serial.println(tmp1);
node_address = (uint16_t) tmp1.toInt();
Serial.println(“my node_address:”);
Serial.println(node_address);
}

// Ensure everything is sent
terminal.flush();
}

void loop()
{
Blynk.run();
state = digitalRead(led);
if(mypassword==“0000”){
terminal.println("please enter my password: ");delay(500);}

if(state!=past_state)
{
if(state==1)
Serial.println(“1”);
else
Serial.println(“0”);
past_state = state;
}
}
`

You are overthinking it from what I can see. At the moment you enter data and press “sent”, then you need to parse the info, not before. So there is no need for delay for one.

  1. Enter “blabla”
  2. Press send
  3. Look at incoming string
  4. do a) in case of string1
  5. otherwise do b)

but i want to know that now is the time for enter new node, and then enter the number of this node. i dont want that the sketch will craete the number of the node like the password… so i cant tell him what to do if he get the String node because i need more data.

How about this:

you can enter “node 9999” and parse that? That would solve your problem :slight_smile:

not working, i alrdeay try this…:confused:

Hi I have the same issue did you solve it? Can u pls help me Y need to do the same get data according to the imput:

if client says
wifi
Then safe wifiname and ask for password
Then safe password

Thanks

Can you explain what you want to achieve with this? Because you need to have a connection before the Terminal works …