|
OpenHarmony上利用Paho MQTT连接云平台
|
Abstract:
在物联网设备与云端之间的通信中,MQTT作为一种轻量级的、基于发布-订阅模式的通信协议,具备了良好的适用性和灵活性,被广泛应用于物联网领域。在OpenHarmony的LiteOS内核上利用MQTT连接云平台是一项关键的技术任务,它涉及在轻量级操作系统上实现MQTT协议的客户端功能,并与云端平台进行稳定和高效的通信,因此需要选择合适的MQTT库,并进行有效的移植和优化,以保证在资源受限的环境下依然能够实现稳定可靠的通信连接。海思Hi3861芯片采用了LiteOS内核。文章探讨了在海思Hi3861芯片上移植和使用Paho MQTT库连接到华为云的实现过程和关键技术。文章首先介绍了MQTT的相关知识,然后详细讨论了嵌入式Paho MQTT库的内容,接着介绍Hi3861芯片相关功能及其移植Paho MQTT的方式,最后描述了使用移植好的程序连接华为云MQTT的步骤,包括设备鉴权方式和消息发布订阅的实现。实验结果验证了在Hi3861平台上使用Paho MQTT库连接到华为云的可行性和效果。文章的结尾探讨了项目未来的工作。
In the communication between IoT devices and the cloud, MQTT, as a lightweight, publish-subscribe communication protocol, offers excellent applicability and flexibility, making it widely used in the IoT field. Utilizing MQTT to connect to cloud platforms on OpenHarmony’s LiteOS kernel is a critical technical task. It involves implementing MQTT client functionality on a lightweight operating system and establishing stable and efficient communication with the cloud platform. Therefore, choosing an appropriate MQTT library and conducting effective porting and optimization are crucial to ensure reliable communication connections in resource-constrained environments. The Hisilicon Hi3861 chip utilizes the LiteOS kernel. This article discusses the process and key technologies of porting and using the Paho MQTT library to connect to Huawei Cloud on the Hisilicon Hi3861 chip. The article begins with an introduction to MQTT concepts, followed by a detailed discussion of the embedded Paho MQTT library. It then covers the features of the Hi3861 chip and how to port Paho MQTT to it. Finally, it describes the steps to connect to Huawei Cloud MQTT using the ported application, including device authentication methods and the implementation of message publishing and subscription. Experimental results validate the feasibility and effectiveness of using the Paho MQTT library to connect to Huawei Cloud on the Hi3861 platform. The article concludes with a discussion on future project directions.
[1] | Vanani, K., Patoliya, J. and Patel, H. (2016) A Survey: Embedded World around MQTT Protocol for IoT Application. International Journal for Scientific Research and Development, 4, 26-29. |
[2] | Light, R.A. (2017) Mosquitto: Server and Client Implementation of the MQTT Protocol. The Journal of Open Source Software, 2, Article 265. https://doi.org/10.21105/joss.00265 |
[3] | Eclipse Paho (2024) Eclipse Paho. https://eclipse.dev/paho/ |
[4] | 海思官网. Hi3861LV100产品简介[EB/OL]. https://www.hisilicon.com/cn/products/connectivity/short-range-IoT/wifi-nearlink-ble/Hi3861V100, 2024-06-27. |
[5] | 何进, 谢松巍. 基于Socket的TCP/IP网络通讯模式研究[J]. 计算机应用研究, 2001(8): 134-135. |