Design and Implementation of Embedded Bluetooth PSTN Voice Access Point

Abstract: First of all, an application of Bluetooth in the public switched telephone network PSTN—three-in-one phone. Then, it will be introduced in detail from three aspects: hardware, driver and application software. Finally, the test results are given and an improvement plan is proposed.

introduction

The open source μClinux has been widely used due to its powerful network function and low cost. The embedded Bluetooth public switched telephone network PSTN (Public Switched Telephone Network) voice access point is a promising application developed on the μClinux system in cooperation with the Guangdong Academy of Telecommunications Research. Its application scenario is shown in Figure 1.

After entering the signal coverage of the Bluetooth PSTN voice access point, the Bluetooth GSM dual-mode mobile phone automatically registers on the PSTN network through the access point, so that the user's traffic is transferred to the PSTN network, and only pays the fixed phone when using it The gateway has the function of a small switch, which can provide similar services for multiple Bluetooth mobile phones; and the Bluetooth mobile phone rooms within the signal coverage of the same access point can also directly communicate with each other without going through the PSTN, just like a walkie-talkie Same, no fee. This article mainly introduces the design and implementation of access point software and hardware and device drivers.

1 Hardware design and implementation

The hardware system block diagram of the embedded Bluetooth PSTN voice access point is shown in Figure 2. The whole access point is mainly composed of gateway control module, telephone line interface module and Bluetooth transceiver module.

1.1 Gateway control module

The gateway control module is the operating platform of the entire gateway software. The linux operating system runs on this hardware platform, and all application software runs on the operating system. Complex control procedures and a large number of external expansion modules require MPU to have strong processing capabilities. After many trade-offs, this design finally chose the ColdFire embedded processor MCF5272 from Motorola.

The SRAM and ROM inside the MCF5272 are far from enough to run the μClinux operating system. This design expands the RAM and ROM of MCF5272, and expands 16MB of SDRAM and 4MB of Flash ROM. This memory configuration not only meets the needs of the voice access point software, but also leaves more room for the gateway to add various functions.

1.2 Telephone line interface module

The telephone line interface module is the interface between the gateway and the PSTN, and is composed of a line switching relay, a telephone line interface chip, a DTMF receiving circuit, a DTMF transmitting circuit, and a FSK demodulation and ringing receiving circuit. It is connected to the gateway control module through 12 GPIO lines of MCF5272 and 4 external interrupt lines. The line switching relay is used to switch the signal on the telephone line between the ringing receiving circuit and the voice circuit, that is, to realize the function of off-hook and on-hook. In the standby state, the relay contacts are switched on the side of the ring receiving circuit, waiting for the ring signal to be received. When you need to go off-hook, MCF5272 controls the relay to switch to the voice circuit side.

The telephone line interface chip selects Philips' TEA1062A. TEA1062A amplifies the analog voice signal sent from the phone line and sends it to the PCM codec of the Bluetooth receiving module; on the contrary, it also amplifies the voice signal sent from the PCM codec and puts it on the phone line for transmission. In addition, it also provides functions such as side tone cancellation and automatic gain control.

The gateway also needs to have the function of forwarding caller ID information. Common caller ID standards are divided into DTMF and FSK. China's national caller ID standard is FSK. Most PSTN switches also support FSK standard caller ID information; however, there are a small number of PSTN switches and some user internal switches that send caller ID information of DTMF standard. Our Holtek HT9170D and HT9032C chips receive DTMF and FSK caller ID information, respectively.

The gateway dials to the PSTN switch just like an ordinary phone, and uses DTMF signals. It can also use the DTMF signal to send some signaling information to the PSTN switch. The gateway's DTMF sending uses FOLTEK's HT9200A chip.

1.3 Bluetooth transceiver module

The Bluetooth transceiver module includes a Bluetooth radio frequency circuit, a baseband processing circuit, and a PCM codec circuit, and is connected to the gateway control module through the UART1 of the MCF5272. The voice signal is connected through the PCM codec MC145483 and the telephone interface chip TEA1062A. The voice signal is connected through the PCM codec MC145483 and the telephone interface chip TEA1062A. The MCF5272 interprets the data received by the Bluetooth module as off-hook, on-hook, dialing, caller ID and other commands through the protocol stack, and controls various operations of the telephone voice receiving and dialing circuits through the data line. The PSTN local telephone network subscriber line is connected to the telephone line interface module. The telephone line interface module transmits the ringing signal and caller ID information of the external PSTN telephone network to the MCF5272 through the data line. MCF5272 then sends these signals into data packets through the Bluetooth software stack and sends them to the Bluetooth module, which sends them to the terminal through the wireless channel. The analog voice information on the telephone line is encoded by the PCM codec and sent to the terminal via the Bluetooth module. At the same time, the Bluetooth module receives the voice data sent by the terminal, decodes by the PCM codec to form an analog voice signal, and sends it to Phone line. The Bluetooth baseband and RF circuit in this design are composed of CSR's BlueCore01b chip plus power amplifier, low noise amplifier, transceiver switch, filter and some peripheral circuits.

2 Driver design and implementation

2.1 Overview of μClinux device driver

Under μClinux, all hardware devices are treated as files. Receiving input data from the device and sending output to the device is like receiving input from an ordinary file and sending output to a file. You can use read (), write (), etc. System call. The application interacts with the kernel through system calls, and the kernel interacts with specific hardware through device drivers, as shown in Figure 3. In general, the operating system kernel needs to access three main types of devices: character devices, block devices, and network devices. The driver of this access point belongs to the character device driver.

Each driver has a data structure called file_operaTIons that contains pointers to most functions within the driver. When the system boots, the driver initialization function sends the pointer of the file_operaTIons structure to the kernel, and the kernel can access the functions in the driver through the pointer. Therefore, these functions are the basic entry points into the driver. When the user program executes a system call, it will cause the corresponding function in the driver to be called.

2.2 Demand analysis

In the hardware design of the embedded Bluetooth PSTN voice access point, the telephone line interface module and the Bluetooth transceiver module are external modules that need to be supported by the μClinux kernel.

The Bluetooth transceiver module is connected to the gateway control module through the serial port 2 of the MCF5272, so the control of this module can be completed directly by using the serial port driver provided by μClinux; and the telephone line interface module is connected to the gateway control module through the GPIO port and the external interrupt line Connected, the driver must be freely provided by us.

2.3 Design and implementation of FSK caller ID chip driver

The main task of FSK caller ID driver is to complete the reception of FSK caller ID information. The overall workflow is shown in Figure 4. Its main functions are completed by the open, release, read, ioctl, and select functions in the basic entry point of the device driver, as well as the device initialization function, interrupt processing function, lower half processing function, and timer timeout processing function. The following is a brief introduction to some of these key functions.

(1) read function

Read and write are called I / O operations on the device. When the user process performs I / O operations on the device, the device may not have the conditions to perform I / O operations. In these cases, the user process can choose to continue to wait, that is, let the user process enter the sleep state through the interrupTIble_sleep_on () function; it can also choose not to wait and return immediately. This produces one or two types of I / O operations, namely blocking I / O and non-blocking I / O. Our driver supports both blocking and non-blocking read operations.

Figure 4

(2) ioctl function

The special device file is special because it represents a device, which can be used to set device attributes, which is different from I / O operations on the device. We use the ioct1 function to achieve, the essence of ioct1 is to send commands to the device to change the attributes of the device. In the process of implementing this driver, it was found that the FSK caller ID chip will also be interfered when there is no real FSK data, which will cause the level of the data line to jump, thereby generating interrupts that should not be generated and affecting the performance of the system. Therefore, 2 ioct1 commands are provided to the user process to control the opening and closing of the FSK interrupt.

(3) select function

In order to enable user processes to use I / O multiplexing technology, the select function is implemented in the driver. When the user process executes the select system call, the select function of each device added to the select test set is called. If any one or more of the devices can perform the required I / O operations, select returns; otherwise, select_wait The () function allows the user process to go to sleep until any device can perform the required I / O operation or time out.

(4) Interrupt handler function and lower half handler function

The FSK caller ID chip has only one data line connected to the GPIO port of the CPU. Each byte of data on this data line starts with 0 and ends with 1, the middle is an 8-bit ASCII code, the lowest bit is sent first, and the data line always protects the high level when there is no count. Because FSK caller ID data has this special format, connect this data line to the external interrupt line of the CPU at the same time, and set it as a falling edge trigger, so that every 1 byte of data will generate an interrupt. The FSK data frame consists of several bytes of such data. The FSK data rate is 1.2kb / s, so 1 bit lasts about 0.83ms. It takes about 8.3ms to receive one byte of data in this way. Obviously, it is not appropriate to receive data in the interrupt handler, so only the mark_up function is called in the interrupt handler to mark the arrival of data, and the task of receiving and processing data is left to the second half of the program to complete.

The lower part of the program is responsible for receiving 1-byte FSK caller ID data. Since there may be multiple drops in 1-byte data, the FSK interrupt must be closed after entering the processing function, and then the GPIO port is read every 0.83ms One bit of data, after receiving 1 byte of data, open the FSK interrupt to receive the next byte of data.

According to whether the FSK interruption is every interruption of this communication, it can be judged whether the received FSK data frame is the first byte of the FSK data frame. If it is, then a kernel timer will be started with a timeout of 1s. (Because the transmission time of a FSK data frame will not exceed 1s). After the timer expires, the kernel will call the processing function when the timer expires, extract the calling user's phone number, and wake up any user process waiting to read this device through the wake_up function.

Figure 5

2.4 Design and implementation of DTMF voice dialing and caller ID driver

Since the DTMF chip needs to provide dual tone multi-frequency dialing function, compared with the FSK chip driver, the DTMF chip driver has an additional write function. The multi-tone multi-frequency dialing part of the DTMF chip has 2 lines connected to the CPU: 1 data line and 1 clock line. The Write function actually transfers the data sent by the user process to the chip according to the write timing of the chip.

Compared with receiving FSK caller ID information, receiving DTMF caller ID information is easier. The DTMF caller ID chip provides 1 interrupt signal line and 4 parallel data lines. Each interruption only needs to read the parallel signal line, and perform simple decoding and buffering work. In addition, for convenience, the commander who picks up, hangs up, raises, or lowers the mute command contains the iotcl command of this driver. Like the FSK driver, in order to prevent interference from affecting the DTMF caller ID information, the iotcl command is also provided to open , Close the DTMF caller ID interrupt command.

3 Design and implementation of application software

The access point application is located on the hardware platform and device driver introduced earlier. The relationship between the three is shown in Figure 5. The access point application is the core of the entire software, it interacts with the serial port driver, FSK caller ID driver, DTMF caller ID driver, DTMF dial driver, Flash driver, ringer driver, and passes the last five drivers The program controls the specific hardware to complete related functions.

The access point can configure the attributes of Bluetooth terminals that are allowed to access. Only authorized Bluetooth terminals can access the PSTN through the access point. The Flash of the access point can set multiple Bluetooth terminals that are allowed to be accessed, and can add, delete one or all of the terminal settings through the phone connected in parallel with the gateway.

For a Bluetooth mobile phone set to dual mode, you must first register with the network, and the network returns a successful message before establishing a physical and logical link with the gateway; and when the dual mode mobile phone actively disconnects the physical link from the gateway, you must also register with the network Register. The access point can find out whether the registered dual-mode mobile phone leaves the signal coverage of the gateway, and automatically register with the network to switch the traffic of the dual-mode mobile phone back to the mobile network, and the parallel-mode terminal does not need such operation. The gateway can establish ACL (Asynchronous ConnecTIon Less) with 7 Bluetooth terminals at the same time

For calls of different modulation methods (FSK and DTMF), they can receive numbers and ringing, and analyze the called party according to the caller number, and establish a TCS (Telephone Control Specification) link, SCO according to the Bluetooth cordless telephony profile CTP (Cordless Telephony Profile) (Synchronous Connection Oriented) link. When the incoming call is displayed as a number that starts with a non-special service number, it indicates that the incoming call is a regular call, and all extension terminals connected to the gateway ring. After one terminal answers, the other terminal stops ringing and returns to the idle state. When the caller ID starts with the special service number, it indicates that the caller is accessing a specific terminal's traffic. The format of the caller ID can be analyzed to obtain the access sequence number, and the corresponding Bluetooth terminal can be ringed. The Bluetooth dual-mode or single-mode terminal can make external calls through the gateway and the PSTN network. The gateway supports multiple dialing of the terminal and the external phone can receive the caller ID.

Image 6

The application process we designed is shown in Figure 6. In μClinux system, this application is regarded as a user process. Add this process at the end of the system startup rc script file, the system will automatically start the process after completing the initialization work. For the user process, the hardware device is regarded as a device description file, which is no different from ordinary files, and can be represented by a file descriptor (a non-negative integer). When the program starts, use the open function provided by the Linux system to open these devices and set the working mode of these devices; start the Bluetooth protocol stack and set the working mode, service discovery database and other parameters, so that the gateway is always found and passively built. One side of the chain.

After that, the application program listens and waits for the arrival of data from each device. We use the I / O multiple transfer technology to read, write, and manage multiple descriptors. The basic idea of ​​this technology is: first construct a table of descriptors, and then call a function, it will not return until one of the descriptors is ready to represent I / O. On return, it tells the process which descriptor is ready for I / O. The select function can perform I / O multiplexing, and the parameters passed to the function tell the kernel the descriptors we care about and the conditions we care about for each descriptor (whether to read a given descriptor? Do you want to write one A given descriptor? Do you care about the abnormal condition of a descriptor?) And the time you want to wait (you can wait forever, wait for a fixed time or not at all). We have set a wait forever in the program, that is, only one of the specified descriptors is ready or a signal is captured before returning. When returning from select, the kernel tells us the number of prepared descriptors and which descriptors are ready for reading, writing, or abnormal conditions, and the application enters this information into the corresponding processing submodule.

Conclusion

The Bluetooth PSTN gateway based on the embedded μClinux system realizes all the functions of the operation, making the application of Bluetooth three-in-one phone a reality. Up to 7 Bluetooth terminals can establish physical and logical links with the gateway at the same time, and the gateway can establish a voice link. According to the actual measurement, the voice quality is good and clear without distortion under the premise that the transmission distance does not exceed 10m; after the transmission distance exceeds 10m, due to the automatic power control function of Bluetooth, the transmission power will be increased, and the electromagnetic interference introduced by the analog voice circuit part Increased noise affects the effect of the call. This problem can be eliminated by adjusting the PCB layout and wiring and adding shielding to the interference-prone circuits. According to the standard Bluetooth protocol, up to 3 voice links can be established between the Bluetooth terminal and the gateway, which will be improved in the next version.

Ceiling Fan Size

Ceiling Fan Size,Indoor Ceiling Fan Size,Outdoor Ceiling Fan Sizes,Modern Ceiling Fan Size

Jiangmen MagicPower Electrical Appliances Co.,Ltd. , https://www.magicpowerfan.com