Browse code

added sync, low, high to get433info table

Liviu Pislaru authored on 11/09/2018 10:17:20
Showing 1 changed files
... ...
@@ -108,9 +108,9 @@ while (my $mqttMessage = <$SUB> ) {
108 108
       if ($queue eq "RESULT"){ # topic nou sonoff v6.2.1 sonoff bridge
109 109
         my $decoded = decode_json($json);
110 110
         if (exists $decoded->{'RfReceived'}{'Data'}){
111
-          addRF ($topic, "Data", $decoded->{'RfReceived'}{'Data'});
111
+          addRF ($topic, $decoded->{'RfReceived'}{'Sync'}, $decoded->{'RfReceived'}{'Low'}, $decoded->{'RfReceived'}{'High'}, $decoded->{'RfReceived'}{'Data'});
112 112
         }
113
-      }            
113
+      }
114 114
       if ($queue eq "ESP"){
115 115
         my $decoded = decode_json($json);
116 116
         if (exists $decoded->{'Temp'}){     
... ...
@@ -238,11 +238,11 @@ sub delDB {
238 238
 
239 239
 # adaug/updatez in tabela get433info din baza de date 
240 240
 sub addRF {
241
-  (my $topic, my $camp, my $valoare) = @_;
241
+  (my $topic, my $sync, my $low, my $high, my $data) = @_;
242 242
   (my $user, my $devid) = split /\-/, $topic;
243
-  my $query = "insert into get433info values (?, ?, ?, ?) on duplicate key update camp=?";
243
+  my $query = "insert into get433info values (?, ?, ?, ?, ?, ?) on duplicate key update data=?";
244 244
   my $sth = $dbh->prepare($query) or die "Can't prepare $query: $dbh->errstr\n";
245
-  $sth->execute("$user", "$devid", "$camp", "$valoare", "$camp");
245
+  $sth->execute("$user", "$devid", "$sync", "$low", "$high" "$data", "$data");
246 246
   $sth->finish();
247 247
   return;
248 248
 }