Hi,
does anyone have some example of subscribing of custom MQTT mesage? I suppose it is necessary to set radio module to listening bc_radio_init(BC_RADIO_MODE_NODE_LISTENING); but I am not sure what to do after that. I am also not sure if it is also possible to send MQTT messages in listening mode.
I know that there is some example for power module, but it is not used for listening custom message. I would like to receive some values (intervals how frequently measure some values) and use these values instead of constants.
we did not documented that yet, but its fully functional.
Here I register topic for servo
And then you call this structure in init:
Here’s more topic for 1-wire relays
This functionality was added later and we would like to rewrite older projects to use this dynamic radio subscriptions, then the Dongle does not need to have these topics hard-coded.
My guess is that you have to keep the MQTT topic topic “tree-depth”:
denkovi-relay/q4/state/set
So the format should be
x/y/z/Ĺľ
I think that bcg gateway is using some wildcards ? in the MQTT topics. We did this probably so it is similar to existing style of topics.
let me know the result, send me application.c if you could not get it work.
Also try to update the dongle firmware. I think that anything above 1.8.0 is fine, but please test the latest version as the last option.
OK, I will try it at home at the evening. If I understand correctly, it is needed to keep same structure as using other devices in opposite way (publishing). In my case for getting pressure it is: “greenhouse_climate/barometer/0:0/pressure”. I will try to publish “greenhouse_climate/barometer/0:0/update_interval”
But I am not sure if it is correct that is not possible to subscribe message without this tree. For example when I would like to use some attribute of whole climate kit (core module) It should not be necessary to use this structure. Similar case is, when I would like to subscribe all topics “#”…
In this time, the structure of the subject is solid. Wildcard as # or + doesn’t supported.
You register a/b/c/d for example denkovi-relay/q4/state/set and node added gateway and id added dongle. Result subscibe topic is node//denkovi-relay/q4/state/set .
But we are planning to support a different structure of the topic. However, it should not be forgotten that 868Mhz is not wifi, there is a limited number of messages.
Thank you, for your help, but I it is still not working. I tried to subscribe topic in recommended format. But it doesn’t help. I also tried to update dongle firmware with this command: bcf flash --device /dev/ttyUSB0 bigclownlabs/bcf-gateway-usb-dongle:latest but it still doesn’t work. I am attaching link to file with my code with my examples. Can you please check, what I am doing wrong? Thank you very much.
I tried these payload messages:
node//greenhouse_climate/barometer/update/interval
node/greenhouse_climate/barometer/update/interval
greenhouse_climate/barometer/update/interval
I’m sorry, I overlooked that. I was focused on that commented line and searching for other BC_RADIO_MODE_NODE_SLEEPING in the code, which was stupid.
Now that I have the code I try to test it. I’m not sure if I can do it today. I’ll keep you informed.
There’s also other thing.
The module itself pairs as a climate-monitor:0, I guess that you renamed the module alias to the “greenhouse_climate”, but this name cannot be in the C code. This alias is appended automatically by gateway.
So if your code would work (there’s that topic length bug maybe) then you would need to add another greenhouse_climate to the topic:
node/greenhouse_climate/greenhouse_climate/barometer/update/interval NODE ALIAS
I’ll try to debug the code and let you know later today.
Also if you run bcg manually with --debug, and after it start you reset the climate module, you will see the registration of the dynamic topic (the last line in the debug output below)
Hi, I have one more question about payloads types. Which types of payload are supported? I tried to use same as for publishing, but UINT32 looks that doesn’t work. Or is it needed to use some different format then “BC_RADIO_SUB_PT_UINT32”?
Thank you
I have written this code and ran into the same problem with topic subscription. With topic “barometer/-/interval/set” it works great and for example with topic a/b/c/d, or owar/lcd/temperature/set it does not.
I had similar issues with the topic name, but in my case it doesn’t work too long topics (more than ± 55 characters) or when the topic was too short (or in shorten structure - for example xx/yy).
It is strange that “barometer/-/interval/set” works and “owar/lcd/temperature/set” not… (same structure, similar number of characters)
for me works for example:
“core/barometer/-/val-change/set” (the longest one which I am using)
“core/-/sleep-period/set” (the shortest one which I am using)
It should also work in your code… If not, problem is probably not in the topic name.