First off thank you to @floitsch for his in depth ...
# help
m
Using the code below I get the error report, but if I comment out 'Debug Message:' so the debug message becomes part of report: it doesn't error. ** Start code
Copy code
transport := 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 ******************************************************************************
f
It's hard to tell exactly what's going on. Please use triple backticks to enclose your code, so it gets easier to read. See, https://gist.github.com/matthewzring/9f7bbfd102003963f9be7dbcf7d40e51#code-blocks My guess is, that the client isn't yet running. When using the
FullClient
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.
m
@floitsch thank you once more your help is so appreciated. I will use triple backticks in future (I hadn't found that yet) and yes I will convert to using client instead of full client.
Using just MQTT client solved my problem Thank you.