Disclosure of Invention
In view of the above, it is necessary to provide a method, a system, a gateway and a storage medium for identifying devices by gateways that are compatible with each other.
A method for identifying equipment by a gateway is applied to the gateway and comprises the following steps:
the gateway receives a networking starting instruction, wherein the networking instruction carries a product identification code;
starting networking according to the networking instruction, and establishing a networking relation with the received equipment;
searching for a manufacturer identification code corresponding to the product identification code from a configuration file according to the product identification code, wherein the configuration file comprises product information of a plurality of manufacturers, and the product information comprises: a manufacturer identification code, a product identification code and a model identification code;
inquiring a model identification code corresponding to the equipment based on the networking relationship between the gateway and the equipment;
and determining whether a corresponding product exists according to the manufacturer identification code and the model identification code, and if so, finishing the identification and authentication of the equipment.
A system for a gateway to identify a device, the system comprising: a gateway and a device; the gateway is used for receiving a networking starting instruction, wherein the networking instruction carries a product identification code, networking is started according to the networking instruction, a networking relation is established with received equipment, a manufacturer identification code corresponding to the product identification code is searched from a configuration file according to the product identification code, the configuration file comprises product information of a plurality of manufacturers, and the product information comprises: inquiring the model identification code corresponding to the equipment based on the networking relationship between the gateway and the equipment by using the manufacturer identification code, the product identification code and the model identification code;
the equipment is used for establishing a networking relationship with the gateway, receiving a request for acquiring the model identification code sent by the gateway and returning the model identification code to the gateway according to the request;
the gateway is also used for determining whether a corresponding product exists according to the manufacturer identification code and the model identification code, and if so, the identification and authentication of the equipment are completed.
A gateway comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of:
receiving a networking starting instruction, wherein the networking instruction carries a product identification code;
starting networking according to the networking instruction, and establishing a networking relation with the received equipment;
searching for a manufacturer identification code corresponding to the product identification code from a configuration file according to the product identification code, wherein the configuration file comprises product information of a plurality of manufacturers, and the product information comprises: a manufacturer identification code, a product identification code and a model identification code;
inquiring a model identification code corresponding to the equipment based on the networking relation with the equipment;
and determining whether a corresponding product exists according to the manufacturer identification code and the model identification code, and if so, finishing the identification and authentication of the equipment.
A computer-readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the steps of:
receiving a networking starting instruction, wherein the networking instruction carries a product identification code;
starting networking according to the networking instruction, and establishing a networking relation with the received equipment;
searching for a manufacturer identification code corresponding to the product identification code from a configuration file according to the product identification code, wherein the configuration file comprises product information of a plurality of manufacturers, and the product information comprises: a manufacturer identification code, a product identification code and a model identification code;
inquiring a model identification code corresponding to the equipment based on the networking relation with the equipment;
and determining whether a corresponding product exists according to the manufacturer identification code and the model identification code, and if so, finishing the identification and authentication of the equipment.
According to the method, the system, the gateway and the storage medium for identifying the equipment, after the gateway receives a networking starting instruction, networking is started according to the networking instruction, a networking relation is established with the received equipment, then a corresponding manufacturer identification code is searched from a configuration file according to a product identification code in the networking instruction, a model identification code is obtained from the equipment based on the networking relation between the gateway and the equipment, whether a corresponding product exists or not is determined according to the manufacturer identification code and the model identification code, and if the corresponding product exists, identification and authentication of the equipment are completed. According to the gateway identification method, the configuration file is set in the gateway, the configuration file comprises product information of a plurality of manufacturers, identification and authentication of equipment of each manufacturer are achieved through the configuration file, products of each manufacturer can be identified in a compatible mode, and universality is achieved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, a method for identifying a device by a gateway is provided, where the method for identifying a device by a gateway is applied to a gateway, and the method for identifying a device by a gateway specifically includes the following steps:
step 102, the gateway receives a networking starting instruction, and the networking instruction carries a product identification code.
The gateway receives a networking starting instruction sent by the terminal, wherein the networking instruction comprises a product identification code which is used for identifying a product (namely equipment). Specifically, an APP (application program) is installed in the terminal, and the APP is used for interacting with the user and sending an instruction triggered by the user to the gateway through the server. The gateway has the functions of: and identifying and networking the equipment, and synchronizing the equipment state to the server and the terminal. The gateway can be a zigbee3.0 gateway or other gateways. Fig. 2 is a schematic system architecture diagram of a gateway identification device in an embodiment. The APP (terminal) is connected with the server, the server is connected with the gateway, and the gateway can identify equipment of different manufacturers.
And 104, starting networking according to the networking command, and establishing a networking relation with the received equipment.
After receiving a networking starting instruction, the gateway starts networking, namely, a mode of networking with surrounding equipment is started, and a networking relation is established with the received equipment. Specifically, the process of establishing a networking relationship with the device is as follows: the device searches the gateway, starts networking after the gateway is searched, and the gateway and the device can communicate after networking. The networking can adopt the existing standard networking mode. In one embodiment, the device is a smart home device, such as a smart refrigerator, a smart washing machine, or the like.
Step 106, searching for a manufacturer identification code corresponding to the product identification code from a configuration file according to the product identification code, wherein the configuration file comprises product information of a plurality of manufacturers, and the product information comprises: a vendor identification code, a product identification code, and a model identification code.
Wherein the vendor identification code is used to uniquely identify a vendor. The product identification code is used for uniquely identifying a product, and the model identification code is used for uniquely identifying the model of a product. The vendor identification code is typically server-assigned, as is the product identification code. The model identification code is generally customized by the manufacturer, namely, the model code of the product is given by the manufacturer. The configuration file is preset and the gateway can be downloaded from the server.
Because the networking instruction carries the product identification code, the manufacturer identification code corresponding to the product identification code can be found by searching the configuration file.
In one embodiment, the configuration file is encoded using the JSON format. The configuration file includes: file version number, different product information of a plurality of producers, the product information includes: a vendor identification code, a vendor-defined model id (i.e., a model identification code), a product identification code. In addition, the system also comprises a state attribute list for synchronization, wherein the state attribute list defines the product state attribute corresponding to each product and is used for acquiring the state of the product subsequently. In one embodiment, the configuration format is as follows:
and 108, inquiring the model identification code corresponding to the equipment based on the networking relation between the gateway and the equipment.
After the gateway and the device establish a networking relationship, the gateway can acquire the model identification code of the device from the device. For example, the model identification code may be obtained by sending a request to the device to obtain the model identification code of the device, and then receiving the model identification code returned by the device.
And step 110, determining whether a corresponding product exists according to the manufacturer identification code and the model identification code, and if so, completing the identification and authentication of the equipment.
After the manufacturer identification code and the model identification code are known, whether a corresponding product exists in the configuration file can be inquired according to the manufacturer identification code and the model identification code. The configuration file stores the corresponding relation between the manufacturer and the model identification code.
According to the method for identifying the equipment by the gateway, after receiving a networking starting instruction, the gateway starts networking according to the networking instruction, establishes a networking relation with the received equipment, then searches a corresponding manufacturer identification code from a configuration file according to a product identification code in the networking instruction, obtains a model identification code from the equipment based on the networking relation between the gateway and the equipment, then determines whether a corresponding product exists according to the manufacturer identification code and the model identification code, and if so, completes identification and authentication of the equipment. According to the gateway identification method, the configuration file is set in the gateway, the configuration file comprises product information of a plurality of manufacturers, identification and authentication of equipment of each manufacturer are achieved through the configuration file, products of each manufacturer can be identified in a compatible mode, and universality is achieved.
As shown in fig. 3, in an embodiment, the configuration file further includes: a list of status attributes of the product; the method for identifying the device by the gateway further comprises the following steps:
and step 112, when the gateway is connected to the network, acquiring the device information in the device list.
In order to synchronize the device state to the server in time, after the gateway is connected to the network, the gateway first acquires the device list and then starts to traverse the device information in the device list, so that the states of the devices in the device list are synchronized to the server and the terminal. The device information may refer to an identification code of the device for uniquely identifying one device.
And step 114, inquiring the state attribute list of the product according to the equipment information, and determining the product state attribute corresponding to the equipment information.
The product state attribute set corresponding to each piece of equipment information is recorded in the state attribute list, and the product state attributes corresponding to each piece of equipment may be different, so that the corresponding product state attributes need to be searched according to the equipment information. For example, the attributes corresponding to device one include: switch, time, brightness; the attributes corresponding to the second device comprise: switch, brightness, color.
And step 116, executing corresponding reading operation according to the product state attribute, and synchronizing the read device attribute state to the server.
After the product status attribute is known, the gateway may perform a corresponding reading operation, that is, read the generation status attribute of the corresponding device to obtain the device attribute status, for example, the product status attribute includes: the switch, the brightness and the color are read according to the product state attribute, for example, the read device attribute state is: open, highlight, green. And then synchronizing the read device attribute state to the server and the terminal.
By setting the state attribute list in the configuration file, the device state can be synchronized to the server when the gateway is connected to the network each time.
As shown in fig. 4, which is a schematic flow diagram of synchronizing device states in an embodiment, after a gateway is connected to a network, a device list is traversed from the beginning, a first device in the device list is first obtained, whether the device is a valid device is determined, if the device is a valid device, a product state attribute corresponding to the device is searched in a configuration file, then the device attribute state is read by the searched product state attribute, after reading is completed, a next device is obtained, and the above operations are repeated until all devices in the device list are traversed.
In one embodiment, the method for identifying a device by a gateway further includes: the gateway sends the version information of the configuration file to a server, the server is used for comparing the version information sent by the gateway with the latest version information of the local configuration file, and if the version information is not consistent with the latest version information of the local configuration file, the gateway is informed to update the configuration file; and receiving a message whether the server needs an updated version or not, and downloading the configuration file of the latest version from the server if the server needs the updated version.
Wherein the configuration file supports update extensions. In the process of practical application, products may need to be increased continuously, and the attribute state of an existing product may need to be changed, so that the configuration file needs to support dynamic update. When the configuration file needs to be updated, the configuration file of the latest version is stored in the server. And then the server acquires the version information sent by the gateway, compares the version information of the gateway with the latest version information, if the version information of the gateway is consistent with the latest version information, the latest version information in the gateway is indicated, and updating is not needed, and if the version information of the gateway is inconsistent with the latest version information, the latest version information in the gateway is indicated, and the configuration file of the latest version is required to be issued to the gateway. In one embodiment, when the gateway receives the configuration file of which the latest version needs to be downloaded, the gateway actively sends a request to the server for acquisition. The method for identifying the equipment by the gateway can realize dynamic updating of the configuration file, and is simple and convenient.
In one embodiment, the gateway identification device further includes: and if the corresponding product does not exist according to the manufacturer identification code and the model identification code, judging that the equipment is invalid equipment, deleting the equipment information and unbinding the equipment.
And if the fact that the corresponding product does not exist according to the manufacturer identification code and the model identification code indicates that the networking equipment is invalid equipment, deleting and unbinding the equipment information.
As shown in fig. 5, in one embodiment, a system for identifying a device by a gateway is provided, the system comprising:gateway 502 anddevice 504;
the gateway is used for receiving a networking starting instruction, wherein the networking instruction carries a product identification code, networking is started according to the networking instruction, a networking relation is established with received equipment, a manufacturer identification code corresponding to the product identification code is searched from a configuration file according to the product identification code, the configuration file comprises product information of a plurality of manufacturers, and the product information comprises: inquiring the model identification code corresponding to the equipment based on the networking relationship between the gateway and the equipment by using the manufacturer identification code, the product identification code and the model identification code;
the equipment is used for establishing a networking relationship with the gateway, receiving a request for acquiring the model identification code sent by the gateway and returning the model identification code to the gateway according to the request;
the gateway is also used for determining whether a corresponding product exists according to the manufacturer identification code and the model identification code, if so, finishing the identification and authentication of the equipment, and adding the equipment into a networked equipment list.
As shown in fig. 6, in an embodiment, the system for identifying a device by a gateway further includes: aserver 506; the configuration file further comprises: a list of status attributes of the product;
the gateway is further used for acquiring the equipment information in the equipment list when the gateway is connected to the network, inquiring the state attribute list of the product according to the equipment information, determining the product state attribute corresponding to the equipment information, executing corresponding reading operation according to the product state attribute, and synchronizing the read equipment attribute state to the server;
the server is also used for receiving the equipment attribute state uploaded by the equipment.
In one embodiment, the gateway is further configured to send version information of the configuration file to the server;
the server is also used for comparing the version information sent by the gateway with the latest version information of the local configuration file, and if the version information is not consistent with the latest version information of the local configuration file, the server informs the gateway to update the configuration file;
the gateway is further configured to receive a message that whether the server needs an updated version or not, and if the server needs the updated version, download the configuration file of the latest version from the server.
As shown in fig. 7, in an embodiment, the system for identifying a device by a gateway further includes: a terminal 508;
the terminal is used for sending a networking starting instruction to the gateway through the APP.
In one embodiment, a gateway is proposed, comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the steps of: receiving a networking starting instruction, wherein the networking instruction carries a product identification code; starting networking according to the networking instruction, and establishing a networking relation with the received equipment; searching for a manufacturer identification code corresponding to the product identification code from a configuration file according to the product identification code, wherein the configuration file comprises product information of a plurality of manufacturers, and the product information comprises: a manufacturer identification code, a product identification code and a model identification code; inquiring a model identification code corresponding to the equipment based on the networking relation with the equipment; and determining whether a corresponding product exists according to the manufacturer identification code and the model identification code, if so, finishing the identification authentication of the equipment, and adding the equipment into a networked equipment list.
In one embodiment, the configuration file further includes: a list of status attributes of the product; the method further comprises the following steps: when the gateway is connected to a network, acquiring equipment information in the equipment list; inquiring a state attribute list of the product according to the equipment information, and determining a product state attribute corresponding to the equipment information; and executing corresponding reading operation according to the product state attribute, and synchronizing the read equipment attribute state to a server.
In one embodiment, the computer program is further configured to perform the following steps when executed by the processor: sending the version information of the configuration file to a server, wherein the server is used for comparing the version information sent by a gateway with the latest version information of a local configuration file, and if the version information is inconsistent with the latest version information of the local configuration file, informing the gateway to update the configuration file; and receiving a message whether the server needs an updated version or not, and downloading the configuration file of the latest version from the server if the server needs the updated version.
In one embodiment, the computer program is further configured to perform the following steps when executed by the processor: and if the corresponding product does not exist according to the manufacturer identification code and the model identification code, judging that the equipment is invalid equipment, deleting the equipment information and unbinding the equipment.
In one embodiment, a computer readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the steps of: receiving a networking starting instruction, wherein the networking instruction carries a product identification code; starting networking according to the networking instruction, and establishing a networking relation with the received equipment; searching for a manufacturer identification code corresponding to the product identification code from a configuration file according to the product identification code, wherein the configuration file comprises product information of a plurality of manufacturers, and the product information comprises: a manufacturer identification code, a product identification code and a model identification code; inquiring a model identification code corresponding to the equipment based on the networking relation with the equipment; and determining whether a corresponding product exists according to the manufacturer identification code and the model identification code, if so, finishing the identification authentication of the equipment, and adding the equipment into a networked equipment list.
In one embodiment, the configuration file further includes: a list of status attributes of the product; the method further comprises the following steps: when the gateway is connected to a network, acquiring equipment information in the equipment list; inquiring a state attribute list of the product according to the equipment information, and determining a product state attribute corresponding to the equipment information; and executing corresponding reading operation according to the product state attribute, and synchronizing the read equipment attribute state to a server.
In one embodiment, the computer program is further configured to perform the following steps when executed by the processor: sending the version information of the configuration file to a server, wherein the server is used for comparing the version information sent by a gateway with the latest version information of a local configuration file, and if the version information is inconsistent with the latest version information of the local configuration file, informing the gateway to update the configuration file; and receiving a message whether the server needs an updated version or not, and downloading the configuration file of the latest version from the server if the server needs the updated version.
In one embodiment, the computer program is further configured to perform the following steps when executed by the processor: and if the corresponding product does not exist according to the manufacturer identification code and the model identification code, judging that the equipment is invalid equipment, deleting the equipment information and unbinding the equipment.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.