How to subscribe to receive any float number

Hi,
I am trying to send float number to Core module over the radio via MQTT but I am having an issue with receiving. On the Core module side, I am seeing only a subset of the messages that I am sending over.

For example, in my custom firmware testing handler function is defined like this:

void debug_handler(uint64_t *id, const char *topic, void *value, void *param)
{
    float_t num = *(float_t*)value;
    bc_log_info("Handler triggered with value (%0.2f)", num);
}

and then registered using:

bc_radio_sub_t subs[] = {
    {"usage/-/total/float", BC_RADIO_SUB_PT_FLOAT, debug_handler, NULL}
};

bc_radio_set_subs(subs, sizeof(subs)/sizeof(subs[0]));

And when I am sending these float numbers to MQTT broker via Mosquitto:

# for i in {0..9}; do NUM="50.$i"; echo $NUM; mosquitto_pub -t "node/demo-device:0/usage/-/total/float"  -u homeassistant -P ath15 -m $NUM; sleep 1 ; done
50.0
50.1
50.2
50.3
50.4
50.5
50.6
50.7
50.8
50.9

In the debugging session of the Core module attached to my computer I am seeing that only two messages are actually received:

3.59 <I> Handler triggered with value (50.00)
8.56 <I> Handler triggered with value (50.50)

Is there something I am missing in my code to be able to receive any float number?

Thank you for any advice!

Vladimír

Hi Vladimír,

does it receive every time the same 2 values, or are they different every time you run the bash command?

I use custom topics and I can send a 20 ccharacter text at least 5 times a second without any issue and delay.

Do you have the latest firmware in the Radio Dongle?
Do you have the latest SDK in your project? Command make update will update the SDK.
Can you share the code? Create a ZIP file of /app folder. That way I could test exactly the same code.

Hi Martin,
thank you for your time with testing on your device.

In my testing, I always received the .00 and .50 numbers, regardless of what the whole number was before the separator and the order of the numbers also didn’t matter.

If I send integers, I am receiving everything so I got an impression that I am doing something wrong in my code with the handling of float numbers.

BTW I’ve also tried to send any character string registered to another handler with BC_RADIO_SUB_PT_STRING and those strings were never received also by Core module.

For the radio dongle it seems to be running the latest version available:

gateway/usb-dongle/info {"id": "1b770267f038", "firmware": "bcf-gateway-usb-dongle", "version": "v1.13.0"}

And my firmware was built against an older version of SDK, so I will try to recompile it against the latest, but I would be able to upload it to the device this week as I don’t have physical access to the Core module right now.

Also I’ve uploaded my code to Github repo if it would help. In app/application.c file is the function counter_set_handler_float (https://github.com/machv/bcf-gas-meter/blob/master/app/application.c#L144) which is receiving only a subset of the float numbers sent.