CN105162498A - Bluetooth adapter and communication method thereof - Google Patents

Bluetooth adapter and communication method thereof Download PDF

Info

Publication number
CN105162498A
CN105162498A CN201510628156.9A CN201510628156A CN105162498A CN 105162498 A CN105162498 A CN 105162498A CN 201510628156 A CN201510628156 A CN 201510628156A CN 105162498 A CN105162498 A CN 105162498A
Authority
CN
China
Prior art keywords
bluetooth
card reader
response
host computer
bluetooth card
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.)
Granted
Application number
CN201510628156.9A
Other languages
Chinese (zh)
Other versions
CN105162498B (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.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies 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 Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201510628156.9A priority Critical patent/CN105162498B/en
Publication of CN105162498A publication Critical patent/CN105162498A/en
Application granted granted Critical
Publication of CN105162498B publication Critical patent/CN105162498B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Mobile Radio Communication Systems (AREA)

Abstract

The invention discloses a Bluetooth adapter and a communication method thereof, and belongs to the field of Bluetooth communication. The method comprises: initializing the Bluetooth adapter, declaring the Bluetooth adapter as a CCID device to an upper computer, receiving a CCID instruction issued by the upper computer, converting the CCID instruction into Bluetooth protocol data, sending the Bluetooth protocol data to a Bluetooth card reader, receiving an answer returned by the Bluetooth card reader, converting the answer returned by the Bluetooth card reader into CCID protocol data, and returning the CCID protocol data to the upper computer; and sending a prompt message to the upper computer when receiving a card plug-in and pull-out message sent by the Bluetooth card reader. The Bluetooth adapter comprises an initializing module, an instruction receiving module, an instruction sending module, an answer receiving module, an answer sending module and an event checking module. The Bluetooth adapter and the communication method disclosed by the invention have the beneficial effects that no Bluetooth driver needs to be installed on the terminal, so that the use is convenient, and problems caused by the instability of the Bluetooth driver can be avoided.

Description

Bluetooth adapter and communication means thereof
Technical field
The present invention relates to Bluetooth communication field, particularly relate to a kind of Bluetooth adapter and communication means thereof.
Background technology
Bluetooth (Bluetooth) is a kind of wireless technology standard, uses the UHF radio wave of ISM wave band of 2.4-2.485GHz, can realize permanent plant, short-range data between mobile device and building personal area network exchanges.In prior art, terminal can adopt CCID agreement to communicate with card reader by CCID interface, but the communication realized between the terminal of not bluetooth enable and Bluetooth card reader, just need to use Bluetooth adapter, and the terminal of bluetooth enable can not use CCID agreement and Bluetooth adapter direct communication, need that bluetooth is installed in the terminal of not bluetooth enable to drive, for user, use very inconvenient, and the stability that bluetooth drives is bad, affects Consumer's Experience.
Summary of the invention
The object of the invention is the defect overcoming prior art, a kind of Bluetooth adapter and communication means thereof are provided.
The inventive method is achieved through the following technical solutions:
The invention provides a kind of communication means of Bluetooth adapter on the one hand, described method comprises:
Step S1, Bluetooth adapter initialization, be claimed as CCID equipment to host computer;
Step S2, described Bluetooth adapter judge whether to receive the CCID instruction that host computer issues, and are perform step S3, otherwise re-execute step S2;
The CCID instruction transformation that host computer issues by step S3, described Bluetooth adapter is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Step S4, described Bluetooth adapter wait for the response of Bluetooth card reader, if receive the response that Bluetooth card reader returns, the response returned by Bluetooth card reader is converted to CCID protocol data, described CCID protocol data is sent to host computer, return step S2, if receive time-out, return error code to host computer, return step S2;
Described method also comprises: send information when described Bluetooth adapter receives the card plug message of Bluetooth card reader transmission to host computer.
Further, described step S3 specifically comprises:
Step a1, described Bluetooth adapter add Bluetooth protocol head to the CCID instruction that host computer issues and obtain Bluetooth protocol data;
Step a2, described Bluetooth adapter send described Bluetooth protocol data to Bluetooth card reader;
Further, described step S3 also comprises:
Step a0, described Bluetooth adapter judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, perform described step a1, if exceed, according to the CCID instruction subpackage that MTU issues host computer, successively Bluetooth protocol head is added to each director data bag and obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader.
Or further, described step S3 specifically comprises:
Step b1, described Bluetooth adapter calculate the CRC check position of the CCID instruction that host computer issues, and add Bluetooth protocol head and described CRC check position, obtain Bluetooth protocol data to the CCID instruction that host computer issues;
Step b2, described Bluetooth adapter send described Bluetooth protocol data to Bluetooth card reader;
Further, described step S3 also comprises:
Step b0, described Bluetooth adapter judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, perform described step b1, if exceed, according to the CCID instruction subpackage that MTU issues host computer, calculate the CRC check position of each director data bag respectively, successively Bluetooth protocol data is obtained to each director data bag interpolation Bluetooth protocol head and CRC check position, send described Bluetooth protocol data to Bluetooth card reader.
Further, described step S4 specifically comprises:
The response that step c1, described Bluetooth adapter wait-receiving mode Bluetooth card reader return, if receive, performs step c2, if receive time-out, returns error code to host computer, return step S2;
Step c2, described Bluetooth adapter obtain the HCI layer payload in replying and L2CAP layer payload, judge that whether the length of replying is legal according to the HCI layer payload got and L2CAP layer payload, if legal, perform step c3, if do not conform to rule upwards position machine return error code, return step S2;
Step c3, described Bluetooth adapter obtain the valid data in replying and CRC check position, according to CRC check position, CRC check is carried out to valid data, if verify by; valid data are returned to host computer, return step S2, if verification not by; return error code to host computer, return step S2.
Or further, described step S4 specifically comprises:
The response that steps d 1, described Bluetooth adapter wait-receiving mode Bluetooth card reader return, if receive, performs steps d 2, if receive time-out, returns error code to host computer, return step S2;
Steps d 2, described Bluetooth adapter obtain the HCI layer payload in replying and L2CAP layer payload, judge that whether the length of replying is legal according to the HCI layer payload got and L2CAP layer payload, if legal, perform steps d 3, if do not conform to rule upwards position machine return error code, return step S2;
Steps d 3, described Bluetooth adapter obtain the valid data in response, valid data are returned to host computer, returns step S2.
On the other hand, the invention provides a kind of Bluetooth adapter, specifically comprise:
To host computer, initialization module, for Bluetooth adapter described in initialization, states that described Bluetooth adapter is CCID equipment;
Command reception module, for receiving the CCID instruction that host computer issues;
Instruction sending module, during for receiving CCID instruction that host computer issues when command reception module, the CCID instruction transformation issued by host computer is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Response receiver module, for receiving the response of Bluetooth card reader, and returns error code when receive time-out to host computer;
Response sending module, for when described response receiver module receives the response of Bluetooth card reader, is converted to CCID protocol data by the response of Bluetooth card reader, returns described CCID protocol data to host computer;
Event checking module, for sending information when receiving the card plug message that Bluetooth card reader sends to host computer.
Further, described instruction sending module specifically for: the CCID instruction issued host computer is added Bluetooth protocol head and is obtained Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Further, described instruction sending module specifically for: judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, Bluetooth protocol data is obtained to the CCID instruction interpolation Bluetooth protocol head that host computer issues, sends described Bluetooth protocol data to Bluetooth card reader; If exceed, the CCID instruction subpackage issued host computer according to MTU, adds Bluetooth protocol head to each instruction bag successively, obtains Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader.
Or, further, described instruction sending module specifically for: calculate the CRC check position of CCID instruction that host computer issues, Bluetooth protocol head is added in the CCID instruction issued host computer and CRC check position obtains Bluetooth protocol data, sends described Bluetooth protocol number to Bluetooth card reader;
Further, described instruction sending module specifically for: judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, calculate the CRC check position of the CCID instruction that host computer issues, the CCID instruction interpolation Bluetooth protocol head issue host computer and CRC check position obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader; If exceed, CCID instruction subpackage host computer issued according to MTU, calculate the CRC check position of each instruction bag, successively Bluetooth protocol head and CRC check position are added to each instruction bag, obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader.
Further, described response sending module specifically for: when described response receiver module receives the response of Bluetooth card reader, HCI layer payload in the response that acquisition response receiver module receives and L2CAP layer payload, judge that whether the length of replying the response that receiver module receives is legal according to the HCI layer payload got and L2CAP layer payload, if do not conform to rule upwards position machine return error code, if legal, obtain the valid data in described response and CRC check position, according to CRC check position, CRC check is carried out to valid data, if verification not by, return error code to host computer, if verify by, valid data are returned to host computer as CCID protocol data.
Or, further, described response receiver module specifically for: when described response receiver module receives the response of Bluetooth card reader, HCI layer payload in the response that acquisition response receiver module receives and L2CAP layer payload, judge that whether the length of replying the response that receiver module receives is legal according to the HCI layer payload got and L2CAP layer payload, if do not conform to rule upwards position machine return error code, if legal, obtain the valid data in response, valid data are returned to host computer as CCID protocol data.
Beneficial effect of the present invention is: can realize the communication between the terminal of not bluetooth enable and Bluetooth card reader by Bluetooth adapter provided by the invention, in communication process, terminal can adopt CCID agreement to communicate with Bluetooth adapter, drive without the need to installing bluetooth in terminal, the convenience of use can be improved, avoid bluetooth to drive the unstable problem brought.
Accompanying drawing explanation
In order to the clearer explanation 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.
The flow chart of the communication means of a kind of Bluetooth adapter that Fig. 1 provides for the embodiment of the present invention 1;
The concrete grammar flow chart that Fig. 2 connects for the Bluetooth adapter that provides in the embodiment of the present invention 1 and Bluetooth card reader;
Another concrete grammar flow chart that Fig. 3 connects for the Bluetooth adapter that provides in the embodiment of the present invention 1 and Bluetooth card reader;
Fig. 4 for provide in the embodiment of the present invention 1 Bluetooth adapter search Bluetooth card reader particular flow sheet;
The flow chart of the communication means of a kind of Bluetooth adapter that Fig. 5 provides for the embodiment of the present invention 2;
The flow chart of the communication means of a kind of Bluetooth adapter that Fig. 6 provides for the embodiment of the present invention 3;
The block diagram of a kind of Bluetooth adapter that Fig. 7 provides for the embodiment of the present invention 4.
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 skilled in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
Embodiment 1
The present embodiment provides a kind of communication means of Bluetooth adapter, Bluetooth adapter in the present embodiment is used for communicating with Bluetooth card reader with host computer, Bluetooth adapter in the present embodiment and host computer adopt CCID agreement to communicate, Bluetooth protocol is adopted to communicate with Bluetooth card reader, as shown in Figure 1, described method specifically comprises:
Step 101, Bluetooth adapter initialization, be claimed as CCID equipment to host computer, and search Bluetooth card reader, connects with Bluetooth card reader, prompting connection result;
In the present embodiment, before Bluetooth adapter search Bluetooth card reader, can also comprise: Bluetooth adapter checks whether the facility information of the Bluetooth card reader stored, if have, obtain the facility information of the Bluetooth card reader stored, connect according to the facility information got and Bluetooth card reader, prompting connection result; If not, search for Bluetooth card reader, connect with the Bluetooth card reader searched, prompting connection result; Correspondingly, also comprise after Bluetooth adapter and Bluetooth card reader connect: Bluetooth adapter stores the facility information of Bluetooth card reader.
In the present embodiment, as shown in Figure 2, Bluetooth adapter search Bluetooth card reader can specifically comprise:
Step 1-1, Bluetooth adapter send search instruction;
Step 1-2, Bluetooth adapter wait for bluetooth equipment response, if receive the response of bluetooth equipment, perform step 1-3, if receive time-out, perform step 1-4;
Step 1-3, Bluetooth adapter obtain the MAC Address of bluetooth equipment from the response of bluetooth equipment, return step 1-2;
Such as, in the present embodiment, the response of bluetooth equipment is 0x04020F01EB6A1A52DE8C0102040424616DE5 (small end storage mode), and wherein 5-10 byte is the MAC Address of bluetooth equipment, and the MAC Address of bluetooth equipment is specially 0x8CDE521A6AEB.
Step 1-4, Bluetooth adapter judge whether the MAC Address got, and are, perform step 1-5, otherwise do not search Bluetooth card reader;
Step 1-5, Bluetooth adapter send to the bluetooth equipment that MAC Address is corresponding and obtain device name request, receive the response of bluetooth equipment, obtain the device name of bluetooth equipment in bluetooth equipment response, by the MAC Address corresponding stored of the device name of bluetooth equipment and bluetooth equipment;
Such as, MAC Address is 0x8CDE521A6AEB, and the acquisition device name request that Bluetooth adapter sends to the bluetooth equipment that MAC Address is corresponding is 0x0119040AEB6A1A52DE8C0100D38C; The response of bluetooth equipment is 0x0407FF00EB6A1A52DE8C46545F5F38434445353231413641454200 000000... (clipped is the 0x00 of 228 bytes), wherein the 11st to the 26th byte is the device name of bluetooth equipment, represents that the device name of bluetooth equipment is FT__8CDE521A6AEB.
Whether step 1-6, Bluetooth adapter judge to have in the device name got and meet pre-conditioned, if having, meeting bluetooth equipment corresponding to pre-conditioned device name is Bluetooth card reader, if not, do not search Bluetooth card reader.
In the present embodiment, pre-conditioned for identical with preset name or comprise preset field;
Such as, pre-conditioned for comprising preset field FT in the present embodiment, the device name got as mentioned above is FT__8CDE521A6AEB, comprises preset field FT, meets pre-conditioned, and bluetooth equipment corresponding to this device name is specially Bluetooth card reader.
Preferably, if there is multiple device name to meet pre-conditioned bluetooth equipment, then selects one to connect, such as, select to search at first).
Or in the present embodiment, Bluetooth adapter search Bluetooth card reader specifically comprises:
Step 1-1', Bluetooth adapter send search instruction;
Step 1-2', Bluetooth adapter wait for bluetooth equipment response, if receive the response of bluetooth equipment, perform step 1-3', if receive time-out, perform step 1-4';
Step 1-3', Bluetooth adapter obtain the facility information of bluetooth equipment from the response of bluetooth equipment, return step 1-2';
Step 1-4', Bluetooth adapter judge whether the facility information got, and are, perform step 1-5', otherwise do not search Bluetooth card reader;
Whether step 1-5', Bluetooth adapter judge to have in the facility information got and meet pre-conditioned, if having, meeting bluetooth equipment corresponding to pre-conditioned facility information is Bluetooth card reader, if not, do not search Bluetooth card reader.
In the present embodiment, the facility information of the bluetooth equipment that Bluetooth adapter gets from the response of bluetooth equipment comprises the MAC Address of bluetooth equipment and the device name of bluetooth equipment; Particularly, Bluetooth adapter reads the 6 to 11 byte of the response of bluetooth equipment, obtain the MAC Address of bluetooth equipment, the 13rd byte reading the response of bluetooth equipment obtains the length of the device name of bluetooth equipment, reads the device name of bluetooth equipment according to the length of device name from the 14th byte of the response of bluetooth equipment;
Such as, the response of bluetooth equipment is 0x,04E,21A,020,0EB,6A1,A52,DE8,C00,104,654,5F5,F38,434,445,353,231,413,641 4542 (small end storage mode), Bluetooth adapter reads the 6 to 11 byte of the response of bluetooth equipment, the MAC Address obtaining bluetooth equipment is 0x8CDE521A6AEB, the length that the 13rd byte reading the response of bluetooth equipment obtains the device name of bluetooth equipment is 16 bytes, the data that length is 16 bytes are read from the 14th byte, the device name obtaining bluetooth equipment is 0x4245413641313235454443385F5F5446, the device name of expression bluetooth equipment is FT__8CDE521A6AEB.
In the present embodiment, as shown in Figure 3, Bluetooth adapter and Bluetooth card reader connect and can specifically comprise:
Step 2-1, Bluetooth adapter send to Bluetooth card reader and set up ACL channel connection request, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, perform step 2-2, if receive time-out, and connection failure;
According to the response of Bluetooth card reader, step 2-2, Bluetooth adapter judge whether that successfully setting up ACL channel connects, be perform step 2-3, otherwise connection failure;
Particularly, Bluetooth adapter judges whether the mode bit (the 4th byte) in the response of Bluetooth card reader is 0x00, is then ACL channel successful connection, otherwise ACL channel connects unsuccessful.
Step 2-3, Bluetooth adapter obtain ACL and connect handle from the response of Bluetooth card reader, send to Bluetooth card reader and set up CO channel connection request, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, perform step 2-4, if receive time-out, connection failure;
Particularly, Bluetooth adapter reads 5-6 byte of the response of Bluetooth card reader, obtains ACL and connects handle; Such as, the response of Bluetooth card reader is 0x04030B0033005F21A36010000100 (small end storage mode), then Bluetooth card reader ACL connects handle is 0x0033.
According to the response of Bluetooth card reader, step 2-4, Bluetooth adapter judge whether that successfully setting up CO channel connects, be perform step 2-5, otherwise connection failure;
Particularly, Bluetooth adapter reads the result field (Result) in the response of Bluetooth card reader, and judging whether Result is the first preset value, is then successful connection, otherwise connection failure; Preferably, the first preset value is 0x00.
Step 2-5, Bluetooth adapter obtain channel id from the response of Bluetooth card reader;
Particularly, the SourceCID that Bluetooth card reader reads in the response of Bluetooth card reader obtains channel id.
Step 2-6, Bluetooth adapter send configurating channel parameter request to Bluetooth card reader, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, perform step 2-7, if receive time-out, and connection failure;
Particularly, the parameter of the needs configuration comprised in configurating channel parameter request comprises: MTU (MaximumTransmissionUnit, MTU), Flush_TimeOut and QoS.
Step 2-7, Bluetooth adapter judge channel parameter whether configuration successful according to the response of Bluetooth card reader, are perform step 2-8, otherwise connection failure;
In step 2-7, Bluetooth adapter judges that channel parameter configuration can also return execution step 2-6 time unsuccessful;
Further, in step 2-7, Bluetooth adapter judges that unsuccessful the returning of channel parameter configuration performs before step 2-6 and can also comprise: judge whether configuration failure number of times exceedes preset times, be then connection failure, otherwise return step 2-6;
Particularly, Bluetooth adapter judges channel parameter whether configuration successful according to the result field (Result) in the response of Bluetooth card reader, if Result is the second preset value, then and channel parameter configuration successful, if Result is not the second preset value, then channel parameter configuration failure; Preferably, the second preset value is 0x0000.
Step 2-8, Bluetooth adapter judge whether to need to adjust channel parameter according to the response of Bluetooth card reader, if desired then according to the response adjustment channel parameter of Bluetooth card reader, and successful connection, if do not need, successful connection.
Particularly, Bluetooth adapter judges whether to need to adjust channel parameter according to the adjustment parameter field (Options) in the response of Bluetooth card reader, if Options is sky, do not need to adjust channel parameter, if Options is not sky, need to adjust channel parameter;
In the present embodiment, when Options is not empty, Options comprises the data of at least one following form: parameter identification+parameter value length+parameter value, and Bluetooth adapter judges according to parameter identification the channel parameter needing adjustment, is adjusted to corresponding parameter value; Such as, parameter identification is 0x01, represents that the channel parameter needing adjustment is MTU.
Or in the present embodiment, as shown in Figure 4, Bluetooth adapter and Bluetooth card reader connect and specifically comprise:
Step 3-1, Bluetooth adapter send connection request to Bluetooth card reader, wait for Bluetooth card reader response, if receive the response of Bluetooth card reader, perform step 3-2, if receive time-out, and connection failure;
Step 3-2, Bluetooth adapter judge whether successful connection according to the response of Bluetooth card reader, are, perform step 3-3, otherwise connection failure;
Particularly, the 4th byte that Bluetooth adapter reads in the response of Bluetooth card reader obtains mode field, judges whether mode field is the 3rd preset value, is then successful connection, otherwise connection failure; Preferably, the 3rd preset value is 0x00.
Step 3-3, Bluetooth adapter obtain and connect handle from the response of card reader, main service UUID (UniversallyUniqueIdentifier is sent to Bluetooth card reader, general unique identifier), wait Bluetooth card reader is replied, if receive the response of Bluetooth card reader, perform step 3-4, if receive time-out, connection failure;
Particularly, response the 5th to the 6th byte of Bluetooth adapter reading Bluetooth card reader obtains connecting handle.
According to the response of Bluetooth card reader, step 3-4, Bluetooth adapter judge whether service mates, and is perform step 3-5, otherwise connection failure;
Particularly, Bluetooth adapter is by checking whether the handle information field (HandleInfo) in the response of bluetooth equipment is that sky judges whether service mates, if HandleInfo is sky, serves and do not mate, if HandleInfo is not sky, Service Matching.
In the present embodiment, Bluetooth card reader judges whether to serve UUID with self main identical after receiving the main service UUID that Bluetooth adapter sends, if identical, and Service Matching, if not identical, serve and do not mate, return respective acknowledgement according to judged result to Bluetooth adapter.
Step 3-5, Bluetooth adapter send to Bluetooth card reader and obtain characteristic value handle request, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, obtain the characteristic value handle in the response of Bluetooth card reader, successful connection, if receive time-out, connection failure.
In the present embodiment, the UUID with write attribute is comprised in the acquisition characteristic value handle request that Bluetooth adapter sends to Bluetooth card reader, after Bluetooth card reader receives and obtains characteristic value handle request, obtain the UUID with write attribute in request, search the characteristic value handle that this UUID with write attribute is corresponding, return to Bluetooth adapter.
In the present embodiment, prompting connection result can be that upwards position machine sends connection result, also can be pointed out by the display unit on Bluetooth adapter or voice playing device, such as, represent successful connection and connection failure by the different display modes (color, flashing times etc.) of indicator light.
Step 102, Bluetooth adapter judge whether to receive the CCID instruction that host computer issues, and are perform step 103, otherwise re-execute step 102;
The CCID instruction transformation that host computer issues by step 103, Bluetooth adapter is Bluetooth protocol data, sends Bluetooth protocol data to Bluetooth card reader;
In the present embodiment, step 103 can specifically comprise:
Step 4-1, Bluetooth adapter calculate the CRC check position of CCID instruction, add Bluetooth protocol head and CRC check position, obtain Bluetooth protocol data to the CCID instruction that host computer issues;
Step 4-2, Bluetooth adapter send Bluetooth protocol data to Bluetooth card reader;
Further, can also comprise before step 4-1:
Step 4-0, Bluetooth adapter judge that whether the length of the CCID instruction that host computer issues is more than MTU, if do not exceed, perform step 4-1, if exceed, according to the CCID instruction subpackage that MTU issues host computer, calculate the CRC check position of each director data bag that subpackage obtains respectively, successively Bluetooth protocol head and CRC check position are added to each director data bag, obtain Bluetooth protocol data, send Bluetooth protocol data to Bluetooth card reader;
Particularly, Bluetooth protocol head length is 13 bytes, and the 1st byte is event type mark; 2nd byte is HCI (HostControllerInterface to the 5th byte, HCI) layer Bluetooth protocol head, wherein, the 2nd to the 3rd padding bytes be the first operation result, the 4th byte and the 5th byte are HCI layer payload; 6th byte to the 9th byte is L2CAP layer (logical links and Adaptation protocol layer) Bluetooth protocol head, and wherein, the 6th byte and the 7th byte are L2CAP layer payload, and the 8th byte and the 9th byte are channel id; 10th byte is the second operation result; 11st byte is local specific UIH (unnumberedinformationwithheader) value; 12nd and the 13rd byte are the length of CCID director data;
Event type mark as above is specially 0x02, first operation result is specially 12 results obtained that the value of PB mark (Packet_BoundaryFlag) to be moved to left, the value of BC mark (BroadcastFlag) moves to left, and the result of 14 is connected with ACL the operation result that handle three carries out or computing obtains, wherein, the value of PB mark is specially 0x0000, and the value of BC mark is specially 0x0000, HCI layer payload is specially the length of the data after HCI layer Bluetooth protocol head, L2CAP layer payload is specially the length of the data after L2CAP layer Bluetooth protocol head, second operation result is specially 0x01, the value of outgoing moves to left the result of 1 and DLCI (DataLinkConnectionIdentifier, data link connection identifier) move to left the result that result three carries out or computing obtains of 2, i.e. the second operation result=(0x01<<0) | (outgoing<<1) | (DLCI<<2) wherein, DLCI is specially the operation result that both results are carried out or computing obtains that the value of Server_channel the to be moved to left result of 1 and the value of outgoing and 0x01 carry out step-by-step XOR, i.e. DLCI=(server_channel<<1) | (outgoing^1), the value of above-mentioned outgoing is 0x01, the value of Server_channel is the 4th preset value, local specific UIH value is specially 0xEF, the length of CCID director data is specially the length of the data after described 13rd byte,
Such as, the CCID instruction that host computer issues is 0x6F05000000000A0000000084000008, it is 0x0033 that ACL connects handle, channel id is 0x0040,4th preset value is 0x06, the length of the CCID instruction that host computer issues is not more than MTU, and it is 0x02330018001400400033EF1E006F05000000000A00000000840000 084F (small end storage mode) that the Bluetooth protocol data that Bluetooth protocol head and CRC check position obtain is added in the CCID instruction therefore issued host computer;
Or step 103 specifically comprises:
Step 5-1, Bluetooth adapter add Bluetooth protocol head to the CCID instruction that host computer issues, and obtain Bluetooth protocol data;
Step 5-2, Bluetooth adapter send Bluetooth protocol data to Bluetooth card reader;
Further, can also comprise before step 5-1:
Step 5-0, Bluetooth adapter judge that whether the length of the CCID instruction that host computer issues is more than MTU, if do not exceed, perform step 5-1, if exceed, according to the CCID instruction subpackage that MTU issues host computer, successively Bluetooth protocol head is added to each director data bag, obtain Bluetooth protocol data, send Bluetooth protocol data to Bluetooth card reader;
Particularly, Bluetooth protocol head length is 12 bytes, and the 1st byte is event type mark; 2nd byte is HCI (HostControllerInterface to the 5th byte, HCI) layer Bluetooth protocol head, wherein, the 2 to 3 padding bytes be the 3rd operation result, the 4th byte and the 5th byte are HCI layer payload; 6th byte to the 9th byte is L2CAP layer (logical links and Adaptation protocol layer) Bluetooth protocol head, and the 6th byte and the 7th byte are L2CAP layer payload, and the 8th byte and the 9th byte are channel id; 10th byte is ATT_WRITE_REQUEST; 11st byte and the 12nd padding bytes characteristic value handle;
Event type mark as above is specially 0x02; 3rd operation result be specially by PB mark (Packet_BoundaryFlag) value move to left 12 results obtained, BC mark (BroadcastFlag) value move to left 14 result be connected the operation result that handle three carries out or computing obtains, wherein, the value of PB mark is specially 0x0000, and the value of BC mark is specially 0x0000; HCI layer payload is specially the length of the data after HCI layer Bluetooth protocol head; L2CAP layer payload is specially the length of the data after L2CAP layer Bluetooth protocol head; Channel id is fixed value 0x0004, ATT_WRITE_REQUEST is fixed value 0x12;
Such as, the CCID instruction that host computer issues is 0x6F05000000000A0000000084000008, connection handle is 0x0033, characteristic value handle is 0x0025, the length of the CCID instruction that host computer issues is not more than MTU, and it is 0x0233001600120040001225006F05000000000A0000000084000008 (small end storage mode) that the Bluetooth protocol data that Bluetooth protocol head and CRC check position obtain is added in the CCID instruction therefore issued host computer.
Step 104, Bluetooth adapter wait for the response of Bluetooth card reader, and the response that Bluetooth card reader returns if receive, performs step 105, if receive time-out, perform step 106;
The response that Bluetooth card reader returns by step 105, Bluetooth adapter is converted to CCID protocol data, returns CCID protocol data, return step 102 to host computer;
Step 106, Bluetooth adapter return error code to host computer, return step 102.
In the present embodiment, step 104 can specifically comprise to step 106:
The response that step 6-1, Bluetooth adapter wait-receiving mode Bluetooth card reader return, if receive, performs step 6-2, if receive time-out, returns error code to host computer, return step 102;
Step 6-2, Bluetooth adapter obtain the HCI layer payload in replying and L2CAP layer payload, judge that whether the length of replying is legal according to the HCI layer payload got and L2CAP layer payload, if legal, perform step 6-3, if do not conform to rule upwards position machine return error code, return step 102;
Such as, the response that the Bluetooth card reader that Bluetooth adapter receives returns is: 0x0233201D001900400033FF2800800A000000000B0000008EFBFCE6 8F01BD4C900089, wherein the 4th to the 5th byte representation HCI layer payload is 29 bytes, 6th to the 7th byte representation L2CAP layer payload is 25 bytes, and the length of response is legal.
Step 6-3, Bluetooth adapter obtain response in valid data and CRC check position, according to CRC check position, CRC check is carried out to valid data, and if verification by; perform step 6-4, if verification not by; return error code to host computer, return step 102;
Response as above, the 14th to the 33rd byte is valid data, and the 34th byte is CRC check position, and valid data are specially 0x800A000000000B0000008EFBFCE68F01BD4C9000, and check digit is 0x89.
The valid data got are returned to host computer as CCID protocol data by step 6-4, Bluetooth adapter, return step 102.
Further, when comprising multiple packet in the response that Bluetooth card reader returns, Bluetooth adapter all carries out the operation of step 6-2 and step 6-3 to each packet, obtain the valid data in each packet, and whole valid data are returned to host computer as CCID protocol data.
Or step 104 specifically comprises to step 106:
The response that step 7-1, Bluetooth adapter wait-receiving mode Bluetooth card reader return, if receive, performs step 7-2, if receive time-out, returns error code to host computer, return step 102;
Step 7-2, Bluetooth adapter obtain the HCI layer payload in replying and L2CAP layer payload, judge that whether the length of replying is legal according to the HCI layer payload got and L2CAP layer payload, if legal, perform step 7-3, if do not conform to rule upwards position machine return error code, return step 102;
Such as, the response that the Bluetooth card reader that Bluetooth adapter receives returns is: 0x0233201B0017004000120025800A000000000B0000008EFBFCE68F 01BD4C9000, wherein the 4th to the 5th byte representation HCI layer payload is 27 bytes, 6th to the 7th byte representation L2CAP layer payload is 23 bytes, and the length of response is legal.
Valid data in the response that step 7-3, Bluetooth adapter acquisition Bluetooth card reader returns;
The valid data got are returned to host computer as CCID protocol data by step 7-4, Bluetooth adapter, return step 102.
Response as above, 13-the 32nd byte is valid data, and valid data are specially 0x800A000000000B0000008EFBFCE68F01BD4C9000.
Further, when comprising multiple packet in the response that Bluetooth card reader returns, Bluetooth adapter all carries out the operation of step 7-2 and step 7-3 to each packet, obtain the valid data in each packet, and whole valid data are returned to host computer as CCID protocol data.
In the present embodiment, in step 102, Bluetooth adapter can also comprise the type judging the CCID instruction that host computer issues after judging to receive the CCID instruction that host computer issues, if the type of the CCID instruction that host computer issues is off link order, then Bluetooth adapter sends to Bluetooth card reader and disconnects request, response is returned to host computer, re-execute step 102, otherwise perform step 103; Particularly, disconnect instruction to issue by the extended channel of CCID agreement.
In the present embodiment, described method also comprises: when Bluetooth adapter receives the plug-in card message that the Bluetooth card reader that connects with Bluetooth adapter sends, send information to host computer;
Particularly, plug-in card message comprises plug-in card message and pulls out card message, and plug-in card message is specially 0x5003, pulls out card message and is specially 0x5002;
In the present embodiment, after Bluetooth adapter and Bluetooth card reader connect, when Bluetooth card reader has detected that card inserts, send plug-in card message to Bluetooth adapter; When Bluetooth card reader detects that card is extracted, send and pull out card message to Bluetooth adapter; Produce internal interrupt when Bluetooth adapter receives plug-in card message or pull out card message, enter internal interrupt handling process;
Preferably, internal interrupt handling process comprises: check present mode, if present mode is USB poll pattern, send corresponding information to host computer, exit internal interrupt handling process; If present mode, for waiting for bluetooth answer-mode, directly exits internal interrupt handling process; Described corresponding information can for comprising the information etc. of plug-in card message.
Accordingly, before in step 102, Bluetooth adapter judges whether to receive the CCID instruction that host computer issues, also comprise: it is USB poll pattern that Bluetooth adapter arranges present mode; Also comprise when in described 104, Bluetooth adapter waits for the response of Bluetooth card reader: Bluetooth adapter arranges present mode for waiting for bluetooth answer-mode.
Embodiment 2
The present embodiment provides a kind of communication means of Bluetooth adapter, Bluetooth adapter in the present embodiment is used for communicating with Bluetooth card reader with host computer, Bluetooth adapter in the present embodiment and host computer adopt CCID agreement to communicate, Bluetooth protocol is adopted to communicate with Bluetooth card reader, as shown in Figure 5, described method specifically comprises:
Step 201, Bluetooth adapter initialization, be claimed as CCID equipment to host computer;
Step 202, Bluetooth adapter judge whether to receive the CCID instruction that host computer issues, and are perform step 203, otherwise re-execute step 202;
Step 203, Bluetooth adapter judge the type of the CCID instruction that host computer issues, if link order then performs step 204, otherwise perform step 205;
In the present embodiment, link order is issued by the extended channel of CCID agreement.
Step 204, Bluetooth adapter and Bluetooth card reader connect, and return connection result to host computer, return step 202;
In the present embodiment, step 204 can specifically comprise: Bluetooth adapter obtains the facility information of Bluetooth card reader from link order, and the Bluetooth card reader corresponding with the facility information got connects;
Further, the facility information of Bluetooth card reader can comprise the MAC Address of Bluetooth card reader and/or the device name of Bluetooth card reader; When comprising the MAC Address of Bluetooth card reader in the facility information of Bluetooth card reader, Bluetooth adapter carries out communication to connect according to the MAC Address in the facility information of Bluetooth card reader and Bluetooth card reader, when not comprising the MAC Address of Bluetooth card reader in the facility information of Bluetooth card reader, search the MAC Address corresponding with the device name in the facility information of Bluetooth card reader in the information that Bluetooth adapter prestores in the inside of Bluetooth adapter, carry out communication to connect according to the MAC Address found and Bluetooth card reader;
Or step 204 comprises: Bluetooth adapter search Bluetooth card reader, connects with the Bluetooth card reader searched;
Further, before Bluetooth adapter search Bluetooth card reader, can also comprise: Bluetooth adapter checks whether the facility information of the Bluetooth card reader stored, if have, obtain the facility information of the Bluetooth card reader stored, connect according to the facility information got and Bluetooth card reader, return connection result to host computer; If not, search for Bluetooth card reader, connect with the Bluetooth card reader searched, return connection result to host computer;
In the present embodiment, Bluetooth adapter searches for Bluetooth card reader, connect with Bluetooth card reader the concrete grammar that can adopt and provide in embodiment 1, and the concrete grammar provided in embodiment 1 is in this no longer repeated description.
The CCID instruction transformation that host computer issues by step 205, Bluetooth adapter is Bluetooth protocol data, sends Bluetooth protocol data to Bluetooth card reader;
In the present embodiment, the concrete methods of realizing of step 205 can be identical with the concrete methods of realizing of step 103 in embodiment 1, do not repeat them here.
Step 206, Bluetooth adapter wait for the response of Bluetooth card reader, and the response that Bluetooth card reader returns if receive, performs step 207, if receive time-out, perform step 208;
The response that Bluetooth card reader returns by step 207, Bluetooth adapter is converted to CCID protocol data, returns CCID protocol data, return step 202 to host computer;
Step 208, Bluetooth adapter return error code to host computer, return step 202.
In the present embodiment, the concrete methods of realizing of step 206 to 208 can be identical with the concrete methods of realizing of step 104 to 106 in embodiment 1, do not repeat them here.
In the present embodiment, can also comprise in step 203, if the type of CCID instruction that host computer issues is off link order, then Bluetooth adapter sends to Bluetooth card reader and disconnects request, returns response, re-execute step 202 to host computer; Particularly, disconnect instruction to be issued by the extended channel of CCID agreement.
In the present embodiment, described method also comprises: when Bluetooth adapter receives the plug-in card message that the Bluetooth card reader that connects with Bluetooth adapter sends, send information to host computer;
Particularly, plug-in card message comprises plug-in card message and pulls out card message, and plug-in card message is specially 0x5003, pulls out card message and is specially 0x5002;
In the present embodiment, after Bluetooth adapter and Bluetooth card reader connect, when Bluetooth card reader has detected that card inserts, send plug-in card message to Bluetooth adapter; When Bluetooth card reader detects that card is extracted, send and pull out card message to Bluetooth adapter; Produce internal interrupt when Bluetooth adapter receives plug-in card message or pull out card message, enter internal interrupt handling process;
Preferably, internal interrupt handling process comprises: check present mode, if present mode is USB poll pattern, send corresponding information to host computer, exit internal interrupt handling process; If present mode, for waiting for bluetooth answer-mode, directly exits internal interrupt handling process; Described corresponding information can for comprising the information etc. of plug-in card message.
Accordingly, before in step 202, Bluetooth adapter judges whether to receive the CCID instruction that host computer issues, also comprise: it is USB poll pattern that Bluetooth adapter arranges present mode; Also comprise when in described 206, Bluetooth adapter waits for the response of Bluetooth card reader: Bluetooth adapter arranges present mode for waiting for bluetooth answer-mode.
Embodiment 3
The present embodiment provides a kind of communication means of Bluetooth adapter, Bluetooth adapter in the present embodiment is used for communicating with Bluetooth card reader with host computer, Bluetooth adapter in the present embodiment and host computer adopt CCID agreement to communicate, Bluetooth protocol is adopted to communicate with Bluetooth card reader, as shown in Figure 6, described method specifically comprises:
Step 301, Bluetooth adapter initialization, be claimed as CCID equipment to host computer;
Step 302, Bluetooth adapter judge whether to receive the CCID instruction that host computer issues, and are perform step 303, otherwise re-execute step 302;
Step 303, Bluetooth adapter judge the type of the CCID instruction that host computer issues, if search instruction then performs step 304, if link order then performs step 305, otherwise perform step 306;
In the present embodiment, search instruction and link order are issued by the extended channel of CCID agreement.
Step 304, Bluetooth adapter search Bluetooth card reader, if search, returns the facility information of Bluetooth card reader, returns step 302, if do not search, return error code to host computer, return step 302 to host computer;
In the present embodiment, Bluetooth adapter search Bluetooth card reader can adopt the concrete grammar provided in embodiment 1, and the concrete grammar provided in embodiment 1 is in this no longer repeated description;
In the present embodiment, the facility information of the Bluetooth card reader that Bluetooth adapter returns to host computer is the device name of Bluetooth card reader, or is device name and the MAC Address of Bluetooth card reader;
When the facility information of the Bluetooth card reader that Bluetooth adapter returns to host computer is the device name of Bluetooth card reader, also comprise the device name of Bluetooth card reader and MAC Address corresponding stored get the device name of Bluetooth card reader at Bluetooth adapter after.
Step 305, Bluetooth adapter resolve the facility information obtaining Bluetooth card reader from link order, and the facility information according to Bluetooth card reader connects with corresponding Bluetooth card reader, returns connection result, return step 302 to host computer;
In the present embodiment, the facility information of the Bluetooth card reader comprised in link order is the device name of Bluetooth card reader, or is device name and the MAC Address of Bluetooth card reader;
When the facility information of the Bluetooth card reader comprised in link order is device name and the MAC Address of Bluetooth card reader, Bluetooth adapter connects according to the MAC Address of Bluetooth card reader and Bluetooth card reader;
When the facility information of the Bluetooth card reader comprised in link order is the device name of Bluetooth card reader, search the MAC Address corresponding with the device name of Bluetooth card reader the information that Bluetooth adapter stores in Bluetooth adapter, connect according to the MAC Address found and Bluetooth card reader;
In the present embodiment, Bluetooth adapter and Bluetooth card reader connect the concrete grammar that can adopt and provide in embodiment 1, and the concrete grammar provided in embodiment 1 is in this no longer repeated description.
The CCID instruction transformation that host computer issues by step 306, Bluetooth adapter is Bluetooth protocol data, sends Bluetooth protocol data to Bluetooth card reader;
In the present embodiment, the concrete methods of realizing of step 306 can be identical with the concrete methods of realizing of step 103 in embodiment 1, do not repeat them here.
Step 307, Bluetooth adapter wait for the response of Bluetooth card reader, if receive the response that Bluetooth card reader returns, the response returned by Bluetooth card reader is converted to CCID protocol data, CCID protocol data is returned to host computer, return step 302, if receive time-out, return error code to host computer, return step 302.
In the present embodiment, the concrete methods of realizing of step 307 can be identical with the concrete methods of realizing of step 104 to 106 in embodiment 1, do not repeat them here.
In the present embodiment, can also comprise in step 304, if the type of CCID instruction that host computer issues is off link order, then Bluetooth adapter sends to Bluetooth card reader and disconnects request, returns response, return step 302 to host computer; Particularly, disconnect instruction to be issued by the extended channel of CCID agreement.
In the present embodiment, described method also comprises: when Bluetooth adapter receives the plug-in card message that the Bluetooth card reader that connects with Bluetooth adapter sends, send information to host computer;
Particularly, plug-in card message comprises plug-in card message and pulls out card message, and plug-in card message is specially 0x5003, pulls out card message and is specially 0x5002;
In the present embodiment, after Bluetooth adapter and Bluetooth card reader connect, when Bluetooth card reader has detected that card inserts, send plug-in card message to Bluetooth adapter; When Bluetooth card reader detects that card is extracted, send and pull out card message to Bluetooth adapter; Produce internal interrupt when Bluetooth adapter receives plug-in card message or pull out card message, enter internal interrupt handling process;
Preferably, internal interrupt handling process comprises: check present mode, if present mode is USB poll pattern, send corresponding information to host computer, exit internal interrupt handling process; If present mode, for waiting for bluetooth answer-mode, directly exits internal interrupt handling process; Described corresponding information can for comprising the information etc. of plug-in card message.
Accordingly, before in step 302, Bluetooth adapter judges whether to receive the CCID instruction that host computer issues, also comprise: it is USB poll pattern that Bluetooth adapter arranges present mode; Also comprise when in described 307, Bluetooth adapter waits for the response of Bluetooth card reader: Bluetooth adapter arranges present mode for waiting for bluetooth answer-mode.
Embodiment 4
The present embodiment provides a kind of Bluetooth adapter, described Bluetooth adapter is used for communicating with Bluetooth card reader with host computer, and the concrete CCID agreement that adopts communicates with host computer, adopts Bluetooth protocol to communicate with Bluetooth card reader, as shown in Figure 7, described Bluetooth adapter specifically comprises:
To host computer, initialization module 401, for Bluetooth adapter described in initialization, states that described Bluetooth adapter is CCID equipment;
Command reception module 402, for receiving the CCID instruction that host computer issues;
Instruction sending module 403, during for receiving CCID instruction that host computer issues when command reception module 402, the CCID instruction transformation issued by host computer is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Response receiver module 404, for receiving the response of Bluetooth card reader, and returns error code when receive time-out to host computer;
Response returns module 405, for when described response receiver module 404 receives the response of Bluetooth card reader, the response of Bluetooth card reader is converted to CCID protocol data, returns described CCID protocol data to host computer;
Event checking module 406, for sending information when receiving the card plug message that Bluetooth card reader sends to host computer.
In the present embodiment, instruction sending module 403 can be specifically for: the CCID instruction issued host computer is added Bluetooth protocol head and obtained Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Or, instruction sending module 403 specifically for: judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, Bluetooth protocol head is added to the CCID instruction that host computer issues, obtains Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader; If exceed, the CCID instruction subpackage issued host computer according to MTU, adds Bluetooth protocol head to each instruction bag successively, obtains Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader;
Or, instruction sending module 403 specifically for: calculate the CRC check position of CCID instruction that host computer issues, the CCID instruction interpolation Bluetooth protocol head issue host computer and CRC check position obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader;
Or, instruction sending module 403 specifically for: judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, calculate the CRC check position of the CCID instruction that host computer issues, the CCID instruction interpolation Bluetooth protocol head issue host computer and CRC check position obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader; If exceed, CCID instruction subpackage host computer issued according to MTU, calculate the CRC check position of each instruction bag, successively Bluetooth protocol head and CRC check position are added to each instruction bag, obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader.
In the present embodiment, response returns module 405 can be specifically for: when replying receiver module 404 and receiving the response of Bluetooth card reader, HCI layer payload in the response that acquisition response receiver module 404 receives and L2CAP layer payload, judge that whether the length of replying the response that receiver module 404 receives is legal according to the HCI layer payload got and L2CAP layer payload, if do not conform to rule upwards position machine return error code, if legal, obtain the valid data in response, valid data are returned to host computer as CCID protocol data;
Or, response return module 405 specifically for: when reply receiver module 404 receive the response of Bluetooth card reader time, HCI layer payload in the response that acquisition response receiver module 404 receives and L2CAP layer payload, judge that whether the length of replying the response that receiver module 404 receives is legal according to the HCI layer payload got and L2CAP layer payload, if do not conform to rule upwards position machine return error code, if legal, obtain the valid data in response and CRC check position, according to CRC check position, CRC check is carried out to valid data, if verification not by, return error code to host computer, if verify by, valid data are returned to host computer as CCID protocol data.
In the present embodiment, Bluetooth adapter can also comprise:
Search module, for searching for Bluetooth card reader;
Link block, for connecting with Bluetooth card reader;
Reminding module, for pointing out the connection result of Bluetooth adapter and Bluetooth card reader;
Further, in the present embodiment, Bluetooth adapter can also comprise checking module, for checking whether the facility information of the Bluetooth card reader stored, and obtains the facility information of the Bluetooth card reader stored when being checked through the facility information of the Bluetooth card reader stored;
Correspondingly, search module is specifically for being checked through the facility information of the Bluetooth card reader do not stored during at checking module, search Bluetooth card reader; Link block is specifically for getting the facility information of the Bluetooth card reader stored during at checking module, the Bluetooth card reader corresponding with the facility information that checking module gets connects, and when search module searches Bluetooth card reader, the Bluetooth card reader searched with search module connects;
Further, link block is also for storing the facility information of Bluetooth card reader after setting up at Bluetooth adapter and Bluetooth card reader.
Or Bluetooth adapter also comprises:
Instruction type judge module, during for judging to receive CCID instruction that host computer issues when command reception module 402, judges the type of the CCID instruction that host computer issues;
Search module, for when described instruction type judge module judges that the CCID instruction that host computer issues is link order, search Bluetooth card reader;
Link block, connects for the Bluetooth card reader searched with search module;
Instruction sending module 403 specifically for: when described instruction type judge module judges that CCID instruction that host computer issues is not as link order, the CCID instruction transformation issued by host computer is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Response returns module 405 also for connection result from Bluetooth card reader to host computer that return described Bluetooth adapter and;
Further, Bluetooth adapter also comprises checking module, during for judging that the CCID instruction that host computer issues is link order when instruction type judge module, check whether the facility information of the Bluetooth card reader stored, and obtain the facility information of the Bluetooth card reader stored when being checked through the facility information of the Bluetooth card reader stored; Correspondingly, search module specifically for: when described checking module is checked through the facility information of the Bluetooth card reader do not stored, search Bluetooth card reader; Link block specifically for: when checking module gets the facility information of the Bluetooth card reader stored, the Bluetooth card reader corresponding with the facility information that checking module gets connects, when search module searches Bluetooth card reader, the Bluetooth card reader searched with search module connects;
Bluetooth adapter can also comprise and disconnects module, during for judging that the CCID instruction that host computer issues is off link order when instruction type judge module, send to the Bluetooth card reader be connected with Bluetooth adapter and disconnect request, return to host computer and disconnect repeat-back;
Further, link block is also for storing the facility information of Bluetooth card reader after setting up at Bluetooth adapter and Bluetooth card reader.
Or Bluetooth adapter also comprises:
Instruction type judge module, during for judging to receive CCID instruction when command reception module 402, judges the type of the CCID instruction that host computer issues;
Search module, during for judging that the CCID instruction that host computer issues is search instruction when instruction type judge module, search Bluetooth card reader;
Return module, for returning the facility information of the Bluetooth card reader that search module searches to host computer;
Acquisition module, during for judging that the CCID instruction that host computer issues is link order when instruction type judge module, obtains the facility information of Bluetooth card reader from link order;
Link block, connects for the Bluetooth card reader corresponding with the facility information that acquisition module gets;
Further, instruction sending module 403 specifically for: when instruction type judge module judges that CCID instruction that host computer issues is not as search instruction and link order, the CCID instruction transformation issued by host computer is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader; Correspondingly response returns module 405 also for connection result from Bluetooth card reader to host computer that return Bluetooth adapter and;
Bluetooth adapter can also comprise and disconnects module, during for judging that the CCID instruction that host computer issues is off link order when instruction type judge module, send to the Bluetooth card reader be connected with Bluetooth adapter and disconnect request, return to host computer and disconnect repeat-back;
Further:
Return module specifically for returning device name and the MAC Address of the Bluetooth card reader that search module searches to host computer; Correspondingly, when acquisition module is specifically for judging that the CCID instruction that host computer issues is link order when instruction type judge module, from link order, the MAC Address of Bluetooth card reader is obtained; Link block connects specifically for the MAC Address of Bluetooth card reader that gets according to acquisition module and Bluetooth card reader;
Or, return module specifically for the device name of Bluetooth card reader that searched by search module and MAC Address corresponding stored, return the device name of the Bluetooth card reader that search module searches to host computer; Correspondingly, when acquisition module is link order specifically for the CCID instruction that judges to receive when instruction type judge module, the device name of Bluetooth card reader is obtained, according to the device name got from returning module the MAC Address of searching Bluetooth card reader from link order; Link block connects specifically for the MAC Address of Bluetooth card reader that finds according to acquisition module and Bluetooth card reader.
In the present embodiment, search module specifically for: send search instruction, wait for and receive the response of bluetooth equipment, MAC Address and the device name of bluetooth equipment is obtained according to the response of the bluetooth equipment received, judge whether to have in the device name that gets meet pre-conditioned, that meeting bluetooth equipment corresponding to pre-conditioned device name is Bluetooth card reader, otherwise does not search Bluetooth card reader; Wherein, be pre-conditionedly specially identical with preset name or comprise preset field.
In the present embodiment, above-mentioned link block can specifically comprise:
Set up ACL channel linkage unit, setting up ACL channel connection request for sending to Bluetooth card reader, waiting for the response of Bluetooth card reader, if receive time-out, connection failure; If receive the response of Bluetooth card reader, judge whether that successfully setting up ACL channel connects according to the response of Bluetooth card reader, if success, from the response of Bluetooth card reader, obtain ACL connect handle, if failure, connection failure;
Request linkage unit, setting up CO channel connection request for sending to Bluetooth card reader, waiting for the response of Bluetooth card reader, if receive time-out, and connection failure; If receive the response of Bluetooth card reader, judge whether that successfully setting up CO channel connects, if success, obtains channel id from the response of Bluetooth card reader according to the response of Bluetooth card reader, if failure, connection failure;
Channel parameter dispensing unit, for sending configurating channel parameter request to Bluetooth card reader, waits for the response of Bluetooth card reader, if receive time-out, and connection failure; If receive the response of Bluetooth card reader, judge channel parameter whether configuration successful according to the response of Bluetooth card reader, if configuration failure, connection failure or again send configurating channel parameter request to Bluetooth card reader, if configuration successful, judge whether to need to adjust channel parameter according to the response of Bluetooth card reader, if desired adjust then according to the response adjustment channel parameter of Bluetooth card reader, successful connection, if do not need, successful connection;
Or link block specifically comprises:
Request linkage unit, for sending connection request to Bluetooth card reader, waits for the response of Bluetooth card reader, if receive time-out, and connection failure; If receive the response of Bluetooth card reader, the response according to Bluetooth card reader judges whether successful connection, is then to obtain to connect handle from the response of Bluetooth card reader, otherwise connection failure;
Service Matching unit, for sending main service general exclusive identification code to Bluetooth card reader, waits for the response of Bluetooth card reader, if receive time-out, and connection failure; If receive the response of Bluetooth card reader, judge whether service mates according to the response of Bluetooth card reader, if do not mate, connection failure;
Characteristic value handle acquiring unit, for when described Service Matching unit judges Service Matching, send to Bluetooth card reader and obtain characteristic value handle request, wait for the response of Bluetooth card reader, if receive time-out, connection failure, if receive the response of Bluetooth card reader, from the response of Bluetooth card reader, obtain characteristic value handle, successful connection.
In the present embodiment, response receiver module 404 also for before receiving the response of Bluetooth card reader, Bluetooth adapter is set present mode for waiting for bluetooth answer-mode, and to receive and card that Bluetooth card reader that described Bluetooth adapter connects sends plugs message; Correspondingly, command reception module 402 is also USB poll pattern for arranging the present mode of Bluetooth adapter before judging whether to receive the CCID instruction that host computer issues; Bluetooth adapter also comprises interruption processing module, for producing internal interrupt when replying receiver module 404 and receiving card plug message, enter internal interrupt handling process, check the present mode of Bluetooth adapter, if present mode is USB poll pattern, send corresponding information to host computer, exiting internal interrupt handling process, if present mode is for waiting for bluetooth answer-mode, directly exiting internal interrupt handling process.
Above-described embodiment is the present invention's more preferably embodiment, and the usual change that those skilled in the art carries out within the scope of technical solution of the present invention and replacement all should be included in protection scope of the present invention.

Claims (40)

1. a communication means for Bluetooth adapter, is characterized in that, comprising:
Step S1, Bluetooth adapter initialization, be claimed as CCID equipment to host computer;
Step S2, described Bluetooth adapter judge whether to receive the CCID instruction that host computer issues, and are perform step S3, otherwise re-execute step S2;
The CCID instruction transformation that host computer issues by step S3, described Bluetooth adapter is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Step S4, described Bluetooth adapter wait for the response of Bluetooth card reader, if receive the response that Bluetooth card reader returns, the response returned by Bluetooth card reader is converted to CCID protocol data, described CCID protocol data is sent to host computer, return step S2, if receive time-out, return error code to host computer, return step S2;
Described method also comprises: send information when described Bluetooth adapter receives the card plug message of Bluetooth card reader transmission to host computer.
2. the method for claim 1, is characterized in that, described step S3 specifically comprises:
Step a1, described Bluetooth adapter add Bluetooth protocol head to the CCID instruction that host computer issues and obtain Bluetooth protocol data;
Step a2, described Bluetooth adapter send described Bluetooth protocol data to Bluetooth card reader.
3. method as claimed in claim 2, it is characterized in that, described step S3 also comprises:
Step a0, described Bluetooth adapter judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, perform described step a1, if exceed, according to the CCID instruction subpackage that MTU issues host computer, successively Bluetooth protocol head is added to each director data bag and obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader.
4. the method for claim 1, is characterized in that, described step S3 specifically comprises:
Step b1, described Bluetooth adapter calculate the CRC check position of the CCID instruction that host computer issues, and add Bluetooth protocol head and described CRC check position, obtain Bluetooth protocol data to the CCID instruction that host computer issues;
Step b2, described Bluetooth adapter send described Bluetooth protocol data to Bluetooth card reader.
5. method as claimed in claim 4, it is characterized in that, described step S3 also comprises:
Step b0, described Bluetooth adapter judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, perform described step b1, if exceed, according to the CCID instruction subpackage that MTU issues host computer, calculate the CRC check position of each director data bag respectively, successively Bluetooth protocol data is obtained to each director data bag interpolation Bluetooth protocol head and CRC check position, send described Bluetooth protocol data to Bluetooth card reader.
6. the method for claim 1, is characterized in that, described step S4 specifically comprises:
The response that step c1, described Bluetooth adapter wait-receiving mode Bluetooth card reader return, if receive, performs step c2, if receive time-out, returns error code to host computer, return step S2;
Step c2, described Bluetooth adapter obtain the HCI layer payload in replying and L2CAP layer payload, judge that whether the length of replying is legal according to the HCI layer payload got and L2CAP layer payload, if legal, perform step c3, if do not conform to rule upwards position machine return error code, return step S2;
Step c3, described Bluetooth adapter obtain the valid data in replying and CRC check position, according to CRC check position, CRC check is carried out to valid data, if verify by; valid data are returned to host computer, return step S2, if verification not by; return error code to host computer, return step S2.
7. the method for claim 1, is characterized in that, described step S4 specifically comprises:
The response that steps d 1, described Bluetooth adapter wait-receiving mode Bluetooth card reader return, if receive, performs steps d 2, if receive time-out, returns error code to host computer, return step S2;
Steps d 2, described Bluetooth adapter obtain the HCI layer payload in replying and L2CAP layer payload, judge that whether the length of replying is legal according to the HCI layer payload got and L2CAP layer payload, if legal, perform steps d 3, if do not conform to rule upwards position machine return error code, return step S2;
Steps d 3, described Bluetooth adapter obtain the valid data in response, valid data are returned to host computer, returns step S2.
8. the method for claim 1, is characterized in that, in described step S1, after described Bluetooth adapter initialization, also comprises: described Bluetooth adapter search Bluetooth card reader, connects with Bluetooth card reader, prompting connection result.
9. method as claimed in claim 8, it is characterized in that, before described Bluetooth adapter search Bluetooth card reader, also comprise: described Bluetooth adapter checks whether the facility information of the Bluetooth card reader stored, if have, obtain the facility information of the Bluetooth card reader stored, connect with Bluetooth card reader, prompting connection result; If, do not perform described search Bluetooth card reader.
10. the method for claim 1, it is characterized in that, in described step S2, when described Bluetooth adapter judges to receive the CCID instruction that host computer issues, also comprise: described Bluetooth adapter judges the type of the CCID instruction that host computer issues, if the CCID instruction that host computer issues is link order, searches for Bluetooth card reader, connects with Bluetooth card reader, return connection result to host computer, return step S2; Otherwise, perform step S3.
11. methods as claimed in claim 10, it is characterized in that, before described Bluetooth adapter search Bluetooth card reader, also comprise: described Bluetooth adapter checks whether the facility information of the Bluetooth card reader stored, if have, obtain the facility information of the Bluetooth card reader stored, connect with Bluetooth card reader, return connection result to host computer, return step S2; If, do not perform described search Bluetooth card reader.
12. methods as described in claim 9 or 11, is characterized in that, also comprise: described Bluetooth adapter stores the facility information of Bluetooth card reader with Bluetooth card reader after connecting.
13. the method for claim 1, is characterized in that, in described step S2, when described Bluetooth adapter judges to receive the CCID instruction that host computer issues, also comprise the type that described Bluetooth adapter judges the CCID instruction that host computer issues:
If the CCID instruction that host computer issues is search instruction, search for Bluetooth card reader, return the facility information of the Bluetooth card reader searched to host computer, return step S2;
If the CCID instruction that host computer issues is link order, from link order, obtains the facility information of Bluetooth card reader, connect with Bluetooth card reader, return connection result to host computer, return step S2;
Otherwise, perform step S3.
14. methods as claimed in claim 13, it is characterized in that, described Bluetooth adapter returns the facility information of the Bluetooth card reader searched to host computer, specifically comprise: described Bluetooth adapter returns device name and the MAC Address of the Bluetooth card reader searched to host computer;
Described Bluetooth adapter obtains the facility information of Bluetooth card reader from link order, connect with Bluetooth card reader, specifically comprise: described Bluetooth adapter obtains the MAC Address of Bluetooth card reader from link order, connect according to the MAC Address of the Bluetooth card reader got and Bluetooth card reader.
15. methods as claimed in claim 13, it is characterized in that, described Bluetooth adapter returns the facility information of the Bluetooth card reader searched to host computer, specifically comprise: described Bluetooth adapter, by the device name of Bluetooth card reader and MAC Address corresponding stored, returns the device name of the Bluetooth card reader searched to host computer;
Described Bluetooth adapter obtains the facility information of Bluetooth card reader from link order, connect with Bluetooth card reader, specifically comprise: described Bluetooth adapter obtains the device name of Bluetooth card reader from link order, search the MAC Address of Bluetooth card reader according to the device name of the Bluetooth card reader got, connect according to the MAC Address of the Bluetooth card reader found and Bluetooth card reader.
16. methods as described in claim 8,10 or 13, it is characterized in that, described search Bluetooth card reader specifically comprises:
Step 1-1, described Bluetooth adapter send search instruction, wait for and receive the response of bluetooth equipment;
Step 1-2, described Bluetooth adapter obtain MAC Address and the device name of bluetooth equipment according to the response of the bluetooth equipment received;
Whether step 1-3, described Bluetooth adapter judge to have in the device name got and meet pre-conditioned, are that meeting bluetooth equipment corresponding to pre-conditioned device name is Bluetooth card reader, otherwise does not search Bluetooth card reader;
Describedly pre-conditionedly be specially identical with preset name or comprise preset field.
17. methods as described in claim 8,10 or 13, is characterized in that, describedly connect with Bluetooth card reader, specifically comprise:
Step 2-1, described Bluetooth adapter send to Bluetooth card reader and set up ACL channel connection request, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, perform step 2-2, if receive time-out, and connection failure;
According to the response of Bluetooth card reader, step 2-2, described Bluetooth adapter judge whether that successfully setting up ACL channel connects, and is, obtain ACL and connect handle, perform step 2-3 from the response of Bluetooth card reader, otherwise connection failure;
Step 2-3, described Bluetooth adapter send to Bluetooth card reader and set up CO channel connection request, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, perform step 2-4, if receive time-out, and connection failure;
According to the response of Bluetooth card reader, step 2-4, described Bluetooth adapter judge whether that successfully setting up CO channel connects, and is obtain channel id from the response of Bluetooth card reader, performs step 2-5, otherwise connection failure;
Step 2-5, described Bluetooth adapter send configurating channel parameter request to Bluetooth card reader, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, perform step 2-6, if receive time-out, and connection failure;
Step 2-6, described Bluetooth adapter judge channel parameter whether configuration successful according to the response of Bluetooth card reader, are perform step 2-7, otherwise connection failure or return step 2-5;
Step 2-7, described Bluetooth adapter judge whether to need to adjust channel parameter according to the response of Bluetooth card reader, if desired then according to the response adjustment channel parameter of Bluetooth card reader, and successful connection, if do not need, successful connection.
18. methods as described in claim 8,10 or 13, is characterized in that, describedly connect with Bluetooth card reader, specifically comprise:
Step 3-1, described Bluetooth adapter send connection request to Bluetooth card reader, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, perform step 3-2, if receive time-out, and connection failure;
Step 3-2, described Bluetooth adapter judge whether successful connection according to the response of Bluetooth card reader, are then to obtain to connect handle from the response of Bluetooth card reader, perform step 3-3, otherwise connection failure;
Step 3-3, described Bluetooth adapter send main service general exclusive identification code to Bluetooth card reader, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, perform step 3-4, if receive time-out, and connection failure;
According to the response of Bluetooth card reader, step 3-4, described Bluetooth adapter judge whether service mates, and is perform step 3-5, otherwise connection failure;
Step 3-5, described Bluetooth adapter send to Bluetooth card reader and obtain characteristic value handle request, wait for the response of Bluetooth card reader, if receive the response of Bluetooth card reader, from the response of Bluetooth card reader, obtain characteristic value handle, successful connection, if receive time-out, connection failure.
19. methods as described in claim 10 or 13, it is characterized in that, described Bluetooth adapter also comprises when judging the type of the CCID instruction that host computer issues: if described CCID instruction is off link order, then described Bluetooth adapter sends to the Bluetooth card reader be connected with described Bluetooth adapter and disconnects request, and return to described host computer and disconnect repeat-back, return step S2.
20. the method for claim 1, is characterized in that, Bluetooth adapter described in described step S2 also comprises: it is USB poll pattern that described Bluetooth adapter arranges present mode before judging whether to receive the CCID instruction that host computer issues; Bluetooth adapter described in described step S4 also comprises when waiting for the response of Bluetooth card reader: described Bluetooth adapter arranges present mode for waiting for bluetooth answer-mode;
Described method also comprises: described Bluetooth adapter receives when card that the Bluetooth card reader that connects with described Bluetooth adapter sends plugs message and produces internal interrupt, enter internal interrupt handling process, check the present mode of described Bluetooth adapter, if present mode is USB poll pattern, send corresponding information to host computer, exit internal interrupt handling process; If present mode, for waiting for bluetooth answer-mode, directly exits internal interrupt handling process.
21. 1 kinds of Bluetooth adapter, is characterized in that, comprising:
To host computer, initialization module, for Bluetooth adapter described in initialization, states that described Bluetooth adapter is CCID equipment;
Command reception module, for receiving the CCID instruction that host computer issues;
Instruction sending module, during for receiving CCID instruction that host computer issues when command reception module, the CCID instruction transformation issued by host computer is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Response receiver module, for receiving the response of Bluetooth card reader, and returns error code when receive time-out to host computer;
Response sending module, for when described response receiver module receives the response of Bluetooth card reader, is converted to CCID protocol data by the response of Bluetooth card reader, returns described CCID protocol data to host computer;
Event checking module, for sending information when receiving the card plug message that Bluetooth card reader sends to host computer.
22. Bluetooth adapter as claimed in claim 21, is characterized in that, described instruction sending module specifically for: the CCID instruction issued host computer is added Bluetooth protocol head and is obtained Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader.
23. Bluetooth adapter as claimed in claim 22, it is characterized in that, described instruction sending module specifically for: judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, Bluetooth protocol data is obtained to the CCID instruction interpolation Bluetooth protocol head that host computer issues, sends described Bluetooth protocol data to Bluetooth card reader; If exceed, the CCID instruction subpackage issued host computer according to MTU, adds Bluetooth protocol head to each instruction bag successively, obtains Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader.
24. Bluetooth adapter as claimed in claim 21, it is characterized in that, described instruction sending module specifically for: calculate the CRC check position of CCID instruction that host computer issues, the CCID instruction interpolation Bluetooth protocol head issue host computer and CRC check position obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader.
25. Bluetooth adapter as claimed in claim 24, it is characterized in that, described instruction sending module specifically for: judge whether the length of the CCID instruction that host computer issues exceedes MTU, if do not exceed, calculate the CRC check position of the CCID instruction that host computer issues, the CCID instruction interpolation Bluetooth protocol head issue host computer and CRC check position obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader; If exceed, CCID instruction subpackage host computer issued according to MTU, calculate the CRC check position of each instruction bag, successively Bluetooth protocol head and CRC check position are added to each instruction bag, obtain Bluetooth protocol data, send described Bluetooth protocol data to Bluetooth card reader.
26. Bluetooth adapter as claimed in claim 21, it is characterized in that, described response sending module specifically for: when described response receiver module receives the response of Bluetooth card reader, HCI layer payload in the response that acquisition response receiver module receives and L2CAP layer payload, judge that whether the length of replying the response that receiver module receives is legal according to the HCI layer payload got and L2CAP layer payload, if do not conform to rule upwards position machine return error code, if legal, obtain the valid data in described response and CRC check position, according to CRC check position, CRC check is carried out to valid data, if verification not by, return error code to host computer, if verify by, valid data are returned to host computer as CCID protocol data.
27. Bluetooth adapter as claimed in claim 21, it is characterized in that, described response receiver module specifically for: when described response receiver module receives the response of Bluetooth card reader, HCI layer payload in the response that acquisition response receiver module receives and L2CAP layer payload, judge that whether the length of replying the response that receiver module receives is legal according to the HCI layer payload got and L2CAP layer payload, if do not conform to rule upwards position machine return error code, if legal, obtain the valid data in response, valid data are returned to host computer as CCID protocol data.
28. Bluetooth adapter as claimed in claim 21, is characterized in that, also comprise:
Search module, for searching for Bluetooth card reader;
Link block, for connecting with Bluetooth card reader;
Reminding module, for pointing out the connection result of described Bluetooth adapter and Bluetooth card reader.
29. Bluetooth adapter as claimed in claim 28, it is characterized in that, also comprising checking module, for checking whether the facility information of the Bluetooth card reader stored, and obtaining the facility information of the Bluetooth card reader stored when being checked through the facility information of the Bluetooth card reader stored;
Described search module specifically for: when described checking module is checked through the facility information of the Bluetooth card reader do not stored, search Bluetooth card reader;
Described link block specifically for: when described checking module gets the facility information of the Bluetooth card reader stored, the Bluetooth card reader corresponding with the facility information that described checking module gets connects, when described search module searches Bluetooth card reader, the Bluetooth card reader searched with described search module connects.
30. Bluetooth adapter as claimed in claim 21, is characterized in that, also comprise:
Instruction type judge module, during for receiving CCID instruction that host computer issues when command reception module, judges the type of the CCID instruction that host computer issues;
Search module, for when described instruction type judge module judges that the CCID instruction that host computer issues is link order, search Bluetooth card reader;
Link block, connects for the Bluetooth card reader searched with described search module;
Described instruction sending module specifically for: when described instruction type judge module judges that CCID instruction that host computer issues is not as link order, the CCID instruction transformation issued by host computer is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Described response sending module is also for the connection result returning described Bluetooth adapter and Bluetooth card reader to host computer.
31. Bluetooth adapter as claimed in claim 30, it is characterized in that, also comprise checking module, for when described instruction type judge module judges that the CCID instruction that host computer issues is link order, check whether the facility information of the Bluetooth card reader stored, and obtain the facility information of the Bluetooth card reader stored when being checked through the facility information of the Bluetooth card reader stored;
Described search module specifically for: when described checking module is checked through the facility information of the Bluetooth card reader do not stored, search Bluetooth card reader;
Described link block specifically for: when described checking module gets the facility information of the Bluetooth card reader stored, the Bluetooth card reader corresponding with the facility information that described checking module gets connects, when described search module searches Bluetooth card reader, the Bluetooth card reader searched with described search module connects.
32. Bluetooth adapter as described in claim 29 or 31, it is characterized in that, described link block stores the facility information of Bluetooth card reader after also connecting for described Bluetooth adapter and Bluetooth card reader.
33. Bluetooth adapter as claimed in claim 21, is characterized in that, also comprise:
Instruction type judge module, for when command reception module receives CCID instruction, judges the type of the CCID instruction that host computer issues;
Search module, for when described instruction type judge module judges that the CCID instruction that host computer issues is search instruction, search Bluetooth card reader;
Return module, for returning the facility information of the Bluetooth card reader that search module searches to host computer;
Acquisition module, for when described instruction type judge module judges that the CCID instruction that host computer issues is link order, obtains the facility information of Bluetooth card reader from link order;
Link block, connects for the Bluetooth card reader corresponding with the facility information that described acquisition module gets;
Described instruction sending module specifically for: when described instruction type judge module judges that CCID instruction that host computer issues is not as search instruction and link order, the CCID instruction transformation issued by host computer is Bluetooth protocol data, sends described Bluetooth protocol data to Bluetooth card reader;
Described response sending module is also for the connection result returning described Bluetooth adapter and Bluetooth card reader to host computer.
34. Bluetooth adapter as claimed in claim 33, is characterized in that, described in return module specifically for the device name from the Bluetooth card reader that search module searches to host computer and the MAC Address that return;
Described acquisition module specifically for: when described instruction type judge module judges that the CCID instruction that host computer issues is link order, from link order, obtain the MAC Address of Bluetooth card reader;
Described link block specifically for, MAC Address and the Bluetooth card reader of the Bluetooth card reader got according to described acquisition module connect.
35. Bluetooth adapter as claimed in claim 33, it is characterized in that, described return module specifically for: the device name of the Bluetooth card reader of the Bluetooth card reader searched by described search module and MAC Address corresponding stored, return the device name of the Bluetooth card reader that described search module searches to host computer;
Described acquisition module specifically for: when described instruction type judge module judges that the CCID instruction that host computer issues is link order, from link order, obtain the device name of Bluetooth card reader, the device name according to the Bluetooth card reader got returns module the MAC Address of searching Bluetooth card reader from described;
Described link block specifically for, MAC Address and the Bluetooth card reader of the Bluetooth card reader found according to described acquisition module connect.
36. Bluetooth adapter as described in claim 28,30 or 33, it is characterized in that, described search module specifically for: send search instruction, wait for and receive the response of bluetooth equipment, MAC Address and the device name of bluetooth equipment is obtained according to the response of the bluetooth equipment received, whether judge to have in the device name that gets and meet pre-conditioned, be that meeting bluetooth equipment corresponding to pre-conditioned device name is Bluetooth card reader, otherwise does not search Bluetooth card reader; Describedly pre-conditionedly be specially identical with preset name or comprise preset field.
37. Bluetooth adapter as described in claim 28,30 or 33, it is characterized in that, described link block specifically comprises:
Set up ACL channel linkage unit, setting up ACL channel connection request for sending to Bluetooth card reader, waiting for the response of Bluetooth card reader, if receive time-out, connection failure; If receive the response of Bluetooth card reader, judge whether that successfully setting up ACL channel connects according to the response of Bluetooth card reader, if success, from the response of Bluetooth card reader, obtain ACL connect handle, if failure, connection failure;
Request linkage unit, setting up CO channel connection request for sending to Bluetooth card reader, waiting for the response of Bluetooth card reader, if receive time-out, and connection failure; If receive the response of Bluetooth card reader, judge whether that successfully setting up CO channel connects, if success, obtains channel id from the response of Bluetooth card reader according to the response of Bluetooth card reader, if failure, connection failure;
Channel parameter dispensing unit, for sending configurating channel parameter request to Bluetooth card reader, waits for the response of Bluetooth card reader, if receive time-out, and connection failure; If receive the response of Bluetooth card reader, judge channel parameter whether configuration successful according to the response of Bluetooth card reader, if configuration failure, connection failure or again send configurating channel parameter request to Bluetooth card reader, if configuration successful, judge whether to need to adjust channel parameter according to the response of Bluetooth card reader, if desired adjust then according to the response adjustment channel parameter of Bluetooth card reader, successful connection, if do not need, successful connection.
38. Bluetooth adapter as described in claim 28,30 or 33, it is characterized in that, described link block specifically comprises:
Request linkage unit, for sending connection request to Bluetooth card reader, waits for the response of Bluetooth card reader, if receive time-out, and connection failure; If receive the response of Bluetooth card reader, the response according to Bluetooth card reader judges whether successful connection, is then to obtain to connect handle from the response of Bluetooth card reader, otherwise connection failure;
Service Matching unit, for sending main service general exclusive identification code to Bluetooth card reader, waits for the response of card reader, if receive time-out, and connection failure; If receive the response of Bluetooth card reader, judge whether service mates according to the response of Bluetooth card reader, if do not mate, connection failure;
Characteristic value handle acquiring unit, for when described Service Matching unit judges Service Matching, send to Bluetooth card reader and obtain characteristic value handle request, wait for the response of Bluetooth card reader, if receive time-out, connection failure, if receive the response of Bluetooth card reader, from the response of Bluetooth card reader, obtain characteristic value handle, successful connection.
39. Bluetooth adapter as described in claim 30 or 33, it is characterized in that, also comprise and disconnect module, for when described instruction type judge module judges that the CCID instruction received is off link order, send to the Bluetooth card reader be connected with described Bluetooth adapter and disconnect request, return to described host computer and disconnect repeat-back.
40. Bluetooth adapter as claimed in claim 21, it is characterized in that, described response receiver module also for: the present mode arranging Bluetooth adapter before receiving the response of Bluetooth card reader for waiting for bluetooth answer-mode, and to receive and card that Bluetooth card reader that described Bluetooth adapter connects sends plugs message;
Described command reception module also for: the present mode arranging Bluetooth adapter before receiving the CCID instruction that issues of host computer is USB poll pattern;
Described Bluetooth adapter also comprises interruption processing module, internal interrupt is produced during for receiving card plug message when described response receiver module, enter internal interrupt handling process, check the present mode of described Bluetooth adapter, if present mode is USB poll pattern, send corresponding information to host computer, exit internal interrupt handling process; If present mode for waiting for bluetooth answer-mode, does not directly exit internal interrupt handling process.
CN201510628156.9A 2015-09-28 2015-09-28 Bluetooth adapter and its communication means Active CN105162498B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510628156.9A CN105162498B (en) 2015-09-28 2015-09-28 Bluetooth adapter and its communication means

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510628156.9A CN105162498B (en) 2015-09-28 2015-09-28 Bluetooth adapter and its communication means

Publications (2)

Publication Number Publication Date
CN105162498A true CN105162498A (en) 2015-12-16
CN105162498B CN105162498B (en) 2018-09-25

Family

ID=54803275

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510628156.9A Active CN105162498B (en) 2015-09-28 2015-09-28 Bluetooth adapter and its communication means

Country Status (1)

Country Link
CN (1) CN105162498B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106301488A (en) * 2016-09-29 2017-01-04 飞天诚信科技股份有限公司 A kind of Bluetooth adapter and method of work thereof
CN107135476A (en) * 2017-06-27 2017-09-05 飞天诚信科技股份有限公司 A kind of Bluetooth adapter and its method of work
CN108738000A (en) * 2018-03-30 2018-11-02 晨星半导体股份有限公司 Based on Android(Android)The bluetooth adaptation method and terminal device of system
CN109246668A (en) * 2018-09-07 2019-01-18 国网江苏省电力有限公司苏州供电分公司 A kind of communication equipment and a kind of substation equipment detection system using it
CN109419533A (en) * 2017-08-28 2019-03-05 深圳市理邦精密仪器股份有限公司 Patient monitor and its interface switching method, device
CN110336592A (en) * 2019-06-28 2019-10-15 飞天诚信科技股份有限公司 It is applicable in the data transmission method and electronic equipment of Bluetooth card reader
CN111988065A (en) * 2020-08-25 2020-11-24 重庆百瑞互联电子技术有限公司 Drive-free USB device, method, storage medium and device
CN113691431A (en) * 2021-07-29 2021-11-23 青岛海信日立空调系统有限公司 Communication network system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004010311A2 (en) * 2002-07-18 2004-01-29 Sun Microsystems, Inc. Method and apparatus for zero-copy receive buffer management
CN1936917A (en) * 2006-10-23 2007-03-28 北京飞天诚信科技有限公司 Method and apparatus for host machine and smart card to conduct information interaction
CN101634976A (en) * 2009-08-27 2010-01-27 中兴通讯股份有限公司 Method and terminal for providing Bluetooth function for computer
CN201435745Y (en) * 2009-03-30 2010-03-31 深圳市金积嘉电子工业有限公司 Multifunctional bluetooth earphone
CN202870898U (en) * 2012-08-15 2013-04-10 天长市浩云电子科技有限公司 Radio frequency-based commodity information identification system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004010311A2 (en) * 2002-07-18 2004-01-29 Sun Microsystems, Inc. Method and apparatus for zero-copy receive buffer management
CN1936917A (en) * 2006-10-23 2007-03-28 北京飞天诚信科技有限公司 Method and apparatus for host machine and smart card to conduct information interaction
CN201435745Y (en) * 2009-03-30 2010-03-31 深圳市金积嘉电子工业有限公司 Multifunctional bluetooth earphone
CN101634976A (en) * 2009-08-27 2010-01-27 中兴通讯股份有限公司 Method and terminal for providing Bluetooth function for computer
CN202870898U (en) * 2012-08-15 2013-04-10 天长市浩云电子科技有限公司 Radio frequency-based commodity information identification system

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106301488A (en) * 2016-09-29 2017-01-04 飞天诚信科技股份有限公司 A kind of Bluetooth adapter and method of work thereof
CN107135476A (en) * 2017-06-27 2017-09-05 飞天诚信科技股份有限公司 A kind of Bluetooth adapter and its method of work
CN109419533A (en) * 2017-08-28 2019-03-05 深圳市理邦精密仪器股份有限公司 Patient monitor and its interface switching method, device
CN108738000A (en) * 2018-03-30 2018-11-02 晨星半导体股份有限公司 Based on Android(Android)The bluetooth adaptation method and terminal device of system
CN109246668A (en) * 2018-09-07 2019-01-18 国网江苏省电力有限公司苏州供电分公司 A kind of communication equipment and a kind of substation equipment detection system using it
CN110336592A (en) * 2019-06-28 2019-10-15 飞天诚信科技股份有限公司 It is applicable in the data transmission method and electronic equipment of Bluetooth card reader
CN110336592B (en) * 2019-06-28 2021-03-16 飞天诚信科技股份有限公司 Data transmission method suitable for Bluetooth card reader, electronic equipment and storage medium
US11736149B2 (en) 2019-06-28 2023-08-22 Feitian Technologies Co., Ltd. Data transmission method for Bluetooth card reader and electronic device
CN111988065A (en) * 2020-08-25 2020-11-24 重庆百瑞互联电子技术有限公司 Drive-free USB device, method, storage medium and device
CN113691431A (en) * 2021-07-29 2021-11-23 青岛海信日立空调系统有限公司 Communication network system

Also Published As

Publication number Publication date
CN105162498B (en) 2018-09-25

Similar Documents

Publication Publication Date Title
CN105162498A (en) Bluetooth adapter and communication method thereof
CN102111192B (en) Bluetooth connection method and system
CN101884178B (en) Method and system for communication in near field communication network
CN104469482A (en) Control method and device for connection of intelligent terminal and Bluetooth devices
CN103813472B (en) The system and method for connecting equipment by Wi-Fi network
CN104378145A (en) Pairing method and system of Bluetooth device
CN111200811B (en) TWS earphone, upgrading method and device thereof and readable storage medium
CN103442250B (en) Television set debugging system and method
CN104503378A (en) Robot and household electrical appliance control method based on robot
CN104333913A (en) Electronic device and online setting method of external network and electronic device
CN104184502A (en) Bluetooth pairing device and method
CN103209009B (en) Server wireless input device adopting near field communication (NFC) matching and working method thereof
CN107343325A (en) A kind of data transmission method, device and terminal
CN106101989A (en) A kind of method selecting safe unit and mobile terminal
WO2016058166A1 (en) Method for triggering registration machine protocol interaction, access point and station point
CN104426626A (en) Terminal device and management frame sending method and receiving method
EP2905938B1 (en) Method for acquiring locating information, terminal and mobile broadband interface model (mbim) device
CN112232454A (en) Data writing method and system, terminal, household appliance and computer device
CN105451368A (en) Communication method and apparatus
CN103546531A (en) Quick parameter setting method and quick parameter setting system for smart televisions
CN113595839B (en) Device binding method, terminal device and storage medium
CN110601986A (en) Router supporting peripheral control over mobile terminal equipment, control method and device
CN106790282A (en) Protocol conversion method and device and air conditioning system
CN103987129A (en) Information push method, apparatus and system
CN107636982A (en) Method, near field communication controller and the terminal of data frame route processing

Legal Events

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