This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
uphp:functions:mqtt_subscribe [2017/09/27 10:44] admin created |
uphp:functions:mqtt_subscribe [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 8: | Line 8: | ||
<well size=" | <well size=" | ||
- | <span style=" | + | <span style=" |
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
Line 25: | Line 25: | ||
1 if successful and 0 on failure | 1 if successful and 0 on failure | ||
+ | |||
+ | ====Example==== | ||
+ | |||
+ | <code php> | ||
+ | <? | ||
+ | // Use the # as a wildcard so any messages to /cluster/1/ or its sub channels will be received | ||
+ | |||
+ | mqtt_subscribe("/ | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | ====Example Callback==== | ||
+ | Callbacks can use the '' | ||
+ | |||
+ | <code php> | ||
+ | <? | ||
+ | $f=fopen(" | ||
+ | $st=fgets($f); | ||
+ | $msg=fgets($f); | ||
+ | $response=""; | ||
+ | if (substr($msg, | ||
+ | $variable=substr($msg, | ||
+ | $response=$variable.":" | ||
+ | } | ||
+ | if (strpos($st, | ||
+ | if (strpos($st," | ||
+ | mqtt_publish("/ | ||
+ | } else { | ||
+ | if (strpos($st," | ||
+ | print(" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | ====Note===== | ||
+ | On WattmonPRO & MINI the maximum packet size is 128 bytes. | ||
====See Also==== | ====See Also==== |