Bluetooth module test method, electronic equipment and storage medium

By using a loopback mode between the host and the Bluetooth module to record and compare audio stream parameter information, the problem of low accuracy and reliability in Bluetooth module PCM interface testing is solved, achieving the effect of simplifying the testing environment and improving testing accuracy.

CN121865237APending Publication Date: 2026-04-14QUECTEL WIRELESS SOLUTIONS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-13
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

The existing Bluetooth module PCM interface has low testing accuracy and reliability, and the testing environment is complex and difficult to automate on the production line.

Method used

The system employs a loopback mode between the host and the Bluetooth module. It sends a first audio stream and records a second audio stream that loops back. The host computer then obtains and compares the parameter information of the audio files to get the test results.

Benefits of technology

It simplifies the functional testing of Bluetooth modules, improves the accuracy and reliability of testing, and provides a simple testing environment with high accuracy results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121865237A_ABST
    Figure CN121865237A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of testing, and discloses a Bluetooth module testing method, electronic equipment and a storage medium, and the Bluetooth module testing method comprises the following steps: sending a first audio stream to a Bluetooth module; the first audio stream is sent based on a first audio file stored in the HOST host; recording a second audio stream looped back by the Bluetooth module based on the first audio stream to obtain a second audio file; and sending the second audio file to an upper computer, so that the upper computer obtains parameter information of the second audio file, and compares the parameter information with the parameter information of the first audio file to obtain a test result. According to the embodiment of the invention, the functional test of the Bluetooth module is simplified by using the loopback mode between the HOST host and the Bluetooth module, the test environment of the Bluetooth module is simple, the influence on the test is small, and the accuracy and reliability of the Bluetooth module test are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of testing technology, and in particular to a Bluetooth module testing method, electronic device, and storage medium. Background Technology

[0002] A Bluetooth module is a module with Bluetooth audio and voice functions. It does not have the ability to run software independently and needs to be mounted on a host computer to run; this is known as an HCI (Host Controller Interface) Bluetooth module. The Bluetooth module supports a PCM (Pulse Code Modulation) interface (a digital audio interface used for the transmission and connection of digital audio signals) to support audio data transmission. Currently, the PCM interface of Bluetooth modules is tested on the production line using an impedance testing scheme. This utilizes the inherent impedance of the Bluetooth module's PCM interface pins, along with external pull-up voltage dividers, and uses the MCU's (Microcontroller Unit) ADC (Analog-to-Digital Converter) for testing.

[0003] However, current impedance testing methods for Bluetooth modules still result in relatively low accuracy and reliability in Bluetooth module testing. Summary of the Invention

[0004] The purpose of this application is to provide a Bluetooth module testing method, electronic device, and storage medium, thereby simplifying the functional testing of Bluetooth modules and improving the accuracy and reliability of Bluetooth module testing.

[0005] To address the aforementioned technical problems, embodiments of this application provide a Bluetooth module testing method applied to a host computer. The method includes: sending a first audio stream to the Bluetooth module; the first audio stream being sent based on a first audio file stored on the host computer; recording a second audio stream looped back by the Bluetooth module based on the first audio stream to obtain a second audio file; and sending the second audio file to a host computer so that the host computer can obtain parameter information of the second audio file and compare it with the parameter information of the first audio file to obtain a test result.

[0006] An embodiment of this application also provides a Bluetooth module testing method applied to a host computer. The method includes: receiving a second audio file sent by a host computer; wherein the second audio file is obtained by the host computer recording a second audio stream; the second audio stream is looped back to the host computer by the Bluetooth module based on a first audio stream; the first audio stream is sent by the host computer based on a stored first audio file; obtaining parameter information of the second audio file; comparing the parameter information of the second audio file with the parameter information of the first audio file to obtain a test result.

[0007] Embodiments of this application also provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the Bluetooth module testing method as described above.

[0008] Embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the Bluetooth module testing method described above.

[0009] In some embodiments, before sending the first audio stream to the Bluetooth module, the process includes: initializing the Bluetooth module; setting the encoding method of the Bluetooth module to transparent data; and setting the Bluetooth module to enter PCM loopback mode.

[0010] In some embodiments, the host transmits the first audio stream and receives the second audio stream through a PCM interface; the sampling rate of the host's PCM interface is 16kHz.

[0011] The technical solution provided in this application has at least the following advantages: This embodiment utilizes a loopback mode between the HOST host and the Bluetooth module, enabling the Bluetooth module to loop back a second audio stream based on a first audio stream and record it to obtain a second audio file. The host computer then obtains the test results based on the parameter information of the first audio file and the parameters of the second audio file stored on the HOST host. This simplifies the functional testing of the Bluetooth module, and the testing environment for the Bluetooth module is simple, with minimal impact on the test, thus improving the accuracy and reliability of the Bluetooth module testing. Furthermore, this embodiment uses the HOST host and the host computer to jointly obtain the test results, resulting in high accuracy and fast testing. Attached Figure Description

[0012] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0013] Figure 1 This is a flowchart illustrating a Bluetooth module testing method according to an embodiment of this application; Figure 2 This is a structural diagram of the HOST host, host computer, and Bluetooth module; Figure 3 This is a flowchart illustrating a Bluetooth module testing method according to another embodiment of this application; Figure 4 This is a flowchart illustrating a Bluetooth module testing method according to another embodiment of this application; Figure 5 This is a flowchart illustrating a Bluetooth module testing method according to yet another embodiment of this application; Figure 6 This is a flowchart illustrating each sub-step of step 402; Figure 7 This is a flowchart illustrating a Bluetooth module testing method according to another embodiment of this application; Figure 8 This is a structural block diagram of an electronic device according to another embodiment of this application. Detailed Implementation

[0014] As can be seen from the background technology, the accuracy and reliability of current Bluetooth module testing are still relatively low.

[0015] Analysis revealed that the PCM interface primarily transmits Bluetooth audio data. If the Bluetooth module is tested using the current impedance testing method, i.e., via Bluetooth phone, the production line needs to set up a voice environment, resulting in a complex and unstable testing environment. Furthermore, it is difficult to standardize automated judgment criteria for Bluetooth phone functionality on the production line, thus affecting the accuracy and reliability of Bluetooth module testing and leading to low accuracy and reliability of existing testing methods.

[0016] To address the aforementioned technical issues, this application provides a Bluetooth module testing method applied to a host computer. The Bluetooth module testing method includes: sending a first audio stream to the Bluetooth module; the first audio stream being sent based on a first audio file stored on the host computer; recording a second audio stream looped back by the Bluetooth module based on the first audio stream to obtain a second audio file; and sending the second audio file to a host computer so that the host computer can obtain parameter information of the second audio file and compare it with the parameter information of the first audio file to obtain a test result.

[0017] This embodiment utilizes a loopback mode between the HOST host and the Bluetooth module, enabling the Bluetooth module to loop back a second audio stream based on a first audio stream and record it to obtain a second audio file. The host computer then obtains the test results based on the parameter information of the first audio file and the parameters of the second audio file stored on the HOST host. This simplifies the functional testing of the Bluetooth module, and the testing environment for the Bluetooth module is simple, with minimal impact on the test, thus improving the accuracy and reliability of the Bluetooth module testing. Furthermore, this embodiment uses the HOST host and the host computer to jointly obtain the test results, resulting in high accuracy and fast testing.

[0018] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been provided in the various embodiments of this application to help readers better understand this application. However, the technical solutions claimed in this application can be implemented even without these technical details and various changes and modifications based on the following embodiments. The division of the various embodiments below is for the convenience of description and should not constitute any limitation on the specific implementation of this application. The various embodiments can be combined with and referenced by each other without contradiction.

[0019] One embodiment of this application relates to a Bluetooth module testing method, the specific flowchart of which is shown below. Figure 1 As shown, the Bluetooth module testing method in this embodiment includes the following steps: Step 101: Send the first audio stream to the Bluetooth module.

[0020] Specifically, in this application embodiment, the execution entity is a HOST host, which is communicatively connected to both the host computer and the Bluetooth module. In this application embodiment, the HOST host refers to the computer providing the service. For ease of description, the connection relationships between the HOST host, the host computer, and the Bluetooth module will be explained in detail below.

[0021] like Figure 2 The diagram shows the structure between the HOST host, the host computer, and the Bluetooth module. The HOST host communicates with both the host computer and the Bluetooth module. Specifically, the HOST host includes a UART (Universal Asynchronous Receiver and Transmitter) interface, a PCM interface, and a USB (Universal Serial Bus) interface. The HOST host connects to the host computer via the USB interface, connects to the PCM interface of the Bluetooth module via the PCM interface, and connects to the UART interface of the Bluetooth module via the UART interface.

[0022] Specifically, the host's PCM interface is used to send a first audio stream and receive a second audio stream. The PCM interface forms three paths (PCM_DOUT, PCM_DIN, PCM_CLK). The first audio stream is transmitted to the Bluetooth module via PCM_DOUT. The Bluetooth module internally receives the second audio stream, which is then returned to the host via PCM_DIN. The host synchronizes its clock signal via PCM_CLK. The host's UART interface is used to communicate with the Bluetooth module, such as controlling the Bluetooth module to enable PCM loopback mode. The host's USB interface is used to transfer data with the host computer, such as transferring the second audio file.

[0023] In this embodiment, the host computer stores a first audio file. For example, the host computer stores a special audio file named 1KHzsrc.wav, which is an audio file (wav file) with a fixed frequency of 1KHz and an amplitude of 1V. When testing the Bluetooth module, the host computer plays the first audio file and sends the first audio stream of the first audio file to the Bluetooth module through the PCM interface. The first audio stream is sent based on the first audio file stored in the host computer. Specifically, in this embodiment, the host computer transmits the first audio stream to the PCM interface of the Bluetooth module through the PCM interface, so that the Bluetooth module can loop back the second audio stream based on the first audio stream. The loopback mode between the host computer and the Bluetooth module is used to realize the functional testing of the Bluetooth module, simplifying the testing environment and improving the accuracy and reliability of the test.

[0024] Step 102: Record the second audio stream of the Bluetooth module based on the loopback of the first audio stream to obtain the second audio file.

[0025] In this embodiment, after the Bluetooth module loops back to the second audio stream based on the first audio stream, the host records the looped second audio stream to obtain a second audio file, which is then saved locally for use by the host computer. When the Bluetooth module is functioning normally, the first audio stream and the looped second audio stream are identical. Therefore, by detecting whether the parameters of the second audio file obtained from recording the second audio stream are the same as those of the first audio file, the functionality of the Bluetooth module can be determined.

[0026] Step 103: Send the second audio file to the host computer so that the host computer can obtain the parameter information of the second audio file and compare it with the parameter information of the first audio file to obtain the test result.

[0027] Specifically, if the PCM interface of the Bluetooth module functions normally, the parameter information of the first audio file and the parameter information of the second audio file should be the same. Therefore, after the HOST host of this application embodiment records the second audio file, it sends the second audio file to the host computer. The host computer obtains the parameter information of the second audio file and compares it with the parameter information of the first audio file to obtain the test result.

[0028] The parameter information of the first audio file can be obtained in advance. For example, the host can send the parameter information of the first audio file to the host computer while storing the first audio file, and the host computer can store the parameter information of the first audio file in advance; or, the host can send the first audio file to the host computer while storing the first audio file, and the host computer can calculate the parameter information of the first audio file in the same way.

[0029] The parameter information in the embodiments of this application includes center frequency and amplitude; in some embodiments, the center frequency of the first audio file is 1KHz and the amplitude of the first audio file is 1V.

[0030] If the host computer determines that the center frequency of the second audio file is the same as the center frequency (1kHz) of the first audio file, and the amplitude of the second audio file is the same as the amplitude (1V) of the first audio file, then it outputs a test result indicating that the Bluetooth module is qualified. If the host computer determines that any one of the following is different, the test result indicating that the Bluetooth module is unqualified.

[0031] Another embodiment of this application relates to a Bluetooth module testing method, the specific process diagram of which is shown below. Figure 3 As shown, the Bluetooth module testing method in this embodiment includes the following steps: Step 201: Initialize the Bluetooth module.

[0032] Step 202: Set the encoding method of the Bluetooth module to transparent data.

[0033] Step 203: Set the Bluetooth module to enter PCM loopback mode.

[0034] Step 204: Send the first audio stream to the Bluetooth module.

[0035] Step 205: Record the second audio stream of the Bluetooth module based on the loopback of the first audio stream to obtain the second audio file.

[0036] Step 206: Send the second audio file to the host computer so that the host computer can obtain the parameter information of the second audio file and compare it with the parameter information of the first audio file to obtain the test result.

[0037] Steps 204, 205, and 206 in this embodiment are the same as steps 101, 102, and 103 in the previous embodiment, and will not be repeated here to avoid repetition. The relevant technical details of this embodiment will be described in detail below.

[0038] Before the HOST host and Bluetooth module perform a loopback test, that is, before the HOST host sends the first audio stream to the Bluetooth module, the Bluetooth module must be initialized. The initialization includes at least any of the following steps: power on, set the serial port, set the baud rate, download firmware, reset, etc. This part is executed by the corresponding bootstrap application in the HOST host. The bootstrap application is encapsulated into a shell script for calling.

[0039] After the host initializes the Bluetooth module, this embodiment of the application also configures the initialized Bluetooth module, mainly including two settings: (1) Set the encoding method of the Bluetooth module to transparent data.

[0040] Specifically, the host calls the HCI_Write_Voice_Setting instruction in the HCI (Host Controller Interface, a set of instructions for communication between the host and controller) to set the Bluetooth module's air coding to transparent data. In this way, the Bluetooth module does not perform any additional encoding or processing on the data during transmission; instead, it directly returns the raw data to the host, ensuring that the sent and received data are completely identical, without any modification or compression. Under normal Bluetooth module conditions, this guarantees that the first and second audio streams in this embodiment are completely identical, improving the accuracy of Bluetooth module testing.

[0041] The loopback test in this application embodiment is based on a 16kHz sampling rate, that is, the sampling rate of the PCM interface of the HOST host is 16kHz. At a sampling rate of 16kHz, in order to ensure data integrity and transparent transmission, aircoding needs to be explicitly set to transparent data.

[0042] If the loopback test is based on an 8kHz sampling rate, the default settings may already meet the requirements, or the way the Bluetooth module processes data at an 8kHz sampling rate may not affect the loopback test results. Therefore, in this case, it is not necessary to explicitly set air coding to transparent data.

[0043] (2) Set the Bluetooth module to enter PCM loopback mode.

[0044] Specifically, the host calls the HCI_Write_Loopback_Mode instruction in the HCI to set the Bluetooth module into PCM loopback mode. Loopback mode is a test mode that allows the Bluetooth module to directly return the received audio stream to the host, used to test the integrity and accuracy of the audio stream transmission.

[0045] It should be noted that the above two methods of configuring the HOST host are also implemented by encapsulating the corresponding application in a shell script.

[0046] After configuring the Bluetooth module, the next step in this embodiment is to configure the audio portion of the HOST host. Since the HOST host is based on the Linux ALSA (Advanced Linux Sound Architecture) audio framework, only the amix or tinymix command-line tools need to be called to configure the HOST host's audio portion. The following explanation uses amix as an example. The configuration of the HOST host's audio portion in this embodiment mainly includes the following aspects: (1) Since the HOST host has two I2S (Inter-IC Sound) pins, each I2S pin can be connected to different audio devices, and these interfaces also have corresponding configuration options in the software. Therefore, there are two corresponding options to choose from in the software. In this embodiment, both I2S pins can be set to PCM mode, and the PCM mode can be selected based on the pins of the Bluetooth module and the HOST host.

[0047] (2) The amix tool sets the sampling rate of the PCM interface of the host to 16kHz through the amix command. The amix command can be amix "AUX PCM SampleRate" 1, where "AUX PCM SampleRate" is the name of the mixer control and 1 means set to 16kHz.

[0048] (3) The amix tool sets the audio path of the PCM connected to the Bluetooth module through the amix command. By configuring the front-end PCM device and the back-end DAI (Digital Audio Interface), the audio signal can be correctly transmitted from the PCM device (HOST host) to the DAI device (Bluetooth module).

[0049] All the settings related to the PCM loopback mode have been completed. Now we can start testing. The testing process in this embodiment mainly includes two steps: playing back (i.e., the content of step 204) and recording capture (i.e., the content of step 205). The testing process can also be implemented by directly calling aplay and arecord (arec).

[0050] During playback, the host sends the first audio stream to the Bluetooth module via the PCM interface. The test uses a fixed 1kHz sine wave, stored in a wav file (i.e., the first audio file), and uses aplay for playback testing. aplay is a tool for playing audio files. If there are multiple DAI devices (Bluetooth modules) in the test system, the correct device needs to be specified using the -D parameter. Therefore, aplay needs to specify the corresponding DAI device (Bluetooth module) through the -D parameter, and the front-end PCM device (host) plays the specified file (i.e., the first audio file) to the DAI device (Bluetooth module).

[0051] During the recording capture process, the host records a second audio stream looped back from the Bluetooth module. This second audio stream is based on the first audio stream. Specifically, the host uses arecord to record the second audio stream and obtain a second audio file. arecord is a recording tool that can capture audio input and save it to a file. In this process, the arecord call also needs to specify the front-end PCM device (host) using the -D parameter and specify a path to store the recorded second audio file.

[0052] Specifically, all the above operations can be encapsulated into AT (Attention) commands for use by the host computer, thereby achieving automated testing. All the above operations are encapsulated into three AT commands, which respectively implement the following operations: (1) Initialization of the Bluetooth module, including initialization after the PCM loopback test is completed.

[0053] (2) PCM loopback mode settings for the Bluetooth module, including voice settings.

[0054] (3) The PCM loopback test process includes playback and recording. It should be noted that in this embodiment, recording is performed before playback, and the recording timeout can be set by parameters (based on the playback duration). In addition, the naming of the recorded files meets certain rules, which can be negotiated and set with the production line tool group (host computer). This embodiment does not impose specific limitations.

[0055] In other words, all three operations mentioned above require the host computer to call the corresponding AT commands to complete the initialization operation, PCM loopback mode setting operation, playback, and recording operation. The detailed operations of initialization, PCM loopback mode setting, playback, and recording have been described in detail above and will not be repeated here.

[0056] In this embodiment of the application, during the playback and recording operation, the host computer sends AT commands to the HOST host to record the second audio stream of the Bluetooth module loopback to obtain the second audio file. The HOST host will also name the second audio file according to the SN number of different Bluetooth modules, such as "pcm_SN.wav".

[0057] After the PCM loopback test is completed, the results need to be analyzed. This step is done by the host computer, which needs to export the recorded second audio file to the host computer. The host computer retrieves the recorded second audio file locally using adb (Android Debug Bridge). The adb method uses the adb command-line tool provided by Android. Then, the host computer parses the second audio file and finally outputs the results.

[0058] Specifically, after acquiring the second audio file, the host computer obtains its sampling rate and number of channels. Then, it reads single-channel audio data from the second audio file. The maximum value of the audio data is calculated to obtain the amplitude of the second audio file. A Fourier transform is then performed on the audio data to obtain the amplitude spectrum of the bilateral spectrum. The frequency corresponding to each spectral point in the amplitude spectrum is calculated, and the maximum value of the frequency is taken as the center frequency of the second audio file. If the center frequency and amplitude of the recorded second audio file are the same as those of the original first audio file 1kHzsrc.wav stored in the host computer (i.e., the center frequency of the second audio file is 1kHz and the center amplitude is 1V), then the test is considered passed.

[0059] Another embodiment of this application relates to a Bluetooth module testing method, applied to a host computer, as shown in the detailed flowchart below. Figure 4 As shown, the Bluetooth module testing method in this embodiment includes the following steps: Step 301: Receive the second audio file sent by the HOST host.

[0060] The second audio file is obtained by the HOST host recording a second audio stream; the second audio stream is looped back to the HOST host by the Bluetooth module based on the first audio stream; the first audio stream is sent by the HOST host based on the stored first audio file. Step 302: Obtain the parameter information of the second audio file.

[0061] Step 303: Compare the parameter information of the second audio file with the parameter information of the first audio file to obtain the test result.

[0062] It is not difficult to see that this embodiment is a host computer embodiment corresponding to the above-described host-side embodiment. The relevant technical details mentioned above are still valid in this embodiment, and will not be repeated here to avoid repetition. Correspondingly, the relevant technical details mentioned in this embodiment can also be applied to the above-described host-side embodiment.

[0063] Another embodiment of this application relates to a Bluetooth module testing method, applied to a host computer, as shown in the detailed flowchart below. Figure 5 As shown, the Bluetooth module testing method in this embodiment includes the following steps: Step 401: Receive the second audio file sent by the HOST host.

[0064] Step 401 in this embodiment is largely the same as step 301 in the above embodiment, and will not be repeated here to avoid repetition.

[0065] Step 402: Obtain the center frequency and amplitude of the second audio file.

[0066] Specifically, in this embodiment, the parameter information includes the center frequency and amplitude. Obtaining the parameter information of the second audio file means obtaining the center frequency and amplitude of the second audio file. Then, the host computer compares the center frequency and amplitude of the second audio file with the center frequency and amplitude of the first audio file. For example, the center frequency of the first audio file is 1kHz, and the amplitude of the first audio file is 1V.

[0067] like Figure 6 The diagram shown is a flowchart of each sub-step of step 402 above. Step 402, which involves obtaining the center frequency and amplitude of the second audio file, includes the following sub-steps: Step 4021: Read the audio data of the second audio file.

[0068] Specifically, the audio data is single-channel data, which simplifies subsequent processing steps. In practical applications, audio data is usually stored in digital form, such as PCM (Pulse Code Modulation) format. After reading the audio data from the second audio file, the audio data can be stored as an array or matrix.

[0069] Step 4022: Calculate the maximum value of the audio data to obtain the amplitude of the second audio file.

[0070] Specifically, taking the audio data as an array as an example, the amplitude of the second audio file can be obtained by calculating the maximum absolute value of all elements in the array.

[0071] Step 4023: Perform a Fourier transform on the audio data to obtain the amplitude spectrum of the bilateral spectrum.

[0072] Specifically, the embodiments of this application can convert audio data from the time domain to the frequency domain using Fourier transform, thereby analyzing the frequency components of the audio data. The result of the Fourier transform (i.e., the amplitude spectrum of the bilateral spectrum) is a complex array representing the frequency domain representation of the audio data. Its amplitude can be obtained by calculating the modulus of the complex number, and the amplitude spectrum represents the signal strength at each frequency point.

[0073] Specifically, the amplitude spectrum of the aforementioned bilateral spectrum is in the range of [0, 1]. To obtain the amplitude spectrum of the bilateral spectrum, it is necessary to first calculate the modulus of the complex numbers in the complex number array, i.e., the amplitude; then, the amplitude spectrum is normalized to ensure that the amplitude spectrum value is in the range of [0, 1] to obtain the amplitude spectrum of the bilateral spectrum.

[0074] Step 4024: Calculate the frequency corresponding to each spectral point in the amplitude spectrum.

[0075] Step 4025: Take the maximum value of the frequencies as the center frequency of the second audio file.

[0076] Specifically, in this embodiment of the application, after obtaining the amplitude spectrum of the bilateral spectrum, the frequency corresponding to each spectral point in the amplitude spectrum is calculated, and the frequency point corresponding to the maximum frequency is found. This frequency point represents the strongest frequency component in the audio data, and the frequency of this frequency point is the center frequency of the second audio file. That is, the maximum frequency in the amplitude spectrum is the center frequency of the second audio file.

[0077] Step 403: Determine whether the center frequency of the second audio file is the same as that of the first audio file, and whether the amplitude of the second audio file is the same as that of the first audio file.

[0078] If yes, proceed to step 404, the test is passed; if no, proceed to step 405, the test is failed.

[0079] Step 404, test passed.

[0080] Step 405, test failed.

[0081] Another embodiment of this application relates to a Bluetooth module testing method, applied to a host computer, as shown in the detailed flowchart below. Figure 7 As shown, the Bluetooth module testing method in this embodiment includes the following steps: Step 501: Receive the second audio file sent by the HOST host.

[0082] Step 502: Obtain the format information of the second audio file.

[0083] Specifically, the format information of the second audio file in this embodiment includes the sampling rate and the number of channels.

[0084] Step 503: Read the audio data of the second audio file.

[0085] Specifically, in this embodiment, the audio data read is single-channel data. After obtaining the number of channels of the second audio file, if the second audio file is multi-channel data, the data of one channel of the second audio file is read as audio data to ensure that the audio data is single-channel data. For example, if the second audio file is stereo (dual-channel), it is usually necessary to select one channel (e.g., left channel or right channel) for processing. Retaining single-channel data can simplify subsequent processing steps. If the second audio file is single-channel, the single-channel data of the second audio file is read as audio data.

[0086] Step 504: Calculate the maximum value of the audio data to obtain the amplitude of the second audio file.

[0087] Step 505: Perform a Fourier transform on the audio data to obtain the amplitude spectrum of the bilateral spectrum.

[0088] Step 506: Calculate the frequency corresponding to each spectral point in the amplitude spectrum based on the sampling rate.

[0089] Specifically, in this embodiment of the application, after obtaining the sampling rate of the second audio file, the frequency corresponding to each spectrum point can be obtained by using the sampling rate during the process of obtaining the frequency corresponding to each spectrum point. Specifically, the calculation formula for the frequency corresponding to each spectrum point is f = k × Fs / N, where f is the frequency, k is the index of the spectrum point, Fs is the sampling rate, and N is the number of points of the Fourier transform (usually the length of the audio data).

[0090] Step 507: Take the maximum value of the frequency as the center frequency of the second audio file.

[0091] Step 508: Determine whether the center frequency of the second audio file is the same as the center frequency of the first audio file, and whether the amplitude of the second audio file is the same as the amplitude of the first audio file.

[0092] If yes, proceed to step 509, the test is passed; if no, proceed to step 510, the test is failed.

[0093] Step 509, test passed.

[0094] Step 510, test failed.

[0095] The steps 501, 503, 504, 505, 507, 508, 509, and 510 described above are roughly the same as steps 401, 4021, 4022, 4023, 4025, 403, 404, and 405 in the previous embodiment. To avoid repetition, they will not be described again here.

[0096] Below is the code related to obtaining the center frequency and amplitude of the second audio file: 1. Read the second audio file using (var reader = new AudioFileReader(filePath)) { audioDataf = 0; var waveFormat = reader.WaveFormat; int sampleRate = waveFormat.SampleRate; int channels = waveFormat.Channels; AudioFileReader is a class used to read audio files, typically from the NAudio library. WaveFormat indicates the format information of the second audio file, including sampleRate (the sample rate of the second audio file) and channels (the number of channels in the second audio file).

[0097] 2. Read audio data float[] audioData = new float[reader.Length / sizeof(float)]; reader.Read(audioData, 0, audioData.Length); Here, reader.Length represents the total length of the second audio file (in bytes), sizeof(float) represents the size of each floating-point number (4 bytes), and reader.Read represents reading audio data into the audioData array.

[0098] 3. Extract single-channel data / / If it's stereo, take the data from the first channel. if (channels>1) { audioData = audioData.Where((x, i) =>i % channels == 0).ToArray(); } Here, `Where` indicates that a LINQ query is used to retrieve data from the first channel. `i % channels == 0` means selecting data with indices 0, channels, 2*channels, ..., i.e., data from the first channel.

[0099] 4. Calculate the maximum value of the audio data. audioDataf = audioData.Max(x =>Math.Abs(x)); Where Max represents the maximum absolute value of all elements in the array.

[0100] 5. Perform Fourier transform (FFT) on the audio data. int N = audioData.Length; Complex[] y = new Complex[N]; for (int n = 0; n <N; n++) { y[n] = new Complex(audioData[n], 0); } Fourier.Forward(y, FourierOptions.Matlab); Here, Complex represents a complex number, Complex(audioData[n], 0) means converting audio data into a complex number form, and Fourier.Forward means performing a Fast Fourier Transform (FFT) to convert the time-domain signal into a frequency-domain signal.

[0101] 6. Calculate the amplitude spectrum of the two-sided spectrum. double[] spectrum = new double[N / 2]; for (int i = 0; i <N / 2; i++) { spectrum[i] = Math.Sqrt(Math.Pow(y[i].Real, 2) + Math.Pow(y[i].Imaginary, 2)) / N; } Here, “Math.Sqrt(Math.Pow(y[i].Real, 2) + Math.Pow(y[i].Imaginary,2))” means calculating the modulus of the complex number, i.e., the amplitude. “ / N” means normalization, so that the value of the amplitude spectrum is in the range [0, 1].

[0102] 7. Calculate the frequency double[] hzPerBin = new double[N / 2]; for (int i = 0; i <N / 2; i++) { hzPerBin[i] = (double)i * sampleRate / N; } Where “hzPerBin[i] = (double)i * sampleRate / N” means calculating the frequency corresponding to each spectral point.

[0103] 8. Find the center frequency corresponding to the position of the maximum amplitude spectrum. int maxIndex = 0; for (int i = 1; i <spectrum.Length; i++) { if (spectrum[i]>spectrum[maxIndex]) { maxIndex = i; } } return hzPerBin[maxIndex]; } Where maxIndex represents the position of the maximum amplitude spectrum, and hzPerBin[maxIndex] represents the frequency corresponding to the maximum amplitude spectrum.

[0104] Another embodiment of this application relates to an electronic device, such as... Figure 8 The diagram shown is a structural block diagram of the electronic device of this embodiment. The electronic device includes at least one processor 601 and a memory 602 communicatively connected to at least one processor 601. The memory 602 stores instructions that can be executed by at least one processor 601. The instructions are executed by at least one processor 601 to enable at least one processor 601 to perform the robot control method as described above.

[0105] The memory 602 and processor 601 are connected via a bus, which may include any number of interconnecting buses and bridges. The bus connects various circuits of one or more processors 601 and memory 602 together. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by processor 601 is transmitted over a wireless medium via an antenna, which further receives data and transmits it to processor 601.

[0106] Processor 601 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory 602 can be used to store data used by processor 601 during operation.

[0107] Another embodiment of this application relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the method embodiments described above.

[0108] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0109] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing this application, and in practical applications, various changes can be made to them in form and detail without departing from the spirit and scope of this application.

Claims

1. A Bluetooth module testing method, characterized in that, Applied to a host, the method includes: The first audio stream is sent to the Bluetooth module; the first audio stream is sent based on the first audio file stored in the HOST host. Record the second audio stream based on the loopback of the first audio stream by the Bluetooth module to obtain the second audio file; The second audio file is sent to the host computer so that the host computer can obtain the parameter information of the second audio file and compare it with the parameter information of the first audio file to obtain the test result.

2. The Bluetooth module testing method according to claim 1, characterized in that, Before sending the first audio stream to the Bluetooth module, the process includes: Initialize the Bluetooth module; The encoding method of the Bluetooth module is set to transparent data; Configure the Bluetooth module to enter PCM loopback mode.

3. The Bluetooth module testing method according to claim 1 or 2, characterized in that, The host computer transmits the first audio stream and receives the second audio stream through the PCM interface; the sampling rate of the PCM interface of the host computer is 16kHz.

4. A Bluetooth module testing method, characterized in that, Applied to a host computer, the method includes: The system receives a second audio file sent by the host; wherein the second audio file is obtained by the host recording a second audio stream; the second audio stream is looped back to the host by the Bluetooth module based on a first audio stream; and the first audio stream is sent by the host based on a stored first audio file. Obtain the parameter information of the second audio file; The parameter information of the second audio file is compared with the parameter information of the first audio file to obtain the test results.

5. The Bluetooth module testing method according to claim 4, characterized in that, The parameter information includes the center frequency and amplitude; obtaining the parameter information of the second audio file includes: Obtain the center frequency and amplitude of the second audio file; The step of comparing the parameter information of the second audio file with the parameter information of the first audio file to obtain the test result includes: If the center frequency of the second audio file is the same as that of the first audio file, and the amplitude of the second audio file is the same as that of the first audio file, then the test is passed; otherwise, the test is failed.

6. The Bluetooth module testing method according to claim 5, characterized in that, The step of obtaining the center frequency and amplitude of the second audio file includes: Read the audio data from the second audio file; The amplitude of the second audio file is obtained by calculating the maximum value of the audio data; Perform a Fourier transform on the audio data to obtain the amplitude spectrum of the bilateral spectrum; Calculate the frequency corresponding to each spectral point in the amplitude spectrum; The maximum value of the frequencies is taken as the center frequency of the second audio file.

7. The Bluetooth module testing method according to claim 6, characterized in that, Before reading the audio data of the second audio file, the following steps are included: Obtain the format information of the second audio file, the format information including the sampling rate and the number of channels; The reading of audio data from the second audio file includes: If the second audio file is multi-channel data, read the data from any one channel of the second audio file as the audio data; if the second audio file is single-channel data, read the single-channel data of the second audio file as the audio data. The calculation of the frequency corresponding to each spectral point in the amplitude spectrum includes: The frequency corresponding to each spectral point in the amplitude spectrum is calculated based on the sampling rate.

8. The Bluetooth module testing method according to any one of claims 4 to 7, characterized in that, The center frequency of the first audio file is 1kHz, and the amplitude of the first audio file is 1V.

9. An electronic device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the Bluetooth module testing method as described in any one of claims 1 to 3, or to perform the Bluetooth module testing method as described in any one of claims 4 to 8.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the Bluetooth module testing method according to any one of claims 1 to 3, or implements the Bluetooth module testing method according to any one of claims 4 to 8.