php based mqtt client - receive status
Budget: $10 – $40 USD
We are testing IOT devices using the MQTT protocol and having some trouble.
The main assumption is that all the communication is made between the webapp and the message broker as per the publish/subscribe model that does not allow a direct communication with the IOT device.
We are playing with a smart power strip that has 5 outlets and what we want to achieve is:
- know the status of the five plugs (on or off)
- being able to toggle the status of each of them
All this has been done using a PHP library named "php-mqtt/client" which mainly simplifies the interaction with the message broker and uses an embedded client to talk with the MQTT message broker.
What was achieved:
- being able to change status
What was NOT achieved:
- getting the feedback from the message broker
- subscribe to the message broker to see the plug's status change
In every example that I saw, the idea is to first subscribe to a topic that will show me the result of any publish sent to the device and then send the publish message.
In my mind this should be an async process but it is not clear to me how this could be done within the same code (without involving other languages or different elements)
If I test manually using a mosquitto_pub/sub command I can see the direct feedback from the message broker but when I run the "$client->publish()" I dont get any "feedback" that I can evaluate to know the command was received correctly.
I need someone to explain to me how this could be done so that the php client can get instant status updates.
The main assumption is that all the communication is made between the webapp and the message broker as per the publish/subscribe model that does not allow a direct communication with the IOT device.
We are playing with a smart power strip that has 5 outlets and what we want to achieve is:
- know the status of the five plugs (on or off)
- being able to toggle the status of each of them
All this has been done using a PHP library named "php-mqtt/client" which mainly simplifies the interaction with the message broker and uses an embedded client to talk with the MQTT message broker.
What was achieved:
- being able to change status
What was NOT achieved:
- getting the feedback from the message broker
- subscribe to the message broker to see the plug's status change
In every example that I saw, the idea is to first subscribe to a topic that will show me the result of any publish sent to the device and then send the publish message.
In my mind this should be an async process but it is not clear to me how this could be done within the same code (without involving other languages or different elements)
If I test manually using a mosquitto_pub/sub command I can see the direct feedback from the message broker but when I run the "$client->publish()" I dont get any "feedback" that I can evaluate to know the command was received correctly.
I need someone to explain to me how this could be done so that the php client can get instant status updates.