简体   繁体   English

使用 Paho MQTT C 和 C++ 库交叉编译代码导致使用非零 QoS 发布时出现问题

[英]Cross compiling code using Paho MQTT C & C++ libraries causing issues when publishing with a nonzero QoS

I have tried cross-compiling some small C++ code for a Raspberry Pi Model 3b using my Windows machine via Ubuntu-20.04 on WSL2.我尝试使用我的 Windows 机器通过 WSL2 上的 Ubuntu-20.04 为 Raspberry Pi Model 3b 交叉编译一些小的 C++ 代码。 It uses the Paho MQTT C and C++ libraries to subscribe to and sometimes publish some messages.它使用 Paho MQTT C 和 C++ 库来订阅和有时发布一些消息。 I'm pretty sure that most of it works since MQTT subscriptions work, as well as publishing messages using a QoS of 0.我很确定它的大部分工作都是因为 MQTT 订阅工作,以及使用 0 的 QoS 发布消息。

However, when publishing with a QoS of 1 or 2, I get a runtime error: MQTT error [-9]: Invalid QoS value但是,当使用 1 或 2 的 QoS 发布时,我收到运行时错误: MQTT error [-9]: Invalid QoS value

When I try publishing with a QoS less than 0 or greater than 2, I get this instead: MQTT error [-9]: Bad QoS当我尝试使用小于 0 或大于 2 的 QoS 进行发布时,我得到的是: MQTT error [-9]: Bad QoS

I have compiled the same code in the RPi itself and the code runs without any issues.我在 RPi 本身中编译了相同的代码,并且代码运行没有任何问题。

I'm not completely sure what is happening, but I tried checking why I'm getting the same reason code but different error messages.我不完全确定发生了什么,但我尝试检查为什么我得到相同的原因代码但不同的错误消息。 It appears that the Bad QoS message is written in mqtt/message.h, which can be found in the C++ library, while the Invalid QoS Value can be found in MQTTAsync.c, from the C library. It appears that the Bad QoS message is written in mqtt/message.h, which can be found in the C++ library, while the Invalid QoS Value can be found in MQTTAsync.c, from the C library.

As far as I know MQTT only supports 3 levels of QoS.据我所知,MQTT 仅支持 3 级 QoS。 QoS 0, 1 and 2. Thus using "QoS less than 0 or greater than 2" will indeed give the "Invalid QoS Value" Error. QoS 0、1 和 2。因此使用“QoS 小于 0 或大于 2”确实会给出“无效的 QoS 值”错误。 I suspect cross compilation is doing something unintended.我怀疑交叉编译正在做一些意想不到的事情。 It would be great if you could share more information about the project.如果您可以分享有关该项目的更多信息,那就太好了。 Like What MQTT broker do you use?比如你使用什么 MQTT 代理? How do you cross compile etc.你如何交叉编译等。

Thank You.谢谢你。 Naveen PS纳文 PS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM