CN104796847A - Bluetooth communication method and system - Google Patents

Bluetooth communication method and system Download PDF

Info

Publication number
CN104796847A
CN104796847A CN201510106865.0A CN201510106865A CN104796847A CN 104796847 A CN104796847 A CN 104796847A CN 201510106865 A CN201510106865 A CN 201510106865A CN 104796847 A CN104796847 A CN 104796847A
Authority
CN
China
Prior art keywords
field
equipment
value
bluetooth
son field
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.)
Pending
Application number
CN201510106865.0A
Other languages
Chinese (zh)
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.)
NANTONG COSHIP ELECTRONICS CO Ltd
Original Assignee
NANTONG COSHIP ELECTRONICS CO Ltd
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 NANTONG COSHIP ELECTRONICS CO Ltd filed Critical NANTONG COSHIP ELECTRONICS CO Ltd
Priority to CN201510106865.0A priority Critical patent/CN104796847A/en
Publication of CN104796847A publication Critical patent/CN104796847A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04BTRANSMISSION
    • H04B5/00Near-field transmission systems, e.g. inductive or capacitive transmission systems
    • H04B5/40Near-field transmission systems, e.g. inductive or capacitive transmission systems characterised by components specially adapted for near-field transmission
    • H04B5/48Transceivers
    • GPHYSICS
    • G08SIGNALLING
    • G08BSIGNALLING OR CALLING SYSTEMS; ORDER TELEGRAPHS; ALARM SYSTEMS
    • G08B21/00Alarms responsive to a single specified undesired or abnormal condition and not otherwise provided for
    • G08B21/18Status alarms
    • G08B21/24Reminder alarms, e.g. anti-loss alarms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • H04W24/04Arrangements for maintaining operational condition
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W28/00Network traffic management; Network resource management
    • H04W28/02Traffic management, e.g. flow control or congestion control
    • H04W28/06Optimizing the usage of the radio link, e.g. header compression, information sizing, discarding information
    • H04W28/065Optimizing the usage of the radio link, e.g. header compression, information sizing, discarding information using assembly or disassembly of packets
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Business, Economics & Management (AREA)
  • Emergency Management (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The embodiment of the invention discloses a Bluetooth communication method. The method comprises the following steps that: master equipment generates a first Bluetooth data packet according to a Bluetooth protocol, wherein the first Bluetooth data packet comprises a first flag bit and a first field, the first field comprises a first sub-field and a second sub-field, the first flag bit is used for indicating whether or not the first field is a field of a first data format, and the value of the first sub-field is a control command of the master equipment and the value of the second sub-field is setting information when the first field is the field of the first data format; the master equipment transmits the first Bluetooth data packet to slave equipment; and the slave equipment resolves the first Bluetooth data packet through an RFCOMM protocol, extracts the first flag bit, judges whether or not the first field is the field of the first data format, resolves the first field according to the first data format if the first field is the field of the first data format, and extracts the values of the first sub-field and the second sub-field. Through adoption of the Bluetooth communication method, data communication involved with Prevent to Lost (PTL) can be processed through an extension protocol, and a PTL application can be developed conveniently and rapidly.

Description

A kind of Bluetooth communication method and system
Technical field
The present invention relates to the communications field, particularly relate to a kind of Bluetooth communication method and system.
Background technology
Due to the low power consumption characteristic of Bluetooth technology, the application in a large number based on Bluetooth protocol is risen gradually, and such as bluetooth is anti-lost.Bluetooth protocol can be divided into underlying protocol, intermediate layer protocol and application layer protocol three class from level.Bluetooth core agreement comprises: baseband specification (BaseBand), LMP Link Manager Protocol (LMP), logic link control and adapting protocol specification (L2CAP) and service search agreement (SDP) four part, bluetooth applications layer protocol is also bluetooth applications specification PROFILE, is based upon on the basis of bluetooth core agreement.
The anti-lost basic function of bluetooth can comprise: bluetooth master relies on the power of the Bluetooth signal from Bluetooth slave devices received to judge standoff distance, once the intensity of the Bluetooth signal received is too low or Bluetooth signal disappears, bluetooth master will send prompting to user.At present, the application program realizing the anti-lost function of bluetooth is a lot.The communication that developer can realize between bluetooth master and Bluetooth slave devices based on Bluetooth protocol.But existing bluetooth applications needs the work realizing a large amount of parsings of the blue-teeth data about anti-lost business, adds the complexity of exploitation bluetooth applications program.
Summary of the invention
The embodiment of the present invention provides a kind of Bluetooth communication method and system, and the data communication that anti-lost business can be realized to relate to is by Extended Protocol process, and fast and easy develops anti-lost application.
First aspect, the embodiment of the invention discloses a kind of Bluetooth communication method, comprising:
Main equipment generates the first bluetooth data packets according to Bluetooth protocol, described first bluetooth data packets comprises the first flag bit and the first field, described first field comprises the first son field and the second son field, described first flag bit is used to indicate the field whether described first field is the first data format, when described first field is the field of described first data format, the value of described first son field is the control command of main equipment, and the value of described second son field is configuration information;
Main equipment sends described first bluetooth data packets extremely from equipment;
Described first bluetooth data packets is received from equipment;
After by the first bluetooth data packets described in RFCOMM protocol analysis, described first flag bit is extracted from equipment, and judge that whether described first field is the field of described first data format according to described first flag bit, if, then resolve described first field from equipment according to described first data format, extract the value of described first son field and described second son field.
In conjunction with first aspect, in the implementation that the first is possible, resolve described first field from equipment according to the first data format described, after extracting the value of the first son field and the second son field, also comprise:
Judge that whether the value of described first son field is corresponding from equipment and open anti-lost control command, if so, then from the state of the default communication connection between monitoring of equipment and main equipment, when described default communication connection disconnects, export preset alarm signal from equipment.
In conjunction with the first implementation of first aspect, in the implementation that the second is possible, resolve described first field from equipment according to the first data format described, after extracting the value of the first son field and the second son field, also comprise:
The whether corresponding type of alarm supported from equipment of the value of described second son field is judged from equipment, if, then the type of alarm corresponding to the value of described two son fields is arranged to the effective type of alarm from equipment, and described preset alarm signal is set according to described effective type of alarm.
In conjunction with first aspect, in the implementation that the third is possible, the second bluetooth data packets is generated according to Bluetooth protocol from equipment, described second bluetooth data packets comprises described first flag bit and described second field, described second field comprises the 3rd son field and the 4th son field, described first flag bit is used to indicate the field whether described second field is the second data format, when described second field is the field of described second data format, the value of described 3rd son field is the communication distance supported from equipment, the value of described 4th son field is the type of alarm supported from equipment,
Described second bluetooth data packets is sent to main equipment from equipment;
Main equipment receives described second bluetooth data packets;
After by the first bluetooth data packets described in RFCOMM protocol analysis, main equipment extracts described first flag bit, and judge that whether described second field is the field of described second data format according to described first flag bit, if, then main equipment resolves described second field according to described second data format, extracts the value of described 3rd son field and described 4th son field.
In conjunction with the third implementation of first aspect, in the 4th kind of possible implementation, resolve described second field at described main equipment according to described second data format, after extracting the value of described 3rd son field and the value of described 4th son field, also comprise:
Main equipment judges whether the value of described 3rd son field is in the first number range, if so, then exports the value of described 3rd son field.
In conjunction with the third implementation of first aspect, in the 5th kind of possible implementation, resolve described second field at described main equipment according to described second data format, after extracting the value of described 3rd son field and described 4th son field, also comprise:
Main equipment judges whether the value of described 4th son field is in second value scope, if so, then exports the type of alarm supported from equipment indicated by value of described 4th son field;
Main equipment receives the first input, at the described effective type of alarm selected from the type of alarm of equipment support from equipment, and according to described first input, the value of described second son field is set to the described type of alarm supported from equipment.
Second aspect, the embodiment of the invention discloses a kind of Bluetooth communication system, and this system comprises main equipment and from equipment, wherein:
Main equipment generates the first bluetooth data packets according to Bluetooth protocol, described first bluetooth data packets comprises the first flag bit and the first field, described first field comprises the first son field and the second son field, described first flag bit is used to indicate the field whether described first field is the first data format, when described first field is the field of described first data format, the value of described first son field is the control command of main equipment, and the value of described second son field is configuration information;
Main equipment sends described first bluetooth data packets extremely from equipment;
Described first bluetooth data packets is received from equipment;
After resolving described first bluetooth data packets by Serial Simulation agreement (RFCOMM agreement), described first flag bit is extracted from equipment, and judge that whether described first field is the field of described first data format according to described first flag bit, if, then resolve described first field from equipment according to described first data format, extract the value of described first son field and described second son field.
In conjunction with second aspect, in the implementation that the first is possible, the second bluetooth data packets is generated according to Bluetooth protocol from equipment, described second bluetooth data packets comprises described first flag bit and described second field, described second field comprises the 3rd son field and the 4th son field, described first flag bit is used to indicate the field whether described second field is the second data format, when described second field is the field of described second data format, the value of described 3rd son field is the communication distance supported from equipment, the value of described 4th son field is the type of alarm supported from equipment,
Described second bluetooth data packets is sent to main equipment from equipment;
Main equipment receives described second bluetooth data packets;
After by the first bluetooth data packets described in RFCOMM protocol analysis, main equipment extracts described first flag bit, and judge that whether described second field is the field of described second data format according to described first flag bit, if, then main equipment resolves described second field according to described second data format, extracts the value of described 3rd son field and the value of described 4th son field.
In sum, by implementing the embodiment of the present invention, main equipment generates the first bluetooth data packets according to Bluetooth protocol and sends the first bluetooth data packets extremely from equipment; First bluetooth data packets comprises the first flag bit and the first field, first field is the field of the first data format, first field comprises the first son field and the second son field, and the value of the first son field is the control command of main equipment, and the value of the second son field is configuration information; Accordingly, after the first bluetooth data packets received by RFCOMM protocol analysis from equipment, the first field is resolved according to the first data format, extract the value of the first son field and the second son field, the data communication that anti-lost business can be realized to relate to is by Extended Protocol process, and fast and easy develops anti-lost application.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is the flow chart of the first embodiment of the Bluetooth communication method that the embodiment of the present invention provides;
Fig. 2 is the flow chart of the second embodiment of the Bluetooth communication method that the embodiment of the present invention provides;
Fig. 3 is the flow chart of the 3rd embodiment of the Bluetooth communication method that the embodiment of the present invention provides;
Fig. 4 is the flow chart of the 4th embodiment of the Bluetooth communication method that the embodiment of the present invention provides;
Fig. 5 A is the structural representation of the anti-lost data in the first bluetooth data packets of providing of the embodiment of the present invention;
Fig. 5 B is the structural representation of the anti-lost data in the second bluetooth data packets of providing of the embodiment of the present invention;
Fig. 6 is the part-structure schematic diagram of the anti-lost protocol stack that the embodiment of the present invention relates to;
Fig. 7 is the schematic diagram of Bluetooth communication system provided by the invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
It should be noted that, the term used in embodiments of the present invention is only for the object describing specific embodiment, and not intended to be limiting the present invention." one ", " described " and " being somebody's turn to do " of the singulative used in the embodiment of the present invention and appended claims is also intended to comprise most form, unless context clearly represents other implications.It is also understood that term "and/or" used herein refer to and comprise one or more project of listing be associated any or all may combine.
See Fig. 1, be the flow chart of the first device side of Bluetooth communication method provided by the invention, the method comprises:
Step S101: main equipment generates the first bluetooth data packets according to Bluetooth protocol, first bluetooth data packets comprises the first flag bit and the first field, first field comprises the first son field and the second son field, first flag bit is used to indicate the field whether the first field is the first data format, when the first field is the field of the first data format, the value of the first son field is the control command of main equipment, and the value of the second son field is configuration information.
Concrete, the Bluetooth protocol that the embodiment of the present invention relates to can comprise bluetooth underlying protocol, logic link control and adapting protocol (L2CAP), serial ports simulation protocol (RFCOMM), service discovery protocol (SDP).Wherein, logic link control and adapting protocol carry out the communication of data by Host Controler Interface (Host Controller Interface, HCI) and underlying protocol.The part-structure of the bluetooth protocol repertory that the embodiment of the present invention relates to can as shown in Figure 6, wherein, and the agreement that the anti-lost agreement (Prevent To Lost, PTL) that intermediate protocol layer comprises is expanded for the embodiment of the present invention.For main equipment, the anti-lost agreement that the embodiment of the present invention relates to is mainly used in providing the software interface relevant with anti-lost business to application layer, encapsulates and parses the data relevant to anti-lost business.Such as, the software interface of the data input and data output relevant to anti-lost business is provided to application layer.Again such as, the calling interface controlled from the order of equipment is provided to application layer.Needs illustrate, the protocol name of described anti-lost agreement can change in actual applications, does not affect flesh and blood of the present invention.
The first bluetooth data packets that the embodiment of the present invention relates to comprises: main equipment is to the packet relevant to anti-lost business sent from equipment, or main equipment is to the bluetooth data packets of other business sent from equipment, such as, and search service.
Concrete, described first bluetooth data packets can comprise as shown in Figure 5A: the first flag bit and the first field.Wherein, described first field can comprise the first son field and the second son field.Described first flag bit is used to indicate the field whether described first field is the first data format.Needs illustrate, described first field can also comprise other son fields.Described first data format is used to indicate start bit and the stop bits of each son field in described first field.Such as, the 6th bit of described first field of described first data format regulation is described first son field to the 7th bit, and the 12nd bit of described first field is described second son field to the 16th bit.
In specific implementation, when described first flag bit equals default anti-lost mark, the data format of described first field is described first data format.That is, when described first flag bit equals default anti-lost mark, described first bluetooth data packets is the packet relevant to anti-lost business.As shown in Figure 5A, when the first field is the field of the first data format, the value of the first son field can be the control command of main equipment, and the value of the second son field can be configuration information.Needs illustrate, the first flag bit that the embodiment of the present invention relates to can be a bit, also can be the fields of multiple bit composition.
In specific implementation, the data relevant to anti-lost business that the software interface that main equipment provides by described anti-lost agreement produces to receive application layer, and by anti-lost agreement by this data encapsulation relevant to anti-lost business in the first field of the first data format, then serial ports simulation protocol layer is passed to by by the first field meeting anti-lost protocol specification after anti-lost protocol encapsulation, logic link control and Adaptation protocol layer is passed to again by by the data meeting serial ports simulation protocol specification after the encapsulation of serial ports simulation protocol, be packaged into described first bluetooth data packets from top to bottom layer by layer according to this, finally by physical link, described first bluetooth data packets is sent to from equipment.
Step S103: main equipment sends the first bluetooth data packets extremely from equipment.
Step S105: receive the first bluetooth data packets from equipment.
Step S107: by after RFCOMM protocol analysis first bluetooth data packets, extract the first flag bit from equipment.
Concrete, after reception first bluetooth data packets, successively can resolve the first bluetooth data packets by the underlying protocol Bluetooth protocol and logic link control with adapting protocol from equipment, the first bluetooth data packets after resolving can be exported to serial ports simulation protocol layer afterwards and perform further parsing.After resolving the first bluetooth data packets by serial ports simulation protocol, the first flag bit from equipment can extract the first bluetooth data packets after being resolved by serial ports simulation protocol, in order to judge whether the first flag bit is default anti-lost mark.Needs illustrate, the first blue-teeth data related in the invention process wraps in and also at least can be comprised the first flag bit and the first field by after the parsing of serial ports simulation protocol.
Step S109: judge that whether the first field is the field of the first data format according to the first flag bit from equipment.
Concrete, after the first flag bit in extraction first bluetooth data packets, can judge whether the first flag bit is default anti-lost mark from equipment, if so, then can judge that the data format of the first field is as the first data format.That is, the first bluetooth data packets is the data that business anti-lost to bluetooth is relevant.If the first flag bit is for presetting anti-lost mark, then can performing step S111 from equipment, resolving by being transferred to described anti-lost protocol layer by the first bluetooth data packets after the parsing of serial ports simulation protocol.In specific implementation, if the first flag bit is not default anti-lost mark, then can terminate current procedures from equipment, or other protocol layers that the first bluetooth data packets after being resolved by serial ports simulation protocol is transferred in bluetooth protocol repertory are resolved.
Step S111: resolve the first field according to the first data format from equipment, extracts the value of the first son field and the value of the second son field.
Concrete, as shown in Figure 5A, the first field can comprise the first son field and the second son field.When the first field is the field of the first data format, the value of the first son field can be the control command of main equipment, and the value of the second son field can be configuration information.After the value of extraction first son field and the value of the second son field, the control command of master transmissions can be performed according to the value of the first son field from equipment, the configuration information of master transmissions can be obtained according to the value of the second son field from equipment, or other Content of Communication.
In the embodiment of the present invention, when main equipment is to when sending the data relevant to anti-lost business from equipment, main equipment comprises the first field of the first data format by described anti-lost protocol generation, and the first field is packaged into bluetooth data packets.Accordingly, after the bluetooth data packets received by RFCOMM protocol analysis from equipment, resolve the first field according to the first data format, extract the value of the first son field and the second son field.Main equipment can be realized and will send to the first field becoming the first data format from the data encapsulation relevant to anti-lost business of equipment, the first field parsing the first data format from equipment from the bluetooth data packets received can be realized, and then obtain the data relevant to anti-lost business of main equipment transmission.
See Fig. 2, be the flow chart of the second device side first embodiment of Bluetooth communication method provided by the invention, the method comprises:
Step S201: generate the second bluetooth data packets according to Bluetooth protocol from equipment, second bluetooth data packets comprises the first flag bit and the second field, second field comprises the 3rd son field and the 4th son field, first flag bit is used to indicate the field whether the second field is the second data format, when the second field is the field of the second data format, the value of the 3rd son field is the communication distance supported from equipment, and the value of the 4th son field is the type of alarm supported from equipment.
Concrete, the Bluetooth communication process that the embodiment of the present invention relates to, except comprising above-mentioned steps 101 to step S111, also can comprise: send the process that the process of the second bluetooth data packets and main equipment receive the second bluetooth data packets sent from equipment from equipment to main equipment.For from equipment, the anti-lost agreement that the embodiment of the present invention relates to is mainly used in encapsulating the response of replying from equipment to main equipment, or other data relevant to anti-lost business fed back from equipment to main equipment.In addition, for from equipment, the anti-lost agreement that the embodiment of the present invention relates to is also for parsing the data relevant to anti-lost business that main equipment sends.
The second bluetooth data packets that the embodiment of the present invention relates to comprises: the packet relevant to anti-lost business sent from equipment to main equipment, or main equipment is to the bluetooth data packets of other business sent from equipment.
Concrete, described second bluetooth data packets can comprise as shown in Figure 5 B: the first flag bit and the second field.Wherein, described second field can comprise the 3rd son field and the 4th son field.Described first flag bit is also used to indicate the field whether described second field is the second data format.Needs illustrate, described second field can also comprise other son fields.Described second data format is used to indicate start bit and the stop bits of each son field in described second field.Such as, the 6th bit to the 7th bit of described second field of described second data format regulation is described 3rd son field, and the 12nd bit to the 16th bit of described second field is described 4th son field.
In specific implementation, when described first flag bit equals default anti-lost mark, the data format of described second field is described second data format.That is, when described first flag bit equals default anti-lost mark, described second bluetooth data packets is the packet relevant to anti-lost business.As shown in Figure 5 B, when the second field is the field of the second data format, the value of the 3rd son field can be the communication distance supported from equipment, and the value of the 4th son field can be the type of alarm supported from equipment.Needs illustrate, when implementing the embodiment of the present invention, the value of described 3rd son field or the value of described 4th son field can also be other data relevant to anti-lost business obtained from equipment.
In specific implementation, when sending the data relevant to anti-lost business from equipment to main equipment, from equipment by anti-lost agreement by the data relevant to anti-lost business, such as from the type of alarm that equipment is supported, be encapsulated in the second field of the second data format, then serial ports simulation protocol layer is passed to by by the second field meeting anti-lost protocol specification after anti-lost protocol encapsulation, logic link control and Adaptation protocol layer is passed to again by by the data meeting serial ports simulation protocol specification after the encapsulation of serial ports simulation protocol, be packaged into described second bluetooth data packets from top to bottom layer by layer according to this, finally by physical link, described second bluetooth data packets is sent to main equipment.
Step S203: send the second bluetooth data packets to main equipment from equipment.
Step S205: main equipment receives the second bluetooth data packets.
Step S207: after passing through RFCOMM protocol analysis first bluetooth data packets, main equipment extracts the first flag bit.
Concrete, after reception second bluetooth data packets, main equipment successively can resolve the second bluetooth data packets by the underlying protocol in Bluetooth protocol and logic link control with adapting protocol, the second bluetooth data packets after resolving can be exported to serial ports simulation protocol layer afterwards and perform further parsing.After resolving the second bluetooth data packets by serial ports simulation protocol, main equipment can extract the first flag bit in the second bluetooth data packets after being resolved by serial ports simulation protocol, in order to judge whether the first flag bit is default anti-lost mark.Needs illustrate, the second blue-teeth data related in the invention process wraps in and also at least can be comprised the first flag bit and the second field by after the parsing of serial ports simulation protocol.
Step S209: according to the first flag bit, main equipment judges that whether the second field is the field of the second data format.
Concrete, after the first flag bit in extraction second bluetooth data packets, main equipment can judge whether the second flag bit is default anti-lost mark, if so, then can judge that the data format of the second field is as the second data format.That is, the second bluetooth data packets is the data that business anti-lost to bluetooth is relevant.If the first flag bit is for presetting anti-lost mark, then can performing step S211 from equipment, resolving by being transferred to described anti-lost protocol layer by the second bluetooth data packets after the parsing of serial ports simulation protocol.In specific implementation, if the first flag bit is not default anti-lost mark, then can terminate current procedures from equipment, or other protocol layers that the second bluetooth data packets after being resolved by serial ports simulation protocol is transferred in bluetooth protocol repertory are resolved.
Step S211: main equipment resolves the second field according to the second data format, extracts the value of the 3rd son field and the value of the 4th son field.
Concrete, as shown in Figure 5 B, the second field can comprise the 3rd son field and the 4th son field.When the second field is the field of the second data format, the value of the 3rd son field can be the communication distance supported from equipment, and the value of the 4th son field can be the type of alarm supported from equipment.Needs illustrate, when implementing the embodiment of the present invention, the value of described 3rd son field or the value of described 4th son field can also be other data relevant to anti-lost business obtained from equipment.
After the value of extraction the 3rd son field and the value of the 4th son field, the value of the value of the 3rd son field or the 4th son field can be exported to application layer by main equipment.
In the embodiment of the present invention, when sending the data relevant to anti-lost business from equipment to main equipment, comprised the second field of the second data format from equipment by described anti-lost protocol generation, and the second field is packaged into bluetooth data packets.Accordingly, after the bluetooth data packets that main equipment is received by RFCOMM protocol analysis, resolve the second field according to the second data format, extract the value of the 3rd son field and the value of the 4th son field.The second field will the data encapsulation relevant to anti-lost business of main equipment being sent to become the second data format from equipment can be realized, the second field that main equipment parses the second data format from the bluetooth data packets received can be realized, and then obtain the data relevant to anti-lost business sent from equipment.
See Fig. 3, be the flow chart of the second device side second embodiment of Bluetooth communication method provided by the invention, the method comprises:
Step S301: main equipment generates the first bluetooth data packets according to Bluetooth protocol, first bluetooth data packets comprises the first flag bit and the first field, first field comprises the first son field and the second son field, first flag bit is used to indicate the field whether the first field is the first data format, when the first field is the field of the first data format, the value of the first son field is the control command of main equipment, and the value of the second son field is configuration information.
Concrete, see the content described in the step S101 in Fig. 1 embodiment, can repeat no more here.
Step S303: main equipment sends the first bluetooth data packets extremely from equipment.
Step S305: receive the first bluetooth data packets from equipment.
Step S307: by after RFCOMM protocol analysis first bluetooth data packets, extract the first flag bit from equipment.
Concrete, see the content described in the step S107 in Fig. 1 embodiment, can repeat no more here.
Step S309: judge that whether the first field is the field of the first data format according to the first flag bit from equipment.
Concrete, see the content described in the step S109 in Fig. 1 embodiment, can repeat no more here.
Step S311: resolve the first field according to the first data format from equipment, extracts the value of the first son field and the value of the second son field.
Concrete, see the content described in the step S111 in Fig. 1 embodiment, can repeat no more here.
Step S313: judge that whether the value of the first son field is corresponding from equipment and open anti-lost control command.
Concrete, extract the value of the first son field from the first field after, can judge that whether the value of the first son field is corresponding from equipment and open anti-lost control command, if, then perform step S315, if not, current operation can be terminated, or the control command corresponding according to the value of the first son field performs corresponding operating.
Step S315: from the state of the default communication connection between monitoring of equipment and main equipment, when default communication connection disconnects, exports preset alarm signal from equipment.
Concrete, if the value correspondence of the first son field opens anti-lost control command, then can open monitoring function from equipment, in order to the state of monitoring from the default communication connection between monitoring of equipment and main equipment.If all do not receive the communication data that main equipment sends in equipment certain hour, namely preset communication connection and disconnect, then from the exportable default alarm signal of equipment, such as jingle bell or luminescence.
Step S317: judge the whether corresponding type of alarm supported from equipment of the value of the second son field from equipment.
Concrete, extract the value of the second son field from the first field after, the whether corresponding type of alarm supported from equipment of the value of the second son field can be judged from equipment, if so, then step S319 is performed, if not, can current procedures be terminated, or the value of the second son field is exported to application layer.
Step S319: the type of alarm corresponding to the value of the second son field is arranged to the effective type of alarm from equipment from equipment, and preset alarm signal is set according to effective type of alarm.
Concrete, can receive the configuration information of master transmissions from equipment, this configuration information can be the data that main equipment is received by application layer, the type of alarm from equipment of such as user's input.In specific implementation, from equipment usually in conjunction with the control command that the first son field is corresponding, such as alarm signal arranges instruction, and the configuration information of the second son field arranges the relevant parameter from equipment.If the value of the second son field is corresponding to the one the type of alarm that equipment is supported, then the type of alarm indicated by the value of the second son field can be set to effective type of alarm from equipment, such as jingle bell, and according to this effective type of alarm, the preset alarm signal setting from equipment is become one section of voice signal.
See Fig. 4, be the flow chart of the second device side the 3rd embodiment of Bluetooth communication method provided by the invention, the method comprises:
Step S401: generate the second bluetooth data packets according to Bluetooth protocol from equipment, second bluetooth data packets comprises the first flag bit and the second field, second field comprises the 3rd son field and the 4th son field, first flag bit is used to indicate the field whether the second field is the second data format, when the second field is the field of the second data format, the value of the 3rd son field is the communication distance supported from equipment, and the value of the 4th son field is the type of alarm supported from equipment.
Concrete, see the content described in the step S201 in Fig. 2 embodiment, can repeat no more here.
Step S403: send the second bluetooth data packets to main equipment from equipment.
Step S405: main equipment receives the second bluetooth data packets.
Step S407: after passing through RFCOMM protocol analysis first bluetooth data packets, main equipment extracts the first flag bit.
Concrete, see the content described in the step S207 in Fig. 2 embodiment, can repeat no more here.
Step S409: according to the first flag bit, main equipment judges that whether the second field is the field of the second data format.
Concrete, see the content described in the step S209 in Fig. 2 embodiment, can repeat no more here.
Step S411: main equipment resolves the second field according to the second data format, extracts the value of the 3rd son field and the value of the 4th son field.
Concrete, see the content described in the step S211 in Fig. 2 embodiment, can repeat no more here.
Step S413: main equipment judges whether the value of the 3rd son field is in the first number range.
Concrete, main equipment can obtain the parameter information from equipment, such as, from the communication distance that equipment is supported.In specific implementation, main equipment to from equipment send get parms information request after, receive the data comprising relevant parameter information from device replied.When master devices request obtains the communication distance supported from equipment, main equipment can judge whether the value of the 3rd son field is in the first number range, if so, then can judge that the distance indicated by value of the 3rd son field is legal Bluetooth communication distance, such as 15, and perform step S415; If not, then can judge that the distance indicated by value of the 3rd son field is illegal Bluetooth communication distance, such as 1000, and terminate current procedures.
Step S415: main equipment exports the value of the 3rd son field.
Concrete, if the distance indicated by value of the 3rd son field is legal Bluetooth communication distance, the value of the 3rd son field can be exported to application layer by main equipment, passes through signal output apparatus to make application layer, such as display screen or loud speaker, export the distance indicated by value of the 3rd son field.
Step S417: main equipment judges whether the value of the 4th son field is in second value scope.
Concrete, main equipment also can obtain the type of alarm supported from equipment.In specific implementation, main equipment to send from equipment obtain the type of alarm supported from equipment request after, receive and comprise from device replied the data of type of alarm supported from equipment.Main equipment can judge whether the value of the 4th son field is in second value scope, if, then can judge that the value of the 4th son field is as the type of alarm supported from equipment, the such as value of the 4th son field is in the regulation Chinese character scope of GB, specifically see " national Chinese character standard code ", and step S415 can be performed; If not, then can judge that the value of the 4th son field does not have the corresponding type of alarm supported from equipment, such as, the value of the 4th son field is " 0-127 ", i.e. corresponding A SCII code, and terminate current procedures.
Step S419: main equipment exports the type of alarm supported from equipment indicated by the value of the 4th son field.
Concrete, if the value of the 4th son field is in second value scope, the value of the 4th son field can be exported to application layer by main equipment, passes through signal output apparatus to make application layer, such as display screen or loud speaker, export the type of alarm supported from equipment indicated by value of the 4th son field.
Step S421: main equipment receives the first input, at the described effective type of alarm selected from the type of alarm of equipment support from equipment, and is set to described effective type of alarm from equipment according to described first input by the value of described second son field.
Concrete, after application layer exports the type of alarm indicated by the value of the 4th son field by signal output apparatus, main equipment receives first input of user by application layer, the type of alarm that user selects is arranged to the effective type of alarm from equipment, and the value of the second son field in the first field in the first bluetooth data packets is set to described effective type of alarm from equipment.
See Fig. 7, it is the schematic diagram of Bluetooth communication system provided by the invention.Bluetooth communication system 70 as shown in Figure 7 can comprise: main equipment 701 and from equipment 703.Wherein:
Main equipment 701 can generate the first bluetooth data packets according to Bluetooth protocol, described first bluetooth data packets comprises the first flag bit and the first field, described first field comprises the first son field and the second son field, described first flag bit is used to indicate the field whether described first field is the first data format, when described first field is the field of described first data format, the value of described first son field is the control command of main equipment, and the value of described second son field is configuration information;
Main equipment 701 sends described first bluetooth data packets extremely from equipment 703;
Described first bluetooth data packets is received from equipment 703;
After resolving described first bluetooth data packets by Serial Simulation agreement (RFCOMM agreement), described first flag bit is extracted from equipment 703, and judge that whether described first field is the field of described first data format according to described first flag bit, if, then resolve described first field from equipment 703 according to described first data format, extract the value of described first son field and described second son field.
In specific implementation, described first field is resolved from equipment 703 according to the first data format described, after extracting the value of the first son field and the second son field, from equipment 703 can: judge that the value of described first son field is whether corresponding and open anti-lost control command, if, then monitor the state of the default communication connection between main equipment 701 from equipment 703, when described default communication connection disconnects, export preset alarm signal from equipment 703.
In specific implementation, described first field is resolved from equipment according to the first data format described, after extracting the value of the first son field and the second son field, all right from equipment: to judge the whether corresponding type of alarm supported from equipment of the value of described second son field, if, then the type of alarm corresponding to the value of described two son fields is arranged to the effective type of alarm from equipment, and described preset alarm signal is set according to described effective type of alarm.
Further, in the embodiment of the present invention, the second bluetooth data packets can be generated according to Bluetooth protocol from equipment 703, described second bluetooth data packets comprises described first flag bit and described second field, described second field comprises the 3rd son field and the 4th son field, described first flag bit is used to indicate the field whether described second field is the second data format, when described second field is the field of described second data format, the value of described 3rd son field is the communication distance supported from equipment, and the value of described 4th son field is the type of alarm supported from equipment;
Described second bluetooth data packets is sent to main equipment 701 from equipment 703;
Main equipment 701 receives described second bluetooth data packets;
After by the first bluetooth data packets described in RFCOMM protocol analysis, main equipment 701 extracts described first flag bit, and judge that whether described second field is the field of described second data format according to described first flag bit, if, then main equipment 701 resolves described second field according to described second data format, extracts the value of described 3rd son field and the value of described 4th son field.
In specific implementation, described second field is resolved according to described second data format at described main equipment 701, after extracting the value of described 3rd son field and described 4th son field, main equipment 701 can: judge whether the value of described 3rd son field is in the first number range, if so, the value of described 3rd son field is then exported.
In specific implementation, described second field is resolved according to described second data format at described main equipment 701, after extracting the value of described 3rd son field and described 4th son field, main equipment is all right: judge whether the value of described 4th son field is in second value scope, if so, the type of alarm supported from equipment indicated by value of described 4th son field is then exported.Afterwards, main equipment 701 can receive the first input, at the described effective type of alarm selected from the type of alarm of equipment support from equipment, and according to described first input, the value of described second son field is set to described effective type of alarm from equipment.
Needs illustrate, in Bluetooth communication system 70, main equipment 701 and the Bluetooth communication process from equipment 703 execution with reference to the specific implementation above-mentioned Fig. 1 to Fig. 4 embodiment, can repeat no more here.
In sum, by implementing the embodiment of the present invention, main equipment generates the first bluetooth data packets according to Bluetooth protocol and sends the first bluetooth data packets extremely from equipment; First bluetooth data packets comprises the first flag bit and the first field, first field is the field of the first data format, first field comprises the first son field and the second son field, and the value of the first son field is the control command of main equipment, and the value of the second son field is configuration information; Accordingly, after the first bluetooth data packets received by RFCOMM protocol analysis from equipment, the first field is resolved according to the first data format, extract the value of the first son field and the second son field, the data communication that anti-lost business can be realized to relate to is by Extended Protocol process, and fast and easy develops anti-lost application.
One of ordinary skill in the art will appreciate that all or part of flow process realized in above-described embodiment method, that the hardware that can carry out instruction relevant by computer program has come, described program can be stored in a computer read/write memory medium, this program, when performing, can comprise the flow process of the embodiment as above-mentioned each side method.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
Above disclosedly be only a kind of preferred embodiment of the present invention, certainly the interest field of the present invention can not be limited with this, one of ordinary skill in the art will appreciate that all or part of flow process realizing above-described embodiment, and according to the equivalent variations that the claims in the present invention are done, still belong to the scope that invention is contained.

Claims (8)

1. a Bluetooth communication method, is characterized in that, comprising:
Main equipment generates the first bluetooth data packets according to Bluetooth protocol, described first bluetooth data packets comprises the first flag bit and the first field, described first field comprises the first son field and the second son field, described first flag bit is used to indicate the field whether described first field is the first data format, when described first field is the field of described first data format, the value of described first son field is the control command of main equipment, and the value of described second son field is configuration information;
Main equipment sends described first bluetooth data packets extremely from equipment;
Described first bluetooth data packets is received from equipment;
After by the first bluetooth data packets described in RFCOMM protocol analysis, described first flag bit is extracted from equipment, and judge that whether described first field is the field of described first data format according to described first flag bit, if, then resolve described first field from equipment according to described first data format, extract the value of described first son field and described second son field.
2. the method for claim 1, is characterized in that, resolves described first field, after extracting the value of the first son field and the second son field, also comprise described from equipment according to the first data format:
Judge that whether the value of described first son field is corresponding from equipment and open anti-lost control command, if so, then from the state of the default communication connection between monitoring of equipment and main equipment, when described default communication connection disconnects, export preset alarm signal from equipment.
3. method as claimed in claim 2, is characterized in that, resolves described first field, after extracting the value of the first son field and the second son field, also comprise described from equipment according to the first data format:
The whether corresponding type of alarm supported from equipment of the value of described second son field is judged from equipment, if, then the type of alarm corresponding to the value of described two son fields is arranged to the effective type of alarm from equipment, and described preset alarm signal is set according to described effective type of alarm.
4. the method for claim 1, is characterized in that, also comprises:
The second bluetooth data packets is generated according to Bluetooth protocol from equipment, described second bluetooth data packets comprises described first flag bit and described second field, described second field comprises the 3rd son field and the 4th son field, described first flag bit is used to indicate the field whether described second field is the second data format, when described second field is the field of described second data format, the value of described 3rd son field is the communication distance supported from equipment, and the value of described 4th son field is the type of alarm supported from equipment;
Described second bluetooth data packets is sent to main equipment from equipment;
Main equipment receives described second bluetooth data packets;
After by the second bluetooth data packets described in RFCOMM protocol analysis, main equipment extracts described first flag bit, and judge that whether described second field is the field of described second data format according to described first flag bit, if, then main equipment resolves described second field according to described second data format, extracts the value of described 3rd son field and the value of described 4th son field.
5. method as claimed in claim 4, is characterized in that, resolves described second field, after extracting the value of described 3rd son field and described 4th son field, also comprise at described main equipment according to described second data format:
Main equipment judges whether the value of described 3rd son field is in the first number range, if so, then exports the value of described 3rd son field.
6. method as claimed in claim 4, is characterized in that, resolves described second field, after extracting the value of described 3rd son field and described 4th son field, also comprise at described main equipment according to described second data format:
Main equipment judges whether the value of described 4th son field is in second value scope, if so, then exports the type of alarm supported from equipment indicated by value of described 4th son field;
Main equipment receives the first input, at the described effective type of alarm selected from the type of alarm of equipment support from equipment, and according to described first input, the value of described second son field is set to described effective type of alarm from equipment.
7. a Bluetooth communication system, is characterized in that, comprises main equipment and from equipment, wherein:
Main equipment generates the first bluetooth data packets according to Bluetooth protocol, described first bluetooth data packets comprises the first flag bit and the first field, described first field comprises the first son field and the second son field, described first flag bit is used to indicate the field whether described first field is the first data format, when described first field is the field of described first data format, the value of described first son field is the control command of main equipment, and the value of described second son field is configuration information;
Main equipment sends described first bluetooth data packets extremely from equipment;
Described first bluetooth data packets is received from equipment;
After resolving described first bluetooth data packets by Serial Simulation agreement (RFCOMM agreement), described first flag bit is extracted from equipment, and judge that whether described first field is the field of described first data format according to described first flag bit, if, then resolve described first field from equipment according to described first data format, extract the value of described first son field and described second son field.
8. system as claimed in claim 7, is characterized in that, also comprise:
The second bluetooth data packets is generated according to Bluetooth protocol from equipment, described second bluetooth data packets comprises described first flag bit and described second field, described second field comprises the 3rd son field and the 4th son field, described first flag bit is used to indicate the field whether described second field is the second data format, when described second field is the field of described second data format, the value of described 3rd son field is the communication distance supported from equipment, and the value of described 4th son field is the type of alarm supported from equipment;
Described second bluetooth data packets is sent to main equipment from equipment;
Main equipment receives described second bluetooth data packets;
After by the first bluetooth data packets described in RFCOMM protocol analysis, main equipment extracts described first flag bit, and judge that whether described second field is the field of described second data format according to described first flag bit, if, then main equipment resolves described second field according to described second data format, extracts the value of described 3rd son field and the value of described 4th son field.
CN201510106865.0A 2015-03-11 2015-03-11 Bluetooth communication method and system Pending CN104796847A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510106865.0A CN104796847A (en) 2015-03-11 2015-03-11 Bluetooth communication method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510106865.0A CN104796847A (en) 2015-03-11 2015-03-11 Bluetooth communication method and system

Publications (1)

Publication Number Publication Date
CN104796847A true CN104796847A (en) 2015-07-22

Family

ID=53561281

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510106865.0A Pending CN104796847A (en) 2015-03-11 2015-03-11 Bluetooth communication method and system

Country Status (1)

Country Link
CN (1) CN104796847A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112738786A (en) * 2020-12-31 2021-04-30 展讯通信(上海)有限公司 Bluetooth communication method, first electronic device and second electronic device
CN116033597A (en) * 2022-08-08 2023-04-28 荣耀终端有限公司 Bluetooth connection method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101719304A (en) * 2009-12-01 2010-06-02 成都港奇科技有限公司 Personnel belongings monitoring system based mobile phone Bluetooth
CN103177753A (en) * 2013-04-15 2013-06-26 东莞市美之尊电子科技有限公司 Anti-disclosure and anti-loss mobile storage device with Bluetooth and application method thereof
CN103200263A (en) * 2013-04-02 2013-07-10 上海山景集成电路股份有限公司 Intelligent terminal, Bluetooth audio playing device and interactive method and interactive system for intelligent terminal and Bluetooth audio playing device
CN104333401A (en) * 2014-10-27 2015-02-04 深圳市冠旭电子有限公司 Methods, devices and systems for sending and receiving Bluetooth data

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101719304A (en) * 2009-12-01 2010-06-02 成都港奇科技有限公司 Personnel belongings monitoring system based mobile phone Bluetooth
CN103200263A (en) * 2013-04-02 2013-07-10 上海山景集成电路股份有限公司 Intelligent terminal, Bluetooth audio playing device and interactive method and interactive system for intelligent terminal and Bluetooth audio playing device
CN103177753A (en) * 2013-04-15 2013-06-26 东莞市美之尊电子科技有限公司 Anti-disclosure and anti-loss mobile storage device with Bluetooth and application method thereof
CN104333401A (en) * 2014-10-27 2015-02-04 深圳市冠旭电子有限公司 Methods, devices and systems for sending and receiving Bluetooth data

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112738786A (en) * 2020-12-31 2021-04-30 展讯通信(上海)有限公司 Bluetooth communication method, first electronic device and second electronic device
CN112738786B (en) * 2020-12-31 2022-11-04 展讯通信(上海)有限公司 Bluetooth communication method, first electronic device and second electronic device
CN116033597A (en) * 2022-08-08 2023-04-28 荣耀终端有限公司 Bluetooth connection method and device, electronic equipment and storage medium
CN116033597B (en) * 2022-08-08 2023-12-12 荣耀终端有限公司 Bluetooth connection method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
EP2260626B1 (en) Image-based man-in-the-middle protection in numeric comparison association models
CN105991670B (en) Data sharing method, data sharing device and terminal
CN105528229B (en) Improve the method and device that mobile terminal first powers on speed
CN105069875B (en) Electron key, electronic equipment and electronic equipment networking/matching method
CN104052751B (en) Establish the method and device of communication connection
KR102288521B1 (en) Apparatus and method for storing data based on blockchain
CN108029012A (en) Configuration file processing method, configuration file processing unit, user terminal and eUICC
CN104967758B (en) A kind of method and user terminal for controlling data transfer
CN105427409B (en) A kind of gate inhibition's unlocking method and mobile terminal
CN102843686A (en) Wireless network system and portable electronic device
CN104317648B (en) A kind of method and apparatus of monitoring advertisement
CN103957580A (en) Rapid WIFI networking matching method and module for smart hardware
CN107006066B (en) Communication device, control method of communication device, and program
CN105279209B (en) Method and system for establishing wireless link and electronic device
CN102948079A (en) Systems and methods for remote configuration or re-configuration of software residing on a sim card
CN105744034B (en) A kind of screen intensity output method and device
CN104796847A (en) Bluetooth communication method and system
CN105992188B (en) A kind of application update method and device
CN105282112A (en) Terminal and method for detecting security of data interaction in terminal
CN111740963B (en) Data communication method and device
CN106572226A (en) Contact person sharing method, address list sharing terminal and address list receiving terminal
US10285193B2 (en) Wireless communication system and wireless apparatus
KR101494460B1 (en) Apparatus and method for holding data between devices using local wireless communication
CN107872379A (en) A kind of terminal control method and device based on RCS message
CN106303931A (en) A kind of data transmission method based on NFC and terminal

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20150722