CN109522293B - Low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and method - Google Patents

Low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and method Download PDF

Info

Publication number
CN109522293B
CN109522293B CN201811127587.7A CN201811127587A CN109522293B CN 109522293 B CN109522293 B CN 109522293B CN 201811127587 A CN201811127587 A CN 201811127587A CN 109522293 B CN109522293 B CN 109522293B
Authority
CN
China
Prior art keywords
file
service
gatt
bluetooth
module
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.)
Active
Application number
CN201811127587.7A
Other languages
Chinese (zh)
Other versions
CN109522293A (en
Inventor
刘昊
郦家骅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Southeast University Wuxi Institute Of Integrated Circuit Technology
Southeast University
Original Assignee
Southeast University Wuxi Institute Of Integrated Circuit Technology
Southeast University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Southeast University Wuxi Institute Of Integrated Circuit Technology, Southeast University filed Critical Southeast University Wuxi Institute Of Integrated Circuit Technology
Priority to CN201811127587.7A priority Critical patent/CN109522293B/en
Publication of CN109522293A publication Critical patent/CN109522293A/en
Application granted granted Critical
Publication of CN109522293B publication Critical patent/CN109522293B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention discloses a low-power consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system.A service acquisition module acquires corresponding service and UUID information from a Bluetooth official organization website, and a conversion attribute database service module outputs a gatt file related to the corresponding service according to input parameters; the gatt file is the input to the attribute database compilation module, which generates the. The invention also discloses a method for pre-generating the low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database, which comprises the following steps: inquiring an official website of the Bluetooth technical alliance to obtain the available specific service with the corresponding specification name and the UUID related to the service; converting the service into a corresponding gatt file and adjusting according to the service; the adjusted gatt file is converted to an h file containing an array of attribute databases. The technical scheme can complete the generation of the attribute database and save the code space and the storage space.

Description

Low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and method
Technical Field
The invention relates to a system and a method for pre-generating a low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database.
Background
The Low power consumption Bluetooth (BLE) technology is a novel ultra-Low power consumption wireless transmission technology, has extremely Low running and standby power consumption, can continuously work for years by using one button cell, and is mainly designed for Low-cost, simple wireless body area networks and wireless personal area networks.
The attribute protocol is a specification for discovering, reading and writing attributes on peer devices. The attribute protocol is located above the L2CAP layer and uses the L2CAP as a transport mechanism for transferring data to provide services for generic attribute specifications. The attribute protocol employs a client-server model. The server exposes a series of attributes to the client. These attributes can be discovered, read, and written by the client, or can be indicated and notified by the server. One device can realize two roles of a client and a server, and the two roles can work normally on the same device or between two same devices at the same time. There can be only one instance of a server on each bluetooth device at any one time.
The attributes in the attribute server are stored in an attribute database, the attribute protocol defines a method for accessing the attribute database, and the attribute method accesses the data in the attribute database through an interface of the attribute database. In the design of the traditional protocol stack, the generation and the access of the attribute database are finished in a chip, and the generation method of the attribute database occupies most of the code amount of the whole attribute database part.
The generation method of the database occupies a large amount of on-chip storage space, and meanwhile, when the protocol stack is initialized, the attribute database is initialized, and the processing time of the MCU is occupied.
Disclosure of Invention
The invention aims to provide a low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and a method, which can complete generation of an attribute database and save code space and storage space.
In order to achieve the above purpose, the solution of the invention is:
a low-power consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system comprises a service acquisition module, a conversion attribute database service module and an attribute database compiling module, wherein the service acquisition module acquires corresponding service and UUID information from a Bluetooth official organization website, and the conversion attribute database service module outputs a gatt file related to the corresponding service according to input parameters; the gatt file is the input to the attribute database compilation module, which generates the.
The service acquisition module is written by python and comprises a codecs module, a datetime module, an os module, a requests module, a sys module and an lxml module.
The conversion attribute database service module comprises an io module, an os module, a re module, a string module and a sys module.
The attribute database compiling module is written by python and comprises a codecs module, a csv module, an io module, an os module, a re module, a string module, a sys module and a requests module.
A pre-generation method for a low-power consumption Bluetooth 4.2 protocol stack attribute protocol database comprises the following steps:
step 1, acquiring acquirable specific services with corresponding standard names and UUIDs related to the services by inquiring an official website of a Bluetooth technical alliance;
step 2, converting the service into a corresponding gatt file;
step 3, adjusting the gatt file according to the service type, and comparing the gatt file with the standard adopted by the Bluetooth official organization;
and 4, converting the adjusted gatt file into an h file containing an attribute database array.
The specific process of the step 4 is as follows:
step 41, inputting parameters, namely a service name, an input file name and an output h file name, taking out the service name and the input file name in the parameters, and creating an empty h file;
step 42, calling a codecs module to open an input file in a reading mode, automatically converting the input file into a UTF-8 format during reading, and assigning a return value of an open function to a fin variable which is one of the form parameters of a parse function; opening an output file in a writing mode and naming the output file as a service name h, automatically converting the output file into a UTF-8 format when reading the output file, and assigning a return value of an open function to a fout variable, which is also one of the form parameters of a parse function;
step 43, crawling out corresponding service data from the official website of the bluetooth alliance and testing whether the service data conforms to the format, if so, entering step 44, otherwise, exiting and prompting error information;
step 44, calling the realized parse function to analyze data, and storing the analyzed data into a list define; traversing the list define and writing the data into the service name h, at which time the program ends and prints out the h file to generate successful status information.
In step 41, after the parameters are input, a judgment is first made, and if the number of the input parameters is less than 3, the process exits and an error message is presented.
In step 42, if the input file or the output file is opened abnormally, the operation is exited and abnormal information is prompted.
After the scheme is adopted, the service acquisition module acquires the specific service and the UUID related to the service, and the conversion attribute database service module generates a corresponding gatt file; the gatt file is the input to the next module attribute database compilation module, which generates the. The invention can save code space and storage space, realizes python script modules such as a service acquisition module, a conversion attribute database service module, an attribute database compiling module and the like, and completes the generation of the attribute database.
Drawings
FIG. 1 is a diagram of the present invention obtaining a particular service and a service-related UUID via a python tool;
FIG. 2 is an intermediate step file;
FIG. 3 is a generic Access service prepared gatt file;
FIG. 4 is the resulting h-file containing the attribute database;
FIG. 5 is a functional block diagram of the present invention;
FIG. 6 is a detailed flow diagram of the attribute database compilation module.
Detailed Description
The technical solution and the advantages of the present invention will be described in detail with reference to the accompanying drawings.
As shown in fig. 5, the present invention provides a bluetooth low energy 4.2 protocol stack attribute protocol database pre-generation system, which includes a service acquisition module, a conversion attribute database service module, and an attribute database compiling module, wherein the service acquisition module uses a codecs module, a datetime module, an os module, a requests module, a sys module, and an lxml module of python; the conversion attribute database service module uses an io module, an os module, a re module, a string module and a sys module; the attribute database compiling module uses a codecs module, a csv module, an io module, an os module, a re module, a string module, a sys module and a requests module of python. The service acquisition module acquires corresponding service and UUID information from a Bluetooth official organization website. The conversion attribute database service module outputs a gatt file related to the corresponding service according to the input parameters; the gatt file is the input to the next module attribute database compilation module, which generates the.
The invention also provides a method for pre-generating the low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database, which comprises the following steps:
step 1: the complete service name is identified. To facilitate the creation of a profile (. gatt file) defined by the standard specification of the bluetooth alliance, the present invention implements a tool service acquisition module (get _ gatt _ service. py) that can acquire a specific service and a service-related UUID of a corresponding specification name that can be acquired by querying an official website of the bluetooth alliance. For example, the service shown in fig. 1.
Step 2: to convert the service into a corresponding gatt file, invoking the facility convert attribute database service module (convert _ gatt _ service. py) and using a particular canonical type results in an output as shown in fig. 2.
And step 3: in most cases you need to customize the gatt file, please note the output of the tool and look at the generated gatt file. For example, prepared for generic access services, the gatt file is shown in fig. 3. Content related to CHARACTERISTIC _ FORMAT may be deleted at this point because this is not necessary if this is not the only instance of the service. Finally please ask you to compare the gatt file with the specifications adopted by the bluetooth official organizations, thus confirming whether the service names and UUIDs in the file conform to the definitions of the bluetooth specifications.
And 4, step 4: the attribute database is actually an array that can be called by the corresponding operating function of the attribute protocol layer. This array is specifically generated by the specific service. The gatt file generated by the above steps needs to be converted into an array which can be understood and operated by the attribute protocol layer, and the invention completes a attribute database compiling module (complex _ gatt. The tool converts the gatt file generated in the above steps to an h-file containing an array of attribute databases, as shown in fig. 4.
The attribute database compiling module, namely the complex _ gatt. The detailed design flow chart of the module is shown in fig. 6, and parameters are required to be input when the module is called, wherein the parameters are a service name, an input file name and an output h file name. The following is a flowchart resolution of this module:
(1) after the parameters are input, the program judges, and if the number of the input parameters is less than 3, the program exits and prints to prompt the correct using method of the module. Otherwise, the normal process flow of the program is entered to take out the service name and the input file name in the parameters, and an empty h file is created.
(2) And then the program calls a codecs module to open the input file in a reading mode, the input file is automatically converted into a UTF-8 format when being read, and if the input file is abnormally opened, the program exits and abnormal information is printed. The return of the open function is now assigned to the fin variable, which will be one of the arguments of the parse function. The program opens the output file in a writing mode and names the output file with a service name h, the output file is automatically converted into a UTF-8 format when being read, if the output file is opened abnormally, the program exits and abnormal information is printed out, otherwise, the program flow continues. The return of the open function is now assigned to the fout variable, which will also be one of the arguments of the parse function.
(3) Then, the corresponding service data is crawled from the official website of the Bluetooth technical alliance (url is 'https:// www.bluetooth.com/specifications/gatt/services') and whether the service data conforms to the format is tested, if not, an exception is thrown out, and the program is ended to print corresponding error information.
(4) And finally, calling the realized parse function to analyze the data, and storing the analyzed data into a list define. Finally, the list define is traversed and the data is written into the service name h. And at the moment, the process is ended and the h file is printed out, so that the successful state information is generated. The ATT database has been generated so far.
The above embodiments are only for illustrating the technical idea of the present invention, and the protection scope of the present invention is not limited thereby, and any modifications made on the basis of the technical scheme according to the technical idea of the present invention fall within the protection scope of the present invention.

Claims (3)

1. A low power consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation method is characterized by comprising the following steps:
step 1, acquiring acquirable specific services with corresponding standard names and UUIDs related to the services by inquiring an official website of a Bluetooth technical alliance;
step 2, converting the service into a corresponding gatt file;
step 3, adjusting the gatt file according to the service type, and comparing the gatt file with the standard adopted by the Bluetooth official organization;
step 4, converting the adjusted gatt file into an h file containing an attribute database array;
the specific process of the step 4 is as follows:
step 41, inputting parameters, namely a service name, an input file name and an output h file name, taking out the service name and the input file name in the parameters, and creating an empty h file;
step 42, calling a codecs module to open an input file in a reading mode, automatically converting the input file into a UTF-8 format during reading, and assigning a return value of an open function to a fin variable which is one of the form parameters of a parse function; opening an output file in a writing mode and naming the output file as a service name h, automatically converting the output file into a UTF-8 format when reading the output file, and assigning a return value of an open function to a fout variable, which is also one of the form parameters of a parse function;
step 43, crawling out corresponding service data from the official website of the bluetooth alliance and testing whether the service data conforms to the format, if so, entering step 44, otherwise, exiting and prompting error information;
step 44, calling the realized parse function to analyze data, and storing the analyzed data into a list define; traversing the list define and writing the data into the service name h, at which time the program ends and prints out the h file to generate successful status information.
2. The bluetooth low energy 4.2 protocol stack attribute protocol database pre-generation method of claim 1, wherein: in step 41, after the parameters are input, firstly, a judgment is made, and if the number of the input parameters is less than 3, the operation is exited and an error message is prompted.
3. The bluetooth low energy 4.2 protocol stack attribute protocol database pre-generation method of claim 1, wherein: in step 42, if the input file or the output file is opened abnormally, the operation is exited and abnormal information is prompted.
CN201811127587.7A 2018-09-27 2018-09-27 Low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and method Active CN109522293B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811127587.7A CN109522293B (en) 2018-09-27 2018-09-27 Low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811127587.7A CN109522293B (en) 2018-09-27 2018-09-27 Low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and method

Publications (2)

Publication Number Publication Date
CN109522293A CN109522293A (en) 2019-03-26
CN109522293B true CN109522293B (en) 2021-08-17

Family

ID=65769816

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811127587.7A Active CN109522293B (en) 2018-09-27 2018-09-27 Low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and method

Country Status (1)

Country Link
CN (1) CN109522293B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106899930A (en) * 2015-12-17 2017-06-27 阿里巴巴集团控股有限公司 Finger print data base construction method, localization method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10395237B2 (en) * 2014-05-22 2019-08-27 American Express Travel Related Services Company, Inc. Systems and methods for dynamic proximity based E-commerce transactions

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106899930A (en) * 2015-12-17 2017-06-27 阿里巴巴集团控股有限公司 Finger print data base construction method, localization method and device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
《四、BLE(中)》;arduino;《bbsmax》;20161004;第1-6页 *
《四、BLE(中)》;arduino;《博客园》;20161004;第1-5页 *
《四、BLE(中)》;arduino;《布布扣》;20161004;第1-4页 *

Also Published As

Publication number Publication date
CN109522293A (en) 2019-03-26

Similar Documents

Publication Publication Date Title
CN105786998B (en) Database middleware system and the method for handling data using it
CN109670081B (en) Method and device for processing service request
US20120246334A1 (en) Unified web service uri builder and verification
CN111585344B (en) Substation intelligent checking method and device based on total station IED simulation
CN102130843B (en) Intelligent-document-platform-based multi-channel information acquisition and exchange method
CN114981775B (en) Cloud-based API metadata management method and system for integrated API management
US8312475B2 (en) Remote control of computing devices via two disparate networks
US7937696B2 (en) Method, system and program product for adapting software applications for client devices
CN112653579A (en) OpenResty-based gray scale publishing method and related equipment
US20030046444A1 (en) System and method for configuring an application
CN105516269B (en) The configuration method of application and the configuration device of application
CN109522293B (en) Low-power-consumption Bluetooth 4.2 protocol stack attribute protocol database pre-generation system and method
CN102546737B (en) Wireless Internet gateway access system and method
CN101039320A (en) Method and apparatus for providing an interface between a client application and a web service
CN113608952A (en) System fault processing method and system based on log construction support environment
CN101321178A (en) Portal workflow engine system and its implementing method
CN105897884A (en) Android mobile phone push platform based on eXtensive messaging presence protocol (XMPP)
CN112650777A (en) Data warehouse manufacturing method and device, terminal equipment and computer storage medium
CN113709187B (en) Multi-server data request method, device, equipment and storage medium
CN104967598A (en) Subscriber multimedia authority information obtaining method and apparatus
CN101976255B (en) Method and device for large-quantity export of webpage information to generate WORD document
CN101132570A (en) Provisioning server and provisioning method
CN112445811A (en) Data service method, device, storage medium and component based on SQL configuration
CN112613965A (en) Method and system for data processing based on middleware
Moons et al. Decentralized linked open data in constrained wireless sensor networks

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant