Due to issues documented here I chose an alternative method for a Google Assistant driven IR remote control project I'm working on. The method uses MQTT based on this article and utilizes Adafruit IO to provide the MQTT Broker service.
However I am encountering a problem subscribing to the topic (feed) on Adafruit IO.
Here is the relevant section of my code:
The resultant log is:
However the "channel" topic (feed) is available and if I subscribe using a wildcard via the following code:
The resultant log does not show a subscription error and on changing the channel topic value it shows those values are received OK, but in the multiple formats provided by Adafruit IO:
Of course I can filter the received messages to extract just the data I require, but looking forward to when I may have multiple topics (feeds), it would be preferable to subscribe specifically to the desired topic (feed).
Incidentally while the MQTT API Documentation suggests using "+" in lieu of "#" as a wildcard would eliminate the /csv feed, when trying that I received a subscription error:
Has anyone had experience subscribing to topics (feeds) on Adafruit IO and if so, what syntax did you find allowed subscription to the desired topic (feed)?
However I am encountering a problem subscribing to the topic (feed) on Adafruit IO.
Here is the relevant section of my code:
B4X:
Sub ConnectToBroker(unused As Byte)
If mqtt.Connect = False Then
Dim mo As MqttConnectOptions
mo.Initialize(MQTT_NAME, MQTT_PASS)
mqtt.Connect2(mo)
Log("Trying to connect again")
CallSubPlus("ConnectToBroker", 1000, 0)
Return
End If
Log("Connected to broker")
mqtt.Subscribe("bryond/feeds/channel", 0)
End Sub
Sub Mqtt_MessageArrived (Topic As String, Payload() As Byte)
Log("Message arrived. Topic=", Topic, " payload: ", Payload)
End Sub
The resultant log is:
B4X:
Connected to broker
Message arrived. Topic=anon/errors payload: "subscription to bryond/feeds/channel failed: not available"
However the "channel" topic (feed) is available and if I subscribe using a wildcard via the following code:
B4X:
Sub ConnectToBroker(unused As Byte)
If mqtt.Connect = False Then
Dim mo As MqttConnectOptions
mo.Initialize(MQTT_NAME, MQTT_PASS)
mqtt.Connect2(mo)
Log("Trying to connect again")
CallSubPlus("ConnectToBroker", 1000, 0)
Return
End If
Log("Connected to broker")
mqtt.Subscribe("bryond/feeds/#", 0)
End Sub
The resultant log does not show a subscription error and on changing the channel topic value it shows those values are received OK, but in the multiple formats provided by Adafruit IO:
B4X:
Connected to broker
Message arrived. Topic=bryond/feeds/channel payload: 200
Message arrived. Topic=bryond/feeds/channel/csv payload: 200,,,
Message arrived. Topic=bryond/feeds/963213 payload: 200
Message arrived. Topic=bryond/feeds/963213/csv payload: 200,,,
Message arrived. Topic=bryond/feeds/channel payload: 201
Message arrived. Topic=bryond/feeds/channel/csv payload: 201,,,
Message arrived. Topic=bryond/feeds/963213 payload: 201
Message arrived. Topic=bryond/feeds/963213/csv payload: 201,,,
Of course I can filter the received messages to extract just the data I require, but looking forward to when I may have multiple topics (feeds), it would be preferable to subscribe specifically to the desired topic (feed).
Incidentally while the MQTT API Documentation suggests using "+" in lieu of "#" as a wildcard would eliminate the /csv feed, when trying that I received a subscription error:
B4X:
Message arrived. Topic=anon/errors payload: "subscription to bryond/feeds/+ failed: not available"
Has anyone had experience subscribing to topics (feeds) on Adafruit IO and if so, what syntax did you find allowed subscription to the desired topic (feed)?