Method, device and system for wireless communication based on wireless communication mode
By introducing data packaging and transmissive transmission mechanisms of wireless communication between devices, the problem of long-term communication development time between devices is solved, and efficient inter-device communication and stable control effects are achieved.
Patent Information
- Application Number
- CN202411296307.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2044-09-18
AI Technical Summary
When developing communication between devices, the prior art requires a comprehensive understanding of the communication protocol, resulting in a long development time and low efficiency.
The data is encapsulated through the control unit of the first device and transmitted to the second device through wireless communication. The second device then unpacks the data to realize contactless data transmission.
It greatly reduces the time for communication between devices, improves the efficiency and control efficiency of communication between devices, and improves the stability of communication.
Smart Images

Figure CN118890655B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of wireless communication technology, and in particular to a method, device and system for performing wireless communication based on a wireless communication mode. Background Art
[0002] With the rapid development of Internet of Things technology, the use of communication between devices to achieve corresponding functions is becoming more and more widely used in many fields. For example, in the field of lighting control, stage lighting control is achieved through communication between lamps and lamps, or between mobile phones and lamps. In the field of smart home, smart control of air conditioners is achieved through communication between mobile phones and smart air conditioners.
[0003] At present, when it is necessary to develop communication between devices, developers often have a comprehensive understanding of the communication protocols used between devices, and then develop communication between devices based on their understanding. However, practice has found that it takes a lot of time to fully understand the communication protocol, which leads to a lot of time and effort to complete the development of communication between devices. Therefore, it is particularly important to propose a technical solution to reduce the development time of communication between devices, improve the communication efficiency between devices, and thus improve the control efficiency of the devices. Summary of the invention
[0004] The present invention provides a method, device and system for wireless communication based on a wireless communication mode, which can reduce the development time of communication between devices, so as to improve the communication efficiency between devices and thus improve the control efficiency of the devices.
[0005] In order to solve the above technical problems, the first aspect of the present invention discloses a method for wireless communication based on a wireless communication method, wherein a first device obtains first data to be transmitted to a second device through a first control unit of the first device, and performs an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain second data;
[0006] The first device transmits the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, so as to trigger the second device to perform the following operations;
[0007] The second device transmits the second data to a second control unit of the second device through a second wireless communication unit of the second device, and decapsulates the second data into the first data through the second control unit according to the encapsulation protocol;
[0008] The current working mode of the first device is an active mode, and the current working mode of the second device is a passive mode, wherein the active mode is used to indicate a mode in which data is actively sent, and the passive mode is used to indicate a mode in which data is passively received;
[0009] The type of the first wireless communication unit is the same as the type of the second wireless communication unit, and the type of the encapsulation protocol is determined by the type of the first wireless communication unit.
[0010] A second aspect of the present invention discloses an apparatus for performing wireless communication based on a wireless communication method, the apparatus comprising a first device, the first device comprising:
[0011] A data acquisition module, used for acquiring first data to be transmitted to a second device through a first control unit of the first device;
[0012] a data encapsulation module, configured to perform an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain second data;
[0013] a data communication module, configured to transmit the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, so as to trigger the second device to perform the following operations;
[0014] The second device transmits the second data to a second control unit of the second device through a second wireless communication unit of the second device, and decapsulates the second data into the first data through the second control unit according to the encapsulation protocol;
[0015] The current working mode of the first device is an active mode, and the current working mode of the second device is a passive mode, wherein the active mode is used to indicate a mode in which data is actively sent, and the passive mode is used to indicate a mode in which data is passively received;
[0016] The type of the first wireless communication unit is the same as the type of the second wireless communication unit, and the type of the encapsulation protocol is determined by the type of the first wireless communication unit.
[0017] A third aspect of the present invention discloses another apparatus for performing wireless communication based on a wireless communication method, the apparatus comprising a first device, the first device comprising:
[0018] A memory storing executable program code;
[0019] a processor coupled to the memory;
[0020] The processor calls the executable program code stored in the memory to execute part or all of the steps in any method for performing wireless communication based on a wireless communication manner disclosed in the first aspect of the present invention.
[0021] A fourth aspect of the present invention discloses a device control system, the device control system includes at least one group of devices, each group of the devices includes a first device and a second device, the first device and the second device respectively have a corresponding control unit and a wireless communication unit, the first control unit is communicatively connected with the first wireless communication unit via a full-duplex synchronous communication bus, the control unit of the second device is communicatively connected with the second wireless communication unit via a full-duplex synchronous communication bus, the first wireless communication unit is wirelessly connected with the second wireless communication unit, the first control unit is used to receive data from an outgoing device, and the second control unit is used to send data to a receiving device;
[0022] Among them, the first device is used to execute part or all of the steps executed by the first device in any method for wireless communication based on wireless communication disclosed in the first aspect of the present invention; the second device is used to execute part or all of the steps executed by the second device in any method for wireless communication based on wireless communication disclosed in the first aspect of the present invention.
[0023] The fifth aspect of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute some or all of the steps in any method for wireless communication based on wireless communication mode disclosed in the first aspect of the present invention.
[0024] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0025] In an embodiment of the present invention, a method, device and system for wireless communication based on a wireless communication method are disclosed, wherein a first device obtains first data to be transmitted to a second device through a first control unit of the first device, and performs an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain second data; the second data is transmitted to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, so as to trigger the second device to perform the following operations; the second device transmits the second data to the second control unit of the second device through the second wireless communication unit of the second device, and decapsulates the second data into the first data through the second control unit according to the encapsulation protocol; wherein the current working mode of the first device is an active mode, and the current working mode of the second device is a passive mode, the active mode is used to indicate a mode of actively sending data, and the passive mode is used to indicate a mode of passively receiving data; the type of the first wireless communication unit is the same as the type of the second wireless communication unit, and the type of the encapsulation protocol is determined by the type of the first wireless communication unit. It can be seen that the present invention encapsulates the data to be transmitted according to the encapsulation protocol matched with the corresponding wireless communication mode through the control unit of the first device, and transmits it to the wireless communication unit corresponding to the control unit, so that the wireless communication unit transmits the data to the second device through the wireless communication mode, so that the second device transmits the received data to the corresponding control unit through the wireless communication unit of the same type as the wireless communication unit of the first device, and unpacks it according to the same encapsulation protocol, so as to realize contactless data transmission, and there is no need for users to understand the communication protocol between devices, which greatly reduces the development time for devices to communicate with each other, improves the efficiency of establishing communication between devices, so as to improve the communication efficiency between devices, thereby improving the control efficiency of devices; and communicating through wireless communication mode, without the need to use line communication or metal contact communication, can also improve the stability of communication, thereby improving the control accuracy and stability of the device; and with the development of major wireless communication mode industries, such as the rapid development of NFC industry, wireless communication technology has been rapidly promoted and widely used in various fields, which also greatly reduces the development cost of the technical solution and broadens the applicability of the technical solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 It is a flowchart of a method for performing wireless communication based on a wireless communication method disclosed in an embodiment of the present invention;
[0028] Figure 2 is a schematic diagram of the hardware architecture of a first device and a second device disclosed in an embodiment of the present invention;
[0029] Figure 3 It is a schematic diagram of a process of transparently transmitting data between a first device and a second device disclosed in an embodiment of the present invention;
[0030] Figure 4 It is a flowchart of another method for performing wireless communication based on a wireless communication method disclosed in an embodiment of the present invention;
[0031] Figure 5 It is a structural schematic diagram of a device for performing wireless communication based on a wireless communication method disclosed in an embodiment of the present invention;
[0032] Figure 6 is a schematic structural diagram of another device for performing wireless communication based on a wireless communication method disclosed in an embodiment of the present invention;
[0033] Figure 7 is a schematic structural diagram of another device for performing wireless communication based on a wireless communication method disclosed in an embodiment of the present invention;
[0034] Figure 8 It is a structural schematic diagram of a device control system for wireless communication based on a wireless communication method disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0035] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product or end including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or ends.
[0037] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0038] The present invention discloses a method, device and system for wireless communication based on a wireless communication mode. The control unit of a first device encapsulates data to be transmitted according to an encapsulation protocol matched with the corresponding wireless communication mode, and transmits the data to a wireless communication unit corresponding to the control unit, so that the wireless communication unit transmits the data to a second device through the wireless communication mode, so that the second device transmits the received data to the corresponding control unit through a wireless communication unit of the same type as the wireless communication unit of the first device, and unpacks the data according to the same encapsulation protocol, so as to realize contactless data transparent transmission, and the user does not need to understand the communication protocol between the devices, which greatly reduces the development time of the communication between the devices, improves the efficiency of establishing communication between the devices, so as to improve the communication efficiency between the devices, thereby improving the control efficiency of the devices; and the communication is carried out through the wireless communication mode, without using line communication or metal contact communication, and the stability of the communication can be improved, thereby improving the control accuracy and stability of the device; and with the development of various wireless communication mode industries, such as the rapid development of the NFC industry, wireless communication technology is rapidly promoted and widely used in various fields, which also greatly reduces the development cost of the technical solution and broadens the applicability of the technical solution. The following is a detailed description of the method, device and system for wireless communication based on the wireless communication method described in the present invention.
[0039] Embodiment 1
[0040] See also Figure 1 , Figure 1 1 is a flow chart of a method for wireless communication based on a wireless communication method disclosed in an embodiment of the present invention. Figure 1 The described method can be applied to any application scenario between two devices that need to communicate wirelessly, wherein the application scenario includes but is not limited to stage control scenarios or smart home control scenarios. For example, in the stage control scenario, the two devices can be lamps and lamps; lamps and lamp accessories; mobile phones and lamps; computers and lamps; microphones and mobile phones, etc., which are devices that can or need to communicate wirelessly.
[0041] like Figure 1As shown, the method for performing wireless communication based on the wireless communication mode may include the following operations:
[0042] 101. A first device obtains first data to be transmitted to a second device through a first control unit of the first device, and performs an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain second data.
[0043] In the embodiment of the present invention, optionally, the current working mode of the first device is an active mode, and the current working mode of the second device is a passive mode, wherein the active mode is used to indicate a mode of actively sending data, such as the PCD (Proximity Coupling Device) mode of NFC, i.e., a reader / writer mode, and the passive mode is used to indicate a mode of passively receiving data, such as the PICC (Proximity Integrated Circuit Card) mode of NFC, i.e., a card emulation mode. The first device and the second device are both provided with an active mode and a passive mode, and the two modes can be switched to each other.
[0044] In an embodiment of the present invention, the first control unit and the first wireless communication unit of the first device, the second control unit and the second wireless communication unit of the second device, each constitute a corresponding contactless communication unit. Optionally, the type of the first control unit of the first device and the second control unit of the second device can be any unit that can implement the present technical solution. And, the type of the first wireless communication unit is the same as the type of the second wireless communication unit, and the type of the encapsulation protocol is determined by the type of the first wireless communication unit. Specifically, when the type of the first wireless communication unit is the NFC communication type, the wireless communication mode is the NFC communication mode, and the encapsulation protocol is the NFC communication protocol; when the type of the first wireless communication unit is the Bluetooth communication type, the wireless communication mode is the Bluetooth communication mode, and the encapsulation protocol is the Bluetooth communication protocol; when the type of the first wireless communication unit is the RFID communication type, the wireless communication mode is the RFID communication mode, and the encapsulation protocol is the RFID communication protocol; when the type of the first wireless communication unit is the WiFi communication type, the wireless communication mode is the WiFi communication mode, and the encapsulation protocol is the WIFI communication protocol. Figure 2 is a schematic diagram of the hardware architecture of a first device and a second device disclosed in an embodiment of the present invention, such as Figure 2As shown, the type of the first control unit of the first device and the second control unit of the second device is an MCU microcontroller, the type of the first wireless communication unit of the first device and the second wireless communication unit of the second device is NFC, the MCU microcontrollers in each of the first device and the second device communicate with the NFC front end through SPI or other buses, the NFC front end of the first device and the NFC front end of the second device communicate with each other through wireless communication, and the MCU microcontrollers of each of the first device and the second device communicate with the external device through the serial port.
[0045] In the embodiment of the present invention, optionally, the first device obtains, through the first control unit, first data to be transmitted to the second device, including:
[0046] The first device reads the data to be sent from the first buffer queue corresponding to the first device through the first control unit as the first data to be transmitted to the second device; or,
[0047] The first device receives data sent by the external device from the serial port of the first control unit through the first control unit, and determines the data sent by the external device as first data that needs to be transmitted to the second device; or
[0048] The first device receives data sent by an external device from the serial port of the first control unit through the first control unit, stores the received data sent by the external device in a first buffer queue corresponding to the first device, and obtains first data to be transmitted to the second device from the first buffer queue.
[0049] Optionally, the first buffer queue and the second device described below may be integrated into respective devices or may be independent of respective devices.
[0050] In this optional embodiment, even if there is no need to transmit data, when data is received from an external device, the data can be buffered in a buffer queue so that the data can be obtained from the buffer queue when transmission is required.
[0051] It can be seen that the embodiments of the present invention enrich the data acquisition method by directly acquiring the data to be transmitted from the buffer queue, or directly using the data sent by the external device as the data to be transmitted, or storing the data sent by the external device in the buffer queue and then acquiring the data to be transmitted from the buffer queue, which is beneficial to improving the data acquisition efficiency and thus the data transmission efficiency; and by buffering the acquired data in the buffer queue in advance, so that when data transmission is required, the data can be directly acquired from the buffer queue without waiting for the external device to send it, thereby further improving the data processing and transmission efficiency.
[0052] 102. The first device transmits the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, so as to trigger the second device to perform the following operations; the second device transmits the second data to the second control unit of the second device through the second wireless communication unit of the second device, and decapsulates the second data into the first data according to the encapsulation protocol through the second control unit.
[0053] In the embodiment of the present invention, optionally, the second device transmits the second data to the second control unit of the second device through the second wireless communication unit of the second device, including:
[0054] The second device receives the second data by wireless communication through the second wireless communication unit and generates a data prompt;
[0055] The second device transmits the data prompt to the second control unit of the second device via the second wireless communication unit to trigger the second control unit to read the second data from the second wireless communication unit after identifying the data prompt;
[0056] Further, the second device stores the first data in a second buffer queue corresponding to the second device through the second control unit;
[0057] Among them, the data in the second buffer queue is used for the second device to read the fifth data from the second buffer queue through the second control unit when it is detected that the serial port of the second control unit meets the predetermined data sending conditions, and perform a transmission operation on the fifth data based on the serial port of the second control unit.
[0058] Optionally, after receiving the second data, the second wireless communication device of the second device sends a corresponding interrupt signal to the second control unit. After receiving the interrupt signal, the second control unit reads the second data from the second wireless communication unit and unpacks it based on the encapsulation protocol to obtain the first data. After unpacking the data, if the serial port of the second control unit is in an idle state, the data is sent from the serial port to an external component or user device, thereby achieving the purpose of data transparent transmission. Among them, the idle state can be understood as a completely idle state, and it can also be understood as a state where its bandwidth size is a bandwidth size that can send the first data.
[0059] Take the NFC wireless communication method as an example for explanation. Figure 3 is a schematic diagram of a process of transparently transmitting data between a first device and a second device disclosed in an embodiment of the present invention, such as Figure 3As shown, the MCU of the first device receives the data sent by the external device from its serial port, and stores it in its receiving buffer queue (corresponding to the first buffer queue). The MCU periodically reads the data to be transmitted from the receiving buffer queue, and packages the data based on the custom packet protocol, and then encapsulates it based on the NFC encapsulation protocol, and sends the packaged and encapsulated data to the NFC front end through the SPI bus. The NFC front end then transmits the data to the NFC front end of the second device through NFC wireless communication. The MCU of the second device reads the received data from its NFC front end through the SPI bus, and unpacks it based on the NFC encapsulation protocol, and unpacks the unpacked data based on the custom packet protocol to obtain data that is exactly the same as the data sent by the external device, and stores the data in the sending buffer queue (corresponding to the second buffer queue). The MCU reads the data periodically, and sends it out when its serial port is idle, thereby realizing accurate transparent transmission of data.
[0060] It can be seen that the method described in the embodiment of the present invention encapsulates the data to be transmitted according to the encapsulation protocol matched with the corresponding wireless communication mode through the control unit of the first device, and transmits it to the wireless communication unit corresponding to the control unit, so that the wireless communication unit transmits the data to the second device through the wireless communication mode, so that the second device transmits the received data to the corresponding control unit through the wireless communication unit of the same type as the wireless communication unit of the first device, and unpacks it according to the same encapsulation protocol, so as to realize contactless data transmission, and there is no need for users to understand the communication protocol between devices, which greatly reduces the development time for devices to communicate with each other, improves the efficiency of establishing communication between devices, so as to improve the communication efficiency between devices, thereby improving the control efficiency of devices; and communicating through wireless communication mode, without the need to use line communication or metal contact communication, can also improve the stability of communication, thereby improving the control accuracy and stability of the device; and with the development of major wireless communication mode industries, such as the rapid development of NFC industry, wireless communication technology has been rapidly promoted and widely used in various fields, which also greatly reduces the development cost of the technical solution and broadens the applicability of the technical solution.
[0061] In an optional embodiment, the method may further include the following steps:
[0062] The first device performs a packetization operation on the first data based on a predetermined packetization protocol through the first control unit to obtain the packetized first data, and performs the above-mentioned operation of performing a packetization operation on the first data through the first control unit according to the predetermined packetization protocol to obtain the second data.
[0063] In this optional embodiment, the packet protocol is a unified packet protocol, and can also be determined based on one or more of the data volume of the first data, the data type, the type of the first device, the type of the second device, and the type of wireless communication method.
[0064] In this optional embodiment, after the second control unit unpacks the second data to obtain the first data, it continues to unpack the unpacked first data based on the above-mentioned packet protocol to obtain the unpacked first data, so as to achieve complete transparent transmission of data.
[0065] It should be noted that the order of data packaging and encapsulation may not be fixed, and it may be packaged first and then packaged. However, the order in which the second control unit decapsulates or packages the received second data first is opposite to the order executed by the first control unit, so as to ensure that the obtained first data is complete and correct, and further ensure the transparent transmission of the data.
[0066] It can be seen that this optional embodiment reduces the amount of data while ensuring the integrity and accuracy of the data by packaging the data, thereby improving the security and efficiency of data transmission.
[0067] In another optional embodiment, the method may further include the following steps:
[0068] When entering the active mode, the first device generates data according to the instruction through the first control unit, generates a card search instruction, the instruction generation data includes an encapsulation protocol, and sends the card search instruction outward through the first control unit;
[0069] The first device determines, through the first control unit, whether a response from a certain device is received within a first preset time period, wherein the start time of the first preset time period is the sending time of the card search instruction;
[0070] When it is determined that a response is received from a certain device, the first device executes the above-mentioned operation of transmitting the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit. The certain device is the second device.
[0071] In this optional embodiment, the instruction to generate data may also optionally include one or more of the data volume of the first data, the data type, the type of the first device, the type of the wireless communication method, and the current transmission bandwidth of the wireless communication method.
[0072] In this optional embodiment, the first preset duration may be uniform, such as 30ms, or may be determined based on one or more of the data type and amount of the first data, the type of the first device, the type of the second device, and the type of the wireless communication method, i.e., variable. Set the corresponding weight,
[0073] It should be noted that if a card search instruction has been generated before, when the first device enters the active mode, it does not need to be generated again, and the previous card search instruction can be directly sent out.
[0074] In this optional embodiment, when it is determined that no response is received from a certain device, the operation of sending the card search instruction through the first control unit is re-executed, and if the card search instruction is sent multiple times within the preset time length and still no response is received from a certain device, the passive mode is switched. The starting time of the preset time length is the sending time of the card search instruction, and is greater than the first preset time length.
[0075] It can be seen that when the first device enters the active mode, this optional embodiment actively sends out a card search instruction generated based on the encapsulation protocol so that a device that can recognize the encapsulation protocol can respond, thereby quickly and accurately finding a matching device, which is beneficial to improving the efficiency of establishing wireless communication methods, thereby improving the efficiency and stability of data transmission.
[0076] In another optional embodiment, optionally, the first device and the second device may have multiple wireless communication modes at the same time, and for each wireless communication mode, communication can be performed only when the types of the wireless communication modes of the two devices are the same; and the method may further include the following steps:
[0077] The first device analyzes, through the first control unit, a bandwidth required for sending the first data outward according to the data volume of the first data, analyzes the urgency of sending the first data outward according to the data type and the data volume of the first data, and analyzes the time required for transmitting the first data to the second device according to the type of the wireless communication mode and the current transmission bandwidth of the wireless communication mode;
[0078] According to the bandwidth required by the first data, the outgoing urgency of the first data, and the time required for the first data, corresponding weights are set for the data volume of the first data, the data type of the first data, and the type of the wireless communication method, wherein the higher the outgoing urgency, the greater the weight of the data type;
[0079] The first device generates data according to the instruction through the first control unit to generate a card search instruction, including:
[0080] The first device generates a corresponding card-searching instruction through the first control unit according to the bandwidth required by the first data, the urgency of sending the first data, the time required by the first data, and the encapsulation protocol.
[0081] In this optional embodiment, the card-seeking instruction carries the encapsulation protocol, the bandwidth required for the first data, the urgency of sending the first data, and the time required for the first data, and is used to send it outward to prompt a device that meets the bandwidth, time and urgency requirements for sending the first data to respond to the first device, or to prompt the device that responds to the first device to switch the serial port of its control unit to an idle state in advance so that it can send the first data out immediately when it receives it.
[0082] It can be seen that this optional embodiment generates an accurate card-seeking instruction by combining the outbound bandwidth required for the data, the outbound urgency of the data, the transmission time required for the data and the encapsulation protocol, and sends it outward, so that the device that meets the corresponding requirements of its bandwidth, outbound urgency and data transmission time responds to the first device, especially when there are multiple devices around, the matching accuracy of the devices is improved, thereby further improving the data transmission efficiency and improving the efficiency and success of sending the data out, thereby improving the efficiency and success of data transmission.
[0083] In yet another optional embodiment, the method may further include the following steps:
[0084] When determining that a response from a certain device is received, the first device determines, through the first control unit, whether an attribute parameter of the certain device is read;
[0085] When it is determined that the attribute parameters of a certain device are read, the first device executes the above-mentioned operation of transmitting the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through the wireless communication method matching the first wireless communication unit.
[0086] In this optional embodiment, the attribute parameter of a certain device includes one or more of the device identification of the certain device, the identification of the control unit, and the identification of the wireless communication unit. This is conducive to improving the judgment efficiency of reading the attribute parameters of the device.
[0087] In this optional embodiment, only devices with the same wireless communication mode can respond to the first device, and only the corresponding attribute parameters can be read by the first device. Furthermore, after reading the corresponding attribute parameters, the attribute parameters are further verified, such as determining whether the attribute parameters match the pre-stored attribute parameters. If so, the above-mentioned operation of transmitting the second data to the first wireless communication unit of the first device through the first control unit is continued, so that the first wireless communication unit transmits the second data to the second device through the wireless communication mode matching the first wireless communication unit.
[0088] In this optional embodiment, when it is determined that the attribute parameters of a certain device are not read or the read attribute parameters are incorrect, the above-mentioned operation of determining whether a response from a certain device is received within a first preset time period by the first control unit is re-executed.
[0089] It can be seen that this optional embodiment, after determining that a device has responded, further determines that the attribute parameters of the responding device have been read, and then confirms that the device has been correctly identified, which can improve the recognition accuracy and reliability of the device, thereby facilitating an increase in the probability of successful data transmission.
[0090] Embodiment 2
[0091] See also Figure 4 , Figure 4 1 is a flow chart of another method for wireless communication based on a wireless communication method disclosed in an embodiment of the present invention. Figure 4 The described method can be applied to any application scenario where wireless communication is required between two devices, including but not limited to stage control scenarios or smart home control scenarios. For example, in stage control scenarios, the two devices can be lamps and lamps; lamps and lamp accessories; mobile phones and lamps; computers and lamps; microphones and mobile phones, etc., which can or need to communicate wirelessly. Figure 4 As shown, the method for performing wireless communication based on the wireless communication mode may include the following operations:
[0092] 201. A first device obtains first data to be transmitted to a second device through a first control unit of the first device, and performs an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain second data.
[0093] 202. The first device transmits the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, so as to trigger the second device to perform the following operations; the second device transmits the second data to the second control unit of the second device through the second wireless communication unit of the second device, and decapsulates the second data into the first data through the second control unit according to the encapsulation protocol.
[0094] In an embodiment of the present invention, the current working mode of the first device is an active mode, and the current working mode of the second device is a passive mode. The active mode is used to indicate a mode of actively sending data, and the passive mode is used to indicate a mode of passively receiving data. The type of the first wireless communication unit is the same as the type of the second wireless communication unit, and the type of the encapsulation protocol is determined by the type of the first wireless communication unit.
[0095] 203. The first device detects, through the first control unit, whether a response from the second device is received within a second preset time period. When a response from the second device is detected, the first device re-executes step 201; when no response from the second device is detected, step 204 is triggered.
[0096] In the embodiment of the present invention, the start time of the second preset duration is the time when the second data is transmitted to the second device through the wireless communication method matching the first wireless communication unit, such as within 5 seconds.
[0097] 204. The first device switches the current mode from the active mode to the passive mode through the first control unit.
[0098] In the embodiment of the present invention, for other related descriptions of step 201-step 202, please refer to the detailed description of other technical contents in step 101-step 102 in embodiment 1, and the embodiment of the present invention will not be repeated here.
[0099] It can be seen that the embodiment of the present invention encapsulates the data to be transmitted according to the encapsulation protocol matched with the corresponding wireless communication method through the control unit of the first device, and transmits it to the wireless communication unit corresponding to the control unit, so that the wireless communication unit transmits the data to the second device through the wireless communication method, so that the second device transmits the received data to the corresponding control unit through its wireless communication unit of the same type as the wireless communication unit of the first device for unsealing according to the same encapsulation protocol, so as to realize contactless data transmission, and there is no need for users to understand the communication protocol between devices, which greatly reduces the development time for devices to communicate with each other, improves the efficiency of establishing communication between devices, so as to improve the communication efficiency between devices, thereby improving the control efficiency of devices; and communicates through wireless communication methods without using Line communication or metal contact communication can also improve the stability of communication, thereby improving the control accuracy and stability of the equipment; and with the development of major wireless communication industries, such as the rapid development of the NFC industry, wireless communication technology has been rapidly promoted and widely used in various fields, which has greatly reduced the development cost of the present technical solution and broadened the applicability of the present technical solution; in addition, after sending data to the second device, by detecting whether the second device responds within a specified time period, if a response is detected, data transparent transmission continues to be performed to reduce the situation where the device is removed but data is still sent, resulting in unsuccessful data transmission and wasting bandwidth resources, thereby increasing the probability of successful data transparent transmission; if no response is detected, it switches to passive mode so that other devices with the same wireless communication method can establish wireless communication with it, thereby performing data transparent transmission.
[0100] In an optional embodiment, the method may further include the following steps:
[0101] When detecting a response from the second device, the first device determines whether there is third data that needs to be sent to the second device;
[0102] When it is determined that there is third data that needs to be sent to the second device, the first device re-executes the above-mentioned operation of performing encapsulation operation on the first data according to the predetermined encapsulation protocol through the first control unit to obtain the second data, and the first data is the third data;
[0103] When it is determined that there is no third data that needs to be sent to the second device, the first device sends a first heartbeat packet to the second wireless communication unit in a wireless communication manner through the first wireless communication unit;
[0104] After sending the first heartbeat packet, the first device determines whether there is fourth data that needs to be sent to the second device within a third preset time length (such as 6s), wherein the starting time of the third preset time length is the time when the first heartbeat packet is sent;
[0105] When it is determined that the fourth data exists, the first device re-executes the above-mentioned operation of performing the encapsulation operation on the first data according to the predetermined encapsulation protocol through the first control unit to obtain the second data, and the first data is the fourth data;
[0106] When it is determined that the fourth data does not exist, the first device switches the current mode from the active mode to the passive mode through the first control unit, or re-executes the above operation of sending the card search instruction outward through the first control unit.
[0107] It can be seen that when this optional embodiment detects a response from the second device, if there is data to be transmitted, data transparent transmission continues to be performed to achieve complete data transparent transmission; if there is no data, a heartbeat packet is sent to maintain a wireless communication connection with the second device, so that when there is data transmission, there is no need to re-establish communication with the second device, and data transparent transmission can be performed directly, thereby improving the efficiency of data transparent transmission; if there is still no data to be transmitted after sending the heartbeat packet for a long period of time, it is switched to passive mode, thereby improving the execution accuracy and reliability of the passive mode switching action.
[0108] In another optional embodiment, the method may further include the following steps:
[0109] When in the passive mode, the first device collects communication medium data around the first device through the first control unit;
[0110] The first device determines, by the first control unit, whether the first device meets the medium condition for switching from the passive mode to the active mode according to the collected communication medium data;
[0111] When it is determined that the medium condition is met, the first device switches the current mode from the passive mode to the active mode through the first control unit.
[0112] In this optional embodiment, different wireless communication methods have corresponding communication media, such as the NFC communication method, whose communication medium is the RF field.
[0113] In this optional embodiment, the communication medium data around the first device may include the communication medium type and the communication medium strength, and further, may include the communication medium range.
[0114] It can be seen that after the first device switches to passive mode, if it is determined based on the communication medium around it that it meets the conditions for switching to active mode, this optional embodiment automatically switches it to active mode to achieve flexible switching between active and passive modes, thereby realizing data transparent transmission.
[0115] In this optional embodiment, optionally, the first device determines, by the first control unit, whether the first device meets the medium condition for switching from the passive mode to the active mode according to the collected communication medium data, including:
[0116] The first device determines, through the first control unit, based on the collected communication medium data, whether a communication medium matching the type of the first wireless communication unit is detected;
[0117] When a communication medium matching the type of the first wireless communication unit is detected, the first device determines, through the first control unit, whether data transmitted by the third device is received within a fourth preset time length (e.g., 200 ms), wherein the start time of the fourth preset time length is determined by the time when the communication medium data collection is completed, such as the time when the collection is completed, or a time after the time when the collection is completed;
[0118] When it is determined that no data transmitted by the third device is received, the first device determines, through the first control unit, that the current state of the first device satisfies the condition that the current mode of the first device needs to be switched from the passive mode to the active mode.
[0119] In this optional embodiment, different wireless communication methods all have matching communication media, such as the communication medium of the NFC wireless communication method is an RF field.
[0120] It can be seen that this optional embodiment improves the flexibility of mode switching by automatically switching to active mode even when a communication medium matching the wireless communication method of the first device is detected but no data sent by a device with the same wireless communication method is received after a long period of time, thereby facilitating the first device to find a matching device through a card search instruction, thereby performing data transparent transmission operations.
[0121] In yet another optional embodiment, the method may further include the following steps:
[0122] When it is determined that data transmitted by the third device is received, the first device performs a communication interaction operation with the control unit of the third device and the wireless communication unit of the third device through the first control unit and the first wireless communication unit, where the communication interaction operation includes a data receiving operation or a second heartbeat packet receiving operation;
[0123] When the communication interaction operation is completed, the first device determines through the first control unit whether data transmitted by the third device or the second heartbeat packet is detected within a fifth preset time length (such as 5s), wherein the starting time of the fifth preset time length is the time when the communication interaction operation is completed;
[0124] When it is determined that no data or second heartbeat packet transmitted by the third device is detected within the fifth preset time period, the first device determines through the first control unit that the current state of the first device meets the condition for switching the current mode of the first device from passive mode to active mode.
[0125] It should be noted that the third device may be the second device that re-establishes a communication connection with the first device, or may be other devices.
[0126] It can be seen that even if this optional embodiment detects a communication medium that matches its wireless communication method and receives data sent by the device that generates the communication medium, but still does not receive the data or heartbeat packet sent by it after a long time after the interaction with it ends, it will still switch to the active mode, enriching the determination method of switching to the active mode, thereby improving the efficiency and flexibility of the device switching to the active mode, and further facilitating the first device to find a matching device through a card search instruction to perform data transparent transmission operations.
[0127] In yet another optional embodiment, the method may further include the following steps:
[0128] When a communication medium matching the type of the first wireless communication unit is detected, the first device determines, through the first control unit, whether a duration of detecting the communication medium matching the type of the first wireless communication unit is greater than or equal to a seventh preset duration (e.g., 200 ms);
[0129] When it is determined that the time is greater than or equal to the seventh preset time, the first device executes the above-mentioned operation of determining by the first control unit whether data transmitted by the third device is received within the fourth preset time.
[0130] In this optional embodiment, optionally, when it is determined that the time is less than the seventh preset time length, the current process can be terminated, or the above-mentioned operation of collecting the communication medium data around the first device through the first control unit can be re-executed.
[0131] It can be seen that even after detecting a communication medium that matches it, this optional embodiment will only perform the subsequent operation of determining whether the data sent by the device that generates the communication medium is received within the specified time period when it is determined that the communication medium has been detected for a long time. This can improve the accuracy and reliability of the execution of the operation; and by continuously detecting the communication medium for a long time, it can improve the reliability of the power supply stability of the device, thereby improving the reliability of communication between devices, and further improving the accuracy and efficiency of data transmission.
[0132] In yet another optional embodiment, the method may further include the following steps:
[0133] When no communication medium matching the type of the first wireless communication unit is detected, the first device re-executes the above-mentioned operation of collecting the communication medium data around the first device through the first control unit when the real-time moment monitored by the first control unit reaches the end time of the sixth preset time length, wherein the start time of the sixth preset time length is determined by the time when the communication medium data collection is completed, such as the time when the collection is completed, or a time after the time when the collection is completed;
[0134] When it is determined that the number of times the target operation is executed this time is greater than or equal to a preset number of times (such as 2 times, 3 times) and still no communication medium matching the type of the first wireless communication unit is detected, the first device determines through the first control unit that the current state of the first device meets the condition that the current mode of the first device needs to be switched from the passive mode to the active mode;
[0135] In this optional embodiment, the target operation is to re-execute the operation of collecting communication medium data around the first device through the first control unit when the real-time monitoring moment reaches the end time of the sixth preset time length.
[0136] In this optional embodiment, optionally, after executing the target operation a preset number of times (such as 2 times, 3 times), further wait for a period of time (such as 150ms), if the communication medium matching the type of the first wireless communication unit is still not detected, switch to active mode.
[0137] It can be seen that after the first device enters the passive mode, if the communication medium matching its wireless communication method is not detected, the optional embodiment continues to wait and repeatedly checks whether the communication medium matching its wireless communication method is detected. If it is still not detected, it automatically switches to the active mode, further enriching the determination method of the mode switching and improving the flexibility of the mode switching, which is conducive to the first device finding a matching device through the card search instruction to perform data transmission operations.
[0138] Embodiment 3
[0139] See also Figure 5 , Figure 5 is a schematic diagram of a structure of a device for wireless communication based on a wireless communication method disclosed in an embodiment of the present invention. Figure 5 The described device can be applied to any application scenario where wireless communication is required between two devices, including but not limited to stage control scenarios or smart home control scenarios. For example, in the stage control scenario, the two devices can be lamps and lamps; lamps and lamp accessories; mobile phones and lamps; computers and lamps; microphones and mobile phones, etc., which can or need to communicate wirelessly.
[0140] like Figure 5 As shown, the apparatus may include a first device, the first device including:
[0141] A data acquisition module 301 is used to acquire first data to be transmitted to a second device through a first control unit of a first device;
[0142] The data encapsulation module 302 is used to perform an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain second data;
[0143] The data communication module 303 is used to transmit the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through the wireless communication method matching the first wireless communication unit, so as to trigger the second device to perform the following operations: the second device transmits the second data to the second control unit of the second device through the second wireless communication unit of the second device, and the second control unit decapsulates the second data into the first data according to the encapsulation protocol;
[0144] In the embodiment of the present invention, the current working mode of the first device is the active mode, and the current working mode of the second device is the passive mode. The active mode is used to indicate the mode of actively sending data, and the passive mode is used to indicate the mode of passively receiving data. The type of the first wireless communication unit is the same as the type of the second wireless communication unit, and the type of the encapsulation protocol is determined by the type of the first wireless communication unit. Specifically, when the type of the first wireless communication unit is the NFC communication type, the wireless communication mode is the NFC communication mode; when the type of the first wireless communication unit is the Bluetooth communication type, the wireless communication mode is the Bluetooth communication mode; when the type of the first wireless communication unit is the RFID communication type, the wireless communication mode is the RFID communication mode; when the type of the first wireless communication unit is the WiFi communication type, the wireless communication mode is the WiFi communication mode.
[0145] In the embodiment of the present invention, optionally, the specific manner in which the data acquisition module 301 acquires the first data to be transmitted to the second device through the first control unit includes:
[0146] Reading the data to be sent from the first buffer queue corresponding to the first device through the first control unit as the first data to be transmitted to the second device; or
[0147] receiving, through the first control unit, data sent by the external device from the serial port of the first control unit, and determining the data sent by the external device as first data to be transmitted to the second device; or
[0148] Through the first control unit, data sent by the external device is received from the serial port of the first control unit, and the received data sent by the external device is stored in the first buffer queue corresponding to the first device, and the first data to be transmitted to the second device is obtained from the first buffer queue.
[0149] In the embodiment of the present invention, optionally, a specific manner in which the second device transmits the second data to the second control unit of the second device through the second wireless communication unit of the second device includes:
[0150] Receiving second data by wireless communication through the second wireless communication unit and generating a data prompt;
[0151] transmitting the data prompt to the second control unit of the second device via the second wireless communication unit to trigger the second control unit to read the second data from the second wireless communication unit after identifying the data prompt;
[0152] Furthermore, the second device is further configured to store the first data in a second buffer queue corresponding to the second device through a second control unit;
[0153] Among them, the data in the second buffer queue is used for the second device to read the fifth data from the second buffer queue through the second control unit when it is detected that the serial port of the second control unit meets the predetermined data sending conditions, and perform a transmission operation on the fifth data based on the serial port of the second control unit.
[0154] It can be seen that implementation Figure 5 The described device encapsulates the data to be transmitted according to the encapsulation protocol matched with the corresponding wireless communication mode through the control unit of the first device, and transmits it to the wireless communication unit corresponding to the control unit, so that the wireless communication unit transmits the data to the second device through the wireless communication mode, so that the second device transmits the received data to the corresponding control unit through the wireless communication unit of the same type as the wireless communication unit of the first device, and unpacks it according to the same encapsulation protocol, so as to realize contactless data transmission, and there is no need for users to understand the communication protocol between devices, which greatly reduces the development time for devices to communicate with each other, improves the efficiency of establishing communication between devices, so as to improve the communication efficiency between devices, thereby improving the control efficiency of devices; and communicating through wireless communication mode, without the need to use line communication or metal contact communication, can also improve the stability of communication, thereby improving the control accuracy and stability of the device; and with the development of major wireless communication mode industries, such as the rapid development of NFC industry, wireless communication technology has been rapidly promoted and widely used in various fields, which also greatly reduces the development cost of the technical solution and broadens the applicability of the technical solution.
[0155] In an alternative embodiment, Figure 6 is a schematic diagram of the structure of another device for wireless communication based on a wireless communication method disclosed in an embodiment of the present invention, such as Figure 6 As shown, the first device may further include:
[0156] The instruction generation module 304 is used to generate a card search instruction according to the instruction generation data through the first control unit when entering the active mode, and the instruction generation data includes an encapsulation protocol;
[0157] The data communication module 303 is also used to send a card search instruction to the outside through the first control unit;
[0158] The first judgment module 305 is used to judge whether a response from a certain device is received within a first preset time period through the first control unit, wherein the starting time of the first preset time period is the sending time of the card search instruction; when it is judged that a response from a certain device is received, the data communication module 303 is triggered to execute the above-mentioned operation of transmitting the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, and the certain device is the second device.
[0159] It can be seen that implementation Figure 6 When the first device enters the active mode, the described apparatus actively sends out a card search instruction generated based on the encapsulation protocol so that a device that can recognize the encapsulation protocol can respond, thereby quickly and accurately finding a matching device, which is beneficial to improving the efficiency of establishing wireless communication methods and improving the efficiency and stability of data transmission.
[0160] In another optional embodiment, Figure 6 As shown, the first judgment module 305 is also used to determine whether the attribute parameters of a certain device are read through the first control unit when it is determined that a response from a certain device is received; when it is determined that the attribute parameters of a certain device are read, the data communication module 303 is triggered to execute the above-mentioned operation of transmitting the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit.
[0161] It can be seen that implementation Figure 6 The described device confirms that the device is correctly identified after determining that a device has responded and further determining that the attribute parameters of the responding device have been read, which can improve the recognition accuracy and reliability of the device, thereby facilitating an increase in the probability of successful data transmission.
[0162] In yet another optional embodiment, Figure 6 As shown, the first device also includes:
[0163] The detection module 306 is used to detect whether a response from the second device is received within a second preset time period through the first control unit after the data communication module 303 transmits the second data to the first wireless communication unit of the first device through the first control unit so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, and when a response from the second device is detected, trigger the data acquisition module 301 to re-execute the above-mentioned operation of acquiring the first data to be transmitted to the second device through the first control unit;
[0164] The mode switching module 307 is used to switch the current mode from the active mode to the passive mode through the first control unit when no response from the second device is detected.
[0165] It can be seen that implementation Figure 6 After sending data to the second device, the described device detects whether the second device responds within a specified time period. If a response is detected, the data is continued to be transparently transmitted to reduce the situation where the device is removed but data is still sent, resulting in unsuccessful data transmission and wasting bandwidth resources, thereby increasing the success probability of data transparent transmission; if no response is detected, it switches to passive mode so that other devices with the same wireless communication method can establish wireless communication with it, thereby realizing data transparent transmission.
[0166] In yet another optional embodiment, Figure 6 As shown, the first device also includes:
[0167] The second judgment module 308 is used to judge whether there is third data that needs to be sent to the second device when a response from the second device is detected; when it is judged that there is third data that needs to be sent to the second device, trigger the data encapsulation module 302 to re-execute the above-mentioned operation of performing an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain the second data, and the first data is the third data;
[0168] The data communication module 303 is further configured to send a first heartbeat packet to the second wireless communication unit in a wireless communication manner through the first wireless communication unit when it is determined that there is no third data that needs to be sent to the second device;
[0169] The second judgment module 308 is further used to judge whether there is fourth data that needs to be sent to the second device within a third preset time (such as 6s) after the first heartbeat packet is sent, wherein the starting time of the third preset time is the time when the first heartbeat packet is sent; when it is judged that there is fourth data, the data encapsulation module 302 is triggered to re-execute the above-mentioned operation of performing encapsulation operation on the first data according to the predetermined encapsulation protocol through the first control unit to obtain the second data, and the first data is the fourth data;
[0170] The mode switching module 307 is further configured to switch the current mode from the active mode to the passive mode through the first control unit when it is determined that the fourth data does not exist, or,
[0171] The data communication module 303 is further configured to re-execute the above-mentioned operation of sending a card search instruction to the outside through the first control unit when it is determined that the fourth data does not exist.
[0172] It can be seen that implementation Figure 6 When the described device detects a response from the second device, if there is still data to be transmitted, it continues to transparently transmit the data to achieve complete transparent transmission of the data; if there is no data, it sends a heartbeat packet to maintain a wireless communication connection with the second device, so that when there is data transmission, there is no need to re-establish communication with the second device, and data transparent transmission can be directly performed, thereby improving the efficiency of data transparent transmission; if there is still no data to be transmitted after sending the heartbeat packet for a long period of time, it switches to passive mode, thereby improving the execution accuracy and reliability of the switching action of the passive mode.
[0173] In yet another optional embodiment, Figure 6 As shown, the data acquisition module 301 is also used to collect communication medium data around the first device through the first control unit when in the passive mode;
[0174] The detection module 306 is further configured to determine, through the first control unit, based on the collected communication medium data, whether the first device meets the medium condition for switching from the passive mode to the active mode;
[0175] The mode switching module 307 is further configured to switch the current mode from the passive mode to the active mode through the first control unit when it is determined that the medium condition is met.
[0176] It can be seen that implementation Figure 6 After the first device switches to the passive mode, the described device automatically switches it to the active mode if it determines that the communication medium around it satisfies the switching to the active mode, so as to realize flexible switching between the active and passive modes, thereby realizing data transparent transmission.
[0177] In yet another optional embodiment, the detection module 306 determines, through the first control unit, based on the collected communication medium data, whether the first device meets the medium condition for switching from the passive mode to the active mode. The specific manner includes:
[0178] By the first control unit, judging whether a communication medium matching the type of the first wireless communication unit is detected according to the collected communication medium data;
[0179] When a communication medium matching the type of the first wireless communication unit is detected, the first control unit determines whether data transmitted by the third device is received within a fourth preset time length (e.g., 200 ms), wherein the start time of the fourth preset time length is determined by the time when the communication medium data collection is completed, such as the time when the collection is completed or a certain time after the time when the collection is completed;
[0180] When it is determined that no data transmitted by the third device is received, the first control unit determines that the current state of the first device meets the condition that the current mode of the first device needs to be switched from the passive mode to the active mode.
[0181] It can be seen that implementation Figure 6 The described device improves the flexibility of mode switching by automatically switching to active mode even when a communication medium matching the wireless communication method of the first device is detected but no data sent by a device with the same wireless communication method is received after a long period of time, thereby facilitating the first device to find a matching device through a card search instruction, thereby performing data transparent transmission operations.
[0182] In yet another optional embodiment, Figure 6 As shown, the specific manner in which the detection module 306 determines whether the first device meets the medium condition for switching from the passive mode to the active mode through the first control unit according to the collected communication medium data also includes:
[0183] When it is determined that data transmitted by the third device is received, a communication interaction operation is performed with the control unit of the third device and the wireless communication unit of the third device through the first control unit and the first wireless communication unit, and the communication interaction operation includes a data receiving operation or a second heartbeat packet receiving operation;
[0184] When the communication interaction operation is completed, the first control unit determines whether data transmitted by the third device or the second heartbeat packet is detected within a fifth preset time length (such as 5s), wherein the starting time of the fifth preset time length is the time when the communication interaction operation is completed;
[0185] When it is determined that no data or second heartbeat packet transmitted by the third device is detected within the fifth preset time period, the first control unit determines that the current state of the first device meets the condition for switching the current mode of the first device from passive mode to active mode.
[0186] It can be seen that implementation Figure 6 Even if the described device detects a communication medium that matches its wireless communication method and receives data sent by the device that generates the communication medium, but still does not receive the data or heartbeat packet sent by it after a long time after the interaction with it ends, it will still switch to active mode, enriching the determination method of switching to active mode, thereby improving the efficiency and flexibility of the device switching to active mode, and further facilitating the first device to find a matching device through a card search instruction to perform data transparent transmission operations.
[0187] In yet another optional embodiment, Figure 6 As shown, the specific manner in which the detection module 306 determines whether the first device meets the medium condition for switching from the passive mode to the active mode through the first control unit according to the collected communication medium data also includes:
[0188] When no communication medium matching the type of the first wireless communication unit is detected, the operation of collecting the communication medium data around the first device by the first control unit is re-executed when the real-time moment monitored by the first control unit reaches the end time of the sixth preset time length, wherein the start time of the sixth preset time length is determined by the time when the collection of the communication medium data is completed, such as the time when the collection is completed, or a time after the time when the collection is completed;
[0189] When it is determined that the number of times the target operation is executed this time is greater than or equal to a preset number of times (such as 2 times, 3 times) and still no communication medium matching the type of the first wireless communication unit is detected, the first control unit determines that the current state of the first device satisfies the condition that the current mode of the first device needs to be switched from the passive mode to the active mode;
[0190] In this optional embodiment, the target operation is to re-execute the operation of collecting communication medium data around the first device through the first control unit when the real-time monitoring moment reaches the end time of the sixth preset time length.
[0191] It can be seen that implementation Figure 6After the first device enters the passive mode, if the described device does not detect a communication medium that matches its wireless communication method, it continues to wait and repeatedly checks whether a communication medium that matches its wireless communication method is detected. If it is still not detected, it automatically switches to the active mode, further enriching the determination method of the mode switching and improving the flexibility of the mode switching, which is conducive to the first device finding a matching device through a card search instruction to perform data transparent transmission operations.
[0192] In yet another optional embodiment, Figure 6 As shown, the detection module 306 is also used to determine, through the first control unit, whether the duration of detection of the communication medium matching the type of the first wireless communication unit is greater than or equal to a seventh preset time length (such as 200ms) when a communication medium matching the type of the first wireless communication unit is detected; when it is determined to be greater than or equal to the seventh preset time length, trigger the execution of the above-mentioned operation of determining, through the first control unit, whether data transmitted by the third device is received within the fourth preset time length.
[0193] It can be seen that implementation Figure 6 The described device, even after detecting a communication medium that matches it, will only perform a subsequent operation of determining whether data sent by the device that generates the communication medium is received within a specified time period if it determines that the communication medium has been detected for a long time, thereby ensuring the accuracy and reliability of the execution of the operation; and by detecting the communication medium for a long time, it can improve the reliability of the power supply stability of the device, thereby improving the reliability of communication between devices.
[0194] In yet another optional embodiment, Figure 6 As shown, the data encapsulation module 302 is also used to perform a packetization operation on the first data through the first control unit according to a predetermined packetization protocol to obtain the packetized first data, and perform the above-mentioned operation of performing a packetization operation on the first data through the first control unit according to a predetermined packetization protocol to obtain the second data.
[0195] It can be seen that implementation Figure 6 The described device reduces the data volume while ensuring the integrity and accuracy of the data by packaging the data, thereby improving the data transmission security and transmission efficiency.
[0196] Embodiment 4
[0197] See also Figure 7 , Figure 7 is a schematic diagram of the structure of another device for wireless communication based on a wireless communication method disclosed in an embodiment of the present invention. Figure 7The described device can be applied to any application scenario where wireless communication is required between two devices, including but not limited to stage control scenarios or smart home control scenarios. For example, in stage control scenarios, the two devices can be lamps and lamps; lamps and lamp accessories; mobile phones and lamps; computers and lamps; microphones and mobile phones, etc., which can or need to communicate wirelessly. Figure 7 As shown, the apparatus may include a first device, and the first device includes:
[0198] A memory 401 storing executable program codes;
[0199] a processor 402 coupled to the memory 401;
[0200] Furthermore, it may also include an input interface 403 and an output interface 404 coupled to the processor 402;
[0201] The processor 402 calls the executable program code stored in the memory 401 to execute all or part of the steps executed by the first device in any one of the methods for performing wireless communication based on a wireless communication manner disclosed in Embodiment 1 or Embodiment 2 of the present invention.
[0202] Embodiment 5
[0203] See also Figure 8 , Figure 8 is a device control system disclosed in an embodiment of the present invention, such as Figure 8 As shown, the device control system includes at least one group of devices, each group of devices includes a first device and a second device, the first device and the second device respectively have corresponding control units and wireless communication units, the first control unit of the first device is communicatively connected with the first wireless communication unit of the first device through a full-duplex synchronous communication bus, the second control unit of the second device is communicatively connected with the second wireless communication unit of the second device through a full-duplex synchronous communication bus, the first wireless communication unit is wirelessly connected with the second wireless communication unit, the first control unit is used to receive data from an outgoing device, and the second control unit is used to send data to a receiving device;
[0204] The first device may include: Figure 5 , Figure 6 The device for performing wireless communication based on the wireless communication method described in the embodiment 1 or the embodiment 2 of the present invention, and the first device is used to execute all or part of the steps executed by the first device in any one of the methods for performing wireless communication based on the wireless communication method disclosed in the embodiment 1 or the embodiment 2 of the present invention; the second device executes all or part of the steps executed by the second device in any one of the methods for performing wireless communication based on the wireless communication method disclosed in the embodiment 1 or the embodiment 2 of the present invention.
[0205] Embodiment 6
[0206] An embodiment of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute all or part of the steps in the method for performing wireless communication based on a wireless communication method disclosed in Embodiment 1 of the present invention.
[0207] The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, i.e., they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.
[0208] Through the specific description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the above technical solution can be essentially or partly contributed to the prior art in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0209] Finally, it should be noted that the method, device, and system for wireless communication based on wireless communication disclosed in the embodiments of the present invention are only preferred embodiments of the present invention, which are only used to illustrate the technical solution of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for wireless communication based on a wireless communication method, characterized in that: The method comprises: The first device obtains first data to be transmitted to the second device through a first control unit of the first device, and performs an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain second data; The first device transmits the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, so as to trigger the second device to perform the following operations; The second device transmits the second data to a second control unit of the second device through a second wireless communication unit of the second device, and decapsulates the second data into the first data through the second control unit according to the encapsulation protocol; The current working mode of the first device is an active mode, and the current working mode of the second device is a passive mode, wherein the active mode is used to indicate a mode in which data is actively sent, and the passive mode is used to indicate a mode in which data is passively received; The type of the first wireless communication unit is the same as the type of the second wireless communication unit, and the type of the encapsulation protocol is determined by the type of the first wireless communication unit; The method further comprises: The first device performs a packetization operation on the first data based on a predetermined packetization protocol through the first control unit to obtain the packetized first data, and performs the operation of performing a packetization operation on the first data through the first control unit according to the predetermined packetization protocol to obtain the second data, wherein the packetization protocol is determined based on one or more of the data volume and data type of the first data, the type of the first device, the type of the second device, and the type of the wireless communication method; The method further comprises: When entering the active mode, the first device generates a card search instruction through the first control unit according to the encapsulation protocol included in the instruction generation data, and sends the card search instruction outward through the first control unit; The first device determines, through the first control unit, whether a response from a certain device is received within a first preset time period; When it is determined that a response is received from the certain device, the first device executes the operation of transmitting the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit. The certain device is the second device.
2. The method for wireless communication based on wireless communication method according to claim 1, characterized in that: The instruction generation data includes the encapsulation protocol; The starting time of the first preset time length is the sending time of the card searching instruction.
3. The method for wireless communication based on wireless communication mode according to claim 2, characterized in that: The method further comprises: When it is determined that a response from the certain device is received, the first device determines, through the first control unit, whether an attribute parameter of the certain device is read; When it is determined that the attribute parameters of the certain device are read, the first device executes the operation of transmitting the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit.
4. The method for wireless communication based on a wireless communication method according to any one of claims 1 to 3, characterized in that: After the first device transmits the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, the method further includes: The first device detects, by the first control unit, whether a response from the second device is received within a second preset time period, wherein the start time of the second preset time period is the time when the second data is transmitted to the second device by a wireless communication method matching the first wireless communication unit; When a response from the second device is detected, the first device re-executes the operation of acquiring the first data to be transmitted to the second device through the first control unit; When no response from the second device is detected, the first device switches a current mode from the active mode to the passive mode through the first control unit.
5. The method for wireless communication based on wireless communication mode according to claim 4, characterized in that: The method further comprises: When detecting a response from the second device, the first device determines whether there is third data that needs to be sent to the second device; When it is determined that there is third data that needs to be sent to the second device, the first device re-executes the operation of encapsulating the first data through the first control unit according to the predetermined encapsulation protocol to obtain the second data, and the first data is the third data; When it is determined that there is no third data that needs to be sent to the second device, the first device sends a first heartbeat packet to the second wireless communication unit in the wireless communication manner through the first wireless communication unit; After sending the first heartbeat packet, the first device determines whether there is fourth data that needs to be sent to the second device within a third preset time period, wherein the starting time of the third preset time period is the time when the first heartbeat packet is sent; When it is determined that the fourth data exists, the first device re-executes the operation of performing the encapsulation operation on the first data according to the predetermined encapsulation protocol through the first control unit to obtain the second data, and the first data is the fourth data; When it is determined that the fourth data does not exist, the first device switches the current mode from the active mode to the passive mode through the first control unit, or re-executes the operation of sending the card search instruction outward through the first control unit.
6. The method for wireless communication based on wireless communication mode according to claim 4, characterized in that: The method further comprises: When in the passive mode, the first device collects communication medium data around the first device through the first control unit; The first device determines, by the first control unit, whether the first device meets the medium condition for switching from the passive mode to the active mode according to the collected communication medium data; When it is determined that the medium condition is met, the first device switches the current mode from the passive mode to the active mode through the first control unit.
7. The method for wireless communication based on wireless communication mode according to claim 6, characterized in that: The first device determines, by the first control unit, whether the first device meets the medium condition for switching from the passive mode to the active mode according to the collected communication medium data, including: The first device determines, through the first control unit, based on the collected communication medium data, whether a communication medium matching the type of the first wireless communication unit is detected; When a communication medium matching the type of the first wireless communication unit is detected, the first device determines, through the first control unit, whether data transmitted by the third device is received within a fourth preset time period, wherein the start time of the fourth preset time period is determined by the time when the data collection of the communication medium is completed; When it is determined that no data transmitted by the third device is received, the first device determines, through the first control unit, that the current state of the first device satisfies the condition for switching the current mode of the first device from the passive mode to the active mode.
8. The method for wireless communication based on wireless communication mode according to claim 7, characterized in that: The method further comprises: When it is determined that data transmitted by the third device is received, the first device performs a communication interaction operation with the control unit of the third device and the wireless communication unit of the third device through the first control unit and the first wireless communication unit, and the communication interaction operation includes a data receiving operation or a second heartbeat packet receiving operation; When the communication interaction operation ends, the first device determines through the first control unit whether the data transmitted by the third device or the second heartbeat packet is detected within a fifth preset time length, wherein the starting time of the fifth preset time length is the time when the communication interaction operation ends; When it is determined that no data transmitted by the third device or the second heartbeat packet is detected within the fifth preset time period, the first device determines through the first control unit that the current state of the first device meets the condition for switching the current mode of the first device from the passive mode to the active mode.
9. The method for wireless communication based on wireless communication mode according to claim 7 or 8, characterized in that: The method further comprises: When no communication medium matching the type of the first wireless communication unit is detected, the first device re-executes the operation of collecting the communication medium data around the first device through the first control unit when the real-time moment monitored by the first control unit reaches the end time of the sixth preset time length, wherein the start time of the sixth preset time length is determined by the time when the collection of the communication medium data is completed; When it is determined that the communication medium matching the type of the first wireless communication unit is still not detected when the number of times the target operation is performed this time is greater than or equal to the preset number of times, the first device determines through the first control unit that the current state of the first device satisfies the condition that the current mode of the first device needs to be switched from the passive mode to the active mode; The target operation is to re-execute the operation of collecting communication medium data around the first device through the first control unit when the real-time monitoring moment reaches the end time of the sixth preset time length.
10. The method for wireless communication based on wireless communication mode according to claim 7, characterized in that: The method further comprises: When a communication medium matching the type of the first wireless communication unit is detected, the first device determines, through the first control unit, whether a duration of detecting the communication medium matching the type of the first wireless communication unit is greater than or equal to a seventh preset duration; When it is determined that the time period is greater than or equal to the seventh preset time period, the first device executes the operation of determining, by the first control unit, whether data transmitted by the third device is received within the fourth preset time period.
11. The method for wireless communication based on a wireless communication method according to any one of claims 1, 2, 3, 5, 6, 7, 8 and 10, characterized in that: The first device acquires, through the first control unit, first data to be transmitted to the second device, including: The first device reads the data to be sent from the first buffer queue corresponding to the first device through the first control unit as the first data to be transmitted to the second device; or The first device receives data sent by an external device from a serial port of the first control unit through the first control unit, and determines the data sent by the external device as first data to be transmitted to the second device; or The first device receives data sent by an external device from the serial port of the first control unit through the first control unit, stores the received data sent by the external device in a first buffer queue corresponding to the first device, and obtains first data to be transmitted to the second device from the first buffer queue.
12. The method for wireless communication based on a wireless communication method according to any one of claims 1, 2, 3, 5, 6, 7, 8 and 10, characterized in that: The second device transmits the second data to a second control unit of the second device through a second wireless communication unit of the second device, including: The second device receives the second data through the second wireless communication unit in the wireless communication manner, and generates a data prompt; The second device transmits the data prompt to a second control unit of the second device through the second wireless communication unit to trigger the second control unit to read the second data from the second wireless communication unit after identifying the data prompt; The method further comprises: The second device stores the first data in a second buffer queue corresponding to the second device through the second control unit; Among them, the data in the second buffer queue is used for the second device to read the fifth data from the second buffer queue through the second control unit when it is detected that the serial port of the second control unit meets the predetermined data sending conditions, and perform a transmission operation on the fifth data based on the serial port of the second control unit.
13. The method for wireless communication based on a wireless communication method according to any one of claims 1, 2, 3, 5, 6, 7, 8 and 10, characterized in that: When the type of the first wireless communication unit is an NFC communication type, the wireless communication mode is an NFC communication mode; when the type of the first wireless communication unit is a Bluetooth communication type, the wireless communication mode is a Bluetooth communication mode; when the type of the first wireless communication unit is an RFID communication type, the wireless communication mode is an RFID communication mode; when the type of the first wireless communication unit is a WiFi communication type, the wireless communication mode is a WiFi communication mode.
14. A device for wireless communication based on a wireless communication method, characterized in that: The apparatus is used to execute the method for performing wireless communication based on a wireless communication method according to any one of claims 1 to 13, and the apparatus includes a first device, and the first device includes: A data acquisition module, used for acquiring first data to be transmitted to a second device through a first control unit of the first device; a data encapsulation module, configured to perform an encapsulation operation on the first data according to a predetermined encapsulation protocol through the first control unit to obtain second data; a data communication module, configured to transmit the second data to the first wireless communication unit of the first device through the first control unit, so that the first wireless communication unit transmits the second data to the second device through a wireless communication method matching the first wireless communication unit, so as to trigger the second device to perform the following operations; The second device transmits the second data to a second control unit of the second device through a second wireless communication unit of the second device, and decapsulates the second data into the first data through the second control unit according to the encapsulation protocol; The current working mode of the first device is an active mode, and the current working mode of the second device is a passive mode, wherein the active mode is used to indicate a mode in which data is actively sent, and the passive mode is used to indicate a mode in which data is passively received; The type of the first wireless communication unit is the same as the type of the second wireless communication unit, and the type of the encapsulation protocol is determined by the type of the first wireless communication unit.
15. A device for wireless communication based on a wireless communication method, characterized in that: The apparatus comprises a first device, wherein the first device comprises: A memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the method for performing wireless communication based on a wireless communication method as described in any one of claims 1-13.
16. A device control system for wireless communication based on wireless communication, characterized in that: The device control system includes at least one group of devices, each group of devices includes a first device and a second device, the first device and the second device respectively have corresponding control units and wireless communication units, the first control unit of the first device is connected to the first wireless communication unit of the first device through a full-duplex synchronous communication bus, the second control unit of the second device is connected to the second wireless communication unit of the second device through a full-duplex synchronous communication bus, the first wireless communication unit is connected to the second wireless communication unit of the second device through wireless communication, the first control unit is used to receive data from an external device, and the second control unit is used to send data to a receiving device; The first device is used to execute the steps performed by the first device in the method for wireless communication based on a wireless communication method as described in any one of claims 1-13; the second device is used to execute the steps performed by the second device in the method for wireless communication based on a wireless communication method as described in any one of claims 1-13.
Citation Information
Patent Citations
Communication method, device and system and computer readable storage medium
CN111601285A
Communication method and device
CN117459605A