Browse Source

喇叭播报调整

master
weigang 5 years ago
parent
commit
9820a42aff
  1. 2
      app/Libs/MQTTClient.php
  2. 6
      app/Service/FeiePrintService.php
  3. 2
      app/TaskWorker/MQTTClientTask.php

2
app/Libs/MQTTClient.php

@ -322,7 +322,7 @@ class MQTTClient {
} }
// Set socket timeout // Set socket timeout
ini_set('default_socket_timeout', 10);
ini_set('default_socket_timeout', '10');
stream_set_timeout($this->socket, 0, $this->socketTimeout * 1000); stream_set_timeout($this->socket, 0, $this->socketTimeout * 1000);
// Set stream to non-blocking mode, ie do not wait to read if stream is empty // Set stream to non-blocking mode, ie do not wait to read if stream is empty
stream_set_blocking($this->socket, true); stream_set_blocking($this->socket, true);

6
app/Service/FeiePrintService.php

@ -141,7 +141,7 @@ class FeiePrintService implements FeiePrintServiceInterface
$m = $m+$j; $m = $m+$j;
$tail = $new; $tail = $new;
// $lenght = iconv("UTF-8", "GBK//IGNORE", $new); // $lenght = iconv("UTF-8", "GBK//IGNORE", $new);
$k = $A - mb_strlen($new);
$k = $A - mb_strlen($new,'utf-8');
for($q=0;$q<$k;$q++){ for($q=0;$q<$k;$q++){
$kw3 .= ' '; $kw3 .= ' ';
} }
@ -166,7 +166,7 @@ class FeiePrintService implements FeiePrintServiceInterface
foreach ($result as $key=>$value) { foreach ($result as $key=>$value) {
if($key < 1){ if($key < 1){
// $v_lenght = iconv("UTF-8", "GBK//IGNORE", $value); // $v_lenght = iconv("UTF-8", "GBK//IGNORE", $value);
$v_lenght = mb_strlen($value);
$v_lenght = mb_strlen($value,'utf-8');
if($v_lenght == 13) $value = $value." "; if($v_lenght == 13) $value = $value." ";
$head .= $value.' '.$price.' '.$num.' '.$prices; $head .= $value.' '.$price.' '.$num.' '.$prices;
}else{ }else{
@ -213,7 +213,7 @@ class FeiePrintService implements FeiePrintServiceInterface
$str = $user_name . $total; $str = $user_name . $total;
$kw5 = ''; $kw5 = '';
// $lenght = iconv("UTF-8", "GBK//IGNORE", $str); // $lenght = iconv("UTF-8", "GBK//IGNORE", $str);
$total_len = 32 - mb_strlen($str);
$total_len = 32 - mb_strlen($str,'utf-8');
for ($q = 0; $q < $total_len; $q++) { for ($q = 0; $q < $total_len; $q++) {
$kw5 .= ' '; $kw5 .= ' ';
} }

2
app/TaskWorker/MQTTClientTask.php

@ -41,7 +41,7 @@ class MQTTClientTask
$topic .= '/'.$toClientId; $topic .= '/'.$toClientId;
} }
$curClientId OR $curClientId = rand(1,999999999);
$curClientId OR $curClientId = (string)rand(1,999999999);
$success = $this->mqttClient->sendConnect($curClientId); $success = $this->mqttClient->sendConnect($curClientId);
if ($success) { if ($success) {

Loading…
Cancel
Save