From 24df57265e413b28aee13bf0a475eb4f5dc4c6ae Mon Sep 17 00:00:00 2001 From: weigang Date: Fri, 14 Aug 2020 14:54:44 +0800 Subject: [PATCH] Debug (cherry picked from commit b789d72128d10d4f0d33dc208c055d83685975db) --- app/Libs/MQTTClient.php | 6 +++++- app/Service/MqttSpeakerService.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Libs/MQTTClient.php b/app/Libs/MQTTClient.php index 56584c0..7c02ad7 100644 --- a/app/Libs/MQTTClient.php +++ b/app/Libs/MQTTClient.php @@ -218,6 +218,8 @@ class MQTTClient { * @return boolean Returns false if connection failed */ public function sendConnect($clientId, $cleanSession=false, $keepAlive=10, $timeout=5000) { + + var_dump('serverAddress', $this->serverAddress); if (!$this->serverAddress) return false; // Basic validation of clientid @@ -390,8 +392,9 @@ class MQTTClient { * @return boolean */ public function sendPublish($topic, $message, $qos = self::MQTT_QOS1, $retain = 0) { + var_dump('connect:', $this->isConnected()); if(!$this->isConnected()) return false; - +var_dump('sendpublish', [$topic, $message, $qos]); if($qos!=self::MQTT_QOS0 && $qos!=self::MQTT_QOS1 && $qos!=self::MQTT_QOS2) return false; $packetId = $this->getNextPacketId(); @@ -405,6 +408,7 @@ class MQTTClient { $dupFlag = 0; $header = $this->createHeader(self::MQTT_PUBLISH + ($dupFlag<<3) + ($qos<<1) + $retain, $payload); $this->debugMessage('Sending PUBLISH'); + var_dump('sendpublish-$payload', $header.$payload); $this->send($header . $payload); if($qos == self::MQTT_QOS1) { diff --git a/app/Service/MqttSpeakerService.php b/app/Service/MqttSpeakerService.php index 080e0c1..617eb3a 100644 --- a/app/Service/MqttSpeakerService.php +++ b/app/Service/MqttSpeakerService.php @@ -76,7 +76,7 @@ class MqttSpeakerService implements MqttServiceInterface $curClientId OR $curClientId = (string)rand(1,999999999); $success = $client->sendConnect($curClientId); - + var_dump('$success', $success); if ($success) { $client->sendPublish($topic, json_encode($msgArr), MQTTClient::MQTT_QOS2); $client->sendDisconnect();