phpMQTT | simple php class to connect/publish/subscribe to a MQTT | Pub Sub library
kandi X-RAY | phpMQTT Summary
kandi X-RAY | phpMQTT Summary
2020 Update I am restarting the project so watch this space. Blue Rhinos Consulting Andrew Milsted | andrew@bluerhinos.co.uk | | @bluerhinos. A simple php class to connect/publish/subscribe to an MQTT broker. Documentation: Coming Soon Source:
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Connect to the server
- Process a command
- Process a message
- Publishes content to the socket
- Subscribes to the socket
- Read from socket
- Subscribes to a specific topic .
- Sets the size of the given length .
- Prints a string
- Get the length of a message
phpMQTT Key Features
phpMQTT Examples and Code Snippets
Community Discussions
Trending Discussions on phpMQTT
QUESTION
I'm trying to figure something out here
I have a 'sequence' to be executed via a serial port (on an RPI).
I have an supervisored PHP command in Laravel running that connects to a MQTT broker.
When I send a message to that broker, the RPI picks it up and processes it. Now, I have a moment in which I wait for user interaction. The issue here is, sometimes the user does not interact with the system and the PI keeps "waiting" for serial data. When a user presses a button, I get serial data, which I can process.
I tried to use a while (true) {}
loop that reads the serial data, but it just stops suddenly. Here is some example code;
ANSWER
Answered 2021-Dec-05 at 12:15If you look at the source of lepiaf\SerialPort you'll find it sets the stream in non blocking mode, however the read method does an infinite loop until it finds the separator. This means it will never return unless the separator is received, and depending on your configuration your script will be killed once the php max execution time is reached. Since the library is very simple the better option is to edit the read method adding a timeout parameter. Edit the file "lepiaf/SerialPort/SerialPort.php", scroll down to the read method (line 107) and change it as follows:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install phpMQTT
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page