WO2023116564A1 - Mqtt communication method and apparatus, electronic device, and storage medium - Google Patents

Mqtt communication method and apparatus, electronic device, and storage medium Download PDF

Info

Publication number
WO2023116564A1
WO2023116564A1 PCT/CN2022/139551 CN2022139551W WO2023116564A1 WO 2023116564 A1 WO2023116564 A1 WO 2023116564A1 CN 2022139551 W CN2022139551 W CN 2022139551W WO 2023116564 A1 WO2023116564 A1 WO 2023116564A1
Authority
WO
WIPO (PCT)
Prior art keywords
mqtt
server
communication
connection
geographic location
Prior art date
Application number
PCT/CN2022/139551
Other languages
French (fr)
Chinese (zh)
Inventor
柳春阳
Original Assignee
锐迪科创微电子(北京)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 锐迪科创微电子(北京)有限公司 filed Critical 锐迪科创微电子(北京)有限公司
Publication of WO2023116564A1 publication Critical patent/WO2023116564A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/52Network services specially adapted for the location of the user terminal
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04QSELECTING
    • H04Q9/00Arrangements in telecontrol or telemetry systems for selectively calling a substation from a main station, in which substation desired apparatus is selected for applying a control signal thereto or for obtaining measured values therefrom

Definitions

  • the present application relates to the field of communication technologies, and in particular to a (Message Queuing Telemetry Transport, MQTT for short) communication method, device, electronic equipment and storage medium.
  • MQTT Message Queuing Telemetry Transport
  • the MQTT protocol is a message protocol based on the publish/subscribe paradigm under the ISO standard. Devices with low hardware performance and devices with poor network conditions can communicate based on the MQTT protocol.
  • a device supporting the MQTT protocol can perform MQTT service communication through a server.
  • the first device acts as a publisher and sends MQTT data to the server, so that the server sends the MQTT data to at least one second device as a subscriber .
  • the present application provides an MQTT communication method, device, electronic equipment and storage medium to solve the technical problem of insufficient intelligence of the equipment when performing MQTT communication.
  • the first aspect of the present application provides an MQTT communication method, including: the first device determines its geographic location; when the geographic location satisfies a first preset condition, the first device establishes an MQTT connection with the server, and passes The MQTT connection performs MQTT communication.
  • the determining the geographic location of the first device includes: the first device determining the geographic location through a FLP.
  • the first preset condition includes: the distance between the geographic location and the first preset location is smaller than a first threshold; or, the distance between the geographic location and the second preset The distance between the locations is greater than a second threshold, the second threshold being greater than the first threshold.
  • the establishing an MQTT connection between the first device and the server includes: establishing an MQTT connection between the first device and the server through a General Packet Radio Service GRPS network; or, the The first device establishes an MQTT connection with the server through a Wi-Fi network.
  • GRPS General Packet Radio Service
  • the first device before the first device establishes an MQTT connection with the server through the Wi-Fi network, it further includes: the first device starts the Wi-Fi service; Determining AP information corresponding to the geographic location in the storage unit; wherein at least one geographic location and AP information corresponding to each geographic location are stored in the storage unit; the first device according to the AP Information, establish an MQTT connection with the server through the Wi-Fi network provided by the AP.
  • the MQTT communication performed by the first device includes: when the distance between the geographic location and the third preset location is less than a third threshold, the first device uses the publisher MQTT communication in a subscriber mode; when the distance between the geographic location and a third preset location is greater than a third threshold, the first device performs MQTT communication in a subscriber mode.
  • the first device after the first device performs MQTT communication through the MQTT connection, it further includes: when the geographic location where the first device is located satisfies a second preset condition, the second A device disconnects the MQTT connection with the server.
  • the first device after the first device establishes the MQTT connection with the server, it further includes: the first device sends a prompt message to remind the user that the MQTT connection has been established; the first device Perform MQTT communication through the MQTT connection according to receiving the instruction information sent by the user.
  • the first device after the first device establishes an MQTT connection with the server, it further includes: obtaining the moving speed of the first device according to the geographical location determined within a preset time period, The preset time period is a time period before the first device establishes an MQTT connection; determine the MQTT data to be sent to the server according to the moving speed, and send the MQTT data to the server through the MQTT connection.
  • the second aspect of the present application provides an MQTT communication device, which can be used to implement the MQTT communication method provided in the first aspect of the present application.
  • the device includes: a processing module and a communication module; wherein, the processing module is used to determine the geographic location; when When the geographic location satisfies the first preset condition, the communication module is controlled to establish an MQTT connection with the server, and the communication module is controlled to perform MQTT communication through the MQTT connection.
  • the processing module specifically determines the geographic location through the FLP.
  • the first preset condition includes: the distance between the geographic location and the first preset location is smaller than a first threshold; or, the distance between the geographic location and the second preset The distance between the locations is greater than a second threshold, the second threshold being greater than the first threshold.
  • the communication module specifically establishes an MQTT connection with the server through a General Packet Radio Service GRPS network; or, establishes an MQTT connection with the server through a Wi-Fi network.
  • GRPS General Packet Radio Service
  • the processing module is further configured to enable the Wi-Fi service of the communication module, and determine the access point AP information corresponding to the geographic location from the storage unit; wherein, the The storage unit stores at least one geographic location, and AP information corresponding to each geographic location; according to the AP information, the control communication module establishes an MQTT connection with the server through the Wi-Fi network provided by the AP.
  • the processing module is further configured to, when the distance between the geographic location and the third preset location is less than a third threshold, perform MQTT in publisher mode through the communication module Communication: when the distance between the geographic location and the third preset location is greater than a third threshold, MQTT communication is performed in a subscriber mode through the communication module.
  • the processing module is further configured to control the communication module to disconnect the MQTT connection with the server when the geographic location where the first device is located satisfies a second preset condition connect
  • the processing module is further configured to control the prompt module to issue prompt information to prompt the user that the MQTT connection has been established; according to the indication module receiving the indication information sent by the user, and controlling the The communication module performs MQTT communication through the MQTT connection.
  • the processing module is further configured to obtain the moving speed of the first device according to the geographical location determined within a preset time period, and the preset time period is the A time period before the first device establishes an MQTT connection; determine the MQTT data to be sent to the server according to the moving speed, and control the communication module to send the MQTT data to the server through the MQTT connection.
  • the third aspect of the present application provides an electronic device, including: a processor and a memory; wherein, a computer program is stored in the memory, and when the processor executes the computer program, the processor can be used to execute any one of the first aspects of the present application.
  • a computer program is stored in the memory, and when the processor executes the computer program, the processor can be used to execute any one of the first aspects of the present application.
  • the fourth aspect of the present application provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed, it can be used to perform MQTT communication as described in any one of the first aspect of the present application method.
  • the first device establishes an MQTT connection with the server after detecting that its geographic location satisfies the first preset condition; MQTT communication via MQTT connection.
  • the first device automatically establishes an MQTT connection and performs MQTT communication more intelligently without manual operation and settings by the user of the first device, thereby reducing the number of operations and operations required by the user of the first device when performing MQTT communication.
  • the time consumed during operation improves the intelligence of the device when performing MQTT communication, thereby improving the communication efficiency during MQTT communication between devices, and also improving the user experience of the device performing MQTT communication.
  • FIG. 1 is a schematic diagram of an application scenario provided by the present application
  • Fig. 2 is a schematic diagram of an MQTT communication method
  • FIG. 3 is a schematic flow diagram of an embodiment of the MQTT communication method provided by the present application.
  • FIG. 4 is a schematic diagram of an embodiment of an MQTT communication device provided by the present application.
  • FIG. 5 is a schematic structural diagram of an embodiment of an electronic device provided by the present application.
  • Figure 1 is a schematic diagram of the application scenario provided by this application, as shown in Figure 1, this application is applied in the scenario of Message Queuing Telemetry Transport (MQTT for short), as shown in Figure 1 MQTT communication
  • the system specifically includes: a first device, a server and at least one second device, wherein the first device can perform MQTT communication with the at least one second device through the server.
  • Fig. 2 is a schematic diagram of an MQTT communication method.
  • the communication method shown in Fig. 2 can be applied to the MQTT communication system shown in Fig. 1.
  • the P1 part of the communication method in order to carry out MQTT communication, it is first necessary to carry out equipment To connect with the server, establish an MQTT connection between the first device and the server through S11, and establish an MQTT connection between the second device and the server through S12. After the P1 part, MQTT communication can be performed between the first device and the second device through the server.
  • the user needs to establish an MQTT communication connection with the server through S12 through After the first device such as the mobile phone carried by the user establishes an MQTT communication connection with the server.
  • the user can use the MQTT communication between the first device and the second device in the home, so as to realize the smart home function that the user obtains the dynamics in the home and controls the devices in the home.
  • the device sending MQTT data may be called a "publisher”, and the device receiving MQTT data may be called a "subscriber".
  • the first device can serve as a publisher and send the first MQTT data to the server in S21, so that the server sends the first MQTT data to at least one second device as a subscriber in S22 .
  • the first device can act as a subscriber.
  • the MQTT service sends the second MQTT data to the first device in S32 .
  • the device before the device performs MQTT communication, it needs to perform MQTT connection according to the usage of the user, especially when the first device is a device such as a mobile phone carried by the user, often Due to signal coverage, application settings in the mobile phone, etc., the connection to the server is disconnected, so that the user needs to manually connect every time MQTT communication is required, resulting in insufficient intelligence of the device when performing MQTT communication, and due to user
  • the steps required to manually make an MQTT connection are cumbersome, time-consuming, and inefficient, which in turn reduces the communication efficiency for MQTT communication between devices.
  • the present application provides an MQTT communication method, device, electronic equipment, and storage medium to solve the technical problem of insufficient intelligence of the equipment during MQTT communication, to reduce the number of MQTT connections manually performed by the user, and to improve the efficiency of the equipment when performing MQTT communication.
  • the degree of intelligence improves the communication efficiency of MQTT communication between devices.
  • FIG. 3 is a schematic flow diagram of an embodiment of the MQTT communication method provided by the present application.
  • the MQTT communication method shown in FIG. 3 can be applied to the MQTT communication system shown in FIG. 1 , specifically, including:
  • the first device determines its geographic location.
  • the first device may specifically determine its geographic location by means of an AutoNavi Fused Location Provider (FLP for short).
  • FLP AutoNavi Fused Location Provider
  • the first device with integrated positioning service function integrates multiple positioning methods including Global Positioning System (Global Positioning System, GPS) positioning, base station positioning, Wi-Fi positioning, Bluetooth positioning and sensor positioning at its system layer. Therefore, the geographic location of the first device is jointly determined through the fusion of multiple positioning results, which can realize indoor and outdoor integration and precise positioning under different motion states.
  • the determined geographic location may be identified by latitude and longitude coordinates, etc., and different geographic locations have different latitude and longitude coordinates.
  • S102 When the geographic location determined in S101 satisfies the first preset condition, and the current first device does not establish a connection with the server, the first device establishes an MQTT connection relationship with the server.
  • This application does not limit the specific implementation of establishing an MQTT connection between the first device and the server.
  • the first device may send a connection establishment request to the server. After receiving the request, the server sends a connection establishment response to the first device. Establishment of MQTT connection, etc.
  • S103 Perform MQTT communication between the first device and the server through the MQTT connection established in S102.
  • the MQTT communication includes: the first device sends the first MQTT data to the server, so that the server sends the first MQTT data to at least one second device; or, the first device receives the second MQTT data sent by the server, and the second The MQTT data is sent by the second device, and after the first device establishes a connection with the server, the server sends the second MQTT data to the first device.
  • the first preset condition includes: the distance between the geographic location and the first preset location is smaller than a first threshold.
  • the first preset location may be the location of his home specified by the user in advance, and the first threshold may be 10 meters, 50 meters, 100 meters, etc., when the distance between the geographic location and the first preset location is less than the first threshold , indicating that the user brings the first device close to the first preset location, and may connect to the server and perform MQTT communication.
  • the first device "automatically" establishes an MQTT connection relationship with the server without any operation by the user, and can then use the established MQTT connection relationship to perform MQTT communication.
  • the first device when the user is carrying the first device on the way home, when the first device determines that the distance between its geographic location and the first preset location in the home is less than the first threshold through FLP, the first device establishes an MQTT connection relationship between servers. Subsequently, the first device may send the control command to the second device stored by the user in advance as the first MQTT data to the server, so that the server sends the first MQTT data to the corresponding second device, so that the second device receives the first After the MQTT data, execute the control command stored in the first device in advance by the user.
  • the control command may be a command to turn on smart devices such as air conditioners and purifiers, a mode adjustment command, and the like.
  • the first device can also receive the second MQTT data sent by the server from the second device.
  • the second MQTT data can be the data collected by the second device such as the temperature and humidity sensor and camera in the user's home, so that the first device can send The user presents a real-time scene at home. Therefore, before the user returns home, and without the user operating the first device to establish an MQTT connection, the first device has automatically established a connection with the server and performed MQTT communication.
  • the relationship between the smart bracelet supervisor and the server The MQTT connection relationship between them.
  • the smart bracelet can send the detected patient's human body data such as heartbeat, blood pressure, temperature, etc. to the server as the first MQTT data, so that the server sends these human body data to the hospital database as the second device, so that the patient No further baseline measurements are required upon arrival at the hospital.
  • the smart bracelet can also receive the second MQTT data sent by the hospital database through the server, the second MQTT data can include the basic information of the hospital, medical information, flow information, etc.
  • the interaction between the smart bracelet and the hospital database based on MQTT communication for patient information and hospital information is realized.
  • the first device is the patient's smart bracelet
  • the smart bracelet detects that it is on the ambulance, regardless of whether the geographical location meets the first preset condition, it will automatically establish an MQTT connection and perform MQTT Communication, realize the interaction of patient information and hospital information between the smart bracelet and the hospital database in advance.
  • the first preset condition includes: the distance between the geographic location and the second preset location is greater than a second threshold.
  • the second preset location may be the location of his home specified by the user in advance, and the second threshold may be 10 kilometers, 20 kilometers, etc.
  • the first device can actively connect to the server and perform MQTT communication, and send the geographic location of the first device to the second device at home through MQTT communication, so that The family was able to confirm its location.
  • the first device may also "automatically" establish an MQTT connection relationship with the server without any operation by the user, and then use the established MQTT connection relationship to perform MQTT communication.
  • the first device disconnects the MQTT communication connection with the server.
  • the second preset condition may be that the distance between the geographic location and the fourth preset location is greater than a fourth threshold, for example, the fourth preset location may be the location of the user's home specified in advance, and the fourth threshold may be 10 meters, 50 meters, etc.
  • the first device takes the temperature control module at home as an example.
  • the first device When it is placed at home and the distance from the fourth preset position is less than the fourth threshold, the first device maintains the MQTT communication connection with the server; when it is moved away from home, it cannot continue In normal use, when the geographical position detected by the first device and the fourth preset position are greater than the fourth threshold, the first device actively disconnects the MQTT communication connection to reduce the invalid MQTT communication connection and data of the first device. Interactive, save power consumption.
  • MQTT communication performed by the first device in the above example is only an example, and this application does not limit the MQTT-related operations performed after the first device establishes an MQTT connection with the server.
  • MQTT-related operations such as publishing, subscribing, and unsubscribing in MQTT communication may also be included.
  • the first device detects that its geographic location meets the first preset condition, it establishes an MQTT connection with the server; thus, MQTT communication can be performed through the MQTT connection; and After the geographic location satisfies the second preset condition, disconnect the MQTT connection with the server.
  • the user of the first device can automatically establish an MQTT connection and perform MQTT communication, or disconnect the MQTT connection more intelligently without manual operation and settings, thereby reducing the need for the user of the first device to perform MQTT
  • the operations required for communication and the time consumed during operation improve the intelligence of the device when performing MQTT communication, thereby improving the communication efficiency during MQTT communication between devices, and also improving the user experience of devices performing MQTT communication.
  • the specific communication method when establishing an MQTT connection between the first device and the server is not limited. Establish an MQTT connection.
  • the GPRS network may specifically be a 4G network, a 5G network, and the like.
  • the first device may also establish an MQTT connection with the server through a wireless fidelity (Wireless Fidelity, Wi-Fi for short) network.
  • wireless fidelity Wireless Fidelity, Wi-Fi for short
  • the first device when the first device establishes an MQTT connection with the server through the Wi-Fi network, before establishing the MQTT connection, if the Wi-Fi service of the first device is not enabled, the first device may first enable the Wi-Fi service .
  • the user when the first device establishes an MQTT connection with the server through the Wi-Fi network, the user can connect the first device to the Wi-Fi access point (Access Point, referred to as: AP) used by the Wi-Fi network It is configured so that the storage unit of the first device stores AP information near different geographic locations in advance. Then when the distance between the geographic location of the first device and the stored geographic location is smaller than the first threshold, the first device can directly determine the AP information corresponding to the geographic location from the storage unit, and according to the Wi-Fi network provided by the AP and the The server establishes an MQTT connection.
  • AP Wi-Fi access Point
  • the storage unit of the first device can store multiple geographic locations and the AP information corresponding to each geographic location information, so that the first device can establish APs based on AP information in different geographic locations through pre-configured APs.
  • MQTT connection so as to further improve the intelligence and automation of the first device to establish the MQTT connection, and further improve the communication efficiency of the device when performing MQTT communication.
  • the first device provided in the embodiment of the present application can not only connect and disconnect the MQTT connection according to the geographical location, but also switch between the publisher mode and the subscriber mode according to the geographical location, so as to realize a more flexible MQTT communication. For example, when the first device determines that the distance between its geographic location and the third preset location is less than the third threshold, it will perform MQTT communication in publisher mode and actively send the first MQTT data to the server; when the first device determines that its geographic location If the distance between the location and the third preset location is greater than the third threshold, the MQTT communication is performed in the subscriber mode, and the second MQTT data sent by the server from the second device is received.
  • the first device when the first device is in the venue and the distance from the third preset position in the venue is less than the third threshold, the first device sends a message to the venue in publisher mode.
  • the management server sends the information of the participants; when the first device leaves the venue and the distance from the third preset position in the venue is greater than the third threshold, the first device receives the conference information sent by the management server in the venue in subscriber mode .
  • the first device can automatically establish an MQTT connection and perform MQTT communication according to the geographic location, while in other embodiments, after the server establishes the MQTT connection, the first device can also use ringing, vibration Send a prompt message in the form of other forms, prompting the user that the MQTT connection has been established. Subsequently, after receiving the user's instruction information, the first device performs corresponding MQTT communication according to the user's instruction information, thereby improving the controllability of MQTT communication, and performing MQTT communication strictly according to the user's instruction.
  • the first device can obtain its geographic location in the form of FLP, when the geographic location obtained by the first device within the preset time period, the location of the first device within the preset time period can be obtained. Therefore, the first device can determine the MQTT data to be sent to the server according to the current moving speed, and finally send the MQTT data corresponding to the moving speed to the server. That is, the MQTT data is related to the moving speed of the first device.
  • the second A device can send a mid-range mode control command to the home air purifier through MQTT communication; and when the user takes the first device home by car, the first device determines the distance from the first preset location in the home according to the geographic location.
  • the first device can send a high-end mode control command to the home air purifier through MQTT communication, so as to complete the air purification faster.
  • the first device performs different MQTT communications according to the moving speed of the first device, such as sending different MQTT data, which further enriches the application scenarios of this embodiment and the second
  • the functions of a device and further reduce the settings that users need to make, replace the user's selection of MQTT data, improve the intelligence of the device when performing MQTT communication, thereby improving the communication efficiency of MQTT communication between devices, and also Improved user experience for devices communicating with MQTT.
  • the MQTT communication method provided by the embodiment of the present application is introduced, and in order to realize the functions of the MQTT communication method provided by the above-mentioned embodiment of the present application, the first device as the execution subject may include a hardware structure and and/or software modules, which implement the above functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether one of the above-mentioned functions is executed in the form of a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraints of the technical solution.
  • FIG. 4 is a schematic diagram of an embodiment of an MQTT communication device provided in this application.
  • the MQTT communication device 100 shown in FIG. 4 includes: a processing module 1001 and a communication module 1002 .
  • the processing module 1001 is used to determine the geographic location, and when the geographic location satisfies the first preset condition, establish an MQTT connection with the server through the communication module 1002, and perform MQTT communication through the MQTT connection.
  • the processing module 1001 is used to determine the geographic location, and when the geographic location satisfies the first preset condition, establish an MQTT connection with the server through the communication module 1002, and perform MQTT communication through the MQTT connection.
  • each module of the above device is only a division of logical functions, and may be fully or partially integrated into one physical entity or physically separated during actual implementation.
  • these modules can all be implemented in the form of calling software through processing elements; they can also be implemented in the form of hardware; some modules can also be implemented in the form of calling software through processing elements, and some modules can be implemented in the form of hardware. It may be a separately established processing element, or it may be integrated into a certain chip of the above-mentioned device. In addition, it may also be stored in the memory of the above-mentioned device in the form of program code, which is called and executed by a certain processing element of the above-mentioned device. Determine the functionality of the module.
  • each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or an instruction in the form of software.
  • the above modules may be one or more integrated circuits configured to implement the above method, for example: one or more specific integrated circuits (application specific integrated circuit, ASIC), or, one or more microprocessors (digital signal processor, DSP), or, one or more field programmable gate arrays (field programmable gate array, FPGA), etc.
  • ASIC application specific integrated circuit
  • DSP digital signal processor
  • FPGA field programmable gate array
  • the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program codes.
  • these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
  • SOC system-on-a-chip
  • all or part of them may be implemented by software, hardware, firmware or any combination thereof.
  • software When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application will be generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.).
  • the computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center integrated with one or more available media.
  • the available medium may be a magnetic medium (such as a floppy disk, a hard disk, or a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
  • FIG. 5 is a schematic structural diagram of an embodiment of an electronic device provided by the present application.
  • the present application also provides an electronic device 200, including: a processor 2001 and a memory 2002; wherein, a computer program is stored in the memory 2002.
  • the processor 2001 executes As a computer program, the processor 2001 may be used to execute the MQTT communication method in any one of the foregoing embodiments of the present application.
  • the processor 2001 can establish an MQTT connection, perform MQTT communication, etc. through the communication interface 2003.
  • the present application also provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed, it can be used to execute the MQTT communication method in any one of the foregoing embodiments of the present application.
  • the embodiment of the present application also provides a chip for running instructions, and the chip is used to implement the MQTT communication method according to any one of the foregoing embodiments of the present application.
  • the aforementioned program can be stored in a computer-readable storage medium.
  • the program executes the steps including the above-mentioned method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.

Abstract

Embodiments of the present application provide an MQTT communication method and apparatus, an electronic device, and a storage medium. Upon detecting that a geographic position of a first device satisfies a first preset condition, the first device establishes an MQTT connection with a server, so that the first device can perform MQTT communication by means of the MQTT connection. According to the embodiments of the present application, operations required to perform MQTT communication by a user of the first device and the time consumed by the operations are reduced, thereby improving the intelligence level of the device during MQTT communication.

Description

MQTT通信方法、装置、电子设备及存储介质MQTT communication method, device, electronic equipment and storage medium
本申请要求于2021年12月23日提交中国国家知识产权局、申请号为202111589302.3、申请名称为“MQTT通信方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed with the State Intellectual Property Office of China on December 23, 2021, with the application number 202111589302.3 and the application name "MQTT communication method, device, electronic equipment and storage medium", the entire content of which is passed References are incorporated in this application.
技术领域technical field
本申请涉及通信技术领域,尤其涉及一种(Message Queuing Telemetry Transport,简称:MQTT)通信方法、装置、电子设备及存储介质。The present application relates to the field of communication technologies, and in particular to a (Message Queuing Telemetry Transport, MQTT for short) communication method, device, electronic equipment and storage medium.
背景技术Background technique
MQTT协议是ISO标准下基于发布/订阅范式的消息协议,硬件性能低下的设备以及网络状况糟糕的设备可以基于MQTT协议进行通信。The MQTT protocol is a message protocol based on the publish/subscribe paradigm under the ISO standard. Devices with low hardware performance and devices with poor network conditions can communicate based on the MQTT protocol.
现有技术中,支持MQTT协议的设备可以通过服务器进行MQTT服通信,例如,第一设备作为发布者,将MQTT数据发送至服务器,使得服务器将MQTT数据发送至作为订阅者的至少一个第二设备。In the prior art, a device supporting the MQTT protocol can perform MQTT service communication through a server. For example, the first device acts as a publisher and sends MQTT data to the server, so that the server sends the MQTT data to at least one second device as a subscriber .
但是,现有技术中,设备在进行MQTT通信之前,需要根据用户的使用情况进行MQTT连接等,造成了设备进行MQTT通信时的智能化程度不足。However, in the prior art, before the device performs MQTT communication, it needs to perform MQTT connection according to the usage of the user, which results in insufficient intelligence of the device when performing MQTT communication.
发明内容Contents of the invention
本申请提供一种MQTT通信方法、装置、电子设备及存储介质,以解决设备进行MQTT通信时智能化程度不足的技术问题。The present application provides an MQTT communication method, device, electronic equipment and storage medium to solve the technical problem of insufficient intelligence of the equipment when performing MQTT communication.
本申请第一方面提供一种MQTT通信方法,包括:第一设备确定其所在的地理位置;当所述地理位置满足第一预设条件时,所述第一设备与服务器建立MQTT连接,并通过所述MQTT连接进行MQTT通信。The first aspect of the present application provides an MQTT communication method, including: the first device determines its geographic location; when the geographic location satisfies a first preset condition, the first device establishes an MQTT connection with the server, and passes The MQTT connection performs MQTT communication.
在本申请第一方面一实施例中,所述确定所述第一设备所在的地理位置,包括:所述第一设备通过融合定位服务FLP确定所述地理位置。In an embodiment of the first aspect of the present application, the determining the geographic location of the first device includes: the first device determining the geographic location through a FLP.
在本申请第一方面一实施例中,所述第一预设条件包括:所述地理位 置与第一预设位置之间的距离小于第一阈值;或者,所述地理位置与第二预设位置之间的距离大于第二阈值,所述第二阈值大于所述第一阈值。In an embodiment of the first aspect of the present application, the first preset condition includes: the distance between the geographic location and the first preset location is smaller than a first threshold; or, the distance between the geographic location and the second preset The distance between the locations is greater than a second threshold, the second threshold being greater than the first threshold.
在本申请第一方面一实施例中,所述第一设备与所述服务器建立MQTT连接,包括:所述第一设备通过通用分组无线服务GRPS网络与所述服务器建立MQTT连接;或者,所述第一设备通过无线保真Wi-Fi网络与所述服务器建立MQTT连接。In an embodiment of the first aspect of the present application, the establishing an MQTT connection between the first device and the server includes: establishing an MQTT connection between the first device and the server through a General Packet Radio Service GRPS network; or, the The first device establishes an MQTT connection with the server through a Wi-Fi network.
在本申请第一方面一实施例中,所述第一设备通过Wi-Fi网络与所述服务器建立MQTT连接之前,还包括:所述第一设备开启Wi-Fi服务;所述第一设备从存储单元中确定与所述地理位置对应的接入点AP信息;其中,所述存储单元中存储有至少一个地理位置,以及每个地理位置对应的AP信息;所述第一设备根据所述AP信息,通过所述AP提供的Wi-Fi网络与所述服务器建立MQTT连接。In an embodiment of the first aspect of the present application, before the first device establishes an MQTT connection with the server through the Wi-Fi network, it further includes: the first device starts the Wi-Fi service; Determining AP information corresponding to the geographic location in the storage unit; wherein at least one geographic location and AP information corresponding to each geographic location are stored in the storage unit; the first device according to the AP Information, establish an MQTT connection with the server through the Wi-Fi network provided by the AP.
在本申请第一方面一实施例中,所述第一设备进行MQTT通信,包括:当所述地理位置与第三预设位置之间的距离小于第三阈值,所述第一设备以发布者模式进行MQTT通信;当所述地理位置与第三预设位置之间的距离大于第三阈值,所述第一设备以订阅者模式进行MQTT通信。In an embodiment of the first aspect of the present application, the MQTT communication performed by the first device includes: when the distance between the geographic location and the third preset location is less than a third threshold, the first device uses the publisher MQTT communication in a subscriber mode; when the distance between the geographic location and a third preset location is greater than a third threshold, the first device performs MQTT communication in a subscriber mode.
在本申请第一方面一实施例中,所述第一设备通过所述MQTT连接进行MQTT通信之后,还包括:当所述第一设备所在的地理位置满足第二预设条件时,所述第一设备断开与所述服务器之间的MQTT连接。In an embodiment of the first aspect of the present application, after the first device performs MQTT communication through the MQTT connection, it further includes: when the geographic location where the first device is located satisfies a second preset condition, the second A device disconnects the MQTT connection with the server.
在本申请第一方面一实施例中,所述第一设备与所述服务器建立MQTT连接之后,还包括:所述第一设备发出提示信息,向用户提示已建立MQTT连接;所述第一设备根据接收到所述用户发出的指示信息,通过所述MQTT连接进行MQTT通信。In an embodiment of the first aspect of the present application, after the first device establishes the MQTT connection with the server, it further includes: the first device sends a prompt message to remind the user that the MQTT connection has been established; the first device Perform MQTT communication through the MQTT connection according to receiving the instruction information sent by the user.
在本申请第一方面一实施例中,所述第一设备与所述服务器建立MQTT连接之后,还包括:根据预设时间段内所确定的地理位置,得到所述第一设备的移动速度,所述预设时间段为所述第一设备建立MQTT连接之前的时间段;根据所述移动速度确定向所述服务器发送的MQTT数据,通过所述MQTT连接向所述服务器发送所述MQTT数据。In an embodiment of the first aspect of the present application, after the first device establishes an MQTT connection with the server, it further includes: obtaining the moving speed of the first device according to the geographical location determined within a preset time period, The preset time period is a time period before the first device establishes an MQTT connection; determine the MQTT data to be sent to the server according to the moving speed, and send the MQTT data to the server through the MQTT connection.
本申请第二方面提供一种MQTT通信装置,可用于执行如本申请第一 方面提供的MQTT通信方法,该装置包括:处理模块和通信模块;其中,处理模块用于确定所在的地理位置;当地理位置满足第一预设条件时,控制所述通信模块与服务器建立MQTT连接,并控制所述通信模块通过所述MQTT连接进行MQTT通信。The second aspect of the present application provides an MQTT communication device, which can be used to implement the MQTT communication method provided in the first aspect of the present application. The device includes: a processing module and a communication module; wherein, the processing module is used to determine the geographic location; when When the geographic location satisfies the first preset condition, the communication module is controlled to establish an MQTT connection with the server, and the communication module is controlled to perform MQTT communication through the MQTT connection.
在本申请第二方面一实施例中,处理模块具体通过融合定位服务FLP确定所述地理位置。In an embodiment of the second aspect of the present application, the processing module specifically determines the geographic location through the FLP.
在本申请第二方面一实施例中,所述第一预设条件包括:所述地理位置与第一预设位置之间的距离小于第一阈值;或者,所述地理位置与第二预设位置之间的距离大于第二阈值,所述第二阈值大于所述第一阈值。In an embodiment of the second aspect of the present application, the first preset condition includes: the distance between the geographic location and the first preset location is smaller than a first threshold; or, the distance between the geographic location and the second preset The distance between the locations is greater than a second threshold, the second threshold being greater than the first threshold.
在本申请第二方面一实施例中,所述通信模块具体通过通用分组无线服务GRPS网络与所述服务器建立MQTT连接;或者,通过无线保真Wi-Fi网络与所述服务器建立MQTT连接。In an embodiment of the second aspect of the present application, the communication module specifically establishes an MQTT connection with the server through a General Packet Radio Service GRPS network; or, establishes an MQTT connection with the server through a Wi-Fi network.
在本申请第二方面一实施例中,所述处理模块还用于,开启通信模块的Wi-Fi服务,从存储单元中确定与所述地理位置对应的接入点AP信息;其中,所述存储单元中存储有至少一个地理位置,以及每个地理位置对应的AP信息;根据所述AP信息,控制通信模块通过所述AP提供的Wi-Fi网络与所述服务器建立MQTT连接。In an embodiment of the second aspect of the present application, the processing module is further configured to enable the Wi-Fi service of the communication module, and determine the access point AP information corresponding to the geographic location from the storage unit; wherein, the The storage unit stores at least one geographic location, and AP information corresponding to each geographic location; according to the AP information, the control communication module establishes an MQTT connection with the server through the Wi-Fi network provided by the AP.
在本申请第二方面一实施例中,所述处理模块还用于,当所述地理位置与第三预设位置之间的距离小于第三阈值,通过所述通信模块以发布者模式进行MQTT通信;当所述地理位置与第三预设位置之间的距离大于第三阈值,通过所述通信模块以订阅者模式进行MQTT通信。In an embodiment of the second aspect of the present application, the processing module is further configured to, when the distance between the geographic location and the third preset location is less than a third threshold, perform MQTT in publisher mode through the communication module Communication: when the distance between the geographic location and the third preset location is greater than a third threshold, MQTT communication is performed in a subscriber mode through the communication module.
在本申请第二方面一实施例中,所述处理模块还用于,当所述第一设备所在的地理位置满足第二预设条件时,控制通信模块断开与所述服务器之间的MQTT连接In an embodiment of the second aspect of the present application, the processing module is further configured to control the communication module to disconnect the MQTT connection with the server when the geographic location where the first device is located satisfies a second preset condition connect
在本申请第二方面一实施例中,所述处理模块还用于,控制提示模块发出提示信息,向用户提示已建立MQTT连接;根据指示模块接收到所述用户发出的指示信息,并控制所述通信模块通过所述MQTT连接进行MQTT通信。In an embodiment of the second aspect of the present application, the processing module is further configured to control the prompt module to issue prompt information to prompt the user that the MQTT connection has been established; according to the indication module receiving the indication information sent by the user, and controlling the The communication module performs MQTT communication through the MQTT connection.
在本申请第二方面一实施例中,所述处理模块还用于,根据预设时间段内所确定的地理位置,得到所述第一设备的移动速度,所述预设时间段为所述第一设备建立MQTT连接之前的时间段;根据所述移动速度确定向所述服 务器发送的MQTT数据,控制所述通信模块通过所述MQTT连接向所述服务器发送所述MQTT数据。In an embodiment of the second aspect of the present application, the processing module is further configured to obtain the moving speed of the first device according to the geographical location determined within a preset time period, and the preset time period is the A time period before the first device establishes an MQTT connection; determine the MQTT data to be sent to the server according to the moving speed, and control the communication module to send the MQTT data to the server through the MQTT connection.
本申请第三方面提供一种电子设备,包括:处理器及存储器;其中,存储器中存储有计算机程序,当处理器执行计算器程序时,处理器可用于执行如本申请第一方面任一项所述的MQTT通信方法。The third aspect of the present application provides an electronic device, including: a processor and a memory; wherein, a computer program is stored in the memory, and when the processor executes the computer program, the processor can be used to execute any one of the first aspects of the present application. The MQTT communication method described above.
本申请第四方面提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被执行时可用于执行如本申请第一方面任一项所述的MQTT通信方法。The fourth aspect of the present application provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed, it can be used to perform MQTT communication as described in any one of the first aspect of the present application method.
综上,本申请实施例提供的MQTT通信方法、装置、电子设备及存储介质,第一设备在检测到其地理位置满足第一预设条件后,就建立与服务器之间的MQTT连接;从而可以通过MQTT连接进行MQTT通信。使得第一设备的用户在无需手动操作和设置的情况下,第一设备更加智能化地自动建立MQTT连接并进行MQTT通信,因此能够减少了第一设备的用户在进行MQTT通信时需要的操作和操作时所消耗的时间,提高设备进行MQTT通信时的智能化程度,从而提高设备之间进行MQTT通信时的通信效率,还提高了进行MQTT通信的设备的用户体验。To sum up, in the MQTT communication method, device, electronic device, and storage medium provided by the embodiments of the present application, the first device establishes an MQTT connection with the server after detecting that its geographic location satisfies the first preset condition; MQTT communication via MQTT connection. The first device automatically establishes an MQTT connection and performs MQTT communication more intelligently without manual operation and settings by the user of the first device, thereby reducing the number of operations and operations required by the user of the first device when performing MQTT communication. The time consumed during operation improves the intelligence of the device when performing MQTT communication, thereby improving the communication efficiency during MQTT communication between devices, and also improving the user experience of the device performing MQTT communication.
附图说明Description of drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present application. Those skilled in the art can also obtain other drawings based on these drawings without any creative effort.
图1为本申请提供的应用场景的示意图;FIG. 1 is a schematic diagram of an application scenario provided by the present application;
图2为一种MQTT通信方法的示意图;Fig. 2 is a schematic diagram of an MQTT communication method;
图3为本申请提供的MQTT通信方法一实施例的流程示意图;FIG. 3 is a schematic flow diagram of an embodiment of the MQTT communication method provided by the present application;
图4为本申请提供的MQTT通信装置一实施例的示意图;FIG. 4 is a schematic diagram of an embodiment of an MQTT communication device provided by the present application;
图5为本申请提供的电子设备一实施例的结构示意图。FIG. 5 is a schematic structural diagram of an embodiment of an electronic device provided by the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行 清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例例如能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and not necessarily Used to describe a specific sequence or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein, for example, can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or device comprising a sequence of steps or elements is not necessarily limited to the expressly listed instead, may include other steps or elements not explicitly listed or inherent to the process, method, product or apparatus.
下面在正式介绍本申请实施例之前,先结合附图,对本申请所应用的场景,以及场景中存在的问题进行说明。例如,图1为本申请提供的应用场景的示意图,如图1所示,本申请应用在消息队列遥测传输(Message Queuing Telemetry Transport,简称:MQTT)的场景中,如图1所示的MQTT通信系统中具体包括:第一设备、服务器和至少一个第二设备,其中,第一设备可以通过服务器与至少一个第二设备进行MQTT通信。Before formally introducing the embodiments of the present application, the scenarios to which the present application is applied and the problems existing in the scenarios will be described with reference to the accompanying drawings. For example, Figure 1 is a schematic diagram of the application scenario provided by this application, as shown in Figure 1, this application is applied in the scenario of Message Queuing Telemetry Transport (MQTT for short), as shown in Figure 1 MQTT communication The system specifically includes: a first device, a server and at least one second device, wherein the first device can perform MQTT communication with the at least one second device through the server.
图2为一种MQTT通信方法的示意图,如图2所示的通信方法可应用于如图1所示的MQTT通信系统中,在该通信方法的P1部分,为了进行MQTT通信,首先需要进行设备与服务器之间的连接,分别通过S11建立第一设备与服务器之间的MQTT连接、以及通过S12建立第二设备与服务器之间的MQTT连接。使得在P1部分之后第一设备和第二设备之间可以通过服务器进行MQTT通信。Fig. 2 is a schematic diagram of an MQTT communication method. The communication method shown in Fig. 2 can be applied to the MQTT communication system shown in Fig. 1. In the P1 part of the communication method, in order to carry out MQTT communication, it is first necessary to carry out equipment To connect with the server, establish an MQTT connection between the first device and the server through S11, and establish an MQTT connection between the second device and the server through S12. After the P1 part, MQTT communication can be performed between the first device and the second device through the server.
示例性地,当如图1所示的MQTT通信系统应用于智能家居等物联网场景时,用户需要通过S12将家中设置的传感器、智能电器等第二设备与服务器建立MQTT通信连接,并可以通过用户随身携带的手机等第一设备与服务器建立MQTT通信连接后。用户就可以使用第一设备与家中的第二设备之间进行MQTT通信,实现用户获取家中动态、控制家中设备的智能家居功能。Exemplarily, when the MQTT communication system shown in Figure 1 is applied to IoT scenarios such as smart homes, the user needs to establish an MQTT communication connection with the server through S12 through After the first device such as the mobile phone carried by the user establishes an MQTT communication connection with the server. The user can use the MQTT communication between the first device and the second device in the home, so as to realize the smart home function that the user obtains the dynamics in the home and controls the devices in the home.
在一些实施例中,对于进行MQTT通信的两个设备中,发送MQTT数据的设备可以被称为“发布者”,接收MQTT数据的设备可以被称为“订阅者”。 如图2所示的P2部分中,第一设备可以作为发布者,在S21中将第一MQTT发送至服务器,使得服务器在S22中将第一MQTT数据发送到至少一个作为订阅者的第二设备。在图2所示的P3部分中,第一设备可以作为订阅者,当第二设备在S31中将第二MQTT数据发送至服务器后,MQTT服务在S32中将第二MQTT数据发送至第一设备。In some embodiments, among two devices performing MQTT communication, the device sending MQTT data may be called a "publisher", and the device receiving MQTT data may be called a "subscriber". In the P2 part shown in Figure 2, the first device can serve as a publisher and send the first MQTT data to the server in S21, so that the server sends the first MQTT data to at least one second device as a subscriber in S22 . In the P3 part shown in Figure 2, the first device can act as a subscriber. After the second device sends the second MQTT data to the server in S31, the MQTT service sends the second MQTT data to the first device in S32 .
但是,在如图2所示的MQTT通信方法中,设备在进行MQTT通信之前,需要根据用户的使用情况进行MQTT连接等,尤其是当第一设备是用户随身携带的手机等设备时,经常会由于信号覆盖、手机内应用程序的设置等原因断开与服务器的连接,使得每次需要进行MQTT通信时用户都需要手动进行连接,造成了设备进行MQTT通信时的智能化程度不足,并且因用户手动进行MQTT连接所需的步骤繁琐、费时且效率低下,进而降低了设备之间进行MQTT通信的通信效率。However, in the MQTT communication method shown in Figure 2, before the device performs MQTT communication, it needs to perform MQTT connection according to the usage of the user, especially when the first device is a device such as a mobile phone carried by the user, often Due to signal coverage, application settings in the mobile phone, etc., the connection to the server is disconnected, so that the user needs to manually connect every time MQTT communication is required, resulting in insufficient intelligence of the device when performing MQTT communication, and due to user The steps required to manually make an MQTT connection are cumbersome, time-consuming, and inefficient, which in turn reduces the communication efficiency for MQTT communication between devices.
因此,本申请提供一种MQTT通信方法、装置、电子设备及存储介质,用以解决MQTT通信时设备智能化程度不足的技术问题,来减少用户手动进行的MQTT连接,提高设备进行MQTT通信时的智能化程度,从而提高设备之间进行MQTT通信时的通信效率。下面以具体地实施例对本申请的技术方案进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例不再赘述。Therefore, the present application provides an MQTT communication method, device, electronic equipment, and storage medium to solve the technical problem of insufficient intelligence of the equipment during MQTT communication, to reduce the number of MQTT connections manually performed by the user, and to improve the efficiency of the equipment when performing MQTT communication. The degree of intelligence improves the communication efficiency of MQTT communication between devices. The technical solution of the present application will be described in detail below with specific embodiments. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
图3为本申请提供的MQTT通信方法一实施例的流程示意图,如图3所示的MQTT通信方法可应用于如图1所示的MQTT通信系统中,具体地,包括:FIG. 3 is a schematic flow diagram of an embodiment of the MQTT communication method provided by the present application. The MQTT communication method shown in FIG. 3 can be applied to the MQTT communication system shown in FIG. 1 , specifically, including:
S101、第一设备确定其所在的地理位置。S101. The first device determines its geographic location.
在一些实施例中,第一设备可以具体通过融合定位服务(AutoNavi Fused Location Provider,简称:FLP)的方式确定其所在的地理位置。其中,具有融合定位服务功能的第一设备在其系统层融合包括全球定位系统(Global Positioning System,简称:GPS)定位、基站定位、Wi-Fi定位、蓝牙定位和传感器定位等多种定位方式,从而通过多种定位结果融合的方式共同确定第一设备所在的地理位置,能够实现室内外一体化、以及不同运动状态下的精准定位。所确定的地理位置可以通过经纬度坐标等形式进行标识,不同的地理位置具有不同的经纬度坐标。In some embodiments, the first device may specifically determine its geographic location by means of an AutoNavi Fused Location Provider (FLP for short). Among them, the first device with integrated positioning service function integrates multiple positioning methods including Global Positioning System (Global Positioning System, GPS) positioning, base station positioning, Wi-Fi positioning, Bluetooth positioning and sensor positioning at its system layer. Therefore, the geographic location of the first device is jointly determined through the fusion of multiple positioning results, which can realize indoor and outdoor integration and precise positioning under different motion states. The determined geographic location may be identified by latitude and longitude coordinates, etc., and different geographic locations have different latitude and longitude coordinates.
S102:当S101中所确定的地理位置满足第一预设条件,且当前第一设备 没有与服务器建立连接时,第一设备与服务器建立MQTT连接关系。本申请对第一设备和服务器之间建立MQTT连接的具体实现方式不做限定,例如可以由第一设备向服务器发送连接建立请求,服务器接收到请求后向第一设备发送连接建立响应后,实现MQTT连接的建立等。S102: When the geographic location determined in S101 satisfies the first preset condition, and the current first device does not establish a connection with the server, the first device establishes an MQTT connection relationship with the server. This application does not limit the specific implementation of establishing an MQTT connection between the first device and the server. For example, the first device may send a connection establishment request to the server. After receiving the request, the server sends a connection establishment response to the first device. Establishment of MQTT connection, etc.
S103:第一设备与服务器之间通过S102中所建立的MQTT连接,进行MQTT通信。其中,所述MQTT通信包括:第一设备向服务器发送第一MQTT数据,使服务器将第一MQTT数据发送到至少一个第二设备;或者,第一设备接收服务器发送的第二MQTT数据,第二MQTT数据是第二设备发送的,在第一设备与服务器建立连接之后,服务器将第二MQTT数据发送至第一设备。S103: Perform MQTT communication between the first device and the server through the MQTT connection established in S102. Wherein, the MQTT communication includes: the first device sends the first MQTT data to the server, so that the server sends the first MQTT data to at least one second device; or, the first device receives the second MQTT data sent by the server, and the second The MQTT data is sent by the second device, and after the first device establishes a connection with the server, the server sends the second MQTT data to the first device.
在一些实施例中,第一预设条件包括:地理位置与第一预设位置之间的距离小于第一阈值。例如,第一预设位置可以是用户提前指定的其家中所在的位置,第一阈值可以是10米、50米、100米等,当地理位置与第一预设位置之间距离小于第一阈值,说明用户携带着第一设备靠近第一预设位置,可能会连接服务器并进行MQTT通信。此时,第一设备在不需要用户进行任何操作的情况下,“自动”地与服务器建立MQTT连接关系,并在随后可以使用所建立的MQTT连接关系进行MQTT通信。In some embodiments, the first preset condition includes: the distance between the geographic location and the first preset location is smaller than a first threshold. For example, the first preset location may be the location of his home specified by the user in advance, and the first threshold may be 10 meters, 50 meters, 100 meters, etc., when the distance between the geographic location and the first preset location is less than the first threshold , indicating that the user brings the first device close to the first preset location, and may connect to the server and perform MQTT communication. At this time, the first device "automatically" establishes an MQTT connection relationship with the server without any operation by the user, and can then use the established MQTT connection relationship to perform MQTT communication.
示例性地,当用户携带第一设备回家途中,当第一设备通过FLP的方式确定其所在的地理位置与家中第一预设位置之间的距离小于第一阈值,则第一设备建立与服务器间的MQTT连接关系。随后,第一设备可以将用户提前存储的向第二设备的控制命令作为第一MQTT数据发送至服务器,使得服务器将第一MQTT数据发送到对应的第二设备,使得第二设备接收到第一MQTT数据后,执行用户所提前存储在第一设备的控制命令。控制命令可以是对空调、净化器等智能设备的打开命令、模式调整命令等。以及,第一设备还可也接收到服务器发送的来自第二设备的第二MQTT数据,第二MQTT数据可以是用户家中温湿度传感器、摄像头等第二设备采集的数据,使得第一设备可以向用户呈现家中的实时场景。从而实现用户在回到家之前,且在用户没有操作第一设备建立MQTT连接的情况下,第一设备就已经自动与服务器建立连接并进行MQTT通信。For example, when the user is carrying the first device on the way home, when the first device determines that the distance between its geographic location and the first preset location in the home is less than the first threshold through FLP, the first device establishes an MQTT connection relationship between servers. Subsequently, the first device may send the control command to the second device stored by the user in advance as the first MQTT data to the server, so that the server sends the first MQTT data to the corresponding second device, so that the second device receives the first After the MQTT data, execute the control command stored in the first device in advance by the user. The control command may be a command to turn on smart devices such as air conditioners and purifiers, a mode adjustment command, and the like. And, the first device can also receive the second MQTT data sent by the server from the second device. The second MQTT data can be the data collected by the second device such as the temperature and humidity sensor and camera in the user's home, so that the first device can send The user presents a real-time scene at home. Therefore, before the user returns home, and without the user operating the first device to establish an MQTT connection, the first device has automatically established a connection with the server and performed MQTT communication.
又示例性地,当第一设备是病患携带的智能手环,该智能手环在检测到距离医院的第一预设位置之间的距离小于第一阈值,则智能手环监理与服务器之间的MQTT连接关系。随后,智能手环可以将其检测的病患的心跳、血压、 气温等人体数据作为第一MQTT数据发送至服务器,使得服务器将这些人体数据发送到作为第二设备的医院数据库中,使得病患在抵达医院后无需再进行基础测量。以及,智能手环还可以接收到医院数据库通过服务器发送的第二MQTT数据,第二MQTT数据可以包括医院的基本信息、就诊信息、人流量信息等,使得病患在没有抵达医院且没有操作第一设备的情况下,实现了智能手环和医院的数据库之间对病患信息、医院信息基于MQTT通信进行的交互。或者,当第一设备是病患的智能手环时,还可以在智能手环检测到其位于救护车上后,不论地理位置是否满足第一预设条件,都将自动建立MQTT连接并进行MQTT通信,提前实现智能手环和医院的数据库之间对病患信息、医院信息的交互。In another example, when the first device is a smart bracelet carried by a patient, and the distance between the smart bracelet and the first preset position detected from the hospital is less than the first threshold, the relationship between the smart bracelet supervisor and the server The MQTT connection relationship between them. Subsequently, the smart bracelet can send the detected patient's human body data such as heartbeat, blood pressure, temperature, etc. to the server as the first MQTT data, so that the server sends these human body data to the hospital database as the second device, so that the patient No further baseline measurements are required upon arrival at the hospital. And, the smart bracelet can also receive the second MQTT data sent by the hospital database through the server, the second MQTT data can include the basic information of the hospital, medical information, flow information, etc. In the case of a device, the interaction between the smart bracelet and the hospital database based on MQTT communication for patient information and hospital information is realized. Or, when the first device is the patient's smart bracelet, after the smart bracelet detects that it is on the ambulance, regardless of whether the geographical location meets the first preset condition, it will automatically establish an MQTT connection and perform MQTT Communication, realize the interaction of patient information and hospital information between the smart bracelet and the hospital database in advance.
在另一些实施例中,第一预设条件包括:地理位置与第二预设位置之间的距离大于第二阈值。例如,第二预设位置可以是用户提前指定的其家中所在的位置,第二阈值可以是10公里、20公里等,当地理位置与第二预设位置之间距离大于第二阈值,说明用户携带着第一设备远离了第二预设位置,为了防止发生意外,第一设备可以主动连接服务器并进行MQTT通信,将第一设备的地理位置通过MQTT通信方式发送给家中的第二设备,使得家人能够确认其位置。此时,第一设备也可以在不需要用户进行任何操作的情况下,“自动”地与服务器建立MQTT连接关系,并在随后可以使用所建立的MQTT连接关系进行MQTT通信。In some other embodiments, the first preset condition includes: the distance between the geographic location and the second preset location is greater than a second threshold. For example, the second preset location may be the location of his home specified by the user in advance, and the second threshold may be 10 kilometers, 20 kilometers, etc. When the distance between the geographic location and the second preset location is greater than the second threshold, it means that the user Carrying the first device away from the second preset location, in order to prevent accidents, the first device can actively connect to the server and perform MQTT communication, and send the geographic location of the first device to the second device at home through MQTT communication, so that The family was able to confirm its location. At this time, the first device may also "automatically" establish an MQTT connection relationship with the server without any operation by the user, and then use the established MQTT connection relationship to perform MQTT communication.
在一些实施例中,当第一设备通过如图3所示的方式与服务建立MQTT通信连接并进行MQTT通信之后,第一设备还可以继续按照一定的周期通过FLP方式确定其地理位置,并在第一位置满足第二预设条件后,第一设备断开其与服务器之间的MQTT通信连接。例如,第二预设条件可以是地理位置与第四预设位置之间的距离大于第四阈值,例如,第四预设位置可以是用户提前指定的其家中所在的位置,第四阈值可以是10米、50米等。第一设备以家中的温控模块为例,当放置在家中时与第四预设位置的距离小于第四阈值,第一设备保持与服务器的MQTT通信连接;当被移动拿开家中,无法继续正常使用,此时第一设备检测到的地理位置与第四预设位置的位置大于第四阈值,第一设备主动断开MQTT通信连接,来减少第一设备进行无效的MQTT通信的连接和数据交互、节省电量消耗。In some embodiments, after the first device establishes an MQTT communication connection with the service as shown in FIG. After the first location satisfies the second preset condition, the first device disconnects the MQTT communication connection with the server. For example, the second preset condition may be that the distance between the geographic location and the fourth preset location is greater than a fourth threshold, for example, the fourth preset location may be the location of the user's home specified in advance, and the fourth threshold may be 10 meters, 50 meters, etc. The first device takes the temperature control module at home as an example. When it is placed at home and the distance from the fourth preset position is less than the fourth threshold, the first device maintains the MQTT communication connection with the server; when it is moved away from home, it cannot continue In normal use, when the geographical position detected by the first device and the fourth preset position are greater than the fourth threshold, the first device actively disconnects the MQTT communication connection to reduce the invalid MQTT communication connection and data of the first device. Interactive, save power consumption.
需要说明的是,上述示例中第一设备所进行的MQTT通信仅为示例,本申 请对第一设备建立与服务器之间的MQTT连接之后,所进行的与MQTT相关的操作不做限定。例如还可以包括MQTT通信中发布、订阅、取消订阅等MQTT相关的操作。It should be noted that the MQTT communication performed by the first device in the above example is only an example, and this application does not limit the MQTT-related operations performed after the first device establishes an MQTT connection with the server. For example, MQTT-related operations such as publishing, subscribing, and unsubscribing in MQTT communication may also be included.
综上,本实施例提供的MQTT通信方法中,第一设备在检测到其地理位置满足第一预设条件后,就建立与服务器之间的MQTT连接;从而可以通过MQTT连接进行MQTT通信;以及地理位置满足第二预设条件后,断开与服务器之间的MQTT连接。使得第一设备的用户在无需手动操作和设置的情况下,第一设备更加智能化地自动建立MQTT连接并进行MQTT通信、或者断开MQTT连接,因此能够减少了第一设备的用户在进行MQTT通信时需要的操作和操作时所消耗的时间,提高设备进行MQTT通信时的智能化程度,从而提高设备之间进行MQTT通信时的通信效率,还提高了进行MQTT通信的设备的用户体验。To sum up, in the MQTT communication method provided by this embodiment, after the first device detects that its geographic location meets the first preset condition, it establishes an MQTT connection with the server; thus, MQTT communication can be performed through the MQTT connection; and After the geographic location satisfies the second preset condition, disconnect the MQTT connection with the server. The user of the first device can automatically establish an MQTT connection and perform MQTT communication, or disconnect the MQTT connection more intelligently without manual operation and settings, thereby reducing the need for the user of the first device to perform MQTT The operations required for communication and the time consumed during operation improve the intelligence of the device when performing MQTT communication, thereby improving the communication efficiency during MQTT communication between devices, and also improving the user experience of devices performing MQTT communication.
本申请实施例中,对第一设备与服务器之间建立MQTT连接时的具体通信方式不做限定,例如,第一设备可以通过通用分组无线服务(General Packet Radio Service,简称:GPRS)网络与服务器建立MQTT连接。GPRS网络具体可以是4G网络、5G网络等。或者,第一设备还可以通过无线保真(Wireless Fidelity,简称:Wi-Fi)网络与服务器建立MQTT连接。In the embodiment of the present application, the specific communication method when establishing an MQTT connection between the first device and the server is not limited. Establish an MQTT connection. The GPRS network may specifically be a 4G network, a 5G network, and the like. Alternatively, the first device may also establish an MQTT connection with the server through a wireless fidelity (Wireless Fidelity, Wi-Fi for short) network.
在一些实施例中,第一设备通过Wi-Fi网络与服务器建立MQTT连接时,在建立MQTT连接之前,若第一设备的Wi-Fi服务没有开启,则第一设备可以首先开启Wi-Fi服务。In some embodiments, when the first device establishes an MQTT connection with the server through the Wi-Fi network, before establishing the MQTT connection, if the Wi-Fi service of the first device is not enabled, the first device may first enable the Wi-Fi service .
在一些实施例中,当第一设备通过Wi-Fi网络与服务器建立MQTT连接时,用户可以对第一设备连接Wi-Fi网络所使用的Wi-Fi接入点(Access Point,简称:AP)进行配置,使得第一设备的存储单元中提前存储不同地理位置附近的AP信息。则当第一设备的地理位置与存储的地理位置之间距离小于第一阈值后,第一设备可以直接从存储单元中确定地理位置对应的AP信息,并根据该AP提供的Wi-Fi网络与服务器建立MQTT连接。可以理解的是,第一设备的存储单元中可以存储多个地理位置以及每个地理位置信息对应的AP信息,使得第一设备可以在不同地理位置都可以根据AP信息,通过提前配置的AP建立MQTT连接,从而进一步提高第一设备建立MQTT连接的智能化、自动化程度,进一步提高设备进行MQTT通信时的通信效率。In some embodiments, when the first device establishes an MQTT connection with the server through the Wi-Fi network, the user can connect the first device to the Wi-Fi access point (Access Point, referred to as: AP) used by the Wi-Fi network It is configured so that the storage unit of the first device stores AP information near different geographic locations in advance. Then when the distance between the geographic location of the first device and the stored geographic location is smaller than the first threshold, the first device can directly determine the AP information corresponding to the geographic location from the storage unit, and according to the Wi-Fi network provided by the AP and the The server establishes an MQTT connection. It can be understood that the storage unit of the first device can store multiple geographic locations and the AP information corresponding to each geographic location information, so that the first device can establish APs based on AP information in different geographic locations through pre-configured APs. MQTT connection, so as to further improve the intelligence and automation of the first device to establish the MQTT connection, and further improve the communication efficiency of the device when performing MQTT communication.
进一步地,本申请实施例提供的第一设备除了根据地理位置,进行MQTT 连接的连接与断开,还可以根据地理位置进行发布者模式和订阅者模式之间的切换,从而实现更加灵活的MQTT通信。例如,当第一设备确定其地理位置与第三预设位置之间的距离小于第三阈值,则以发布者模式进行MQTT通信,主动向服务器发送第一MQTT数据;当第一设备确定其地理位置与第三预设位置之间的距离大于第三阈值,则以订阅者模式进行MQTT通信,接收服务器发送的来自第二设备的第二MQTT数据。例如,以第一设备是参会人员携带的手环为例,当第一设备在会场中时,与会场内第三预设位置的距离小于第三阈值,第一设备以发布者模式向会场的管理服务器发送参会人的信息;当第一设备离开会场后,与会场内第三预设位置的距离大于第三阈值,第一设备以订阅者模式接收会场内的管理服务器发送的会议信息。Further, the first device provided in the embodiment of the present application can not only connect and disconnect the MQTT connection according to the geographical location, but also switch between the publisher mode and the subscriber mode according to the geographical location, so as to realize a more flexible MQTT communication. For example, when the first device determines that the distance between its geographic location and the third preset location is less than the third threshold, it will perform MQTT communication in publisher mode and actively send the first MQTT data to the server; when the first device determines that its geographic location If the distance between the location and the third preset location is greater than the third threshold, the MQTT communication is performed in the subscriber mode, and the second MQTT data sent by the server from the second device is received. For example, if the first device is a wristband carried by a participant, when the first device is in the venue and the distance from the third preset position in the venue is less than the third threshold, the first device sends a message to the venue in publisher mode. The management server sends the information of the participants; when the first device leaves the venue and the distance from the third preset position in the venue is greater than the third threshold, the first device receives the conference information sent by the management server in the venue in subscriber mode .
在本申请前述实施例中,第一设备根据地理位置可以自动地建立MQTT连接并进行MQTT通信,而在另一些实施例中,第一设备在于服务器建立MQTT连接之后,还可以通过响铃、振动等形式发出提示信息,向用户提示已建立MQTT连接。随后,当第一设备接收到用户的指示信息后,根据用户的指示信息进行相应的MQTT通信,从而提高了进行MQTT通信时的可控程度,严格按照用户的指示准确地进行MQTT通信。In the aforementioned embodiments of the present application, the first device can automatically establish an MQTT connection and perform MQTT communication according to the geographic location, while in other embodiments, after the server establishes the MQTT connection, the first device can also use ringing, vibration Send a prompt message in the form of other forms, prompting the user that the MQTT connection has been established. Subsequently, after receiving the user's instruction information, the first device performs corresponding MQTT communication according to the user's instruction information, thereby improving the controllability of MQTT communication, and performing MQTT communication strictly according to the user's instruction.
在一些实施例中,基于第一设备可以通过FLP的形式获取其所在的地理位置,则当第一设备在预设时间端内所获取的地理位置,就可以得到第一设备在预设时间段内的速度,因此,第一设备就可以根据当前的移动速度,确定向服务器发送的MQTT数据,并最终向服务器发送移动速度对应的MQTT数据。也就是说,MQTT数据与第一设备的移动速度有关。例如,当用户携带第一设备以步行的方式回家时,当第一设备根据地理位置确定距离家中的第一预设位置的距离小于第一阈值,且移动速度小于预设速度时,则第一设备可以通过MQTT通信的方式向家中空气净化器发送中档模式的控制命令;而当用户携带第一设备乘车回家时,第一设备根据地理位置确定距离家中的第一预设位置的距离小于第一阈值,且移动速度大于预设速度时,则第一设备可以通过MQTT通信的方式向家中空气净化器发送高档模式的控制命令,从而更快地完成对空气的净化。通过本实施例,第一设备在根据位置信息建立MQTT连接的基础上,根据第一设备的移动速度进行不同的MQTT通信,例如发送不同的MQTT数据,进一步丰富了本实施例的应用场景以及第一设备所具有的功能,并进一步减少了用户需要进行的设置,代替用户进行MQTT数据的选择,提高 设备进行MQTT通信时的智能化程度,从而提高设备之间进行MQTT通信时的通信效率,还提高了进行MQTT通信的设备的用户体验。In some embodiments, based on the fact that the first device can obtain its geographic location in the form of FLP, when the geographic location obtained by the first device within the preset time period, the location of the first device within the preset time period can be obtained. Therefore, the first device can determine the MQTT data to be sent to the server according to the current moving speed, and finally send the MQTT data corresponding to the moving speed to the server. That is, the MQTT data is related to the moving speed of the first device. For example, when the user walks home with the first device, and when the first device determines that the distance from the first preset location in the home is less than the first threshold and the moving speed is lower than the preset speed according to the geographic location, the second A device can send a mid-range mode control command to the home air purifier through MQTT communication; and when the user takes the first device home by car, the first device determines the distance from the first preset location in the home according to the geographic location When the speed is less than the first threshold and the moving speed is greater than the preset speed, the first device can send a high-end mode control command to the home air purifier through MQTT communication, so as to complete the air purification faster. Through this embodiment, on the basis of establishing an MQTT connection according to the location information, the first device performs different MQTT communications according to the moving speed of the first device, such as sending different MQTT data, which further enriches the application scenarios of this embodiment and the second The functions of a device, and further reduce the settings that users need to make, replace the user's selection of MQTT data, improve the intelligence of the device when performing MQTT communication, thereby improving the communication efficiency of MQTT communication between devices, and also Improved user experience for devices communicating with MQTT.
在前述各实施例中,对本申请实施例提供的MQTT通信方法进行了介绍,而为了实现上述本申请实施例提供的MQTT通信方法中的各功能,作为执行主体的第一设备可以包括硬件结构和/或软件模块,以硬件结构、软件模块、或硬件结构加软件模块的形式来实现上述各功能。上述各功能中的某个功能以硬件结构、软件模块、还是硬件结构加软件模块的方式来执行,取决于技术方案的特定应用和设计约束条件。In the above-mentioned embodiments, the MQTT communication method provided by the embodiment of the present application is introduced, and in order to realize the functions of the MQTT communication method provided by the above-mentioned embodiment of the present application, the first device as the execution subject may include a hardware structure and and/or software modules, which implement the above functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether one of the above-mentioned functions is executed in the form of a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraints of the technical solution.
例如,图4为本申请提供的MQTT通信装置一实施例的示意图,如图4所示的MQTT通信装置100包括:处理模块1001和通信模块1002。其中,处理模块1001用于确定地理位置,并在地理位置满足第一预设条件时,通过通信模块1002与服务器建立MQTT连接,并通过所述MQTT连接进行MQTT通信。MQTT通信装置中的各模块分别执行的上述步骤的具体原理及实现方式,可参考本申请前述实施例中的MQTT通信方法中的描述,不再赘述。For example, FIG. 4 is a schematic diagram of an embodiment of an MQTT communication device provided in this application. The MQTT communication device 100 shown in FIG. 4 includes: a processing module 1001 and a communication module 1002 . Wherein, the processing module 1001 is used to determine the geographic location, and when the geographic location satisfies the first preset condition, establish an MQTT connection with the server through the communication module 1002, and perform MQTT communication through the MQTT connection. For the specific principle and implementation of the above steps performed by each module in the MQTT communication device, reference may be made to the description of the MQTT communication method in the foregoing embodiments of the present application, and details are not repeated here.
需要说明的是,应理解以上装置的各个模块的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且这些模块可以全部以软件通过处理元件调用的形式实现;也可以全部以硬件的形式实现;还可以部分模块通过处理元件调用软件的形式实现,部分模块通过硬件的形式实现。可以为单独设立的处理元件,也可以集成在上述装置的某一个芯片中实现,此外,也可以以程序代码的形式存储于上述装置的存储器中,由上述装置的某一个处理元件调用并执行以上确定模块的功能。其它模块的实现与之类似。此外这些模块全部或部分可以集成在一起,也可以独立实现。这里所述的处理元件可以是一种集成电路,具有信号的处理能力。在实现过程中,上述方法的各步骤或以上各个模块可以通过处理器元件中的硬件的集成逻辑电路或者软件形式的指令完成。It should be noted that it should be understood that the division of each module of the above device is only a division of logical functions, and may be fully or partially integrated into one physical entity or physically separated during actual implementation. And these modules can all be implemented in the form of calling software through processing elements; they can also be implemented in the form of hardware; some modules can also be implemented in the form of calling software through processing elements, and some modules can be implemented in the form of hardware. It may be a separately established processing element, or it may be integrated into a certain chip of the above-mentioned device. In addition, it may also be stored in the memory of the above-mentioned device in the form of program code, which is called and executed by a certain processing element of the above-mentioned device. Determine the functionality of the module. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, and can also be implemented independently. The processing element mentioned here may be an integrated circuit with signal processing capability. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or an instruction in the form of software.
例如,以上这些模块可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个特定集成电路(application specific integrated circuit,ASIC),或,一个或多个微处理器(digital signal processor,DSP),或,一个或者多个现场可编程门阵列(field programmable gate array,FPGA)等。再如,当以上某个模块通过处理元件调度程序代码的形式实现时,该处理元件 可以是通用处理器,例如中央处理器(central processing unit,CPU)或其它可以调用程序代码的处理器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,SOC)的形式实现。For example, the above modules may be one or more integrated circuits configured to implement the above method, for example: one or more specific integrated circuits (application specific integrated circuit, ASIC), or, one or more microprocessors (digital signal processor, DSP), or, one or more field programmable gate arrays (field programmable gate array, FPGA), etc. For another example, when one of the above modules is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program codes. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘solid state disk(SSD))等。In the above embodiments, all or part of them may be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application will be generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center integrated with one or more available media. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, or a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
图5为本申请提供的电子设备一实施例的结构示意图,本申还提供一种电子设备200,包括:处理器2001以及存储器2002;其中,存储器2002中存储有计算机程序,当处理器2001执行计算机程序时,处理器2001可用于执行如本申请前述实施例中任一的MQTT通信方法。处理器2001可以通过通信接口2003建立MQTT连接、进行MQTT通信等。5 is a schematic structural diagram of an embodiment of an electronic device provided by the present application. The present application also provides an electronic device 200, including: a processor 2001 and a memory 2002; wherein, a computer program is stored in the memory 2002. When the processor 2001 executes As a computer program, the processor 2001 may be used to execute the MQTT communication method in any one of the foregoing embodiments of the present application. The processor 2001 can establish an MQTT connection, perform MQTT communication, etc. through the communication interface 2003.
本申请还提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序被执行时可用于执行如本申请前述实施例中任一的MQTT通信方法。The present application also provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed, it can be used to execute the MQTT communication method in any one of the foregoing embodiments of the present application.
本申请实施例还提供一种运行指令的芯片,所述芯片用于执行如本申请前述任一实施例的MQTT通信方法。The embodiment of the present application also provides a chip for running instructions, and the chip is used to implement the MQTT communication method according to any one of the foregoing embodiments of the present application.
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码 的介质。Those of ordinary skill in the art can understand that all or part of the steps for implementing the above method embodiments can be completed by program instructions and related hardware. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above-mentioned method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.
最后应说明的是:以上各实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述各实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, rather than limiting them; although the application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the various embodiments of the present application. scope. .

Claims (12)

  1. 一种消息队列遥测传输MQTT通信方法,其特征在于,包括:A message queue telemetry transmission MQTT communication method is characterized in that, comprising:
    第一设备确定其所在的地理位置;The first device determines its geographic location;
    当所述地理位置满足第一预设条件时,所述第一设备与服务器建立MQTT连接,并通过所述MQTT连接进行MQTT通信。When the geographic location satisfies the first preset condition, the first device establishes an MQTT connection with the server, and performs MQTT communication through the MQTT connection.
  2. 根据权利要求1所述的方法,其特征在于,所述确定所述第一设备所在的地理位置,包括:所述第一设备通过融合定位服务FLP确定所述地理位置。The method according to claim 1, wherein the determining the geographic location of the first device comprises: determining the geographic location by the first device through a fusion positioning service (FLP).
  3. 根据权利要求2所述的方法,其特征在于,所述第一预设条件包括:The method according to claim 2, wherein the first preset condition comprises:
    所述地理位置与第一预设位置之间的距离小于第一阈值;The distance between the geographic location and the first preset location is smaller than a first threshold;
    或者,所述地理位置与第二预设位置之间的距离大于第二阈值,所述第二阈值大于所述第一阈值。Alternatively, the distance between the geographic location and the second preset location is greater than a second threshold, and the second threshold is greater than the first threshold.
  4. 根据权利要求1-3任一项所述的方法,其特征在于,所述第一设备与所述服务器建立MQTT连接,包括:The method according to any one of claims 1-3, wherein establishing an MQTT connection between the first device and the server includes:
    所述第一设备通过通用分组无线服务GRPS网络与所述服务器建立MQTT连接;The first device establishes an MQTT connection with the server through a General Packet Radio Service GRPS network;
    或者,所述第一设备通过无线保真Wi-Fi网络与所述服务器建立MQTT连接。Alternatively, the first device establishes an MQTT connection with the server through a Wi-Fi Wi-Fi network.
  5. 根据权利要求4所述的方法,其特征在于,所述第一设备通过Wi-Fi网络与所述服务器建立MQTT连接之前,还包括:The method according to claim 4, wherein, before the first device establishes an MQTT connection with the server through the Wi-Fi network, further comprising:
    所述第一设备开启Wi-Fi服务;The first device starts the Wi-Fi service;
    所述第一设备从存储单元中确定与所述地理位置对应的接入点AP信息;其中,所述存储单元中存储有至少一个地理位置,以及每个地理位置对应的AP信息;The first device determines AP information corresponding to the geographic location from a storage unit; wherein at least one geographic location and AP information corresponding to each geographic location are stored in the storage unit;
    所述第一设备根据所述AP信息,通过所述AP提供的Wi-Fi网络与所述服务器建立MQTT连接。The first device establishes an MQTT connection with the server through the Wi-Fi network provided by the AP according to the AP information.
  6. 根据权利要求3所述的方法,其特征在于,所述第一设备进行MQTT通信,包括:The method according to claim 3, wherein the first device performing MQTT communication comprises:
    当所述地理位置与第三预设位置之间的距离小于第三阈值,所述第 一设备以发布者模式进行MQTT通信;When the distance between the geographic location and the third preset location is less than a third threshold, the first device performs MQTT communication in publisher mode;
    当所述地理位置与第三预设位置之间的距离大于第三阈值,所述第一设备以订阅者模式进行MQTT通信。When the distance between the geographic location and the third preset location is greater than a third threshold, the first device performs MQTT communication in a subscriber mode.
  7. 根据权利要求1所述的方法,其特征在于,所述第一设备通过所述MQTT连接进行MQTT通信之后,还包括:The method according to claim 1, wherein after the first device performs MQTT communication through the MQTT connection, further comprising:
    当所述第一设备所在的地理位置满足第二预设条件时,所述第一设备断开与所述服务器之间的MQTT连接。When the geographic location where the first device is located satisfies a second preset condition, the first device disconnects the MQTT connection with the server.
  8. 根据权利要求1所述的方法,其特征在于,所述第一设备与所述服务器建立MQTT连接之后,还包括:The method according to claim 1, wherein after the first device establishes an MQTT connection with the server, further comprising:
    所述第一设备发出提示信息,向用户提示已建立MQTT连接;The first device sends a prompt message, prompting the user that the MQTT connection has been established;
    所述第一设备根据接收到所述用户发出的指示信息,通过所述MQTT连接进行MQTT通信。The first device performs MQTT communication through the MQTT connection according to receiving the indication information sent by the user.
  9. 根据权利要求1所述的方法,其特征在于,所述第一设备与所述服务器建立MQTT连接之后,还包括:The method according to claim 1, wherein after the first device establishes an MQTT connection with the server, further comprising:
    根据预设时间段内所确定的地理位置,得到所述第一设备的移动速度,所述预设时间段为所述第一设备建立MQTT连接之前的时间段;Obtaining the moving speed of the first device according to the determined geographic location within a preset time period, where the preset time period is a time period before the first device establishes an MQTT connection;
    根据所述移动速度确定向所述服务器发送的MQTT数据,通过所述MQTT连接向所述服务器发送所述MQTT数据。Determine the MQTT data to be sent to the server according to the moving speed, and send the MQTT data to the server through the MQTT connection.
  10. 一种MQTT通信装置,其特征在于,包括:处理模块和通信模块;其中,处理模块用于确定所在的地理位置;当地理位置满足第一预设条件时,控制所述通信模块与服务器建立MQTT连接,并控制所述通信模块通过所述MQTT连接进行MQTT通信。An MQTT communication device, characterized in that it includes: a processing module and a communication module; wherein the processing module is used to determine the geographic location; when the geographic location meets the first preset condition, the communication module is controlled to establish an MQTT with the server connection, and control the communication module to perform MQTT communication through the MQTT connection.
  11. 一种电子设备,其特征在于,包括:处理器及存储器;其中,存储器中存储有计算机程序,当处理器执行计算器程序时,处理器可用于执行如权利要求1-9任一项所述的MQTT通信方法。An electronic device, characterized in that it includes: a processor and a memory; wherein, a computer program is stored in the memory, and when the processor executes the computer program, the processor can be used to execute the computer program described in any one of claims 1-9. The MQTT communication method.
  12. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序被执行时可用于执行如权利要求1-9任一项所述的MQTT通信方法。A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, and when the computer program is executed, it can be used to execute the MQTT communication method according to any one of claims 1-9.
PCT/CN2022/139551 2021-12-23 2022-12-16 Mqtt communication method and apparatus, electronic device, and storage medium WO2023116564A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111589302.3 2021-12-23
CN202111589302.3A CN114339469A (en) 2021-12-23 2021-12-23 MQTT communication method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2023116564A1 true WO2023116564A1 (en) 2023-06-29

Family

ID=81055356

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/139551 WO2023116564A1 (en) 2021-12-23 2022-12-16 Mqtt communication method and apparatus, electronic device, and storage medium

Country Status (2)

Country Link
CN (1) CN114339469A (en)
WO (1) WO2023116564A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114339469A (en) * 2021-12-23 2022-04-12 锐迪科创微电子(北京)有限公司 MQTT communication method, device, electronic equipment and storage medium
CN115580700A (en) * 2022-09-15 2023-01-06 海南视联通信技术有限公司 Terminal quitting method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108173860A (en) * 2017-12-29 2018-06-15 深圳市泛海三江科技发展有限公司 A kind of MQTT connection methods, system, terminal and the server of low side constrained devices
CN109040326A (en) * 2018-11-02 2018-12-18 北京京东金融科技控股有限公司 The method and apparatus of PUSH message
US20210248905A1 (en) * 2020-02-12 2021-08-12 Global Traffic Technologies, Llc Location-based message distribution
CN113246117A (en) * 2020-02-11 2021-08-13 株式会社日立制作所 Robot control method and device and building management system
CN114339469A (en) * 2021-12-23 2022-04-12 锐迪科创微电子(北京)有限公司 MQTT communication method, device, electronic equipment and storage medium
CN114501378A (en) * 2022-03-06 2022-05-13 南京理工大学 Special environment emergency communication method and system based on vehicle-road cooperation

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101316399A (en) * 2007-05-31 2008-12-03 华为技术有限公司 Method, system and device for updating communication terminal appearance
CN102956052A (en) * 2012-08-14 2013-03-06 姚利龙 Queuing method and queuing system based on mobile intelligent terminal
CN105208029B (en) * 2015-09-30 2018-01-16 北京奇虎科技有限公司 A kind of data processing method and terminal device
CN105553796A (en) * 2015-12-31 2016-05-04 杭州智蚁科技有限公司 Mobile phone location based smart home control method and system
CN110278221A (en) * 2018-03-15 2019-09-24 蔚来汽车有限公司 The method of long-range control vehicle
CN108683573A (en) * 2018-03-27 2018-10-19 青岛海尔科技有限公司 A kind of safety establishes the method and device of remote control
CN108965319A (en) * 2018-08-03 2018-12-07 珠海格力电器股份有限公司 Apparatus control method, system and storage medium
CN109215304A (en) * 2018-10-28 2019-01-15 全家慧 The anti-lost system of important item and anti-loss method
CN109712375B (en) * 2018-12-29 2021-06-15 杭州平普智能科技有限公司 Monitoring management method and device for specific personnel
CN110139220A (en) * 2019-05-06 2019-08-16 江南大学 A kind of anti-lost tracing system based on NB-IoT
CN112229037B (en) * 2019-06-30 2022-09-09 广东美的制冷设备有限公司 Control method of air conditioner, terminal, air conditioner and storage medium
CN111880551A (en) * 2020-07-21 2020-11-03 中通服软件科技有限公司 Unmanned aerial vehicle signal transmission method, system, equipment and storage medium
CN111866161A (en) * 2020-07-28 2020-10-30 中国联合网络通信集团有限公司 Information subscription and publishing method and device, server, system, equipment and medium
CN112383960A (en) * 2021-01-15 2021-02-19 南京安全无忧网络科技有限公司 Two-dimensional and three-dimensional integrated factory personnel positioning system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108173860A (en) * 2017-12-29 2018-06-15 深圳市泛海三江科技发展有限公司 A kind of MQTT connection methods, system, terminal and the server of low side constrained devices
CN109040326A (en) * 2018-11-02 2018-12-18 北京京东金融科技控股有限公司 The method and apparatus of PUSH message
CN113246117A (en) * 2020-02-11 2021-08-13 株式会社日立制作所 Robot control method and device and building management system
US20210248905A1 (en) * 2020-02-12 2021-08-12 Global Traffic Technologies, Llc Location-based message distribution
CN114339469A (en) * 2021-12-23 2022-04-12 锐迪科创微电子(北京)有限公司 MQTT communication method, device, electronic equipment and storage medium
CN114501378A (en) * 2022-03-06 2022-05-13 南京理工大学 Special environment emergency communication method and system based on vehicle-road cooperation

Also Published As

Publication number Publication date
CN114339469A (en) 2022-04-12

Similar Documents

Publication Publication Date Title
WO2023116564A1 (en) Mqtt communication method and apparatus, electronic device, and storage medium
EP3735785B1 (en) Multicast and broadcast services in 5g networks for iot applications
CN107409269A (en) It is determined that to the route for acting on behalf of flow between mobile client and agent equipment
CN109792684A (en) UE is set to keep waking up
KR101945779B1 (en) Method for operating wake on wlan and apparatus for the same
EP3100471A1 (en) Context-aware and proximity-aware service layer connectivity management
WO2015161442A1 (en) D2d communication detection method, device and system
JP2006518162A5 (en)
EP3068150B1 (en) Method and device for controlling device
CN107258092A (en) Supported for the discovery of mobile client device and the cloud of data transfer
CN110351828A (en) A kind of localization method and device
WO2018233510A1 (en) Communication method and apparatus
CN108270745B (en) Business customized information pushing method, terminal and master control Bluetooth device
WO2015184823A1 (en) Access control method and device for mobile terminal, and computer storage medium
JP4842968B2 (en) Method and apparatus for the generation and transport of multimedia content flows to distribution networks
US10133754B2 (en) Peer-to-peer picture sharing using custom based rules for minimal power consumption and better user experience
KR20170050552A (en) A method and apparatus for group communicatoin
WO2019238050A1 (en) Communication method and apparatus
WO2022105711A1 (en) Ims registration method, terminal device and storage medium
EP4050964A1 (en) Method and apparatus for modifying pdu session and always-on pdu session in wireless communication system
JP2023519735A (en) POSITIONING CONTROL METHOD AND APPARATUS BY MOVEMENT OF TERMINAL IN WIRELESS COMMUNICATION
WO2024036453A1 (en) Federated learning method and related device
WO2024021853A1 (en) Communication method and communication apparatus
EP4358589A1 (en) Electronic apparatus, control circuit, and transmission control method
US20220322462A1 (en) Method and apparatus for configuring edge computing service information

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22909878

Country of ref document: EP

Kind code of ref document: A1