Macca
04/07/2023, 2:55 AMtransport := mqtt.TcpTransport net.open --host=HOST --port=PORT
client := mqtt.FullClient --transport=transport
options := mqtt.SessionOptions --client_id=CLIENT_ID
unsubscribed_latch := monitor.Latch
// ------------------------------------------------------------------
report:
Temp /string := ""
temperatures.do: Temp = it //client.publish "$TOPIC_PREFIX/temps" it.to_byte_array --qos=1
DS18B20_Ids.do:client.publish "$TOPIC_PREFIX/" + it Temp.to_byte_array --qos=1
// ------------------------------------------------------------------
Debug Message:
client.publish "$TOPIC_PREFIX/Debug" Message.to_byte_array
// ------------------------------------------------------------------
main:
task:: MQTT
Debug "Started"
Decoding by jag
, device has version
******************************************************************************
Class 'Null_' does not have any method 'pending_count'.
0: FullClient.publish. /full_client.toit:964:43
1: Signal.wait. /monitor.toit:153:17
2: __Monitor__.locked_. /core/monitor_impl_.toit:123:12
3: __Monitor__.locked_ /core/monitor_impl_.toit:95:3
4: Signal.wait /monitor.toit:152:3
5: FullClient.publish /full_client.toit:964:28
6: Debug HWS_Monitor.toit:48:10
7: main HWS_Monitor.toit:54:3
******************************************************************************floitsch
04/07/2023, 1:02 PMFullClient
you need to call connect
and handle
. See an example here: https://github.com/toitware/mqtt/blob/main/examples/full_client.toit
When using the standard Client
you only need to call start
.
See an example here: https://github.com/toitware/mqtt/blob/main/examples/publish.toit
Generally the Client
is easier to use, so I would recommend that one, unless you need more features.Macca
04/08/2023, 12:09 AMMacca
04/11/2023, 12:30 AM