Communication method, system, apparatus, computer device and storage medium

文档序号:912033 发布日期:2021-02-26 浏览:28次 中文

阅读说明:本技术 通信方法、系统、装置、计算机设备和存储介质 (Communication method, system, apparatus, computer device and storage medium ) 是由 唐基岩 于 2020-11-03 设计创作,主要内容包括:本申请涉及一种通信方法、系统、装置、计算机设备和存储介质,属于通讯技术领域。所述方法包括:接收耳机通信指令;响应于所述耳机通信指令,将第一通信串口的数据传输状态切换为通信数据发送状态,通过处于通信数据发送状态的所述第一通信串口发送所述耳机通信指令所对应的耳机通信数据到目标耳机;当确认所述耳机通信数据发送完成后,将所述第一通信串口的数据传输状态切换为通信数据接收状态,通过处于通信数据接收状态的所述第一通信串口接收所述目标耳机发送的回复数据,所述回复数据是所述目标耳机响应于所述耳机通信数据进行数据处理得到的;基于所述回复数据进行响应。采用本方法能够降低实现串口通信的成本。(The application relates to a communication method, a communication system, a communication device, computer equipment and a storage medium, and belongs to the technical field of communication. The method comprises the following steps: receiving an earphone communication instruction; responding to the earphone communication instruction, switching the data transmission state of a first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to a target earphone through the first communication serial port in the communication data sending state; after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state, wherein the reply data is obtained by the target earphone through data processing in response to the earphone communication data; responding based on the reply data. The method can reduce the cost for realizing serial port communication.)

1. A communication method applied to a charging box, the method comprising:

receiving an earphone communication instruction;

responding to the earphone communication instruction, switching the data transmission state of a first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to a target earphone through the first communication serial port in the communication data sending state;

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state, wherein the reply data is obtained by the target earphone through data processing in response to the earphone communication data;

responding based on the reply data.

2. The method of claim 1, wherein the target earphone comprises a first earphone and a second earphone, and the switching a data transmission state of a first communication serial port to a communication data transmission state in response to the earphone communication command, and transmitting the earphone communication data corresponding to the earphone communication command to the target earphone through the first communication serial port in the communication data transmission state comprises:

when the earphone communication instruction is determined to be an instruction for indicating the first earphone to communicate with the second earphone, switching a data transmission state of a first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to the first earphone through the first communication serial port in the communication data sending state;

the responding based on the reply data comprises:

when receiving the reply data sent by the first earphone, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the reply data to the second earphone through the first communication serial port in the communication data sending state.

3. The method according to claim 2, wherein the headset communication instruction is a headset pairing instruction, and the switching the data transmission state of the first communication serial port to a communication data reception state after the headset communication data transmission is confirmed to be completed, and the receiving the reply data sent by the target headset via the first communication serial port in the communication data reception state includes:

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving an earphone pairing address sent by the first earphone through the first communication serial port in the communication data receiving state;

the method further comprises the following steps:

the second earphone is paired with the first earphone based on the earphone pairing address to obtain a pairing result;

and after the charging box confirms that the earphone pairing address is sent to the second earphone, the data transmission state of the first communication serial port is switched to a communication data receiving state, and the first communication serial port in the communication data receiving state receives the pairing result sent by the second earphone and outputs the pairing result.

4. The method of claim 1, wherein the headset communication instruction is triggered in response to a user action, and wherein responding based on the reply data comprises:

determining an operation result corresponding to the user operation based on the reply data;

and outputting the operation result.

5. The method according to claim 1, wherein the switching a data transmission state of a first communication serial port to a communication data transmission state in response to the headset communication command, and transmitting the headset communication data corresponding to the headset communication command to a target headset through the first communication serial port in the communication data transmission state comprises:

responding to the earphone communication instruction, and switching the data transmission state of the first communication serial port into a communication data sending state;

acquiring corresponding communication content and an earphone to be communicated according to the earphone communication instruction, and taking the earphone to be communicated as a target earphone;

and generating a communication data packet according to the communication content and the communication address of the target earphone, wherein the communication data packet comprises the instruction type of the earphone communication instruction, the communication content and the communication address, so that after the target earphone confirms that a receiver is a local terminal based on the communication address, data processing is carried out according to the instruction type and the communication content to obtain reply data.

6. A communication system, comprising a charging box and a target headset:

the charging box is used for receiving an earphone communication instruction;

the charging box is used for responding to the earphone communication instruction, switching the data transmission state of a first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data sending state;

the target earphone is used for responding to the earphone communication data to perform data processing to obtain reply data when the earphone communication data are received, switching the data transmission state of a second communication serial port into a communication data sending state, and sending the reply data through the second communication serial port in the communication data sending state;

the charging box is used for switching the data transmission state of the first communication serial port into a communication data receiving state after the earphone communication data is confirmed to be sent, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state;

the charging box is further used for responding based on the reply data.

7. The system of claim 6, wherein the target earpiece comprises a first earpiece and a second earpiece;

the charging box is used for switching the data transmission state of a first communication serial port into a communication data sending state when the earphone communication instruction is determined to be an instruction indicating that the first earphone is communicated with the second earphone, and sending earphone communication data corresponding to the earphone communication instruction to the first earphone through the first communication serial port in the communication data sending state;

the charging box is further used for switching the data transmission state of the first communication serial port into a communication data sending state when receiving the reply data sent by the first earphone, and sending the reply data to the second earphone through the first communication serial port in the communication data sending state.

8. A communications apparatus, the apparatus comprising:

the earphone communication instruction receiving module is used for receiving an earphone communication instruction;

the earphone communication data sending module is used for responding to the earphone communication instruction, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data sending state;

the target earphone sends back a reply data receiving module which is used for switching the data transmission state of the first communication serial port into a communication data receiving state after the earphone communication data is sent, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state;

and the reply data response module is used for responding based on the reply data.

9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 5.

10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 5.

Technical Field

The present application relates to the field of communications technologies, and in particular, to a communication method, system, apparatus, computer device, and storage medium.

Background

With the development of science and technology, communication with the headset is required in many scenarios. For example, communication may be via serial communication techniques. The serial communication is a common data communication mode, has the characteristics of simple communication line, low cost, long communication distance, full duplex realization and the like, and has very wide application in the field of data communication.

However, the current serial communication method at least includes three communication lines, namely a data receiving communication line, a data sending communication line and a ground line, so that the cost for realizing the serial communication is increased.

Disclosure of Invention

In view of the foregoing, it is desirable to provide a communication method, system, apparatus, computer device, and storage medium capable of reducing the cost of implementing serial communication.

A method of communication, the method comprising:

receiving an earphone communication instruction;

responding to the earphone communication instruction, switching the data transmission state of a first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to a target earphone through the first communication serial port in the communication data sending state;

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state, wherein the reply data is obtained by the target earphone through data processing in response to the earphone communication data;

responding based on the reply data.

In one embodiment, the target earphone includes a first earphone and a second earphone, and the switching the data transmission state of the first communication serial port to the communication data transmission state in response to the earphone communication instruction, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data transmission state includes:

when the earphone communication instruction is determined to be an instruction for indicating the first earphone to communicate with the second earphone, switching a data transmission state of a first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to the first earphone through the first communication serial port in the communication data sending state;

the responding based on the reply data comprises:

when receiving the reply data sent by the first earphone, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the reply data to the second earphone through the first communication serial port in the communication data sending state.

In one embodiment, the earphone communication instruction is an earphone pairing instruction, and when it is determined that the earphone communication data transmission is completed, the data transmission state of the first communication serial port is switched to a communication data reception state, and the reply data sent by the target earphone is received by the first communication serial port in the communication data reception state, including:

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving an earphone pairing address sent by the first earphone through the first communication serial port in the communication data receiving state;

the method further comprises the following steps:

the second earphone is paired with the first earphone based on the earphone pairing address to obtain a pairing result;

and after the charging box confirms that the earphone pairing address is sent to the second earphone, the data transmission state of the first communication serial port is switched to a communication data receiving state, and the first communication serial port in the communication data receiving state receives the pairing result sent by the second earphone and outputs the pairing result.

In one embodiment, the headset communication instruction is triggered in response to a user operation, and the responding based on the reply data includes:

determining an operation result corresponding to the user operation based on the reply data;

and outputting the operation result.

In one embodiment, the switching the data transmission state of the first communication serial port to the communication data transmission state in response to the headset communication instruction, and transmitting the headset communication data corresponding to the headset communication instruction to the target headset through the first communication serial port in the communication data transmission state includes:

responding to the earphone communication instruction, and switching the data transmission state of the first communication serial port into a communication data sending state;

acquiring corresponding communication content and an earphone to be communicated according to the earphone communication instruction, and taking the earphone to be communicated as a target earphone;

and generating a communication data packet according to the communication content and the communication address of the target earphone, wherein the communication data packet comprises the instruction type of the earphone communication instruction, the communication content and the communication address, so that after the target earphone confirms that a receiver is a local terminal based on the communication address, data processing is carried out according to the instruction type and the communication content to obtain reply data.

A communication system comprising a charging box and a target headset:

the charging box is used for receiving an earphone communication instruction;

the charging box is used for responding to the earphone communication instruction, switching the data transmission state of a first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data sending state;

the target earphone is used for responding to the earphone communication data to perform data processing to obtain reply data when the earphone communication data are received, switching the data transmission state of a second communication serial port into a communication data sending state, and sending the reply data through the second communication serial port in the communication data sending state;

the charging box is used for switching the data transmission state of the first communication serial port into a communication data receiving state after the earphone communication data is confirmed to be sent, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state;

the charging box is further used for responding based on the reply data.

In one embodiment, the target headset of the communication system comprises a first headset and a second headset;

the charging box is used for switching the data transmission state of a first communication serial port into a communication data sending state when the earphone communication instruction is determined to be an instruction indicating that the first earphone and the second earphone are communicated, and sending the earphone communication data corresponding to the earphone communication instruction to the first earphone through the first communication serial port in the communication data sending state;

the charging box is further used for switching the data transmission state of the first communication serial port into a communication data sending state when receiving the reply data sent by the first earphone, and sending the reply data to the second earphone through the first communication serial port in the communication data sending state.

A communications apparatus, the apparatus comprising:

the earphone communication instruction receiving module is used for receiving an earphone communication instruction;

the earphone communication data sending module is used for responding to the earphone communication instruction, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data sending state;

the target earphone sends back a reply data receiving module which is used for switching the data transmission state of the first communication serial port into a communication data receiving state after the earphone communication data is sent, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state;

and the reply data response module is used for responding based on the reply data.

A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:

receiving an earphone communication instruction;

responding to the earphone communication instruction, switching the data transmission state of a first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to a target earphone through the first communication serial port in the communication data sending state;

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state, wherein the reply data is obtained by the target earphone through data processing in response to the earphone communication data;

responding based on the reply data.

A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:

receiving an earphone communication instruction;

responding to the earphone communication instruction, switching the data transmission state of a first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to a target earphone through the first communication serial port in the communication data sending state;

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state, wherein the reply data is obtained by the target earphone through data processing in response to the earphone communication data;

responding based on the reply data.

According to the communication method, the communication system, the communication device, the computer equipment and the storage medium, after the charging box responds to the earphone communication instruction, the data transmission state of the first communication serial port is switched to the communication data sending state, so that the charging box actively initiates communication data sending to the target earphone; when the earphone communication data corresponding to the earphone communication instruction sent by the first communication serial port is sent to the target earphone, the charging box can switch the data transmission state of the first communication serial port into a communication data receiving state and receive reply data sent by the target earphone, so that the communication data sending and the communication data receiving can be realized on the same communication serial port line at different time periods; meanwhile, the charging box can respond based on the reply data, so that a user can obtain feedback information of the earphone communication instruction in time, and the user can apply the charging box more conveniently and directly.

Drawings

FIG. 1 is a diagram of an application environment of a communication method in one embodiment;

FIG. 2 is a flow diagram of a communication method in one embodiment;

FIG. 3 is a diagram illustrating packet composition in one embodiment;

FIG. 4 is a diagram illustrating the data forwarding functionality of the charging box in one embodiment;

fig. 5 is a schematic flow chart illustrating the process of confirming that the transmission of the headset communication data is completed in one embodiment;

FIG. 6 is a flow chart illustrating a communication method according to another embodiment;

FIG. 7 is a flow chart illustrating a communication method according to another embodiment;

FIG. 8 is a diagram illustrating the organization of headers in a packet, according to one embodiment;

FIG. 9 is a schematic diagram of a communication flow between the charging box and the left and right earphones according to an embodiment;

FIG. 10 is a schematic diagram of the communication connection of the charging box to the left and right earphones in one embodiment;

FIG. 11 is a block diagram of a communication device in one embodiment;

FIG. 12 is a diagram illustrating an internal structure of a computer device according to an embodiment.

Detailed Description

In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.

The communication method provided by the present application can be applied to the application environment shown in fig. 1, and is particularly applied to a communication system. The communication system includes a charging box 102 and a target headset. The charging box 102 executes a communication method, specifically, the charging box 102 receives an earphone communication instruction, responds to the earphone communication instruction, switches the data transmission state of the first communication serial port to a communication data sending state, and sends earphone communication data corresponding to the earphone communication instruction to a target earphone; and after the communication data of the earphone is sent, switching the data transmission state of the first communication serial port into a communication data receiving state, receiving reply data sent by the target earphone through the first communication serial port, and responding by the charging box based on the received reply data to make corresponding feedback. The charging box 102 may be, but is not limited to, a charging box for various earphones, and may provide power for the earphones while establishing a communication connection with the earphones. The target earphone may be a plurality of earphones, and may include at least one of the first earphone 104 and the second earphone 106, for example, the first earphone 104 may be an earphone adapted to the left ear, or may be simply referred to as a left earphone, and the second earphone 106 may be an earphone adapted to the right ear, or may be simply referred to as a right earphone. The charging box may communicate with the first earphone 102 and the second earphone 104 simultaneously, or may communicate with the first earphone and then with the second earphone using the first earphone as a target earphone.

In one embodiment, as shown in fig. 2, a communication method is provided, which is exemplified by the method applied to the charging box in fig. 1, and includes the following steps:

step 202, receiving an earphone communication instruction.

The headset communication command refers to a command for communicating with a headset, and for example, the command includes a headset status query command or a headset pairing command.

In particular, the headset communication instruction may be triggered in response to a user's operation, automatically, or by a third party device. For example, a user may operate a button on the charging box having a function of executing a headset communication command, and the charging box may respond to the operation of the button to obtain the headset communication command. In one embodiment, the charging box may further receive an earphone communication instruction sent by a third party terminal device through a network connection. For example, the charging box may receive headset communication instructions sent by a cell phone.

And 204, responding to the earphone communication instruction, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data sending state.

The first communication serial port refers to a communication serial port of the charging box; the data transmission state refers to the input and output states of a communication serial port for transmitting data; the earphone communication data is data which is sent to a target earphone and carries an earphone communication instruction.

Specifically, in the same time, only one device can be controlled to be in a sending state through a communication protocol, and other devices are required to be in a receiving state, so that data sending collision is avoided; after the data transmission is completed, the device at the transmitting side immediately switches to the receiving state, and the received data is prevented from missing. If no device sends data at a certain time, all devices on the data bus are in an idle state, and the devices in the idle state default to a receiving mode. After the charging box receives the earphone communication instruction, the charging box can switch the data transmission state of the first communication serial port of the local terminal from the communication data receiving state to the communication data sending state, and the earphone communication data corresponding to the communication instruction is sent to the target earphone through the first communication serial port. For example, the user needs to query the electric quantity of the headset through the charging box, and at this time, the charging box can send the communication data corresponding to the queried electric quantity to the target headset by operating a corresponding query button on the charging box.

In one embodiment, the communication data corresponding to the command is transmitted between the charging box and the target earphone in the form of data packets, as shown in fig. 3, each data packet includes five parts, which are a data header, a command type, a data length, a data content, and a CRC check, where the data header includes a sender address and a receiver address of the data, and occupies a byte size; the instruction type is the meaning of each instruction and occupies one byte size; the length of the data means that the data comprises a plurality of bytes in total and occupies the size of one byte; the data content is specific data related to a specific instruction, and occupies the size of N bytes; the CRC (cyclic Redundancy check) check is a calculated value of CRC16 for all previous data, which is two bytes in size.

And step 206, after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port to a communication data receiving state, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state.

The reply data is data obtained after the target earphone responds to the earphone communication data and performs data processing, for example, if the earphone communication instruction is an instruction for inquiring the electric quantity, the reply data is the electric quantity of the earphone.

Specifically, after the charging box confirms that the sending of the communication data of the earphone is completed, the data transmission state of the first communication serial port at the home terminal is switched to the communication data receiving state, and the reply data sent by the target earphone is received. It is understood that the reply data also includes an acknowledgement signal data ack (acknowledgement character). For example, the charging box sends communication data corresponding to a communication instruction for inquiring the electric quantity of the target earphone to the target earphone, when the charging box confirms that the communication data are sent completely, the data transmission state of the first communication serial port of the local terminal is switched to a communication data receiving state, and at this time, if the communication between the charging box and the target earphone is successful, relevant communication data representing the electric quantity of the earphone is returned, for example, the electric quantity is 60%.

At step 208, a response is made based on the reply data.

Specifically, after the target earphone returns the reply data, the charging box may visually display the relevant reply data or display the reply data on the charging box through the display state of the indicator lamp, and the like. For example, the specific numerical value of the electric quantity is displayed in an area that can be displayed by the charging box.

In the communication method, after the charging box responds to the earphone communication instruction, the data transmission state of the first communication serial port is switched to a communication data sending state, so that the charging box actively initiates communication data sending to a target earphone; when the first communication serial port sends the earphone communication data corresponding to the earphone communication instruction to the target earphone, the charging box can switch the data transmission state of the first communication serial port into a communication data receiving state, receives reply data sent by the target earphone, and realizes the sending and receiving of the communication data on the same communication serial port line; meanwhile, the charging box can respond based on the reply data, and a user can obtain feedback information of the earphone communication instruction in time through response, so that the user can more conveniently apply the charging box.

In one embodiment, the target earphone comprises a first earphone and a second earphone, switching a data transmission state of the first communication serial port to a communication data transmission state in response to an earphone communication instruction, and transmitting earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data transmission state comprises: and when the earphone communication instruction is determined to be an instruction for indicating the first earphone to communicate with the second earphone, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the first earphone through the first communication serial port in the communication data sending state. Responding based on the reply data includes: and when the reply data is received, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the reply data back to the second earphone through the first communication serial port in the communication data sending state.

The first earphone can be an earphone matched with the left ear or the right ear; correspondingly; the second earphone can be a right ear or an earphone matched with a left ear; when the first earphone is the earphone of the right ear, the second earphone is the earphone of the left ear, and when the first earphone is the earphone of the left ear, the second earphone is the earphone of the right ear. The instruction indicating that the first earphone and the second earphone communicate with each other is an instruction that the first earphone and the second earphone need to communicate with each other through the charging box, for example, an earphone pairing instruction indicating that the first earphone and the second earphone are paired through the charging box.

Specifically, when the data transmission state of the first communication serial port at the local end of the charging box is switched to the communication data transmission state, the earphone communication data corresponding to the communication instruction enabling the first earphone and the second earphone to communicate is transmitted to the first earphone.

In an embodiment, the headset communication data corresponding to the communication instruction enabling the first headset to communicate with the second headset may be communication data corresponding to the communication instruction for acquiring the MAC address of the first headset, and the communication data is sent to the first headset, so that after receiving the communication instruction, the first headset acquires the MAC address of the first headset, and the first headset replies the MAC address of the first headset to the charging box. As shown in fig. 4, when the charging box receives the reply data sent by the first earphone, the data transmission state of the first communication serial port of the local terminal is switched from the receiving state to the sending state, and the received reply data of the first earphone is forwarded to the second earphone, so that the first earphone and the second earphone can communicate with each other.

In this embodiment, by charging and sending the communication data to the first earphone and sending the received reply information of the first earphone to the second earphone, the communication data forwarding function through the charging box can be achieved, and communication between the first earphone and the second earphone can be achieved.

In an embodiment, the headset communication instruction may be a headset pairing instruction, as shown in fig. 5, when it is determined that the sending of the headset communication data is completed, the data transmission state of the first communication serial port is switched to a communication data receiving state, and receiving the reply data sent by the target headset through the first communication serial port in the communication data receiving state includes:

and 510, pairing the second earphone with the first earphone based on the earphone pairing address to obtain a pairing result.

Specifically, after the charging box receives the earphone pairing address sent by the first earphone, the charging box sends the received earphone pairing address of the first earphone to the second earphone, the second earphone searches the earphone pairing address of the first earphone stored in the home terminal according to the received earphone pairing address, the home terminal of the second earphone searches the earphone pairing address and then connects the earphone pairing address, pairing between the first earphone and the second earphone is achieved, and the second earphone returns a pairing result which is successfully paired to the charging box.

In one embodiment, after the first earphone and the second earphone are successfully paired, the first earphone sends the device name of the first earphone in a broadcast communication mode, at this time, the terminal can search the device name of the first earphone and initiate connection, and after the connection is successful, the pairing connection between the terminal and the first earphone is realized. Similarly, the pairing process with the terminal in this embodiment is also applicable to the second headset.

In one embodiment, the pairing address of the first headset or the second headset may be a MAC address. When a certain function required by a user can be realized only by matching the first earphone with the second earphone, the first earphone and the second earphone need to be paired, and respective MAC addresses of the first earphone and the second earphone are paired through forwarding of the charging box, so that a pairing result is obtained.

And step 512, after the charging box confirms that the earphone pairing address is sent to the second earphone, switching the data transmission state of the first communication serial port into a communication data receiving state, receiving the pairing result sent by the second earphone through the first communication serial port in the communication data receiving state, and outputting the pairing result.

Specifically, after the charging box confirms that the earphone pairing address is sent to the second earphone, the data transmission state of the first communication serial port at the home terminal is switched from the sending state to the receiving state, the pairing result sent by the second earphone is received, and the pairing result is output.

In one embodiment, the pairing result may be visually displayed on an interface of the charging box, played in a voice form on the charging box, or represented by a display state of an indicator lamp on the charging box, or the like.

In the embodiment, the pairing address of the first earphone is forwarded to the second earphone through the charging box, then the second earphone searches the pairing address of the first earphone, the second earphone searches the pairing address of the first earphone and then connects the first earphone and the second earphone after searching the pairing address of the second earphone, pairing between the first earphone and the second earphone is realized, a pairing result is obtained, the pairing result is output, pairing between the first earphone and the second earphone can be realized through the forwarding function of the charging box, and the first earphone and the second earphone are paired more accurately; meanwhile, the pairing result is output on the charging box, so that the charging box can visually feed the pairing result back to the user.

In one embodiment, as shown in fig. 6, the headset communication command is triggered in response to a user operation, and responding based on the reply data includes:

step 602, determining an operation result corresponding to the user operation based on the reply data.

The user operation refers to control operation of a user on functions of the charging box, and the control operation is used for controlling the charging box to communicate with the earphone; the operation result refers to a feedback result received by the charging box based on a user operation.

In one embodiment, the user may instruct the charging box to perform data query on the first headset or the second headset through user operation, and the charging box obtains a result of the query. For example, the power of the headset or the bluetooth connection state of the headset is queried, at this time, the user can make the charging box respectively send power or a bluetooth query command to the first headset and the second headset by operating the charging box, the first headset or the second headset respectively sends specific power or a bluetooth connection state to the charging box after receiving the command, and the charging box can obtain a corresponding operation result as specific power or a bluetooth connection state.

In one embodiment, the user may instruct the charging box to assist the first headset or the second headset to pair through user operation, and the charging box obtains a pairing result. For example, the first headset and the second headset are bluetooth headsets and need to be paired. When the first earphone and the second earphone are paired, respective MAC addresses need to be forwarded and exchanged through the charging box, and the charging box receives the pairing result of the first earphone and the second earphone.

And step 604, outputting the operation result.

Specifically, after the charging box receives the reply data sent by the first earphone or the second earphone, the charging box outputs an operation result according to the reply data, for example, the electric quantity of the earphone, and the output form can be displayed on an interface of the charging box in a visual form, can also be played on the charging box in a voice form, or can be represented on the charging box through the display state of an indicator light, and the like.

In this embodiment, the operation result of the user operation is received by the charging box and output, so that the operation result can be visually represented.

In one embodiment, as shown in fig. 7, in response to the headset communication instruction, switching the data transmission state of the first communication serial port to the communication data transmission state, and sending the headset communication data corresponding to the headset communication instruction to the target headset through the first communication serial port in the communication data transmission state includes:

step 702, in response to the earphone communication instruction, switching the data transmission state of the first communication serial port to a communication data sending state.

Specifically, when the charging box receives the earphone communication instruction, the charging box responds to the received earphone communication instruction, and switches the data transmission state of the first communication serial port of the home terminal from the receiving state to the sending state.

Step 704, obtaining the corresponding communication content and the headset to be communicated according to the headset communication instruction, and taking the headset to be communicated as a target headset.

The communication content refers to data content in a communication protocol used in a transmission process between the charging box and the headset to be communicated, and the data content may be specific data related to a specific command specified in the communication protocol.

Specifically, the charging box may obtain specific data corresponding to the headset communication instruction according to the headset communication instruction, and use a headset to be communicated, for example, a first headset, as a target headset, so that a communication function can be realized between the charging box and the target headset according to the headset communication instruction.

Step 706, generating a communication data packet according to the communication content and the communication address of the target earphone, wherein the communication data packet includes the instruction type, the communication content and the communication address of the earphone communication instruction, so that after the target earphone confirms that the receiver is the home terminal based on the communication address, data processing is performed according to the instruction type and the communication content to obtain reply data.

The communication address refers to a uniquely determined address capable of communication, and comprises an address of a sender and an address of a receiver; the communication data packet is the smallest transmission unit for data transmission when the charging box and the target earphone are communicated; the communication data packet comprises the instruction type, the communication content and the communication address of the headset communication instruction.

Specifically, when the charging box and the target earphone are communicated, the communication is performed in the form of continuously sending data packets, and the command type, the communication content and the communication address of the earphone communication command form the data packets in the form of the data packets. As shown in fig. 8, the communication address includes a sender address and a receiver address, which respectively occupy 4 bits, the sender address occupies bits 4 to 7, the receiver address occupies bits 0 to 3, the target earphone can be determined according to the receiver address in the communication address, when the target earphone receives a data packet, the sender can be determined as a charging box according to the sender address in the communication address in the data packet, and the receiver can be determined as a home terminal according to the address of the receiver; correspondingly, after the target earphone carries out data processing according to the instruction type and the communication content in the data packet, the reply data is fed back to the charging box in the form of the data packet, and when the reply data is fed back, the address of the sender in the communication address in the data packet becomes the address of the receiver, and the address of the receiver becomes the address of the sender.

In one embodiment, the data packet transmitted between the charging box and the target earphone further includes a data length portion, and when the type of the command issued by the charging box has no relevant data, the data length portion in the data packet has a value of 0, and the communication content portion in the data packet may be omitted.

In one embodiment, the data packet sent by the charging box includes the verification data. Specifically, the charging box may obtain the verification data of the data packet to be generated, the verification data may divide the specific number selected by the transmitting end and the receiving end, generate a new data packet to be transmitted from the data packet and the verification data transmitted by the charging box, and transmit the new data packet to the target earphone. Wherein the specific number is a preset number value, and the specific number is stored in the charging box and the target earphone in advance. And when the new data packet reaches the target earphone, the target earphone acquires the byte number of the received new data packet, divides the byte number by the specific number stored in advance, and if no remainder exists, the data packet is correct in the transmission process. If the data is correct, corresponding action is carried out according to the communication command requirement, then the data is replied to the charging box, and if the data is wrong, the charging box waits for new data to be sent again.

In this embodiment, the charging box and the target earphone are communicated with each other in a data packet mode, and the data packet is added with a verification part, so that the received data can be ensured to be accurate.

In one embodiment, all communications are initiated by the charging box first, as shown in fig. 9. The charging box will resend the communication command at most 3 times each time, until the reply of the target earphone is received. When the charging box needs to send a communication instruction, the charging box switches the data transmission state of the communication serial port to a sending state, and at the moment, the first earphone and the second earphone are both in a receiving state. The charging box firstly sends communication data to the first earphone, and after the communication data are sent, the communication serial port of the charging box is immediately switched to a receiving state; if the first earphone receives the communication data, the communication serial port of the first earphone is switched to a sending state, and the communication serial port sends the data back to the charging box. And after the first earphone sends the communication data, the communication serial port is immediately switched to a receiving state. After the charging box receives the reply data of the first earphone, the communication serial port of the charging box is switched to a sending state, the communication data is sent to the second earphone, after the communication data is sent, the communication serial port of the charging box is immediately switched to a receiving state, if the second earphone receives the communication data, the communication serial port of the second earphone is switched to the sending state, and the command reply data is sent to the charging box. And the communication serial port is also immediately switched into a receiving state after the second earphone finishes sending the data. The communication data is retransmitted at most three times each time, and when the charging box receives the command reply of the earphone, the retransmission of the communication data is stopped immediately; if the charging box does not receive the reply data of the earphone, retransmitting the data; and if the charging box does not receive the reply data after retransmitting the communication data for three times, the charging box gives an error warning.

It should be understood that although the various steps in the flowcharts of fig. 2, 5 or 6-7 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2, 5 or 6-7 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or at least partially with other steps or with at least some of the other steps.

In one embodiment, a communication system is provided, the communication system comprising a charging box and a target headset:

the charging box is used for receiving the earphone communication instruction;

the charging box is used for responding to the earphone communication instruction, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data sending state;

the target earphone is used for responding to the earphone communication data to perform data processing to obtain reply data when the earphone communication data are received, switching the data transmission state of the second communication serial port into a communication data sending state, and sending back complex data through the second communication serial port in the communication data sending state;

the charging box is used for switching the data transmission state of the first communication serial port into a communication data receiving state after the communication data of the earphone is confirmed to be sent, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state;

and the charging box is also used for responding based on the reply data.

In one embodiment, the target earpiece includes a first earpiece and a second earpiece; the charging box is used for switching the data transmission state of the first communication serial port into a communication data sending state when the earphone communication instruction is determined to be an instruction indicating that the first earphone is communicated with the second earphone, and sending the earphone communication data corresponding to the earphone communication instruction to the first earphone through the first communication serial port in the communication data sending state; and the charging box is also used for switching the data transmission state of the first communication serial port into a communication data sending state when receiving the reply data, and sending the reply data to the second earphone through the first communication serial port in the communication data sending state.

In one embodiment, as shown in fig. 10, the communication system includes a charging box, a left earphone and a right earphone, the charging box is provided with a data port TX/RX for receiving and transmitting communication data, and further includes a charging port change. Wherein, TX represents a data transmitting port, RX represents a data receiving port, and the left earphone and the right earphone are respectively connected through a +5V usb (universal Serial bus) line VBUS, and each of the left earphone and the right earphone comprises a data port TX, a data port RX, and a charging port BAT. When at least one of the left earphone and the right earphone needs to communicate with the charging box respectively, the data port TX/RX of the charging box is connected with the USB line VBUS, and the data port TX or the data port RX of at least one of the left earphone and the right earphone is connected through the USB line VBUS. When communication is needed between the left earphone and the right earphone and communication needs to be established through the charging box, the data port TX/RX of the charging box is connected with the USB line VBUS, and the data port TX or the data port RX of the left earphone or the right earphone is simultaneously connected through the USB line VBUS. When the left earphone or the right earphone needs to be charged by the charging box, the charging port CHAGGE of the charging box is connected with the USB line VBUS, and the charging port BAT of the left earphone or the right earphone is connected with the USB line VBUS, so that the charging of the charging box on the left earphone or the right earphone is realized.

The embodiment can realize the sending and receiving of data and the charging of the left earphone and/or the right earphone by utilizing one communication line, and can reduce the hardware cost.

In one embodiment, as shown in fig. 11, there is provided a communication apparatus 1100, comprising: the earphone communication instruction receiving module 1102, the earphone communication data sending module 1104, the target earphone sending back complex data receiving module 1106 and the reply data responding module 1108, wherein:

the earphone communication instruction receiving module is used for receiving an earphone communication instruction;

the earphone communication data sending module is used for responding to an earphone communication instruction, switching the data transmission state of the first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to a target earphone through the first communication serial port in the communication data sending state;

the target earphone sends back the complex data receiving module, which is used for switching the data transmission state of the first communication serial port into a communication data receiving state after the earphone communication data is sent, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state;

and the reply data response module is used for responding based on the reply data.

In an embodiment, the headset communication data sending module 1104 is further configured to, when it is determined that the headset communication instruction is an instruction indicating that the first headset communicates with the second headset, switch a data transmission state of the first communication serial port to a communication data sending state, and send, through the first communication serial port in the communication data sending state, headset communication data corresponding to the headset communication instruction to the first headset;

the reply data response module 1108 is further configured to switch the data transmission state of the first communication serial port to a communication data sending state when receiving the reply data, and send the reply data to the second earphone through the first communication serial port in the communication data sending state.

In one embodiment, the target earphone sends back the complex data receiving module 1106, and is further configured to switch the data transmission state of the first communication serial port to the communication data receiving state after the earphone communication data transmission is confirmed to be completed, and receive the earphone pairing address sent by the first earphone through the first communication serial port in the communication data receiving state;

the communication apparatus further includes: a pairing result acquisition module and a pairing result output module, wherein:

the pairing result acquisition module is used for pairing the second earphone with the first earphone based on the earphone pairing address to obtain a pairing result;

and the pairing result output module is used for switching the data transmission state of the first communication serial port into a communication data transmission state after the charging box confirms that the earphone communication address is transmitted to the second earphone, receiving the pairing result transmitted by the second earphone through the first communication serial port in the communication data transmission state and outputting the pairing result.

In one embodiment, the reply data response module 1108 includes: an operation result determining module and an operation result output module, wherein:

the operation result determining module is used for determining an operation result corresponding to the user operation based on the reply data;

and the operation result output module is used for outputting the operation result.

In one embodiment, the headset communication data transmission module 1104 includes: data transmission state unit, communication content and earphone acquisition unit and reply data acquisition unit that wait to communicate, wherein:

the data transmission state unit is used for responding to the earphone communication instruction and switching the data transmission state of the first communication serial port into a communication data sending state;

the communication content and to-be-communicated earphone acquisition unit acquires corresponding communication content and to-be-communicated earphones according to the earphone communication instruction, and takes the to-be-communicated earphones as target earphones;

and the reply data obtaining unit is used for generating a communication data packet according to the communication content and the communication address of the target earphone, wherein the communication data packet comprises the instruction type, the communication content and the communication address of the earphone communication instruction, so that the target earphone carries out data processing according to the instruction type and the communication content after confirming that the receiver is the local terminal based on the communication address, and the reply data is obtained.

For the specific limitations of the communication device, reference may be made to the above limitations of the communication method, which are not described herein again. The respective modules in the above-described communication apparatus may be implemented in whole or in part by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.

In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 12. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a communication method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.

Those skilled in the art will appreciate that the architecture shown in fig. 12 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.

In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:

receiving an earphone communication instruction;

responding to the earphone communication instruction, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data sending state;

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state, wherein the reply data is obtained by the target earphone through data processing in response to the earphone communication data;

responding based on the reply data.

In one embodiment, the processor, when executing the computer program, further performs the steps of:

when the earphone communication instruction is determined to be an instruction for indicating the first earphone to communicate with the second earphone, switching the data transmission state of the first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to the first earphone through the first communication serial port in the communication data sending state;

and when the reply data is received, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the reply data back to the second earphone through the first communication serial port in the communication data sending state.

In one embodiment, the processor, when executing the computer program, further performs the steps of:

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving an earphone pairing address sent by the first earphone through the first communication serial port in the communication data receiving state;

the communication method further comprises:

the second earphone is paired with the first earphone based on the earphone pairing address to obtain a pairing result;

and after the charging box confirms that the earphone communication address is sent to the second earphone, the data transmission state of the first communication serial port is switched to a communication data sending state, and the first communication serial port in the communication data sending state receives the pairing result sent by the second earphone and outputs the pairing result.

In one embodiment, the processor, when executing the computer program, further performs the steps of:

determining an operation result corresponding to the user operation based on the reply data;

and outputting the operation result.

In one embodiment, the processor, when executing the computer program, further performs the steps of:

responding to the earphone communication instruction, and switching the data transmission state of the first communication serial port into a communication data sending state;

acquiring corresponding communication content and an earphone to be communicated according to the earphone communication instruction, and taking the earphone to be communicated as a target earphone;

and generating a communication data packet according to the communication content and the communication address of the target earphone, wherein the communication data packet comprises the instruction type, the communication content and the communication address of the earphone communication instruction, so that the target earphone carries out data processing according to the instruction type and the communication content to obtain reply data after confirming that the receiver is the home terminal based on the communication address.

In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:

receiving an earphone communication instruction;

responding to the earphone communication instruction, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the earphone communication data corresponding to the earphone communication instruction to the target earphone through the first communication serial port in the communication data sending state;

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving reply data sent by the target earphone through the first communication serial port in the communication data receiving state, wherein the reply data is obtained by the target earphone through data processing in response to the earphone communication data;

responding based on the reply data.

In one embodiment, the computer program when executed by the processor further performs the steps of:

when the earphone communication instruction is determined to be an instruction for indicating the first earphone to communicate with the second earphone, switching the data transmission state of the first communication serial port into a communication data sending state, and sending earphone communication data corresponding to the earphone communication instruction to the first earphone through the first communication serial port in the communication data sending state;

and when the reply data is received, switching the data transmission state of the first communication serial port into a communication data sending state, and sending the reply data back to the second earphone through the first communication serial port in the communication data sending state.

In one embodiment, the computer program when executed by the processor further performs the steps of:

after the earphone communication data is confirmed to be sent, switching the data transmission state of the first communication serial port into a communication data receiving state, and receiving an earphone pairing address sent by the first earphone through the first communication serial port in the communication data receiving state;

the method further comprises the following steps:

the second earphone is paired with the first earphone based on the earphone pairing address to obtain a pairing result;

and after the charging box confirms that the earphone communication address is sent to the second earphone, the data transmission state of the first communication serial port is switched to a communication data sending state, and the first communication serial port in the communication data sending state receives the pairing result sent by the second earphone and outputs the pairing result.

In one embodiment, the computer program when executed by the processor further performs the steps of:

determining an operation result corresponding to the user operation based on the reply data;

and outputting the operation result.

In one embodiment, the computer program when executed by the processor further performs the steps of:

responding to the earphone communication instruction, and switching the data transmission state of the first communication serial port into a communication data sending state;

acquiring corresponding communication content and an earphone to be communicated according to the earphone communication instruction, and taking the earphone to be communicated as a target earphone;

and generating a communication data packet according to the communication content and the communication address of the target earphone, wherein the communication data packet comprises the instruction type, the communication content and the communication address of the earphone communication instruction, so that the target earphone carries out data processing according to the instruction type and the communication content to obtain reply data after confirming that the receiver is the home terminal based on the communication address.

It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.

The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.

The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

24页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:检测电路以及运作方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类