简体   繁体   English

MQTT中回调有什么用?

[英]What is the use of callback in MQTT?

I am trying to implement a weather monitoring system using Arduino and MQTT protocol.我正在尝试使用 Arduino 和 MQTT 协议实现天气监测系统。 While trying to understand the code behind this, I have come across a function:在试图理解这背后的代码时,我遇到了一个函数:

void callback(char* topic, byte* payload, unsigned int length) {
}

So, my question is, what exactly is this function used for in MQTT?所以,我的问题是,这个函数在 MQTT 中究竟是做什么用的? If someone explains to me or links a tutorial that will be useful.如果有人向我解释或链接一个有用的教程。 Thanks in advance!提前致谢!

This function is called by the underlying MQTT library when a new message is received from the broker (for a topic you have subscribed to).当从代理接收到新消息(对于您订阅的主题)时,底层 MQTT 库会调用此函数。

It is up to you to fill in the detail of how you want to process the message.您可以填写有关如何处理消息的详细信息。

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

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