Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Missing file in commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan-Langlais committed Apr 3, 2021
1 parent 0b66aec commit 3113cba
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/YeePHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ protected function connect(): bool
$sock = fsockopen($this->lightIP, $this->lightPort, $errCode, $errStr, 30);
if (!$sock) return false;

// stream_set_blocking($sock, false);
stream_set_blocking($sock, false);
$this->socket = $sock;

return true;
Expand Down Expand Up @@ -451,10 +451,11 @@ protected function makeRequest(array $job): ?array
fwrite($this->socket, $requestStr);
fflush($this->socket);

// usleep(100 * 1000); // 0.7s -> wait for the light response
usleep(100 * 1000); // 0.7s -> wait for the light response


$res = fgets($this->socket);
$res = '';
while ($out = stream_get_line($this->socket, 4096, "\r\n"))
$res = $out;


$result = null;
Expand All @@ -464,10 +465,10 @@ protected function makeRequest(array $job): ?array

if (!array_key_exists('error', $res) && array_key_exists('result', $res))
$result = $res['result'];
} else {
throw new Exception('No response received from device !');
}

var_dump($requestStr, json_encode($res));

return $result;
}

Expand Down

0 comments on commit 3113cba

Please sign in to comment.