u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
287 stars 82 forks source link

u_cell_mqtt module issue #197

Closed AntonZyma closed 5 months ago

AntonZyma commented 5 months ago

Hi!

I've found an issue when working with MQTT over SARA-R5 modem. When reading an MQTT message that doesn't fit into the buffer provided to the uMqttClientMessageRead(), the function will not return U_ERROR_COMMON_TRUNCATED, but the failure will be reported.

The issue is that uAtClientReadBytes() must be used with standalone parameter set to true in case uAtClientIgnoreStopTag() has been called. So, the only function call that happens with "truncated" state is done wrong. This leads to the improper operation of the readMessage() function.

https://github.com/u-blox/ubxlib/blob/9ce2d92bb594f7d4010964a57ca2a28d9cf902f9/cell/src/u_cell_mqtt.c#L2068

Could you please check this and similar possible issues across the library?

Thanks, Anton

RobMeades commented 5 months ago

Hi, and thanks for spotting this. I really should have followed my own advice :-).

Searching for uAtClientIgnoreStopTag() throughout the code, as far as I can tell all other cases are fine, testing fix now.

RobMeades commented 5 months ago

I've also pushed a preview branch with the fix here:

https://github.com/u-blox/ubxlib/tree/preview_fix_cell_mqtt_truncate_rmea

...if you would like to check that it does the trick yourself.

AntonZyma commented 5 months ago

Thanks @RobMeades !

RobMeades commented 5 months ago

Now pushed here in commit https://github.com/u-blox/ubxlib/commit/928ee28a6799bc7be2351c27d81bf88a7ed75335; I will close this issue and will delete the preview branch some time next week.