Disclosure of Invention
In view of the above problems, the present invention aims to provide a method and a device for implementing a local scene linkage gateway based on slicing, which implement local scene and linkage of an intelligent home gateway, solve the problem that no network exists, and enable a localized key scene to be effective for old, so that the intelligent home is not limited by the network.
The invention provides a local scene linkage gateway realization method based on a slice type, which comprises the following steps:
Triggering matching and enqueuing: when the gateway receives the uplink data of the terminal through the LoRa, the gateway can trigger and inquire a local scene and a linkage trigger source list, inquire whether new trigger source information exists, if so, the parent class in the trigger source is extracted into a trigger source temporary queue, and the uplink data of the terminal is corrected to be triggered to the local linkage or scene (used for distinguishing whether the command needs a server to trigger the linkage or scene) and then is reported to the server;
instruction information processing: the gateway inquires whether the temporary queue of the triggering source has data, if so, the gateway indicates that the corresponding local scene or linkage needs to be triggered; extracting a cmd instruction for verification, correcting the sequence number of the data packet after the cmd instruction is successfully verified, merging the packed data into a queue of a terminal, and waiting for local linkage or scene interaction;
local linkage or scene interaction: whether the gateway is networked or not, the gateway performs data control interaction with the terminal according to the data descending to the terminal queue; if the gateway is networked at this time, all the uplink data of the terminals in the interaction process are synchronized to the server.
Local linkage and deletion, modification and acquisition of scenes: after the gateway is networked, a request for acquiring a local scene and linkage is initiated to a server, and the server splits a parent scene or parent linkage into a plurality of sub scenes or sub linkages according to the byte size of each scene and linkage and predetermined rules and transmits the sub scenes or sub linkages to the gateway;
The gateway judges whether the transmission is repeated or not according to a scene and linkage triggering source storage table, a scene and linkage normal execution information storage table, a scene and linkage delay execution information table, a downlink equipment list information storage table and a scene and linkage CMD command storage table, and if the transmission is new, the transmission is stored in the corresponding positions in the five tables; until the server pushes all sub-scenes and sub-links;
meanwhile, when the server finds that the scene is updated, the gateway is informed to delete the corresponding sub-scene, after receiving the response of the completion of the deletion of the gateway, the corresponding sub-scene is issued to the gateway to update the sub-scene;
similarly, when the server finds that linkage update exists, the gateway is informed to delete the corresponding sub-linkage, after receiving the response of the completion of the gateway deletion, the corresponding sub-linkage is issued to the gateway to update the sub-linkage.
In this scheme, trigger matching and enqueuing specifically are:
the gateway checks the LoRa received data, if the received data, the local scene and the linked trigger source list are inquired, whether the data equipment ID is the trigger source ID is compared, if not, the data equipment ID is reported to the server, if yes, whether the data equipment ID is the trigger action is judged, if not, the data equipment ID is reported to the server, if yes, the data equipment ID is returned to the triggered scene or the linked parent class and other information;
And then modifying the frame head and frame tail fields of the trigger command, modifying all uplink serial numbers which are the same as the trigger source ID, returning information to enqueue the trigger source temporary queue, and reporting to the server.
In this scheme, instruction information processing specifically includes:
the gateway inquires whether the temporary queue of the trigger source has data or not;
inquiring all subclasses of which the field parent class is the same as the field parent class in the trigger source temporary queue in the execution information table according to the field parent class in the trigger source temporary queue, and extracting cmd storage position location, cmd instruction number cmd_num and cmd instruction total length corresponding to the corresponding subclasses;
judging whether the cmd instruction is delayed to descend, if so, carrying out delay processing, and returning to inquire whether the temporary queue of the receiving trigger source has data again; if not, different cmd instructions are respectively intercepted according to the data protocol format, verification processing is respectively carried out, and if the verification is successful, the packed data are merged into a queue and are sent down to a terminal queue, and the downlink processing is waited. If the delay flag in the trigger source is set, the delay time delay of the corresponding instruction is also required to be extracted, and the data is enqueued in delay instruction information processing. Delaying other processes is consistent with normal processes.
In this scheme, delay instruction information processing specifically is:
and triggering one inquiry after each time of delay for 1s, inquiring whether the delay time in the delay array is 0 if the delay cmd instruction exists, re-inquiring if the delay time is 0, subtracting 1s from the delay time of the cmd instruction with the delay requirement in the delay array if the delay time is not 0, re-inquiring if the delay time of the cmd is not 0 at the moment, indicating that the instruction needs to be downlink at the moment if the delay time of the cmd is 0, taking out the corresponding cmd instruction in the array, queuing the packaged data into a downlink terminal queue, and delivering downlink program processing.
The invention provides a local scene linkage gateway realization device based on a slice type, which comprises a main control unit, a static memory, an external expansion FLASH module, an Ethernet module and a LoRa module, wherein the static memory, the external expansion FLASH module, the Ethernet module and the LoRa module are connected with the main control unit;
the main control unit is connected with the server through the Ethernet module and communicated with the terminal through the LoRa module;
the main control unit controls the device;
and the FLASH module realizes code storage, local linkage and scene storage. .
In this scheme, the FLASH module of expanding has five tables to store, is respectively:
A scene and linkage trigger source storage table, a scene and linkage normal execution information storage table, a scene and linkage delay execution information table, a downlink equipment list information storage table, and a scene and linkage CMD command storage table;
the scene and linkage trigger source storage table is used for storing the scene or linkage trigger source and the information corresponding to the trigger source; the method is used for comparing the received data and extracting corresponding information; corresponding to the scene and the linkage normal execution information storage table;
the scene and linkage normal execution information storage table stores the position information location, the instruction quantity cmd_num and the total length of each sub-class stored in the FLASH module; the intermediaries are used for scene and linkage trigger source storage tables and scene and linkage CMD command storage table storage tables;
the scene and linkage delay execution information storage table has the same functions as the scene and linkage normal execution information storage table, and one more field delay time delay is used for scenes and linkages with requirements on delay processing;
the downlink equipment list information storage table stores an equipment list of a downlink terminal, and is used for distinguishing whether single fire equipment or zero fire equipment and a multicast instruction according to a field type and notifying a downlink Cheng Cai to take different downlink strategies;
The scenario and linkage CMD command storage table stores instructions for the scenario or linkage for all subclasses.
In this scheme, the model of the main control chip of main control unit is: STM32H750ZBT6; the model of the LoRa chip of the LoRa module is ZM470SX-M; the type of the memory chip of the static memory is as follows: CY62157EV30LL-45ZSXI; the model of the external expansion chip of the external expansion FLASH module is as follows: W25Q128 ffsg; the main chip model of the Ethernet is as follows: LAN8720A.
In this scheme, the device can implement the following method:
triggering matching and enqueuing: when the gateway receives the uplink data of the terminal through the LoRa, the gateway can trigger and inquire a local scene and a linkage trigger source list, inquire whether new trigger source information exists, if so, the parent class in the trigger source is extracted into a trigger source temporary queue, and the uplink data of the terminal is corrected to be triggered to the local linkage or scene (used for distinguishing whether the command needs a server to trigger the linkage or scene) and then is reported to the server;
instruction information processing: the gateway inquires whether the temporary queue of the triggering source has data, if so, the gateway indicates that the corresponding local scene or linkage needs to be triggered; extracting a cmd instruction for verification, correcting the sequence number of the data packet after the cmd instruction is successfully verified, merging the packed data into a queue of a terminal, and waiting for local linkage or scene interaction;
Local linkage or scene interaction: whether the gateway is networked or not, the gateway performs data control interaction with the terminal according to the data descending to the terminal queue; if the gateway is networked at this time, all the uplink data of the terminals in the interaction process are synchronized to the server.
Local linkage and deletion, modification and acquisition of scenes: after the gateway is networked, a request for acquiring a local scene and linkage is initiated to a server, and the server splits a parent scene or parent linkage into a plurality of sub scenes or sub linkages according to the byte size of each scene and linkage and predetermined rules and transmits the sub scenes or sub linkages to the gateway;
the gateway judges whether the transmission is repeated or not according to a scene and linkage triggering source storage table, a scene and linkage normal execution information storage table, a scene and linkage delay execution information table, a downlink equipment list information storage table and a scene and linkage CMD command storage table, and if the transmission is new, the transmission is stored in the corresponding positions in the five tables; until the server pushes all sub-scenes and sub-links;
meanwhile, when the server finds that the scene is updated, the gateway is informed to delete the corresponding sub-scene, after receiving the response of the completion of the deletion of the gateway, the corresponding sub-scene is issued to the gateway to update the sub-scene;
Similarly, when the server finds that linkage update exists, the gateway is informed to delete the corresponding sub-linkage, after receiving the response of the completion of the gateway deletion, the corresponding sub-linkage is issued to the gateway to update the sub-linkage.
In this scheme, trigger matching and enqueuing specifically are:
the gateway checks the LoRa received data, if the received data, the local scene and the linked trigger source list are inquired, whether the data equipment ID is the trigger source ID is compared, if not, the data equipment ID is reported to the server, if yes, whether the data equipment ID is the trigger action is judged, if not, the data equipment ID is reported to the server, if yes, the data equipment ID is returned to the triggered scene or the linked parent class and other information;
then, modifying the frame head and frame tail fields of the trigger command, modifying all uplink serial numbers which are the same as the trigger source ID, returning information to enqueue the trigger source temporary queue, and reporting to a server;
the instruction information processing specifically comprises the following steps:
the gateway inquires whether the temporary queue of the trigger source has data or not;
inquiring all subclasses of which the field parent class is the same as the field parent class in the trigger source temporary queue in the execution information table according to the field parent class in the trigger source temporary queue, and extracting cmd storage position location, cmd instruction number cmd_num and cmd instruction total length corresponding to the corresponding subclasses;
Judging whether the cmd instruction is delayed to descend, if so, carrying out delay processing, and returning to inquire whether the temporary queue of the receiving trigger source has data again; if not, different cmd instructions are respectively intercepted according to the data protocol format, verification processing is respectively carried out, and if the verification is successful, the packed data are merged into a queue and are sent down to a terminal queue, and the downlink processing is waited. If the delay flag in the trigger source is set, the delay time delay of the corresponding instruction is also required to be extracted, and the data is enqueued in delay instruction information processing. Delaying other processes is consistent with normal processes.
In this scheme, delay instruction information processing specifically is:
and triggering one inquiry after each time of delay for 1s, inquiring whether the delay time in the delay array is 0 if the delay cmd instruction exists, re-inquiring if the delay time is 0, subtracting 1s from the delay time of the cmd instruction with the delay requirement in the delay array if the delay time is not 0, re-inquiring if the delay time of the cmd is not 0 at the moment, indicating that the instruction needs to be downlink at the moment if the delay time of the cmd is 0, taking out the corresponding cmd instruction in the array, queuing the packaged data into a downlink terminal queue, and delivering downlink program processing.
The invention discloses a method and a device for realizing a local scene linkage gateway based on a slice type, wherein the method realizes the local scene and linkage of an intelligent home gateway, solves the problem that a network does not exist, and ensures that a localized key pressing scene is old and effective, so that the intelligent home is not limited by the network.
According to the method, the scene and the linkage are subjected to slicing processing, one parent scene or parent linkage can be sliced into sub-scenes or sub-linkages with response lengths, so that all sub-scenes and sub-linkages cannot be excessively long in bytes, space waste is caused, and the requirements of local scenes and linkage on hardware are reduced. The market competitiveness and the practicability of the intelligent gateway are enhanced.
The device corrects the LoRaWAN, and the disadvantages of the LoRaWAN are not limited in transmission speed, namely, the disadvantages are converted into advantages. Meanwhile, the requirements of long-distance transmission and full house coverage can be met.
The local scene and linkage of the method can independently distinguish whether the controlled equipment is powered by single fire or zero fire and whether a multicast mode is adopted, and different communication modes are executed according to the characteristics of the terminal.
According to the method, through field processing, a local scene and a linked trigger source can be reported to a server and are different from other trigger sources, so that the method is a root source of terminal equipment control and is plastic.
The method uses a multi-table storage mode, so that the gateway has higher efficiency in executing.
The method has a serial number identification function, and can identify whether to filter the retransmission data. Local scene and linkage repetitive motion due to retransmission is prevented.
The method supports delay instruction operation in a local scene and a linkage instruction.
The method supports the update of local sub-scenes and sub-links of the gateway at any time when the gateway is connected, and synchronizes the sub-scenes and the sub-links into the latest sub-scenes and sub-links under the condition of the network.
Detailed Description
So that the manner in which the above recited objects, features and advantages of the present application can be understood in detail, a more particular description of the application, briefly summarized below, may be had by reference to the appended drawings. It should be noted that, without conflict, the embodiments of the present application and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application, however, the present application may be practiced in other ways than those described herein, and therefore the scope of the present application is not limited to the specific embodiments disclosed below.
Fig. 1 shows a flow chart of a method for implementing a slice-based local scene linkage gateway according to the present application.
As shown in fig. 1, the application discloses a local scene linkage gateway implementation method based on slice type, which comprises the following steps:
s102: triggering matching and enqueuing: when the gateway receives the uplink data of the terminal through the LoRa, the gateway triggers and inquires a local scene and a linkage trigger source list, inquires whether new trigger source information exists, extracts the father class in the trigger source into a trigger source temporary queue if the new trigger source information exists, corrects the uplink data of the terminal into triggered local linkage or scene (used for distinguishing whether the command needs a server to trigger the linkage or scene) and reports the triggered local linkage or scene to the server;
s104: instruction information processing: the gateway inquires whether the temporary queue of the triggering source has data, and if so, the gateway indicates that the corresponding local scene or linkage needs to be triggered; extracting cmd instructions for verification, and merging the packed data into a terminal queue to be downlink after verification success, wherein local linkage or scene interaction is performed;
S106: local linkage or scene interaction: and whether the gateway is networked or not, the gateway performs data control interaction with the terminal according to the data which is downwards transmitted to the terminal queue. If the gateway is networked at this time, all the uplink data of the terminals in the interaction process are synchronized to the server.
Local linkage and deletion, modification and acquisition of scenes: after the gateway is networked, a request for acquiring a local scene and linkage is initiated to a server, and the server splits a parent scene or parent linkage into a plurality of sub scenes or sub linkages according to the byte size of each scene and linkage and predetermined rules and transmits the sub scenes or sub linkages to the gateway;
the gateway judges whether the transmission is repeated or not according to a scene and linkage triggering source storage table, a scene and linkage normal execution information storage table, a scene and linkage delay execution information table, a downlink equipment list information storage table and a scene and linkage CMD command storage table, and if the transmission is new, the transmission is stored in the corresponding positions in the five tables; until the server pushes all sub-scenes and sub-links;
meanwhile, when the server finds that the scene is updated, the gateway is informed to delete the corresponding sub-scene, after receiving the response of the completion of the deletion of the gateway, the corresponding sub-scene is issued to the gateway to update the sub-scene;
Similarly, when the server finds that linkage update exists, the gateway is informed to delete the corresponding sub-linkage, after receiving the response of the completion of the gateway deletion, the corresponding sub-linkage is issued to the gateway to update the sub-linkage.
According to an embodiment of the present invention, as shown in fig. 2, fig. 2 shows a trigger matching and enqueuing flowchart, where the trigger matching and enqueuing is specifically:
the gateway checks the LoRa received data, if the received data, the local scene and the linked trigger source list are inquired, whether the data equipment ID is the trigger source ID is compared, if not, the data equipment ID is reported to the server, if yes, whether the data equipment ID is the trigger action is judged, if not, the data equipment ID is reported to the server, if yes, the data equipment ID is returned to the triggered scene or the linked parent class and other information;
and then modifying the frame head and frame tail fields of the trigger command, modifying all uplink serial numbers which are the same as the trigger source ID, returning information to enqueue the trigger source temporary queue, and reporting to the server.
When the gateway receives the uplink data of the terminal through the LoRa, the gateway triggers the inquiry of the local scene and the linkage trigger source list, and compares the local scene and the linkage trigger source list with the corresponding information of the uplink data. If the upstream device ID is the same, updating all upstream serial numbers of the same ID as the upstream device in the trigger source list, namely source_id. At this time and comparing whether the source and action in the trigger source list are the same. And if the terminal data bit local scene and the linkage trigger source data are the same, indicating the terminal data bit local scene and the linkage trigger source data. At this time, it is also necessary to compare whether the uplink sequence numbers up_old_serial in the trigger source are the same, and the same indicates that the command is a terminal retransmission command, and the trigger information is not entered into the trigger source temporary queue. If the trigger source information is different, the trigger source information is new, and the father class in the trigger source needs to be extracted into a temporary trigger source queue.
According to an embodiment of the present invention, as shown in fig. 3, fig. 3 shows a normal instruction information processing flowchart, and the instruction information processing specifically includes:
the gateway inquires whether the temporary queue of the trigger source has data or not; inquiring all subclasses of which the field parent class is the same as the field parent class in the trigger source temporary queue in the execution information table according to the field parent class in the trigger source temporary queue, and extracting cmd storage position location, cmd instruction number cmd_num and cmd instruction total length corresponding to the corresponding subclasses;
judging whether the cmd instruction is delayed to descend, if so, carrying out delay processing, and returning to inquire whether the temporary queue of the receiving trigger source has data again; if not, different cmd instructions are respectively intercepted according to the data protocol format, verification processing is respectively carried out, and if the verification is successful, the packed data are merged into a queue and are sent down to a terminal queue, and the downlink processing is waited. If the delay flag in the trigger source is set, the delay time delay of the corresponding instruction is also required to be extracted, and the data is enqueued in delay instruction information processing. Delaying other processes is consistent with normal processes.
It should be noted that the thread is always querying whether the trigger source temporary queue has data. If there is data indicating that the corresponding local scene or linkage needs to be triggered. Inquiring all the sub-classes son of which the fields father are the same as the fields father in the trigger source temporary queue in the execution information table according to the fields father in the trigger source temporary queue, extracting cmd storage positions location, cmd instruction number cmd_num and cmd instruction total length corresponding to the corresponding sub-classes son, extracting cmd according to the storage information, respectively performing verification processing, merging packed data into a terminal queue to be downlink after verification success, and waiting for downlink stroke processing. If the delay flag in the trigger source is set, the delay time delay of the corresponding instruction is also required to be extracted, and the data is enqueued in delay instruction information processing. Delaying other processes is consistent with normal processes.
According to an embodiment of the present application, as shown in fig. 4, fig. 4 shows a delay instruction information processing flow, where the delay instruction information processing specifically includes:
and triggering one inquiry after each time of delay for 1s, inquiring whether the delay time in the delay array is 0 if the delay cmd instruction exists, re-inquiring if the delay time is 0, subtracting 1s from the delay time of the cmd instruction with the delay requirement in the delay array if the delay time is not 0, re-inquiring if the delay time of the cmd is not 0 at the moment, indicating that the instruction needs to be downlink at the moment if the delay time of the cmd is 0, taking out the corresponding cmd instruction in the array, queuing the packaged data into a downlink terminal queue, and delivering downlink program processing.
Fig. 5 shows a block diagram of a slice-based local scene linkage gateway implementation device of the present application.
As shown in fig. 5, the application discloses a local scene linkage gateway implementation device based on a slice, wherein the local scene linkage gateway implementation device 5 based on the slice comprises a main control unit 51, a static memory 52, an external expansion FLASH module 53, an ethernet module 54 and a LoRa module 55 which are connected with the main control unit 51;
the main control unit 51 is in communication with a server through the Ethernet module 54 and is in communication with a terminal through the LoRa module 55;
The main control unit 51 controls and realizes the control of the local scene linkage gateway realizing device 5 based on the slice type;
the FLASH module 53 realizes code storage, local linkage and scene preservation. .
According to the embodiment of the present invention, the FLASH module 53 stores five tables, which are respectively:
the scene and linkage trigger source stores a table, a scene and linkage normal execution information storage table, a scene and linkage delay execution information table, a downlink equipment list information storage table, and a scene and linkage CMD command storage table.
The scene and linkage trigger source storage table is used for storing the scene or linkage trigger source and the information corresponding to the trigger source; the method is used for comparing the received data and extracting corresponding information; corresponding to the scene and the linkage normal execution information storage table.
The scene and linkage normal execution information storage table stores the position information location, the instruction quantity cmd_num and the total length of each sub-class stored in the FLASH module; the intermediary is used for scene and linkage trigger source storage tables and scene and linkage CMD command storage table storage tables.
The scene and linkage delay execution information storage table has the same functions as the scene and linkage normal execution information storage table, and one more field delay time delay is used for scenes and linkages with requirements on delay processing.
The downlink equipment list information storage table stores an equipment list of a downlink terminal, and can distinguish whether single fire equipment or zero fire equipment and a multicast instruction according to field type, so that different downlink strategies can be notified to downlink courses.
The scenario and linkage CMD command storage table stores instructions for the scenario or linkage for all subclasses.
(1) The scene and linkage trigger source store tables are shown in table 1.
Table 1 scenario and linked trigger Source storage Table
Field description:
source_id: triggering a source address;
source: triggering source;
action: triggering actions;
father: a parent class;
up_old_serial: the uplink old serial number is used for comparing whether the command is repeated or not;
delay_type: the data is stored in the delayed or non-delayed region. 0x01: only in the non-delay region; 0x02: only in the delay region; 0x03: both regions are present.
The scene and linkage trigger source storage table is used for storing the scene or linkage trigger source and information corresponding to the trigger source. The method is used for comparing the received data and extracting corresponding information. Corresponding to the scene and the linkage normal execution information storage table.
This embodiment takes linkage and scene and requires each to create a table.
(2) The scene and linkage normal execution information storage table is shown in table 2.
Table 2 scenario and linkage normal execution information storage table
Sequence number
|
father
|
son
|
cmd_num
|
location
|
length
|
1
|
……
|
……
|
……
|
……
|
……
|
2
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
…… |
Field description:
father: a parent class;
son: a subclass;
cmd_num: the total number of commands for the subclass;
positioning: storing the position serial number;
length: the subclass commands total length.
The scene and linkage normal execution information storage table stores the position information location, the instruction number cmd_num and the total length of each subclass son stored in Flash. The intermediary is used for scene and linkage trigger source storage tables and scene and linkage CMD command storage table storage tables.
This embodiment takes linkage and scene and requires each to create a table.
(3) The scene and linkage delay execution information storage table is shown in table 3.
Table 3 scenario and linkage delay execution information store table
Sequence number
|
father
|
son
|
cmd_num
|
location
|
length
|
delay
|
1
|
……
|
……
|
……
|
……
|
……
|
……
|
2
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
……
|
…… |
Field description:
father: a parent class;
son: a subclass;
cmd_num: the total number of commands for the subclass;
positioning: storing the position serial number;
length: the total length of the subclass command;
delay: the instruction delays the issue time.
The scene and linkage delay execution information storage table has the same function as the scene and linkage normal execution information storage table, and a field delay time delay is added for scenes and linkage with requirements on delay processing.
Currently taking linkage and scene requires each creating a table.
(4) The downlink device list information storage table is shown in table 4.
Table 4 downlink device list information storage table
Sequence number
|
down_id
|
type
|
down_old_num
|
1
|
……
|
……
|
……
|
2
|
……
|
……
|
……
|
……
|
……
|
……
|
…… |
Field description:
down_id: executing the terminal address;
type: the terminal type is performed. 0: zero fire equipment; 1: single fire type equipment; 2: multicasting an instruction;
down_old_num: and the downlink old serial number is used for comparing whether the command is repeated or not.
The downlink equipment list information storage table stores an equipment list of a downlink terminal, and can distinguish whether single fire equipment or zero fire equipment and a multicast instruction according to a field type, so that different downlink strategies can be notified to downlink procedures.
In this embodiment, linkage, scene and voice centering require a table to be created together.
(5) The scenario and linkage CMD command memory tables are shown in table 5.
Table 5 scenario and linkage CMD command storage table
Sequence number
|
cmd
|
1
|
……
|
2
|
……
|
……
|
…… |
Field description:
cmd: subclass scenes or linked instruction stores. Instructions of the scene or linkage of all subclasses are stored.
Taking linkage and scene in this embodiment requires each creation of a table.
The relation among the five large tables is shown in fig. 6, fig. 6 shows a relation diagram corresponding to the five large tables, when the LoRa receives data, the LoRa enters the trigger source table for identification, if the LoRa is an effective trigger source, all parent classes which are the same as the LoRa are searched in the normal execution information table and the field father in the delay execution information table according to the field father in the trigger source table, and whether the execution information table exists in the delay table is judged according to the field delay_type in the trigger source table. And then reading out a downlink sub-scene or linkage to be executed in a cmd command table according to a field cmd_ num, location, length in an execution table, finally identifying a specific command type in a field type in a downlink equipment information list table, updating a field down_old_num, and packaging a corresponding terminal downlink command.
According to the embodiment of the invention, the model of the main control chip of the main control unit is as follows: STM32H750ZBT6; the model of the LoRa chip of the LoRa module is ZM470SX-M; the type of the memory chip of the static memory is as follows: CY62157EV30LL-45ZSXI; the model of the external expansion chip of the external expansion FLASH module is as follows: W25Q128 ffsg; the main chip model of the Ethernet is as follows: LAN8720A.
In this embodiment, STM32H750ZBT6 is used as a main control chip to control the function implementation of the whole device. ZM470SX-M is a LoRa chip, and realizes LoRa communication with a terminal. The LAN8720A is an ethernet implementation chip, and is configured to implement data interaction with a server through an ethernet port. W25Q128FVSG is an outward expansion FLASH, and code storage is realized. The hardware adopted by the implementation method of the device of the embodiment has no high requirement, and the local scene and linkage of the gateway are realized in an economic and reliable mode.
According to the embodiment of the invention, the device can realize the following methods:
triggering matching and enqueuing: when the gateway receives the uplink data of the terminal through the LoRa, the gateway can trigger and inquire a local scene and a linkage trigger source list, inquire whether new trigger source information exists, if so, the parent class in the trigger source is extracted into a trigger source temporary queue, and the uplink data of the terminal is corrected to be triggered to the local linkage or scene (used for distinguishing whether the command needs a server to trigger the linkage or scene) and then is reported to the server;
Instruction information processing: the gateway inquires whether the temporary queue of the triggering source has data, if so, the gateway indicates that the corresponding local scene or linkage needs to be triggered; extracting a cmd instruction for verification, correcting the sequence number of the data packet after the cmd instruction is successfully verified, merging the packed data into a queue of a terminal, and waiting for local linkage or scene interaction;
local linkage or scene interaction: whether the gateway is networked or not, the gateway performs data control interaction with the terminal according to the data descending to the terminal queue; if the gateway is networked at this time, all the uplink data of the terminals in the interaction process are synchronized to the server.
Local linkage and deletion, modification and acquisition of scenes: as shown in fig. 7, fig. 7 shows a flow chart of the coordinated interaction. After the gateway is networked, a request for acquiring a local scene and linkage is initiated to a server, and the server splits a parent scene or parent linkage into a plurality of sub scenes or sub linkages according to the byte size of each scene and linkage and predetermined rules and transmits the sub scenes or sub linkages to the gateway;
the gateway judges whether the transmission is repeated or not according to a scene and linkage triggering source storage table, a scene and linkage normal execution information storage table, a scene and linkage delay execution information table, a downlink equipment list information storage table and a scene and linkage CMD command storage table, and if the transmission is new, the transmission is stored in the corresponding positions in the five tables; until the server pushes all sub-scenes and sub-links;
Meanwhile, when the server finds that the scene is updated, the gateway is informed to delete the corresponding sub-scene, after receiving the response of the completion of the deletion of the gateway, the corresponding sub-scene is issued to the gateway to update the sub-scene;
similarly, when the server finds that linkage update exists, the gateway is informed to delete the corresponding sub-linkage, after receiving the response of the completion of the gateway deletion, the corresponding sub-linkage is issued to the gateway to update the sub-linkage.
In this scheme, trigger matching and enqueuing specifically are:
the gateway checks the LoRa received data, if the received data, the local scene and the linked trigger source list are inquired, whether the data equipment ID is the trigger source ID is compared, if not, the data equipment ID is reported to the server, if yes, whether the data equipment ID is the trigger action is judged, if not, the data equipment ID is reported to the server, if yes, the data equipment ID is returned to the triggered scene or the linked parent class and other information;
then, modifying the frame head and frame tail fields of the trigger command, modifying all uplink serial numbers which are the same as the trigger source ID, returning information to enqueue the trigger source temporary queue, and reporting to a server;
the instruction information processing specifically comprises the following steps:
The gateway inquires whether the temporary queue of the trigger source has data or not;
inquiring all subclasses of which the field parent class is the same as the field parent class in the trigger source temporary queue in the execution information table according to the field parent class in the trigger source temporary queue, and extracting cmd storage position location, cmd instruction number cmd_num and cmd instruction total length corresponding to the corresponding subclasses;
judging whether the cmd instruction is delayed to descend, if so, carrying out delay processing, and returning to inquire whether the temporary queue of the receiving trigger source has data again; if not, different cmd instructions are respectively intercepted according to the data protocol format, verification processing is respectively carried out, and if the verification is successful, the packed data are merged into a queue and are sent down to a terminal queue, and the downlink processing is waited. If the delay flag in the trigger source is set, the delay time delay of the corresponding instruction is also required to be extracted, and the data is enqueued in delay instruction information processing. Delaying other processes is consistent with normal processes.
According to the embodiment of the invention, the delay instruction information processing specifically comprises the following steps:
and triggering one inquiry after each time of delay for 1s, inquiring whether the delay time in the delay array is 0 if the delay cmd instruction exists, re-inquiring if the delay time is 0, subtracting 1s from the delay time of the cmd instruction with the delay requirement in the delay array if the delay time is not 0, re-inquiring if the delay time of the cmd is not 0 at the moment, indicating that the instruction needs to be downlink at the moment if the delay time of the cmd is 0, taking out the corresponding cmd instruction in the array, queuing the packaged data into a downlink terminal queue, and delivering downlink program processing.
The invention discloses a method and a device for realizing a local scene linkage gateway based on a slice type, wherein the method realizes the local scene and linkage of an intelligent home gateway, solves the problem that a network does not exist, and ensures that a localized key pressing scene is old and effective, so that the intelligent home is not limited by the network.
According to the method, the scene and the linkage are subjected to slicing processing, one parent scene or parent linkage can be sliced into sub-scenes or sub-linkages with response lengths, so that all sub-scenes and sub-linkages cannot be excessively long in bytes, space waste is caused, and the requirements of local scenes and linkage on hardware are reduced. The market competitiveness and the practicability of the intelligent gateway are enhanced.
The device corrects the LoRaWAN, and the disadvantages of the LoRaWAN are not limited in transmission speed, namely, the disadvantages are converted into advantages. Meanwhile, the requirements of long-distance transmission and full house coverage can be met.
The local scene and linkage of the method can independently distinguish whether the controlled equipment is powered by single fire or zero fire and whether a multicast mode is adopted, and different communication modes are executed according to the characteristics of the terminal.
According to the method, through field processing, a local scene and a linked trigger source can be reported to a server and are different from other trigger sources, so that the method is a root source of terminal equipment control and is plastic.
The method uses a multi-table storage mode, so that the gateway has higher efficiency in executing.
The method has a serial number identification function, and can identify whether to filter the retransmission data. Local scene and linkage repetitive motion due to retransmission is prevented.
The method supports delay instruction operation in a local scene and a linkage instruction.
The method supports the update of local sub-scenes and sub-links of the gateway at any time when the gateway is connected, and synchronizes the sub-scenes and the sub-links into the latest sub-scenes and sub-links under the condition of the network.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above described device embodiments are only illustrative, e.g. the division of the units is only one logical function division, and there may be other divisions in practice, such as: multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. In addition, the various components shown or discussed may be coupled or directly coupled or communicatively coupled to each other via some interface, whether indirectly coupled or communicatively coupled to devices or units, whether electrically, mechanically, or otherwise.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units; can be located in one place or distributed to a plurality of network units; some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present invention may be integrated in one processing unit, or each unit may be separately used as one unit, or two or more units may be integrated in one unit; the integrated units can be realized in a form of hardware or a form of hardware plus a form of software functional units.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware related to program instructions, and the foregoing program may be stored in a computer readable storage medium, where the program when executed performs steps including the above method embodiments; and the aforementioned storage medium includes: a mobile storage device, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk or an optical disk, or the like, which can store program codes.
Alternatively, the above-described integrated units of the present invention may be stored in a computer-readable storage medium if implemented in the form of software functional modules and sold or used as separate products. Based on such understanding, the technical solutions of the embodiments of the present invention may be embodied essentially or in part in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: a removable storage device, ROM, RAM, magnetic or optical disk, or other medium capable of storing program code.