Advertisement
Krzyspx

brama4esptransmit

Dec 6th, 2016
3,698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <Arduino.h>
  2. #include <BlynkSimpleEsp8266.h>
  3.  
  4.  
  5. int termesp = 0;
  6. int seresp = 0;
  7.  
  8. void Blynkwrite(String str2);
  9.  
  10. BLYNK_WRITE(V32) { //on/off serial esp to terminal
  11.   if (param.asInt())termesp = 1; else termesp = 0;
  12. }
  13. BLYNK_WRITE(V33) { //on/off serial esp to serial
  14.   if (param.asInt())seresp = 1; else seresp = 0;
  15. }
  16.  
  17. // ....................................... recive string from serial
  18. bool  stringComplete = false;
  19. String inputString = "";
  20. byte licznikodbioru = 0;
  21. int startrecive = 0;
  22.  
  23. void printterm31() {
  24.   terminal31.println("od  " + (inputString));
  25.   terminal31.flush();
  26. }
  27.  
  28. void recivestrfromserial () {
  29.   if (stringComplete) {
  30.   if(seresp){    Serial.println("od  " + (inputString));  }
  31.   if(termesp){
  32.     printterm31();
  33.   }
  34.     Blynkwrite(inputString);
  35.     inputString = "";
  36.     stringComplete = false;
  37.     licznikodbioru = 0;
  38.     startrecive = 0;
  39.   }
  40. }
  41.  
  42. void myserialEvent() { // string z Serial
  43.   if (Serial.available()) {
  44. //    licznikodbioru++;
  45.     char inChar = (char)Serial.read();
  46.     if (startrecive == 0) {
  47.       if ((inChar == 'S') || (inChar == 'I') || (inChar == 'L') || (inChar == 'C') || (inChar == 'N') || (inChar == 'F')|| (inChar == 'O'))  startrecive = 1;
  48.     }
  49.     if (startrecive == 1) {
  50.       if ((inChar == '\r')||(inChar == '\n'))  {
  51.         stringComplete = true;
  52.         inChar = '\0';
  53.         inputString += inChar;
  54.         startrecive = 0;
  55.       } else  inputString += inChar;
  56.     }
  57.  //   if (licznikodbioru > 50) inputString = "";
  58.   }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement