Disclosure of Invention
The invention aims to disclose a high-reliability communication method and a high-reliability communication system for an intelligent lock based on Redis.
The invention aims at providing a high-reliability communication method of an intelligent lockset based on Redis.
The second invention aims to provide a Redis-based intelligent lockset high-reliability communication system.
In order to achieve the first object, the present invention provides a first technical solution, a highly reliable communication method for an intelligent lock based on Redis, comprising the following steps:
The server application component sends an instruction to the intelligent lockset;
Carrying out a hash algorithm by using an ID of the intelligent lockset, generating a corresponding key in a Redis memory database, and creating a message block in the key, wherein the message block is divided into an uplink message block and a downlink message block;
Storing the instruction into the downlink message block;
the uplink port of the intelligent lock wakes up and sends the uplink message to the uplink message block, and the server application component processes the uplink message;
After the uplink message processing is finished, the instruction stored in the downlink message block is issued to the intelligent lockset.
Preferably, the instruction is one of a character password, fingerprint information or face information.
In order to achieve the first object, the present invention provides a second technical solution, and a highly reliable communication method for an intelligent lock based on Redis, comprising the following steps:
The Web end sends an instruction to the intelligent lockset;
the server application component receives the instruction;
Carrying out a hash algorithm by using an ID of the intelligent lockset, generating a corresponding key in a Redis memory database, and creating a message block in the key, wherein the message block is divided into an uplink message block and a downlink message block;
Storing the instruction into the downlink message block;
the uplink port of the intelligent lock wakes up and sends the uplink message to the uplink message block, and the server application component processes the uplink message;
After the uplink message processing is finished, the instruction stored in the downlink message block is issued to the intelligent lockset.
In order to achieve the first object, the present invention provides a third technical solution, a highly reliable communication method for an intelligent lock based on Redis, comprising the following steps:
The mobile equipment and the intelligent lockset are connected through Bluetooth, and an APP end of the mobile equipment sends an instruction to the intelligent lockset;
the server application component receives the instruction;
Carrying out a hash algorithm by using an ID of the intelligent lockset, generating a corresponding key in a Redis memory database, and creating a message block in the key, wherein the message block is divided into an uplink message block and a downlink message block;
Storing the instruction into the downlink message block;
the uplink port of the intelligent lock wakes up and sends the uplink message to the uplink message block, and the server application component processes the uplink message;
After the uplink message processing is finished, the instruction stored in the downlink message block is issued to the intelligent lockset.
Preferably, when a new instruction is generated, the new instruction is stored at the end of the downstream message block.
Preferably, the message block is deleted after the uplink message and the instruction are processed.
Preferably, the instructions are issued sequentially one by one, and the returned confirmation information is taken as an issuing success mark.
Preferably, the instructions are issued one by one in sequence, and if the returned confirmation information is not received, the instruction issuing is stopped but the instruction which is not successfully sent is reserved.
Preferably, if the instruction needs to be canceled, the server application component traverses the downlink message block of the key to find and delete the instruction needing to be canceled.
In order to achieve the second object, the invention provides a high-reliability communication system of an intelligent lock based on Redis, which comprises a plurality of intelligent locks, a server application component, a Web end, a plurality of mobile equipment ends and a Redis memory database;
The Redis memory database is provided with a first communication port monitoring unit, a second communication port monitoring unit and a third communication port monitoring unit, wherein the first communication port monitoring unit monitors an uplink port of the intelligent lock, the second communication port monitoring unit monitors an uplink port of the Web end, and the third communication port monitoring unit monitors an uplink port of the mobile equipment end;
The server application component generates a hash key of the intelligent lockset in the Redis memory database, and creates a message block in the key, wherein the message block is divided into an uplink message block and a downlink message block.
Compared with the prior art, the invention has the beneficial effects that:
(1) Generating a key-value after carrying out a hash algorithm by using an ID of the intelligent lockset, generating a corresponding key in a Redis memory database, and creating a message block in the key, wherein the message block is divided into an uplink message block and a downlink message block; the uplink message block is used for receiving information sent by an uplink port of the intelligent lock, sending the information to the server application component and processing the information; after the uplink message processing is finished, the instruction stored in the downlink message block is issued to the intelligent lock, and if the instruction occupies a small space, the instruction is directly pushed to the intelligent lock through a single data packet and executed; if the instruction occupies a large space, the instruction is packaged into a plurality of small data packets, the small data packets are ordered and sent in sequence, so that the instruction can be orderly, reliably and completely sent to the intelligent lockset in a short time, and the power consumption of the intelligent lockset can be reduced.
(2) The Web end or the mobile device sends an instruction to the intelligent lockset through the server application component, the instruction is also stored in a key corresponding to the Redis memory database, a message block is created in the key, the Web end is operated by an administrator, and the mobile device is operated by a user, so that the communication between the administrator or the user and the intelligent lockset is realized.
Detailed Description
The present invention will be described in detail below with reference to the embodiments shown in the drawings, but it should be understood that the embodiments are not limited to the present invention, and functional, method, or structural equivalents and alternatives according to the embodiments are within the scope of protection of the present invention by those skilled in the art.
The following describes embodiments of the present invention.
Example 1
Referring to fig. 1, this embodiment discloses a specific implementation of a highly reliable communication method of an intelligent lock based on Redis.
Referring to fig. 1, in the present embodiment, a highly reliable communication method of a smart lock based on Redis,
Step S1: the server application component sends an instruction to the intelligent lockset; specifically, the server application component is deployed on the cloud server, and stores the ID (MAC address) of each intelligent lock managed by the server application component, so that for convenience of unified management, the server application component is required to send an authorization instruction to a specific intelligent lock, the authorization instruction is one of a character password, fingerprint information, an IC card or face information, and after the instruction is sent, the user can unlock the intelligent lock.
Step S2: carrying out a hash algorithm by using an ID of the intelligent lockset, generating a corresponding key in a Redis memory database, and creating a message block in the key, wherein the message block is divided into an uplink message block and a downlink message block; and carrying out a hash algorithm by using the ID of the intelligent lockset to receive the instruction, generating a key-value in a Redis memory database, creating a message block in a key position key, and dividing the message block into an uplink message block and a downlink message block. And the uplink information and the downlink information are not in conflict by the allocation of the uplink information block and the downlink information block.
Step S3: storing the instruction into the downlink message block; specifically, the information in the uplink message block and the downlink message block is stored in a hash table, and the authorization instruction is temporarily stored in the downlink message block; in order to efficiently use the storage space, the longest storage time of the information in the downlink message block is 7 days, and the information is automatically deleted after more than 7 days.
Step S4: the uplink port of the intelligent lock wakes up and sends the uplink message to the uplink message block, and the server application component processes the uplink message; specifically, communication between the intelligent lockset and the server application component must be performed under the condition that the intelligent lockset wakes up, when the intelligent lockset is in a low-power consumption state, the intelligent lockset needs to be wakened up to communicate, the wake-up mode comprises touching a password input area, a periodic heartbeat of the intelligent lockset and the like, after the intelligent lockset wakes up, the intelligent lockset sends wake-up information to a communication port monitoring unit of a Redis memory database through an uplink port of the intelligent lockset, the Redis memory database sends the wake-up information to the server application component, and the server application component processes the wake-up information.
Step S5: after the uplink message processing is finished, the instruction stored in the downlink message block is issued to the intelligent lockset. Specifically, after the server application component processes all the uplink messages of the intelligent lock, the instruction in the downlink message block is issued, namely, the instruction stored in the downlink message block is issued to the intelligent lock; in general, the character password or the IC card authorization instruction data packet is smaller, and the character password or the IC card authorization instruction is sent in a single data packet; the fingerprint information or the human face information instruction data packet is larger, the fingerprint information or the human face information instruction is packaged into a plurality of small data packets and is subjected to queue sorting, the small data packets are sent in sequence, the instruction is sent to the intelligent lock orderly, reliably and completely in a short time, and after the instruction is sent, the intelligent lock enters a low-power consumption state, so that the power consumption of the intelligent lock can be reduced.
Referring to fig. 2, a message block 1 is divided into an uplink message block 2 and a downlink message block 3, each rectangle in the uplink message block 2 representing one piece of uplink information; each rectangle in the downstream message block 3 represents a downstream instruction, and when a new instruction is generated, the new instruction is stored at the tail of the downstream message block 3, so that the instructions are ordered according to the generating order.
In order to fully utilize the storage space of the Redis memory database, after the uplink message and the instruction are processed, the message block 3 is deleted, that is, only the queue message of the intelligent lockset which needs to receive the downlink instruction is stored in the Redis memory database, once the instruction is processed, the corresponding message block 3 is automatically deleted, so that more intelligent lockset instructions can be processed in parallel. In addition, when the parallel instructions are too many, the Redis memory database adopts a cloud service load balancing processor, so that the storage capacity of the Redis memory database is adaptively and dynamically adjusted, and the conflict of the parallel instructions is reduced.
Referring to fig. 3, instructions 1, … and instruction n are sequentially arranged and issued one by one, if the uplink message block receives the return confirmation information and confirms the return confirmation information through the server application component, the instruction is successfully issued, and then the next instruction is issued continuously, so that the instruction is ensured not to lose packets; if the return confirmation information is not received, stopping issuing the instruction but reserving the instruction which is not successfully transmitted until the return confirmation information is received, and continuing to transmit the reserved instruction; by means of the arrangement, feedback and unsuccessful reservation, the reliability and the irreplaceability of the instruction transmission are ensured.
In the instruction queuing process, if one instruction needs to be canceled, for example, fingerprint information authorization of the intelligent lockset is canceled, the server application component traverses all instructions in a downlink message block of the key, finds and deletes the instruction needing to be canceled, and is convenient for managing the issued instruction.
Through the first embodiment, a key-value is generated after a hash algorithm is performed by using an ID of the intelligent lockset, a corresponding key is generated in a Redis memory database, a message block is created in the key, and the message block is divided into an uplink message block and a downlink message block; the uplink message block is used for receiving information sent by an uplink port of the intelligent lock, sending the information to the server application component and processing the information; after the uplink message processing is finished, the instruction stored in the downlink message block is issued to the intelligent lock, and if the instruction occupies a small space, the instruction is directly pushed to the intelligent lock through a single data packet and executed; if the instruction occupies a large space, the instruction is packaged into a plurality of small data packets, the small data packets are ordered and sent in sequence, so that the instruction can be orderly, reliably and completely sent to the intelligent lockset in a short time, and the power consumption of the intelligent lockset can be reduced.
Example two
Referring to fig. 4, this embodiment discloses a specific implementation of a highly reliable communication method of a smart lock based on Redis.
Referring to fig. 4, in this embodiment, the highly reliable communication method of the smart lock based on Redis includes the following steps:
Step A0: the Web terminal sends instructions to the intelligent lockset, specifically, the Web terminal is operated by an administrator and is used for managing a plurality of intelligent locksets, for example, one or more authorization instructions in character passwords, fingerprint information or face information of a user are issued to the intelligent lockset through an uplink port of the Web terminal, or one or more authorization instructions in the character passwords, the fingerprint information or the face information of the user are released and the released instructions are issued to the intelligent lockset.
Step A1: and the server application component receives the instruction, specifically, extracts the ID of the intelligent lockset from the instruction after receiving the instruction sent by the Web terminal.
Step A2: a5, according to the technical scheme of the first step S2-S5 of the embodiment, generating a corresponding key in the Redis memory database, and creating a message block in the key, wherein the message block is divided into an uplink message block and a downlink message block; the uplink message block is used for receiving information sent by an uplink port of the intelligent lock, sending the information to the server application component and processing the information; after the uplink message processing is finished, the instruction stored in the downlink message block is issued to the intelligent lock, and if the instruction occupies a small space, the instruction is directly pushed to the intelligent lock through a single data packet and executed; if the instruction occupies a large space, the instruction is packaged into a plurality of small data packets, the small data packets are ordered and sent in sequence, so that the instruction can be orderly, reliably and completely sent to the intelligent lockset in a short time, and the power consumption of the intelligent lockset can be reduced.
The highly reliable communication method of the smart lock based on Redis in the second embodiment is the same as that in the first embodiment, please refer to the first embodiment, and the description thereof is omitted.
Example III
Referring to fig. 5, this embodiment discloses a specific implementation of a highly reliable communication method of a Redis-based intelligent lock.
Referring to fig. 5, in this embodiment, the highly reliable communication method of the smart lock based on Redis includes the following steps:
Step B0: the mobile device and the intelligent lockset are connected through Bluetooth, the APP end of the mobile device sends an instruction to the intelligent lockset, specifically, the APP end of the mobile device is operated by a user, when the user operates, the Bluetooth of the mobile device is opened firstly, pairing is carried out through Bluetooth and the Bluetooth of the intelligent lockset, after pairing is completed, an authorization instruction is sent to the intelligent lockset, and the authorization instruction is one of a character password, fingerprint information or face information.
Step B1: the server application component receives the instruction, specifically, after receiving the instruction sent by the mobile equipment APP end, the server application component verifies the user identity and extracts the ID of the intelligent lockset in the instruction, and if the user identity is matched with the ID of the intelligent lockset, the instruction can be continuously issued, otherwise, the instruction is intercepted, and the mobile equipment APP end sends the instruction to the intelligent lockset through an uplink port of the instruction.
Step B2: b5 is implemented according to the technical scheme of the first step S2-S5 of the embodiment, a corresponding key is generated in the Redis memory database, a message block is created in the key, and the message block is divided into an uplink message block and a downlink message block; the uplink message block is used for receiving information sent by an uplink port of the intelligent lock, sending the information to the server application component and processing the information; after the uplink message processing is finished, the instruction stored in the downlink message block is issued to the intelligent lock, and if the instruction occupies a small space, the instruction is directly pushed to the intelligent lock through a single data packet and executed; if the instruction occupies a large space, the instruction is packaged into a plurality of small data packets, the small data packets are ordered and sent in sequence, so that the instruction can be orderly, reliably and completely sent to the intelligent lockset in a short time, and the power consumption of the intelligent lockset can be reduced.
After the user sends an authorization instruction successfully through the APP end of the mobile equipment, the user can open the intelligent lockset through one of character passwords, fingerprint information or face information.
The highly reliable communication method of the smart lock based on Redis in the third embodiment is the same as that in the first embodiment, please refer to the first embodiment, and the description thereof is omitted.
Example IV
Referring to fig. 6, this embodiment discloses a specific implementation of a highly reliable communication system for a smart lock based on Redis.
Referring to fig. 6, in this embodiment, the high-reliability communication system of the smart lock based on the Redis includes a plurality of smart locks, a server application component, a Web terminal, a plurality of mobile device terminals, and a Redis memory database;
the Redis memory database is provided with a first communication port monitoring unit, a second communication port monitoring unit and a third communication port monitoring unit, wherein the first communication port monitoring unit monitors an uplink port of the intelligent lock, the second communication port monitoring unit monitors an uplink port of the Web end, and the third communication port monitoring unit monitors an uplink port of the mobile equipment end; the first communication port monitoring unit is used for detecting threads of the uplink port of the intelligent lock, the second communication port monitoring unit is used for detecting threads of the uplink port of the Web end, and the third communication port monitoring unit is used for detecting threads of the uplink port of the mobile equipment end;
The server application component generates a hash key of the intelligent lockset in the Redis memory database, and creates a message block in the key, wherein the message block is divided into an uplink message block and a downlink message block.
Specifically, the server application component sends the instruction through the high-reliability communication method of the smart lockset based on Redis in the embodiment I; the Web end sends an instruction through the Redis-based intelligent lockset high-reliability communication method in the second embodiment; the mobile device side sends the instruction through the high-reliability communication method of the intelligent lockset based on Redis described in the third embodiment.
The highly reliable communication system of the smart lock based on Redis in the fourth embodiment is the same as that in the first, second or third embodiments, please refer to the first, second or third embodiments, and the details are not repeated here.
The above list of detailed descriptions is only specific to practical embodiments of the present invention, and they are not intended to limit the scope of the present invention, and all equivalent embodiments or modifications that do not depart from the spirit of the present invention should be included in the scope of the present invention.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned.
Furthermore, it should be understood that although the present disclosure describes embodiments, not every embodiment is provided with a separate embodiment, and that this description is provided for clarity only, and that the disclosure is not limited to the embodiments described in detail below, and that the embodiments described in the examples may be combined as appropriate to form other embodiments that will be apparent to those skilled in the art.