From abb0bc7bae9ee76bb45ef58b3db608024e13c9a3 Mon Sep 17 00:00:00 2001 From: "Christian W. Zuckschwerdt" Date: Tue, 24 Oct 2023 10:21:21 +0200 Subject: [PATCH] Add php example stream script (closes #2687) Co-authored-by: AutomGuy --- examples/rtl_433_custom.php | 3 +- examples/rtl_433_http_stream.php | 84 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 examples/rtl_433_http_stream.php diff --git a/examples/rtl_433_custom.php b/examples/rtl_433_custom.php index 1c298c37..bcd0a035 100755 --- a/examples/rtl_433_custom.php +++ b/examples/rtl_433_custom.php @@ -19,7 +19,7 @@ Restart=always RestartSec=5 RemainAfterExit=no User=root -ExecStart=/bin/sh -c "/usr/bin/rtl_433 -f 433920000 -f 433920000 -H 120 -F syslog:127.0.0.1:1433" +ExecStart=/bin/sh -c "/usr/bin/rtl_433 -f 433.92M -F syslog:127.0.0.1:1433" [Install] WantedBy=multi-user.target @@ -105,4 +105,3 @@ for (;;) } } ?> - diff --git a/examples/rtl_433_http_stream.php b/examples/rtl_433_http_stream.php new file mode 100644 index 00000000..b62db9fc --- /dev/null +++ b/examples/rtl_433_http_stream.php @@ -0,0 +1,84 @@ +#!/usr/bin/php +\n"; +} else { + fwrite($fp, "GET / HTTP/1.0\r\nHost: " . $adr . "\r\nAccept: */*\r\n\r\n"); + while (!feof($fp)) { + $line = fgets($fp, 1024); + //time is available in all received records, that is the filter word + //for sensor data + if(str__contains($line,"time")) + { + //raw output of json + print_r($line); + /* + do something with content of $line + for example decode $line into an array + $arr = json_decode($line,true); + + do something with that array and + output into a file as json + file_put_contents('test.json', json_encode($arr, JSON_PRETTY_PRINT); + */ + } + } + fclose($fp); +} +?>