This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
uphp:functions:mqtt_subscribe [2017/09/27 11:05] admin |
uphp:functions:mqtt_subscribe [2019/11/29 05:12] admin |
||
---|---|---|---|
Line 8: | Line 8: | ||
<well size=" | <well size=" | ||
- | <span style=" | + | <span style=" |
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
Line 30: | Line 30: | ||
<code php> | <code php> | ||
<? | <? | ||
- | |||
// Use the # as a wildcard so any messages to /cluster/1/ or its sub channels will be received | // Use the # as a wildcard so any messages to /cluster/1/ or its sub channels will be received | ||
Line 38: | Line 37: | ||
====Example Callback==== | ====Example Callback==== | ||
- | Callbacks can use the php://stdin file to read input. | + | Callbacks can use the '' |
<code php> | <code php> | ||
Line 44: | Line 43: | ||
$f=fopen(" | $f=fopen(" | ||
$st=fgets($f); | $st=fgets($f); | ||
- | | + | $msg=fgets($f); |
- | $response=""; | + | $response=""; |
- | if (substr($msg, | + | if (substr($msg, |
- | $variable=substr($msg, | + | $variable=substr($msg, |
- | $response=$variable.":" | + | $response=$variable.":" |
- | } | + | } |
if (strpos($st, | if (strpos($st, | ||
- | | + | if (strpos($st," |
- | + | mqtt_publish("/ | |
- | | + | } else { |
- | } else { | + | if (strpos($st," |
- | if (strpos($st," | + | print(" |
- | print(" | + | } |
- | } | + | } |
- | } | + | |
} | } | ||
?> | ?> | ||
</ | </ | ||
+ | |||
+ | ====Note===== | ||
+ | On WattmonPRO & MINI the maximum packet size is 128 bytes. | ||
+ | |||
====See Also==== | ====See Also==== | ||
[[mqtt_publish()]] - Publish to an MQTT channel | [[mqtt_publish()]] - Publish to an MQTT channel | ||