I am trying to fetch data from my weatherstation sending this every second
Data from tcpdump;
>
> E..(......^............P...2;2YrP.......
> 04:59:10.442725 IP WeatherStation.53724 > raspberrypi.http: Flags [F.], seq 630, ack 485, win 5276, length 0
> E..(......^............P...2;2YrP.......
>
> 04:59:10.608802 IP WeatherStation.61637 > 192.168.1.255.59387: UDP, length 47
> E..K......]..............7......,..M..........EasyWeatherPro-10EED6 V5.1.1.
the above line repeats every second
This every 10'th seconds
> E..(......^............P....O...P....k..
> 04:59:26.403455 IP WeatherStation.53725 > raspberrypi.http: Flags [P.], seq 0:630, ack 1, win 5760, length 630: HTTP: POST easyweather HTTP/1.1
> E.........\,...........P....O...P...#...POST easyweather HTTP/1.1
This is the data i want:
> HOST: 192.168.1.21
> Connection: Close
> Content-Type: application/x-www-form-urlencoded
> Content-Length:492
>
> PASSKEY=F33E247FAB61AEBFC52270E8FA784A8F&stationtype=EasyWeatherPro_V5.1.1&runtime=4&dateutc=2023-08-01+03:59:25&tempinf=70.3&humidityin=46&baromrelin=29.834&baromabsin=29.264&tempf=49.6&humidity=95&winddir=198&windspeedmph=0.00&windgustmph=0.00&maxdailygust=0.00&solarradiation=10.04&uv=0&rainratein=0.000&eventrainin=0.000&hourlyrainin=0.000&dailyrainin=0.000&weeklyrainin=0.020&monthlyrainin=0.000&yearlyrainin=0.020&totalrainin=0.020&wh65batt=0&freq=868M&model=WS2900_V2.01.18&interval=10**
This curl code is similar to the thread; PHP file_get_contents() returns "failed to open stream: HTTP request failed!"
PhP Code
<?php
header("Refresh: 1");
$lurl=get_fcontent("http://WeatherStation");
print_r($lurl);
function get_fcontent( $url, $javascript_loop = 0, $timeout = 5 ) {
$url = str_replace( "&", "&", urldecode(trim($url)) );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_ENCODING, "" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER,true);
$content = curl_exec( $ch );
$response = curl_getinfo( $ch );
curl_close ( $ch );
return array( $content, $response );
}
It seams to only output the header;
[1] => Array ( [url] => http://WeatherStation/ [content_type] => text/html [http_code] => 200 [header_size] => 90 [request_size] => 183 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.115851 [namelookup_time] => 0.088763 [connect_time] => 0.091165 [pretransfer_time] => 0.091338 [size_upload] => 0 [size_download] => 1480 [speed_download] => 12869 [speed_upload] => 0 [download_content_length] => 1480 [upload_content_length] => -1 [starttransfer_time] => 0.100347 [redirect_time] => 0 [redirect_url] => [primary_ip] => 192.168.1.7 [certinfo] => Array ( ) [primary_port] => 80 [local_ip] => 192.168.1.103 [local_port] => 45696 [http_version] => 2 [protocol] => 1 [ssl_verifyresult] => 0 [scheme] => HTTP [appconnect_time_us] => 0 [connect_time_us] => 91165 [namelookup_time_us] => 88763 [pretransfer_time_us] => 91338 [redirect_time_us] => 0 [starttransfer_time_us] => 100347 [total_time_us] => 115851 [effective_method] => GET ) )