#include <Arduino.h>
#include <EEPROM.h>
unsigned char Buffer[24];
bool One =HIGH;
bool Zero=LOW;
int mo = 0;
int so = 1;
String mso="01";
unsigned long msoMs =60000;
int mr = 0;
int sr = 1;
String msr="01";
unsigned long msrMs =60000;
int mm3 = 0;
int sm3 = 1;
String msm3="01";
unsigned long msm3Ms =60000;
int mm4 = 0;
int sm4 = 1;
String msm4="01";
unsigned long msm4Ms =60000;
int mt = 2;
int st = 5;
String mst="25";
unsigned long mstMs =25;
// #define m3 3 //melangeur
//#define m4 11
#define ozane 27
//#define souffleur 10
//#define Res 12
//#define ELV2 9
//bool m3_Status = HIGH;
//bool m4_Status = HIGH;
bool ozane_Status = Zero;
//bool souffleur_Status = HIGH;
//bool Res_Status = HIGH;
//bool ELV2_Status = HIGH;
//bool Start_Command = true;
unsigned long startTime = 0;
void setup() {
Serial.begin(115200);
//
// pinMode(m3, OUTPUT);
// pinMode(m4, OUTPUT);
pinMode(ozane, OUTPUT);
// pinMode(souffleur, OUTPUT);
// pinMode(Res, OUTPUT);
// pinMode(ELV2, OUTPUT);
}
void loop() {
if (Serial.available()) {
/* This loop will store the whole frame in the buffer array */
for (int i = 0; i <= 24; i++) {
//this for to get all data from stone display
Buffer[i] = Serial.read();
Serial.print(Buffer[i],HEX);
Serial.print("-");
}
if (Buffer[0] == 0x53) {
Serial.print("1oki");
/* Checking condition for Relay- 1 [ON] at frame index 18 with value 0xEC */
if (Buffer[13] == 0xAB && Buffer[14]==0x2D ) {
Serial.print(F("ST<{\"cmd_code\":\"get_text\",\"type\":\"label\",\"widget\":\"timeOzane\"}>ET"));
Serial.print("2oki");
delay(20);
}
if (Buffer[13] == 0x6b && Buffer[14]==0x54 ) {
Serial.print(F("ST<{\"cmd_code\":\"get_text\",\"type\":\"label\",\"widget\":\"timeDES\"}>ET"));
Serial.print("2oki");
delay(20);
}
if (Buffer[13] == 0xAB && Buffer[14]==0x69 ) {
Serial.print(F("ST<{\"cmd_code\":\"get_text\",\"type\":\"label\",\"widget\":\"timem3\"}>ET"));
Serial.print("2oki");
delay(20);
}
if (Buffer[13] == 0xAB && Buffer[14]==0xe1 ) {
Serial.print(F("ST<{\"cmd_code\":\"get_text\",\"type\":\"label\",\"widget\":\"timeM4\"}>ET"));
Serial.print("2oki");
delay(20);
}
if (Buffer[13] == 0x6B && Buffer[14]==0xDC ) {
Serial.print(F("ST<{\"cmd_code\":\"get_text\",\"type\":\"label\",\"widget\":\"TempD\"}>ET"));
Serial.print("2oki");
delay(20);
}
if (Buffer[13] == 0x7A ) {
mo = Buffer[19]-48;
so = Buffer[20]-48;
mso=String(mo)+String(so);
msoMs = mso.toInt()*60*1000;
Serial.println(mo);
Serial.println(so);
Serial.println(mso);
Serial.println(msoMs);
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"timeOzane\",\"color_object\":\"text_color\",\"color\":4278145335}>ET"));
delay(20);
}
if (Buffer[13] == 0x45 && Buffer[14] == 0x53 ) {
mr = Buffer[17]-48;
sr = Buffer[18]-48;
msr=String(mr)+String(sr);
msrMs = msr.toInt()*60*1000;
Serial.println(mr);
Serial.println(sr);
Serial.println(msr);
Serial.println(msrMs);
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"timeDES\",\"color_object\":\"text_color\",\"color\":4278145335}>ET"));
delay(20);
}
if (Buffer[13] == 0x33 && Buffer[14] == 0x22 ) {
mm3 = Buffer[16]-48;
sm3 = Buffer[17]-48;
msm3=String(mm3)+String(sm3);
msm3Ms = msm3.toInt()*60*1000;
Serial.println(mm3);
Serial.println(sm3);
Serial.println(msm3);
Serial.println(msm3Ms);
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"timem3\",\"color_object\":\"text_color\",\"color\":4278145335}>ET"));
delay(20);
}
if (Buffer[13] == 0x34 && Buffer[14] == 0x22 ) {
mm4 = Buffer[16]-48;
sm4 = Buffer[17]-48;
msm4=String(mm4)+String(sm4);
msm4Ms = msm4.toInt()*60*1000;
Serial.println(mm4);
Serial.println(sm4);
Serial.println(msm4);
Serial.println(msm4Ms);
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"timeM4\",\"color_object\":\"text_color\",\"color\":4278145335}>ET"));
delay(20);
}
if (Buffer[13] == 0x22&& Buffer[14] == 0x3A ) {
mt = Buffer[15]-48;
st = Buffer[16]-48;
mst=String(mt)+String(st);
mstMs = mst.toInt();
Serial.println(mt);
Serial.println(st);
Serial.println(mst);
Serial.println(mstMs);
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"TempD\",\"color_object\":\"text_color\",\"color\":4278145335}>ET"));
delay(20);
}
if (Buffer[4] == 0x62 && Buffer[12]==0x7a ) {
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"timeOzane\",\"color_object\":\"text_color\",\"color\":4278190080}>ET"));
delay(20);
}
if (Buffer[4] == 0x62 && Buffer[12]==0x45 ) {
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"timeDES\",\"color_object\":\"text_color\",\"color\":4278190080}>ET"));
delay(20);
}
if (Buffer[4] == 0x62 && Buffer[12]==0x33 ) {
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"timem3\",\"color_object\":\"text_color\",\"color\":4278190080}>ET"));
delay(20);
}
if (Buffer[4] == 0x62 && Buffer[10]==0x70 && Buffer[11]==0x44 ) {
Serial.print(F("ST<{\"cmd_code\":\"set_color\",\"type\":\"widget\",\"widget\":\"TempD\",\"color_object\":\"text_color\",\"color\":4278190080}>ET"));
delay(20);
}
if (Buffer[12] == 0x0b && Buffer[13]==0xC3 ) {
ozane_Status=One;
startTime=millis();
Serial.println("-");
Serial.println(msoMs);
Serial.println(msrMs);
Serial.println(msm3Ms);
Serial.println(msm4Ms);
Serial.println(mstMs);
}
}
}
if (ozane_Status == One && millis() - startTime >= msoMs) {
ozane_Status=Zero;
Serial.println("hello from ozone");
}
digitalWrite(ozane, ozane_Status);
}