CN105893038A - Method for porting android Bluetooth protocol stack to Mint17 system - Google Patents
Method for porting android Bluetooth protocol stack to Mint17 system Download PDFInfo
- Publication number
- CN105893038A CN105893038A CN201610194611.3A CN201610194611A CN105893038A CN 105893038 A CN105893038 A CN 105893038A CN 201610194611 A CN201610194611 A CN 201610194611A CN 105893038 A CN105893038 A CN 105893038A
- Authority
- CN
- China
- Prior art keywords
- bluetooth
- hci
- mint17
- uart
- interface
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Withdrawn
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The invention provides a method for porting an android Bluetooth protocol stack to a Mint17 system. The method mainly includes the steps that 1, a user space program is added, a Bluetooth standard interface of a hardware abstraction layer is called to use a Bluetooth function; 2, a Bluetooth core protocol stack is ported to the Mint17; 3, for implementation of an interface bt_vendor_interface_t, a kernel driver is controlled; 4, a Bluetooth drive program in a kernel is modified. The method achieves the feasible scheme of porting the android Bluetooth protocol stack Bluedroid to the Mint17 system by modifying specific drive implementation and a specific module in the Mint17 system based on the specific Linux release version Mint17. The novel Bluetooth protocol stack provided by the invention has clearer hierarchical division and greater flexibility compared with an old version bluez, the extension capability and compatibility of a Linux system to Bluetooth mobile devices can be enhanced.
Description
Technical field
The invention belongs to network security field of computer technology, relate to a kind of Android bluetooth protocol repertory Bluedroid
Method to Mint17 system transplantation.
Background technology
Due to popularizing of current mobile device, the use to bluetooth the most day by day increases, and props up in up-to-date Android system
The bluetooth protocol repertory Bluedroid held provides service with unique advantage for Android user.Along with mobile skill
The development of art and the growth of Android mobile device user group, novel Android bluetooth protocol repertory compares Linux official
Bluetooth protocol repertory bluez more improvement and popularization.Mint17, as a kind of release of Linux, obtains
How increasing user's favor, be transplanted in Mint17 system becoming by Bluedroid agreement and grind
Study carefully focus.Under Mint17 use bluez Bluetooth protocol framework, inner nuclear layer be integrated with hci, l2cap,
Rfcomm, cmtp, bnep agreement, other upper-layer protocols are integrated at user's space, and user's space passes through system
Call ioctl mutual with kernel.The Bluedroid protocol stack begun to use from Android 4.2 version is in structure
There is the biggest difference in upper and bluez.The drive part of its bluetooth is real under the driver catalogue of inner nuclear layer
Existing, but remove all bluetooth modules beyond bluetooth driving and be fully achieved and operate in user's space.
Summary of the invention
The technical problem to be solved in the present invention is to provide a kind of novel bluetooth protocol repertory Bludroid to Mint17
The method of system transplantation, the method realizes framework, concrete by analyze Bluetooth protocol under two kinds of systems of contrast
Realize agreement.Therefrom parse the part relevant to particular system and hardware, the part that extraction system is general,
The transplanting of Mint17 system Bluetooth protocol is completed by the implementation method of amendment goal systems.
In linux kernel, it is integrated with the part core content of BlueZ protocol stack and has achieved bluetooth
The driver of hardware device.And Bluedroid protocol stack is in addition to driver, completely at user's space
Achieve all component of bluetooth.Therefore, with reference to Android Bluedroid Bluetooth system framework, transplantation Project
Method particularly includes: Bluedroid bluetooth framework is realized as the user space program of Linux, removes Android
Part on hardware abstraction layer in bluetooth framework (Hardware Abstract Layer is called for short HAL) layer, passes through
Call HAL standard interface and realize Bluetooth function.Bottom passes through dynamic load library File Open kernel bluetooth equipment
File, by host controller interface (Host Controller Interface, be called for short HCI) to device file
The control of implementing reading and writing bluetooth hardware.
Bluedroid bluetooth protocol repertory general frame divides sees accompanying drawing 1.Wherein comprise 7 main modules,
The substantially function of each module is as follows:
JAVA program: use JAVA programming language to write;Represent the application program of bluetooth framework top,
And the code of the application specification of the various concrete application of correspondence (such as earphone, mouse etc.) realizes.JNI: full name
JAVA Native Interface;Realized by C language, be contact upper strata JAVA application and bottom code
Interface routine.HAL: full name Hardware Abstract Layer, hardware abstraction layer, is Bluedroid
The module that bluetooth protocol repertory is newly added, the Bluetooth protocol of bottom is a hardware by software abstract by this module
Equipment, and unified interface is provided to upper strata, underlying protocol is controlled by upper strata by calling these interfaces.
The part that CORE STACK: Bluetooth protocol implements.HCI: full name Host Controller Interface,
Host controller interface;The isolation module of software and hardware, provides the interface of unified standard to upper strata bluetooth protocol repertory,
By calling the standard interface of HCI, upper strata Bluetooth protocol can complete bluetooth in the way of using unification general
Controlling without the isomery characteristic considering hardware of hardware.VENDOR: different bluetooth manufacturers are complete in this module
The most each specificity configuration of chip product;DRIVER: Bluetooth Device Driver, is positioned at kernel spacing.
The technical scheme is that
A kind of Android bluetooth protocol repertory includes hardware abstraction to the method for Mint17 system transplantation, this implantation method
Layer (HAL), bluetooth core stack (CORE STACK), host controller interface (HCI) and vendor module
(VENDOR).Concretely comprise the following steps:
The first step, adds user space program, and the bluetooth standard interface calling HAL layer uses Bluetooth function.
HAL and the interface on upper strata
This interface provides the entrance of bluetooth basic function, including initializing, opens, search, pairing etc..Blue
Tooth HAL layer also includes that other apply the interface of specification (profile) to realize accordingly.Therefore, user is write empty
Between program, complete standard interface is called to realize corresponding Bluetooth function.
Second step, HAL, CORE STACK, HCI comprise good interface and realize and functional realiey, be not required to repair
Change, bluetooth core protocol stack is grafted directly to Mint17.It is bluetooth core in the middle of HAL layer and vendor module
Protocol stack, Bluedroid provides complete administrative mechanism, and good interface realizes, it is not necessary to change, directly
Connect and be transplanted to Mint17.
3rd step, as the vendor module of connection kernel with user's space, needs to enter according to bottom hardware characteristic
Row is appropriately configured, is therefore to transplant the key content that job demand completes;This layer of vendor module is down, logical
Cross the realization of docking port bt_vendor_interface_t, the different operating that op function in docking port is corresponding
Encode, control the bluetooth driver in kernel, eventually through the device file in read-write kernel to firmly
Part operates.Wherein op is the key component transplanted, and needs to realize what Bluedroid was defined by each manufacturer
The process of operation code.
Bt_vendor_interface_t interface definition is as follows:
Wherein op is the key component transplanted, it is achieved the process to the operation code that Bluedroid defines of each manufacturer,
Operation code is as follows:
Comprising a series of instruction in HCI to send, data transmission etc. operates, and these operations all can be mapped to
The operation code that operation is corresponding.The concrete operations of hardware are controlled by op (opcode, param).Therefore, need
The different operating that op function is corresponding is encoded, eventually through the device file in read-write kernel to hardware
It is controlled.
4th step, modifies to the bluetooth driver in kernel.
In Mint17 kernel, the interface of Bluetooth protocol software and hardware is exactly that host controller interface HCI, HCI carry
For a set of uniform command interface calling bottom hardware.Indigo plant is achieved under path at/drivers/bluetooth
The driver part of tooth.In driver, HCI layer is the most abstract to all of outside bluetooth equipment is a knot
Structure body hci_dev, registering a bluetooth equipment needs to call hci_register_dev () function, and equipment unloads
Call hci_unregister_dev () function.The bluetooth carried in linux kernel drives to be had a lot,
Hci_vhci.c is Bluetooth virtual Host Controller Driver, and hci_uart.c is that serial interface master controller drives
Dynamic program, btusb.c is USB interface Host Controller Driver, and btsdio.c is that SDIO master controller drives
Dynamic program.
All of driving is all in HCI layer implemented below;At the code section of HCI module, by kernel indigo plant
Tooth device file operating process complete bluetooth drive control and data transmission:
4.1//open dynamic link library libbt-vendor.so
Lib_handle=dlopen (VENDOR_LIBRARY_NAME, RTLD_NOW);
4.2//obtain vendor module libbt_vendor.so interface
Vendor_interface=(bt_vendor_interface_t*) dlsym (lib_handle,
VENDOR_LIBRARY_SYMBOL_NAME);
4.3//vendor module initializes registered callbacks function
Int status=vendor_interface-> init (&vendor_callbacks, (unsigned
char*)local_bdaddr);
4.4//call op function, send director data
vendor_interface->op(opcode,param);
4.5//call function and open UART EBI
bool userial_open(userial_port_t port)
4.6//send data, carry out calling during data write is that the linux system of standard calls write letter
Number
// modular system calls write
Ret=write (userial_cb.fd [ch_idx], p_data+total, len);
The amendment detailed process of described bluetooth drive part is:
Hdev-> open=hci_uart_open;//1
Hdev-> close=hci_uart_close;//2
Hdev-> flush=hci_uart_flush;//3
Hdev-> send=hci_uart_send_frame;//4
Hdev-> setup=hci_uart_setup;//5
Wherein comprising the one two three line code is the basic operation to uart respectively, opens, and closes, and refreshes;The
The four complete paired datas of line code send the setting of control function;Fifth line completes the basic setup to uart.
By the analysis of above code, the HCI operation to file, what reading and writing data etc. used is all standard
Linux system calls open, close, read, write etc. thus in terms of carrying out standard control kernel empty
Between the general bluetooth driver of device drives reusable.On the other hand, need to realize more such as bluetooth equipment
(power adding as realizing more becoming more meticulous controls and adds in kernel-driven part to add complicated control function
Bluetooth-power.c file) specific aim can add corresponding file.
The invention have the benefit that 1) novel bluetooth protocol repertory compares legacy version bluez and has more clear
Clear distinguishing hierarchy, has higher motility, and at all levels, developer only need to add or revise
Corresponding code can complete interpolation or the optimization of New function, greatly improves the extensibility of system.Logical
Cross novel bluetooth protocol repertory, make up the defect that legacy version development difficulty is big.2) by novel Bluetooth protocol
The transplanting of stack Bluedroid, can strengthen linux system to the extension of Bluetooth mobile equipment and compatibility.
Redaction bluetooth protocol repertory Bluedroid is in addition to driving, and whole Bluetooth protocols realize at user's space completely,
Improve the safety of linux kernel.
Accompanying drawing explanation
Accompanying drawing is bluetooth subsystem general frame figure in Android 5.1.1 in embodiment.
Detailed description of the invention
A kind of Android Bluetooth, to the method for Mint system transplantation, needs to remove Bluez in Linux
Relevant module, retains kernel-driven, and Bluedroid is as user's null process.Complete by read-write equipment file
Bluetooth hardware is become to control.Specifically include following steps:
The first step, adds user space program, calls HAL layer bluetooth standard interface bt_interface_t
Use Bluetooth function.
Second step, HAL, CORE STACK, HCI are not required to amendment, are grafted directly to by bluetooth core protocol stack
In Mint17.
3rd step, this layer of vendor module is down, by the realization of docking port bt_vendor_interface_t, right
The different operating that op function is corresponding encodes, and controls kernel-driven, eventually through the equipment in read-write kernel
Hardware is operated by file.
As a example by the vendor module of high pass Bluetooth chip is supported, in Android 5.1.1 official source code, corresponding
Vendor module code only comprises three files:
Bt_vendor_qcom.c
Hardware.c
Userial_vendor.c
Bt_vendor_qcom.c is to vendor module interface bt_vendor_interface_t above-mentioned
Code realize.
Hardware.c file realizes the reading of status information, transmission.
Userial_vendor.c file then realizes the opening operation of bluetooth equipment file in kernel.Bluetooth is supported
Communication mode UART and SMD of two kinds of data, SMD is supported by high pass, is directed to two equipment
The read-write of file:
Wherein/dev/smd3 is instruction, and event port ,/dev/smd2 is data transmit-receive port.
Libbt_vendor.so module mainly complete the relevant device file of bluetooth in linux kernel open and
Close, and the initialization of hardware device and work is set etc..And the instruction transmission of bluetooth, event transmission,
The operation such as data transmission is then to be realized by HCI module.Vendor module realizes code and is positioned at catalogue
/hardware/qcom/bt/libbt_vendor/.In vendor module, open file operation
// open device file
Fd=open (s_pszDevSmd [chId], (and O_RDWR | O_NOCTTY));
// open main line equipment
Fd=open (bt_hci_transport_device.name, (and O_RDWR | O_NOCTTY));
It is all that the system of employing standard is called to the operation of file.
4th step, in Mint17 kernel, the interface of Bluetooth protocol software and hardware is host controller interface,
The driver part of bluetooth is realized under/drivers/bluetooth path;In driver, HCI layer is to all
Outside bluetooth equipment the most abstract be a structure hci_dev, registering bluetooth equipment needs to call
Hci_register_dev () function, hci_unregister_dev () function is called in equipment unloading, it is achieved in kernel
The amendment of bluetooth drive part.
All of bluetooth drives all around this structure of hci_dev, then completes operation as follows:
Hdev-> open=hci_uart_open;
Hdev-> close=hci_uart_close;
Hdev-> flush=hci_uart_flush;
Hdev-> send=hci_uart_send_frame;
Hdev-> setup=hci_uart_setup;
Underlying device is connected by bluetooth protocol repertory generally by serial ports, between the two by HCI protocol communication.
Requirement realizes a tty serial port drive.For Bluez, its upper strata be sent by socket,
Receive data.Therefore, in Bluetooth communication, it is socket communication to upper layer application, is that tty drives to lower floor
Dynamic realization.Tty drive at path/drivers/Bluetooth/hci_ll.c and
In/drivers/Bluetooth/hci_ldis.c.
Hci_ldis.c achieves the transmission specification of a bluetooth specific, wherein tty serial ports has been carried out some
Arrange, as follows.
Initialize and realize:
All of driving is all in HCI layer implemented below, at the code section of HCI module, it is achieved internally
In core, bluetooth driver calls and controls.
Claims (1)
1. an Android bluetooth protocol repertory is to the method for Mint17 system transplantation, it is characterised in that include following
Step:
The first step, adds user space program, calls HAL layer bluetooth standard interface and uses Bluetooth function;
Second step, HAL, CORE STACK, HCI are not required to amendment, by direct for bluetooth core protocol stack
It is transplanted in Mint17;
3rd step, this layer of vendor module down, by the realization of docking port bt_vendor_interface_t,
The different operating that op function is corresponding is encoded, controls kernel-driven, eventually through in read-write kernel
Device file hardware is operated;
4th step, in Mint17 kernel, realizes the driving of bluetooth under/drivers/bluetooth path
Program part;In driver, all of outside bluetooth equipment of HCI layer is abstract is a structure
Hci_dev, registering a bluetooth equipment needs to call hci_register_dev () function, and equipment unloading is called
Hci_unregister_dev () function, it is achieved the amendment to the bluetooth drive part in kernel, bluetooth drives
The amendment process of part is:
Hdev-> open=hci_uart_open;//1
Hdev-> close=hci_uart_close;//2
Hdev-> flush=hci_uart_flush;//3
Hdev-> send=hci_uart_send_frame;//4
Hdev-> setup=hci_uart_setup;//5
Wherein, the one two three line code is the basic operation to uart respectively: open, and closes, and refreshes;
The complete paired data of fourth line code sends the setting of control function;Fifth line completes substantially setting uart
Put.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610194611.3A CN105893038A (en) | 2016-03-30 | 2016-03-30 | Method for porting android Bluetooth protocol stack to Mint17 system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610194611.3A CN105893038A (en) | 2016-03-30 | 2016-03-30 | Method for porting android Bluetooth protocol stack to Mint17 system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105893038A true CN105893038A (en) | 2016-08-24 |
Family
ID=57014392
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610194611.3A Withdrawn CN105893038A (en) | 2016-03-30 | 2016-03-30 | Method for porting android Bluetooth protocol stack to Mint17 system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105893038A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109167617A (en) * | 2018-08-10 | 2019-01-08 | 深圳市智微智能科技开发有限公司 | The method and Related product of Android system adaptation USB Bluetooth adapter |
CN109451472A (en) * | 2018-10-08 | 2019-03-08 | 四川长虹电器股份有限公司 | The dynamic management approach of more Bluetooth chips on Android smart machine |
CN110366039A (en) * | 2019-07-12 | 2019-10-22 | 四川长虹电器股份有限公司 | The compatibility method of different bluetooth mould groups under a kind of android system |
CN111427617A (en) * | 2019-01-09 | 2020-07-17 | 阿里巴巴集团控股有限公司 | Data processing method, device and equipment |
CN111954039A (en) * | 2020-07-02 | 2020-11-17 | 深圳市华曦达科技股份有限公司 | Set top box Bluetooth configuration method and device, electronic equipment and storage medium |
CN113099433A (en) * | 2021-04-14 | 2021-07-09 | 深圳泰科晶显科技有限公司 | Android system-based dynamic method compatible with WIFI and Bluetooth modules of different manufacturers |
CN114860629A (en) * | 2022-05-16 | 2022-08-05 | 哈尔滨国铁科技集团股份有限公司 | Computer equipment reading method based on USB virtualization |
WO2023284699A1 (en) * | 2021-07-12 | 2023-01-19 | 北京字节跳动网络技术有限公司 | Protocol stack data transmission method based on linux system, and computer device and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101924582A (en) * | 2010-07-29 | 2010-12-22 | 上海慧翰信息技术有限公司 | Communication device and middleware thereof |
-
2016
- 2016-03-30 CN CN201610194611.3A patent/CN105893038A/en not_active Withdrawn
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101924582A (en) * | 2010-07-29 | 2010-12-22 | 上海慧翰信息技术有限公司 | Communication device and middleware thereof |
Non-Patent Citations (2)
Title |
---|
FLY123456789: "android bluetooth 移植相关注意事项", 《HTTP://BLOG.CHINAUNIX.NET/UID-20768928-ID-5674215.HTML》 * |
MANTEAU: "enable_native中的hci dev注册和up", 《HTTP://WWW.XUEBUYUAN.COM/1494166.HTML》 * |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109167617A (en) * | 2018-08-10 | 2019-01-08 | 深圳市智微智能科技开发有限公司 | The method and Related product of Android system adaptation USB Bluetooth adapter |
CN109167617B (en) * | 2018-08-10 | 2022-04-01 | 深圳市智微智能科技股份有限公司 | Method for adapting USB Bluetooth adapter to android system and related product |
CN109451472A (en) * | 2018-10-08 | 2019-03-08 | 四川长虹电器股份有限公司 | The dynamic management approach of more Bluetooth chips on Android smart machine |
CN109451472B (en) * | 2018-10-08 | 2021-04-06 | 四川长虹电器股份有限公司 | Dynamic management method for multiple Bluetooth chips on Android intelligent device |
CN111427617A (en) * | 2019-01-09 | 2020-07-17 | 阿里巴巴集团控股有限公司 | Data processing method, device and equipment |
CN111427617B (en) * | 2019-01-09 | 2023-05-30 | 斑马智行网络(香港)有限公司 | Data processing method, device and equipment |
CN110366039A (en) * | 2019-07-12 | 2019-10-22 | 四川长虹电器股份有限公司 | The compatibility method of different bluetooth mould groups under a kind of android system |
CN111954039A (en) * | 2020-07-02 | 2020-11-17 | 深圳市华曦达科技股份有限公司 | Set top box Bluetooth configuration method and device, electronic equipment and storage medium |
CN111954039B (en) * | 2020-07-02 | 2022-07-01 | 深圳市华曦达科技股份有限公司 | Set top box Bluetooth configuration method and device, electronic equipment and storage medium |
CN113099433A (en) * | 2021-04-14 | 2021-07-09 | 深圳泰科晶显科技有限公司 | Android system-based dynamic method compatible with WIFI and Bluetooth modules of different manufacturers |
WO2023284699A1 (en) * | 2021-07-12 | 2023-01-19 | 北京字节跳动网络技术有限公司 | Protocol stack data transmission method based on linux system, and computer device and storage medium |
CN114860629A (en) * | 2022-05-16 | 2022-08-05 | 哈尔滨国铁科技集团股份有限公司 | Computer equipment reading method based on USB virtualization |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105893038A (en) | Method for porting android Bluetooth protocol stack to Mint17 system | |
CN104679513B (en) | A kind of device drives framework development approach in intelligent terminal | |
CN102289374B (en) | A kind of method and device for building multi-platform software running environment | |
CN103746746B (en) | A kind of operation system of the network equipment | |
CN105933767B (en) | Middleware device, Middleware implementation method and television set | |
CN105162673A (en) | Data transmission interface and method | |
CN108141733A (en) | NFC " splitting storehouse " architectural framework | |
US7469359B2 (en) | Method and apparatus for testing communication software | |
CN102929645A (en) | Method utilizing embedded Python interpreter to realize secondary development of software system | |
EP4060588A1 (en) | Virtual electronic card management method and system, security chip, terminal, and storage medium | |
CN109358839A (en) | A kind of method and storage medium of embedded scm software development | |
CN105068910A (en) | Testing method and apparatus for smart card | |
CN106598647A (en) | Intelligent apparatus development platform | |
CN102169447A (en) | Method and corresponding system for registering and deregistering self-defined Shell | |
US6651104B1 (en) | Multi-layered interface for interconnecting application programs to system bus lines for electronic devices | |
CN106575278A (en) | Universal serial bus emulation layer | |
CN103024012B (en) | Data interactive method between computer and intelligent terminal modem | |
CN101840391B (en) | Electronic payment system dual-processor sub-system communication method and calling method thereof | |
CN113099433A (en) | Android system-based dynamic method compatible with WIFI and Bluetooth modules of different manufacturers | |
CN104519011B (en) | Semiconductor equipment manages system and its protocol conversion module, semiconductor equipment management method | |
US8844827B2 (en) | Chip card, and method for the software-based modification of a chip card | |
CN101110031A (en) | Interconnection interface for flexible online/offline deployment of an n-layered software application | |
CN107181981A (en) | Method, device, television and system for upgrading television through external equipment | |
CN109857638B (en) | Universal framework for test system software | |
CN101969476B (en) | Communication mode management method and system for emulating semiconductor manufacturing equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20160824 |
|
WW01 | Invention patent application withdrawn after publication |