[go: up one dir, main page]

CN106850784A - Communication method between smart host and cloud service - Google Patents

Communication method between smart host and cloud service Download PDF

Info

Publication number
CN106850784A
CN106850784A CN201710036260.8A CN201710036260A CN106850784A CN 106850784 A CN106850784 A CN 106850784A CN 201710036260 A CN201710036260 A CN 201710036260A CN 106850784 A CN106850784 A CN 106850784A
Authority
CN
China
Prior art keywords
cloud service
smart host
message
connection
smart
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201710036260.8A
Other languages
Chinese (zh)
Inventor
姜楠
徐炜新
程园
汤兆平
张恒
谢昕
万涛
宋凯
李波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
East China Jiaotong University
Original Assignee
East China Jiaotong University
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 East China Jiaotong University filed Critical East China Jiaotong University
Priority to CN201710036260.8A priority Critical patent/CN106850784A/en
Publication of CN106850784A publication Critical patent/CN106850784A/en
Pending legal-status Critical Current

Links

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/142Managing session states for stateless protocols; Signalling session states; State transitions; Keeping-state mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1044Group management mechanisms 
    • H04L67/1046Joining mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • H04L67/125Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks involving control of end-device applications over a network
    • 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/143Termination or inactivation of sessions, e.g. event-controlled end of session

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Theoretical Computer Science (AREA)
  • Cardiology (AREA)
  • Medical Informatics (AREA)
  • Selective Calling Equipment (AREA)

Abstract

本发明涉及一种智能主机与云服务之间的通信方法,应用于智能家居系统。该智能家居系统包括底层设备、智能主机、云服务以及控制终端,控制终端用于与云服务通信,并通过云服务及智能主机控制底层设备工作。所述智能主机与云服务之间的通信方法包括步骤:智能主机向云服务发送连接请求报文请求连接;云服务接收并读取连接请求报文,向智能主机回复请求确认报文;以及智能主机接收请求确认报文,并与云服务保持长连接。智能主机在与云服务保持连接的过程中,每间隔预定时间向云服务发送一条心跳报文,以确认智能主机与云服务之间是否保持连接;其中,报文为二进制字节流报文。上述智能主机与云服务之间的通信方法的实时性较好且相对较为安全。

The invention relates to a communication method between a smart host and a cloud service, which is applied to a smart home system. The smart home system includes bottom equipment, smart host, cloud service and control terminal. The control terminal is used to communicate with the cloud service and control the work of the bottom equipment through the cloud service and smart host. The communication method between the smart host and the cloud service includes the steps: the smart host sends a connection request message to the cloud service to request connection; the cloud service receives and reads the connection request message, and replies to the smart host with a request confirmation message; and The host receives the request confirmation message and maintains a persistent connection with the cloud service. During the process of maintaining connection with the cloud service, the smart host sends a heartbeat message to the cloud service at predetermined intervals to confirm whether the connection between the smart host and the cloud service is maintained; wherein, the message is a binary byte stream message. The above-mentioned communication method between the smart host and the cloud service has good real-time performance and is relatively safe.

Description

智能主机与云服务之间的通信方法Communication method between smart host and cloud service

技术领域technical field

本发明涉及领域智能家居领域,尤其涉及一种智能家居系统的智能主机与云服务之间的通信方法。The invention relates to the field of smart home, in particular to a communication method between a smart host and a cloud service of a smart home system.

背景技术Background technique

随着信息科技的快速发展,智能家居系统由于其便利性,其应用越来越普及。由于传统的智能家居系统的控制中心采用家用个人电脑(PC机)和协调器等设备作为控制中心,基于传统客户端/服务器(C/S)架构的智能家居系统需要保持一台个人电脑(PC机)运行作为中间件才能达到随时控制的目的,通过个人电脑(PC机)保持与服务器的连接,使用户的控制终端(如手机、可穿戴设备遥控器等)能够获取到当前的智能家居系统的底层设备状态。With the rapid development of information technology, smart home systems are becoming more and more popular due to their convenience. Since the control center of the traditional smart home system uses home personal computer (PC) and coordinator and other equipment as the control center, the smart home system based on the traditional client/server (C/S) architecture needs to maintain a personal computer (PC) Machine) run as middleware to achieve the purpose of control at any time, through the personal computer (PC) to maintain the connection with the server, so that the user's control terminal (such as mobile phone, wearable device remote control, etc.) can obtain the current smart home system The underlying device state.

如图4所示,上述应用的客户端/服务器架构的传统智能家居系统的设备控制步骤包括:As shown in Figure 4, the device control steps of the traditional smart home system of the client/server architecture of the above application include:

步骤一:开启一台个人电脑(PC机)保证其能一直连接互联网,启动个人电脑(PC机)内的本地服务器定时3S去访问云服务,并且与网关基于局域网Socket保持长连接。Step 1: Turn on a personal computer (PC) to ensure that it can always connect to the Internet, start the local server in the personal computer (PC) to access cloud services at regular intervals of 3 seconds, and maintain a long-term connection with the gateway based on the LAN Socket.

步骤二:启动一个网关与个人电脑(PC机)通过局域网Socket保持长连接,启动一个线程并对底层设备接收/发送控制数据。Step 2: Start a gateway to maintain a long connection with a personal computer (PC) through a LAN Socket, start a thread and receive/send control data to the underlying device.

步骤三:云服务收到一个用户发送的带有底层设备唯一编号的设备控制指令,并存储下来。Step 3: The cloud service receives a device control instruction with the unique number of the underlying device sent by the user, and stores it.

步骤四:个人电脑(PC机)定时3S主动向云服务发送一个带有底层设备唯一编号的请求最新数据指令。Step 4: The personal computer (PC) sends a command to request the latest data with the unique number of the underlying device to the cloud service at regular intervals of 3 seconds.

步骤五:云服务收到外来的个人电脑(PC机)的连接请求之后。先获取个人电脑(PC机)请求连接的底层设备唯一标志,确定是已注册的个人电脑(PC机)连接请求,则获取当前的底层设备唯一编号,并将云服务存储的当前的底层设备唯一编号的设备控制指令反馈给个人电脑(PC机);如果不对,丢弃不处理,继续监听个人电脑(PC机)连接请求。Step 5: After the cloud service receives a connection request from an external personal computer (PC). First obtain the unique identifier of the underlying device that the personal computer (PC) requests to connect to, and if it is determined that it is a registered personal computer (PC) connection request, then obtain the unique number of the current underlying device, and store the unique number of the current underlying device stored in the cloud service The numbered device control command is fed back to the personal computer (PC); if it is incorrect, it is discarded without processing, and the connection request of the personal computer (PC) is continued to be monitored.

步骤六:个人电脑(PC机)请求云服务获取最新数据指令,在云服务认证确认通过之后,个人电脑(PC机)收到云服务反馈的最新数据指令。解析出来,并通过局域网Socket通信发送给网关,网关收到设备控制指令,下发控制指令控制设备(例如:开灯)。Step 6: The personal computer (PC) requests the cloud service to obtain the latest data instruction, and after the cloud service authentication is confirmed, the personal computer (PC) receives the latest data instruction fed back by the cloud service. Analyze it and send it to the gateway through LAN Socket communication. The gateway receives the device control command and sends the control command to control the device (for example: turn on the light).

以上采用智能家居采用客户端/服务器(C/S)架构的智能家居系统,需要采用一个单独的个人电脑(PC机)与云服务通信,其系统实现成本较高。同时,由于个人电脑(PC机)是定时去访问服务器,用户控制底层设备到底层设备响应并改变状态的实时性较差。整套智能家居系统中使用单独的个人电脑(PC机),增加了耦合度,使所述智能家居系统控制时受网络的稳定性影响加大。The above-mentioned smart home system adopting the client/server (C/S) architecture of the smart home needs to use a separate personal computer (PC) to communicate with the cloud service, and the system implementation cost is relatively high. Simultaneously, because personal computer (PC) visits server regularly, the real-time performance that the user controls bottom equipment to bottom equipment response and changes state is relatively poor. A separate personal computer (PC) is used in the whole smart home system, which increases the degree of coupling, and makes the control of the smart home system more affected by the stability of the network.

发明内容Contents of the invention

本发明实施例的目的在于提供一种实时性较好且相对较为安全的应用于智能家居系统的智能主机与云服务之间的通信方法,用于解决上述技术问题。The purpose of the embodiments of the present invention is to provide a communication method between a smart host and a cloud service in a smart home system with good real-time performance and relatively safe, so as to solve the above-mentioned technical problems.

一种智能主机与云服务之间的通信方法,应用于智能家居系统,所述智能家居系统包括底层设备、智能主机、云服务以及控制终端,所述控制终端用于与所述云服务通信,并通过所述云服务及所述智能主机控制所述底层设备工作。所述智能主机与云服务之间的通信方法包括步骤:所述智能主机向所述云服务发送连接请求报文请求连接;所述云服务接收并读取连接请求报文,向所述智能主机回复请求确认报文;以及所述智能主机接收请求确认报文,并与所述云服务保持长连接。所述智能主机在与所述云服务保持连接的过程中,每间隔预定时间向云服务发送一条心跳报文,以确认所述智能主机与所述云服务之间是否保持连接;其中,所述报文为二进制字节流报文。A communication method between a smart host and a cloud service, which is applied to a smart home system, the smart home system includes underlying equipment, a smart host, a cloud service, and a control terminal, the control terminal is used to communicate with the cloud service, And control the work of the underlying device through the cloud service and the smart host. The communication method between the smart host and the cloud service includes the steps: the smart host sends a connection request message to the cloud service to request connection; the cloud service receives and reads the connection request message, and sends the message to the smart host replying to the request confirmation message; and the smart host receives the request confirmation message and maintains a persistent connection with the cloud service. During the process of maintaining the connection with the cloud service, the smart host sends a heartbeat message to the cloud service at predetermined intervals to confirm whether the connection between the smart host and the cloud service is maintained; wherein, the The message is a binary byte stream message.

在其中一种实施方式中,当所述云服务收到所述智能主机发送的心跳报文时,所述云服务判断该条心跳报文与同一智能主机的上一条心跳报文的时间差,若时间差在预设时间范围内,则所述云服务直接回复一条心跳确认报文,从而使所述云服务与所述智能主机继续保持长连接。In one of the implementation manners, when the cloud service receives the heartbeat message sent by the smart host, the cloud service judges the time difference between the heartbeat message and the previous heartbeat message of the same smart host, if If the time difference is within the preset time range, the cloud service directly replies with a heartbeat confirmation message, so that the cloud service continues to maintain a long connection with the smart host.

在其中一种实施方式中,若所述云服务判断该条心跳报文与同一智能主机的上一条心跳报文的时间差超出预设时间范围,则所述云服务主动断开与所述智能主机的长连接。In one of the implementation manners, if the cloud service judges that the time difference between the heartbeat message and the last heartbeat message of the same smart host exceeds the preset time range, the cloud service actively disconnects from the smart host long connection.

在其中一种实施方式中,当所述云服务主动断开与智能主机的长连接后,所述智能主机再次发送连接请求报文请求连接。In one of the implementation manners, after the cloud service actively disconnects the long connection with the smart host, the smart host sends a connection request message again to request a connection.

在其中一种实施方式中,所述智能主机与所述云服务连接成功后,所述智能主机向所述云服务发送当前与所述智能主机连接下的所有底层设备的设备状态。In one of the implementation manners, after the smart host is successfully connected to the cloud service, the smart host sends device states of all underlying devices currently connected to the smart host to the cloud service.

在其中一种实施方式中,每当有底层设备状态变化时,所述智能主机将该底层设备的设备状态通过报文的形式发送给所述云服务。In one of the implementation manners, whenever there is a change in the state of the underlying device, the smart host sends the device state of the underlying device to the cloud service in the form of a message.

在其中一种实施方式中,所述智能主机在请求连接的过程中,持续监听能否与所述云服务连接,且持续向所述云服务请求连接,直到与所述云服务保持长连接。In one of the implementation manners, during the process of requesting a connection, the smart host continuously monitors whether it can be connected to the cloud service, and continues to request a connection from the cloud service until a long-term connection is maintained with the cloud service.

在其中一种实施方式中,所述云服务在部署在云服务器上时,即持续保持监听等待所述智能主机的连接请求和接收所述智能主机发送的报文。In one of the implementation manners, when the cloud service is deployed on the cloud server, it continuously monitors and waits for the connection request of the smart host and receives the message sent by the smart host.

在其中一种实施方式中,所述云服务接收所述智能主机发送的报文后,首先获取报文中的报文类型信息,并根据报文类型回复一个相应的报文给所述智能主机。In one of the implementation manners, after receiving the message sent by the smart host, the cloud service first obtains the message type information in the message, and replies a corresponding message to the smart host according to the message type .

在其中一种实施方式中,所述报文包括用于区分其他报文的报头以及用于搭载控制信息的数据体。In one implementation manner, the message includes a header used to distinguish other messages and a data body used to carry control information.

相对于现有技术,本发明实施例提供的智能主机与云服务之间的通信方法中,所述智能主机与所述云服务保持长连接,所述云服务收到用户发送的设备控制指令,所述智能主机能够立刻收到,从用户控制到底层设备响应几乎一瞬间完成,实时性强。同时,所述智能主机与所述云服务通过二进制字节流的报文交互,安全保密性强。Compared with the prior art, in the communication method between the smart host and the cloud service provided by the embodiment of the present invention, the smart host maintains a persistent connection with the cloud service, and the cloud service receives a device control instruction sent by the user, The smart host can receive it immediately, and the response from the user control to the underlying equipment is almost instantaneous, and the real-time performance is strong. At the same time, the smart host interacts with the cloud service through messages of binary byte streams, which ensures high security and confidentiality.

附图说明Description of drawings

为了更清楚地说明本发明的技术方案,下面将对实施方式中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solution of the present invention more clearly, the accompanying drawings used in the implementation will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some implementations of the present invention. As far as the skilled person is concerned, other drawings can also be obtained based on these drawings on the premise of not paying creative work.

图1是本发明实施例提供的智能家居系统的框架示意图;Fig. 1 is a schematic framework diagram of a smart home system provided by an embodiment of the present invention;

图2是本发明实施例提供的智能主机与云服务之间的通信报文的结构示意图;FIG. 2 is a schematic structural diagram of a communication message between a smart host and a cloud service provided by an embodiment of the present invention;

图3是本发明实施例提供的智能主机与云服务之间的交互流程示意图;FIG. 3 is a schematic diagram of an interaction flow between a smart host and a cloud service provided by an embodiment of the present invention;

图4是本发明背景技术的示意图。Fig. 4 is a schematic diagram of the background technology of the present invention.

具体实施方式detailed description

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

请同时参阅图1至图3,本发明实施例提供一种如图3所示的智能主机与云服务之间的通信方法,应用于如图1所示的智能家居系统中。所述智能家居系统包括控制终端、远程服务器、家庭控制中心以及底层设备,所述控制终端用于接收用户的操作指令,并用于将所述控制指令发送至所述远程服务器;所述远程服务器用于与所述家庭控制中心交互,并用于将所述控制指令发送至所述家庭控制中心;所述家庭控制中心用于与所述底层设备交互,并根据所述控制指令控制所述底层设备工作。其中,所述底层设备为智能家居设备,包括但不限于为灯光、插座、门磁、红外等。Please refer to FIG. 1 to FIG. 3 at the same time. The embodiment of the present invention provides a communication method between a smart host and a cloud service as shown in FIG. 3 , which is applied to the smart home system as shown in FIG. 1 . The smart home system includes a control terminal, a remote server, a home control center and bottom equipment, the control terminal is used to receive user operation instructions, and is used to send the control instructions to the remote server; the remote server uses for interacting with the home control center, and for sending the control instruction to the home control center; the home control center is for interacting with the bottom device, and controlling the bottom device to work according to the control instruction . Wherein, the underlying device is a smart home device, including but not limited to lights, sockets, door contacts, infrared, and the like.

在本发明实施方式中,所述家庭控制中心为智能主机,所述智能主机与所述底层设备及所述远程服务器通信连接。所述智能主机包括具有网关功能的硬件,所述硬件用于发送、接收所述底层设备的信号,并能够与所述远程服务器保持长连接。所述智能主机与所述底层设备之间的通信基于ZigBee协议。应当理解的是,ZigBee是一种低速短距离传输的无线网络协议。ZigBee协议从下到上分别为物理层(PHY)、媒体访问控制层(MAC)、传输层(TL)、网络层(NWK)、应用层(APL)等。其中物理层和媒体访问控制层遵循IEEE 802.15.4标准的规定。所述长连接应当理解为长期与所述远程服务器连接、收发数据。所述底层设备控制中心与所述底层设备之间的连接基于传感器网络连接,其中,所述传感器网络可以通过ZigBee、Wi-Fi等无线通信技术组建。In the embodiment of the present invention, the home control center is a smart host, and the smart host communicates with the bottom device and the remote server. The smart host includes hardware with a gateway function, and the hardware is used for sending and receiving signals of the underlying device, and can maintain a long-term connection with the remote server. The communication between the smart host and the bottom device is based on the ZigBee protocol. It should be understood that ZigBee is a wireless network protocol for low-speed short-distance transmission. The ZigBee protocol is divided into physical layer (PHY), media access control layer (MAC), transport layer (TL), network layer (NWK), application layer (APL) and so on from bottom to top. Among them, the physical layer and the media access control layer follow the regulations of the IEEE 802.15.4 standard. The long connection should be understood as a long-term connection with the remote server to send and receive data. The connection between the bottom device control center and the bottom device is based on a sensor network connection, wherein the sensor network can be established through wireless communication technologies such as ZigBee and Wi-Fi.

在本发明实施方式中,所述远程服务器为云服务,该云服务应当理解为部署在云服务器上的主从服务器。In the embodiment of the present invention, the remote server is a cloud service, which should be understood as a master-slave server deployed on the cloud server.

在本发明实施方式中,所述控制终端所可以为但不限于为手机、平板电脑、可穿戴设备、遥控器等智能便携式终端,所述控制终端同时具备网络通信功能。用户能够通过所述控制终端实现对所述底层设备的控制,用户的控制模式包括本地模式及远程模式。In the embodiment of the present invention, the control terminal may be, but not limited to, a smart portable terminal such as a mobile phone, a tablet computer, a wearable device, a remote control, etc., and the control terminal also has a network communication function. The user can control the underlying device through the control terminal, and the user's control mode includes a local mode and a remote mode.

所述本地模式应当理解为基于局域网控制模式:所述控制终端与所述智能主机连接于同一局域网,并与所述智能主机进行交互并将控制指令发送至所述智能主机,以使所述控制终端能够通过所述智能主机控制所述底层设备。所述远程模式应当理解为基于互联网模式:所述控制终端连接于通信网络,并与所述云服务进行交互,所述控制终端将控制指令发送至所述云服务后,所述云服务将控制指令发送至所述智能主机,以使所述控制终端能够通过所述云服务、所述智能主机控制所述底层设备。其中,所述控制终端与所述云服务之间、所述云服务与所述智能主机之间的通信协议为TCP/IP协议。The local mode should be understood as a LAN-based control mode: the control terminal is connected to the same local area network as the smart host, and interacts with the smart host and sends control instructions to the smart host, so that the control The terminal can control the underlying device through the smart host. The remote mode should be understood as an Internet-based mode: the control terminal is connected to the communication network and interacts with the cloud service, and after the control terminal sends the control command to the cloud service, the cloud service will control An instruction is sent to the smart host, so that the control terminal can control the underlying device through the cloud service and the smart host. Wherein, the communication protocols between the control terminal and the cloud service, and between the cloud service and the smart host are TCP/IP protocols.

在本发明实施例中,所述智能主机作为所述底层设备控制和连接所述云服务的中间件,保证了所述底层设备与所述云服务的设备信息及控制设备响应的实时性。另外,由于不需要单独的个人电脑(PC机)作为中间件,降低了耦合度,从而降低了网络不稳定对控制所述底层设备带来的不良影响。In the embodiment of the present invention, the smart host is used as the middleware for the underlying device to control and connect to the cloud service, which ensures the real-time response of the underlying device and the cloud service device information and control device response. In addition, since a separate personal computer (PC) is not needed as the middleware, the degree of coupling is reduced, thereby reducing the adverse effect of network instability on the control of the underlying devices.

在本发明实施例中,所述智能家居系统的所述底层设备、所述智能主机、所述云服务及所述控制终端相互之间的通信通过收发报文的方式实现。In the embodiment of the present invention, the communication between the bottom device of the smart home system, the smart host, the cloud service and the control terminal is implemented by sending and receiving messages.

请参阅图2,图2示意性地示出了所述智能主机与所述云服务之间通信的报文的结构。所述智能主机与所述云服务之间通信的报文协议如下:整段报文由二进制的字节流组成,所述报文包括用于区分其他报文的报头及用于搭载控制信息的数据体。所述报头包括头部、时间戳、设备号、报文类型以及数据长度。所述头部用于区分其他报文,所述时间戳用于标示所述报文发送时间,所述设备号用于标示所述报文所对应的底层设备的设备号,所述报文长度用于标示所述数据体的长度。其中,所述数据体的长度在报头的数据长度中有,这样可以避免所述报文被恶意抓包获取数据信息。Please refer to FIG. 2 . FIG. 2 schematically shows a structure of a message communicated between the smart host and the cloud service. The message protocol for communication between the smart host and the cloud service is as follows: the entire message is composed of a binary byte stream, and the message includes a header for distinguishing other messages and a header for carrying control information. data body. The header includes header, time stamp, device number, message type and data length. The header is used to distinguish other messages, the timestamp is used to mark the sending time of the message, the device number is used to mark the device number of the underlying device corresponding to the message, and the message length It is used to indicate the length of the data body. Wherein, the length of the data body is included in the data length of the header, which can prevent the packet from being maliciously captured to obtain data information.

请参阅图3,图3示意性地示出了所述云服务与所述智能主机之间的交互流程。当所述智能主机收到所述底层设备上报的设备状态等报文后,需要将所述底层设备的最新状态通过长连接发送给所述云服务,以允许所述云服务将所述底层设备的状态信息保存在数据库中。所述智能主机与云服务之间的通信方法包括以下步骤:Please refer to FIG. 3 , which schematically shows an interaction process between the cloud service and the smart host. When the smart host receives the device status and other messages reported by the bottom device, it needs to send the latest status of the bottom device to the cloud service through a persistent connection, so as to allow the cloud service to send the bottom device The status information is kept in the database. The communication method between the smart host and the cloud service includes the following steps:

步骤一:所述智能主机每次接电开机,就启动与所述云服务通信的线程并向所述云服务发送连接请求报文。其中,所述智能主机在请求连接的过程中,持续监听能否与所述云服务连接,并且持续向所述云服务请求连接,直到与所述云服务保持长连接。Step 1: Every time the smart host is powered on, it starts a thread for communicating with the cloud service and sends a connection request message to the cloud service. Wherein, during the process of requesting a connection, the smart host continuously monitors whether it can be connected to the cloud service, and continues to request a connection from the cloud service until it maintains a permanent connection with the cloud service.

步骤二:当收到所述智能主机的连接请求报文时,所述云服务首先获取报文中的报文类型信息,若判断是连接请求报文时,所述云服务回复一个请求确认报文给所述智能主机。若判断是其他的报文,所述云服务回复一个相应的报文给所述智能主机。其中,所述云服务在部署于云服务器上的时候,就启动监听等待所述智能主机发送的连接请求和接收所述智能主机发送的报文,所述云服务器可以为阿里云服务器。Step 2: When receiving the connection request message from the smart host, the cloud service first obtains the message type information in the message, and if it is judged to be a connection request message, the cloud service replies with a request confirmation message text to the smart host. If it is judged to be other messages, the cloud service replies a corresponding message to the smart host. Wherein, when the cloud service is deployed on the cloud server, it starts monitoring and waits for the connection request sent by the smart host and receives the message sent by the smart host, and the cloud server may be an Alibaba Cloud server.

步骤三:当所述智能主机收到所述云服务回复的请求确认报文时,则表示所述智能主机与所述云服务连接成功。同时所述智能主机向所述云服务发送当前与所述智能主机连接下的所有底层设备(如插座,开关等)的设备状态。在所述智能主机与所述云服务保持连接的过程中,所述智能主机每间隔预定时间向所述云服务发送一条心跳报文,以确认二者之间是否保持连接。所述预定时间可以为0.1秒、0.5秒、1秒、1.5秒、2秒等等。每当有底层设备状态变化时,所述智能主机将该底层设备的设备状态通过报文的形式发送给所述云服务。Step 3: When the smart host receives the request confirmation message replied by the cloud service, it means that the smart host is successfully connected to the cloud service. At the same time, the smart host sends the device statuses of all underlying devices (such as sockets, switches, etc.) currently connected to the smart host to the cloud service. During the process of maintaining the connection between the smart host and the cloud service, the smart host sends a heartbeat message to the cloud service at predetermined intervals to confirm whether the connection between the two is maintained. The predetermined time may be 0.1 second, 0.5 second, 1 second, 1.5 second, 2 seconds and so on. Whenever there is a change in the state of the underlying device, the smart host sends the device state of the underlying device to the cloud service in the form of a message.

步骤四:所述云服务将请求确认报文回复至所述智能主机之后,持续监听接收所述智能接收主机的报文。当所述云服务收到底层设备状态报文,其存储底层设备状态信息。当所述云服务收到的智能主机的心跳确认报文时,所述云服务判断该条心跳报文与同一智能主机的上一条心跳报文的时间差,若时间差在预设时间范围内,则所述云服务直接回复一条心跳确认报文,从而使所述云服务与所述智能主机继续保持长连接;若所述云服务判断该条心跳报文与同一智能主机的上一条心跳报文的时间差超出预设时间范围,则所述云服务主动断开与所述智能主机的长连接。Step 4: After the cloud service replies the request confirmation message to the smart host, it continues to monitor and receive messages from the smart receiving host. When the cloud service receives the underlying device status message, it stores the underlying device status information. When the cloud service receives the heartbeat confirmation message from the smart host, the cloud service judges the time difference between the heartbeat message and the previous heartbeat message of the same smart host, and if the time difference is within the preset time range, then The cloud service directly replies a heartbeat confirmation message, so that the cloud service continues to maintain a long connection with the smart host; if the cloud service judges that the heartbeat message is different from the previous heartbeat message of the same smart host If the time difference exceeds the preset time range, the cloud service actively disconnects the long connection with the smart host.

步骤五:当所述云服务主动断开与所述智能主机的长连接后,所述智能主机再次发送连接请求报文请求连接,重复步骤一至四。Step 5: After the cloud service actively disconnects the persistent connection with the smart host, the smart host sends a connection request message again to request a connection, and repeats steps 1 to 4.

本发明实施例提供的智能家居系统的智能主机与云服务之间的通信方法中,采用了智能主机替代个人电脑成为家庭控制中心,降低了智能家居系统的实现成本。同时,所述智能主机与所述云服务保持长连接,所述云服务收到用户发送的设备控制指令,所述智能主机能够立刻收到,从用户控制到底层设备响应几乎一瞬间完成,实时性强。另外,所述智能主机与所述云服务通过二进制字节流的报文交互,安全保密性强。In the communication method between the smart host and the cloud service of the smart home system provided by the embodiment of the present invention, the smart host is used to replace the personal computer as the home control center, which reduces the implementation cost of the smart home system. At the same time, the smart host maintains a long-term connection with the cloud service, and the cloud service receives the device control command sent by the user, and the smart host can receive it immediately. Strong. In addition, the smart host interacts with the cloud service through messages of binary byte streams, which has strong security and confidentiality.

最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still be Modifications are made to the technical solutions described in the foregoing embodiments, or equivalent replacements are made to some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims (10)

1. the communication means between a kind of smart host and cloud service, is applied to intelligent domestic system, the intelligent domestic system Including underlying device, smart host, cloud service and control terminal, the control terminal be used for the cloud service communication, and The underlying device is controlled to work by the cloud service and the smart host;It is logical between the smart host and cloud service Letter method includes step:
The smart host sends connection request message request and connects to the cloud service;
The cloud service is received and reads connection request message, and request confirmation message is replied to the smart host;And
The smart host receives request confirmation message, and keeps length to be connected with the cloud service;Wherein, the smart host exists During keeping being connected with the cloud service, jump message of uniting as one is sent to cloud service at interval of the scheduled time, to confirm State and whether kept between smart host and the cloud service connection;Wherein, the message is binary system byte stream packet.
2. the method for claim 1, it is characterised in that when the cloud service receives the heartbeat that the smart host sends During message, the cloud service judges to be united as one on this heartbeat message and same smart host and jumps the time difference of message, if when Between differ from preset time range, then the cloud service is directly replied and united as one jump confirmation message so that the cloud service with The smart host continues to keep connection long.
3. method as claimed in claim 2, it is characterised in that if the cloud service judges this heartbeat message with same intelligence The time difference for jumping message is united as one on main frame beyond preset time range, then the cloud service actively disconnects main with the intelligence The connection long of machine.
4. method as claimed in claim 3, it is characterised in that when the cloud service actively disconnect and the smart host length After connection, the smart host sends the connection of connection request message request again.
5. the method for claim 1, it is characterised in that after the smart host and the cloud service successful connection, institute State the equipment state that smart host sends all underlying devices under being currently connected with the smart host to the cloud service.
6. method as claimed in claim 5, it is characterised in that whenever having underlying device state change, the smart host The equipment state of the underlying device is sent to the cloud service by the form of message.
7. the method for claim 1, it is characterised in that the smart host during connection is asked, lasting prison Can listen be connected with the cloud service, and continue to ask to connect to the cloud service, until keeping length to be connected with the cloud service.
8. method as claimed in claim 7, it is characterised in that the cloud service is when being deployed on Cloud Server, i.e., lasting Keep monitoring the connection request for waiting the smart host and receive the message that the smart host sends.
9. method as claimed in claim 8, it is characterised in that the cloud service receives the message that the smart host sends Afterwards, the type of message information in message is obtained first, and it is main to the intelligence to reply a corresponding message according to type of message Machine.
10. the method for claim 1, it is characterised in that the message include for distinguish the header of other messages with And for carrying the data volume of control information.
CN201710036260.8A 2017-01-17 2017-01-17 Communication method between smart host and cloud service Pending CN106850784A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710036260.8A CN106850784A (en) 2017-01-17 2017-01-17 Communication method between smart host and cloud service

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710036260.8A CN106850784A (en) 2017-01-17 2017-01-17 Communication method between smart host and cloud service

Publications (1)

Publication Number Publication Date
CN106850784A true CN106850784A (en) 2017-06-13

Family

ID=59124529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710036260.8A Pending CN106850784A (en) 2017-01-17 2017-01-17 Communication method between smart host and cloud service

Country Status (1)

Country Link
CN (1) CN106850784A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108183950A (en) * 2017-12-28 2018-06-19 新华三技术有限公司 A kind of network equipment establishes the method and device of connection
CN110572474A (en) * 2019-09-26 2019-12-13 四川长虹电器股份有限公司 Method for embedded terminal long-connection communication
CN112217700A (en) * 2020-11-19 2021-01-12 曹明 Home-side control system of smart home
CN112398897A (en) * 2020-04-24 2021-02-23 江南大学 A Design Scheme of Wireless Remote Control Robot System Based on Socket Communication
CN114640705A (en) * 2022-04-22 2022-06-17 山东恒远智能科技有限公司 Large-scale heartbeat monitoring method for internet of things terminal

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685241A (en) * 2013-11-26 2014-03-26 中国科学院计算技术研究所 Adaptive heartbeat method and adaptive heartbeat system for maintaining long connection of TCP (transmission control protocol)
CN104252136A (en) * 2014-10-10 2014-12-31 中国联合网络通信集团有限公司 Intelligent home control method and system
CN205247087U (en) * 2015-12-12 2016-05-18 山西时代云科技有限公司 Intelligent home control system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685241A (en) * 2013-11-26 2014-03-26 中国科学院计算技术研究所 Adaptive heartbeat method and adaptive heartbeat system for maintaining long connection of TCP (transmission control protocol)
CN104252136A (en) * 2014-10-10 2014-12-31 中国联合网络通信集团有限公司 Intelligent home control method and system
CN205247087U (en) * 2015-12-12 2016-05-18 山西时代云科技有限公司 Intelligent home control system

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108183950A (en) * 2017-12-28 2018-06-19 新华三技术有限公司 A kind of network equipment establishes the method and device of connection
CN108183950B (en) * 2017-12-28 2020-11-06 新华三技术有限公司 Method and device for establishing connection of network equipment
CN110572474A (en) * 2019-09-26 2019-12-13 四川长虹电器股份有限公司 Method for embedded terminal long-connection communication
CN110572474B (en) * 2019-09-26 2021-09-21 四川长虹电器股份有限公司 Method for embedded terminal long-connection communication
CN112398897A (en) * 2020-04-24 2021-02-23 江南大学 A Design Scheme of Wireless Remote Control Robot System Based on Socket Communication
CN112398897B (en) * 2020-04-24 2022-03-11 江南大学 Wireless remote-controlled robot system based on Socket communication
CN112217700A (en) * 2020-11-19 2021-01-12 曹明 Home-side control system of smart home
CN114640705A (en) * 2022-04-22 2022-06-17 山东恒远智能科技有限公司 Large-scale heartbeat monitoring method for internet of things terminal
CN114640705B (en) * 2022-04-22 2022-08-09 山东恒远智能科技有限公司 Large-scale Internet of things terminal heartbeat monitoring method

Similar Documents

Publication Publication Date Title
EP3482554B1 (en) Methods and servers to monitor resources through http/2
US7136645B2 (en) Method and apparatus for providing mobile and other intermittent connectivity in a computing environment
US7644171B2 (en) Mobile networking system and method using IPv4 and IPv6
KR101975365B1 (en) Context-aware proximity services
CN106850784A (en) Communication method between smart host and cloud service
US9473925B2 (en) Method and apparatus for providing mobile and other intermittent connectivity in a computing environment
CN106713090A (en) Smart Home System
KR101042745B1 (en) System and method for session reestablishment between client terminal and server
US10425318B2 (en) Method for heartbeat packet processing by using proxy, apparatus, and communications system
EP1364296A1 (en) Method and apparatus for providing mobile and other intermittent connectivity in a computing environment
US10594844B2 (en) Method and system for wireless network bilateral accelerated transmission
US11343744B2 (en) Method for managing handover roaming
WO2014187295A1 (en) Communication method, terminal and communication system
US20180014355A1 (en) Method and apparatus for data exchange between gateways
CN103516766A (en) Method and system of communication between client-side and application server
US10645184B2 (en) Information transmission method, gateway, and controller
CN102064956A (en) Method for regulating aging time, system and modulator-demodulator
US10127786B1 (en) Internet protocol monitor security apparatus and methods
WO2018068580A1 (en) Instruction method and apparatus for screen locking, and method, apparatus and system for locking screen
JP2011118634A (en) Terminal management device and control method thereof
JP2025510302A (en) Partially Connected Devices
CN120110902A (en) Method, system, device, medium and product for realizing automatic networking based on Internet of Things
CN114268979A (en) A secure communication method for northbound interface of network management terminal
JP2004007080A (en) Radio communication system, housing device, and housing device selection method and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20170613

RJ01 Rejection of invention patent application after publication