CN106211355B - Equipment and system for controlling data interaction and working method thereof - Google Patents
Equipment and system for controlling data interaction and working method thereof Download PDFInfo
- Publication number
- CN106211355B CN106211355B CN201610423079.8A CN201610423079A CN106211355B CN 106211355 B CN106211355 B CN 106211355B CN 201610423079 A CN201610423079 A CN 201610423079A CN 106211355 B CN106211355 B CN 106211355B
- Authority
- CN
- China
- Prior art keywords
- module
- terminal equipment
- bluetooth
- bluetooth key
- key
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 230000003993 interaction Effects 0.000 title claims abstract description 52
- 238000000034 method Methods 0.000 title claims abstract description 42
- 230000001960 triggered effect Effects 0.000 claims description 18
- 238000012544 monitoring process Methods 0.000 claims description 10
- 238000001514 detection method Methods 0.000 claims description 7
- 230000000977 initiatory effect Effects 0.000 claims description 3
- 230000005540 biological transmission Effects 0.000 description 8
- 238000012790 confirmation Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- OLDXRTOEUPVZKB-UHFFFAOYSA-N B1CCCC1 Chemical compound B1CCCC1 OLDXRTOEUPVZKB-UHFFFAOYSA-N 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 239000004984 smart glass Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W76/00—Connection management
- H04W76/10—Connection setup
- H04W76/19—Connection re-establishment
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W76/00—Connection management
- H04W76/10—Connection setup
- H04W76/18—Management of setup rejection or failure
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W4/00—Services specially adapted for wireless communication networks; Facilities therefor
- H04W4/80—Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W76/00—Connection management
- H04W76/10—Connection setup
- H04W76/14—Direct-mode setup
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Mobile Radio Communication Systems (AREA)
- Telephone Function (AREA)
Abstract
The invention discloses equipment and a system for controlling data interaction and a working method thereof, wherein the method for controlling data interaction comprises the following steps: after the terminal equipment establishes connection with the Bluetooth key, generating and displaying a random number; the terminal equipment sends the random number to the Bluetooth key and waits for receiving data returned by the Bluetooth key; the Bluetooth key receives the random number and then displays the random number and prompts a user to confirm the random number; when the Bluetooth key detects that the key is pressed down, corresponding data is returned to the terminal equipment; and the terminal equipment judges whether the received data is a preset value, if so, normal data interaction with the Bluetooth key is started, and if not, the connection with the Bluetooth key is disconnected. According to the technical scheme, the process of comparing the random number by the user is added, so that the Bluetooth key in the hand of the user can be connected by the target terminal equipment, the interference of other equipment is prevented, and the safety of normal data interaction between the terminal equipment and the Bluetooth key is improved.
Description
Technical Field
The invention relates to the field of electronic products, in particular to a device and a system for controlling data interaction and a working method thereof.
Background
With the rapid development of mobile communication technology, more and more intelligent terminals, such as notebook computers, wireless headsets, smart phones, smart glasses, smart bracelets and the like, begin to adopt bluetooth technology for near field wireless communication. The existing connection of the Bluetooth key usually needs to pass key authentication, a peripheral device list of which the Bluetooth is started is obtained when a Bluetooth module is started to scan peripheral Bluetooth devices, and then the Bluetooth key to be connected is selected and a password is input to carry out identity verification, and then a connection channel with the Bluetooth key can be established. Because the low-power-consumption Bluetooth key does not need the confirmation of the user, as long as the low-power-consumption Bluetooth key is in the range capable of being scanned, the intelligent terminals such as mobile phones can be connected with the low-power-consumption Bluetooth key and can communicate with the Bluetooth key, and the situation not only brings inconvenience to the use of the user, but also has potential safety hazards.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides equipment and a system for controlling data interaction and a working method thereof.
The invention provides a method for controlling data interaction, which comprises the following steps:
step S1: after the terminal equipment establishes connection with the Bluetooth key, generating and displaying a random number;
step S2: the terminal equipment sends the random number to the Bluetooth key and waits for receiving data returned by the Bluetooth key;
step S3: the Bluetooth key receives the random number and then displays the random number and prompts a user to confirm the random number;
step S4: when the Bluetooth key detects that the key is pressed down, corresponding data is returned to the terminal equipment;
step S5: and the terminal equipment judges whether the received data is a preset value, if so, normal data interaction with the Bluetooth key is started, and if not, the terminal equipment is disconnected from the Bluetooth key.
Wherein, before the step S1, the method includes:
step A1: the terminal equipment judges whether the terminal equipment supports the low-power-consumption Bluetooth key, if so, the step A2 is executed, otherwise, an error is reported, and the operation is finished;
step A2: the terminal equipment judges whether the connection with the Bluetooth key is established, if so, the step S1 is executed, otherwise, the step A3 is executed;
step A3: and the terminal equipment initiates connection to the Bluetooth key and judges whether the connection is successful, if so, step S1 is executed, otherwise, an error is reported, and the operation is finished.
Wherein, the step A1 and the step A2 comprise:
step P1: the terminal equipment judges whether the Bluetooth of the terminal equipment is started, if so, the step P2 is executed, otherwise, the user is prompted to manually start the Bluetooth, and when the Bluetooth is started, the step P2 is executed;
step P2: and the terminal equipment instantiates the Bluetooth configuration file callback class and registers the callback function.
Wherein, the step a3 specifically includes: and the terminal equipment initiates connection to the Bluetooth key through a first function, calls a first callback function, judges whether the connection is successful or not through a third parameter of the first callback function, if so, executes the step S1, otherwise, reports an error, and ends.
Wherein, the step A3 and the step S1 comprise:
step B1: the terminal equipment acquires the monitoring characteristic value of the Bluetooth key;
step B2: and the terminal equipment judges whether to start data receiving notification, if so, the step S1 is executed, and if not, the connection with the Bluetooth key is disconnected.
Wherein the step S1 further includes: the terminal equipment sets the time for waiting for the key pressing of the user;
after the step B1, the method further comprises: and when the terminal equipment detects that the data returned by the Bluetooth key is not received within the time of waiting for the key pressing of the user, the terminal equipment is disconnected from the Bluetooth key.
Wherein, the step S1 and the step S2 include:
step C1: the terminal equipment acquires the data writing characteristic value of the Bluetooth key and sets a data writing mode;
step C2: the terminal equipment judges whether the number of times of sending the random number is less than the preset number of times of failed retransmission, if so, step S2 is executed, otherwise, the terminal equipment is disconnected from the Bluetooth key;
between the step S2 and the step S3: and the terminal equipment judges whether the random number is successfully transmitted, if so, the step S3 is executed, otherwise, the random number transmitting times is updated, and the step S2 is returned.
Wherein, the step S1 and the step S2 include: the terminal equipment acquires the data writing characteristic value of the Bluetooth key and sets a data writing mode;
between the step S2 and the step S3:
step D1: the terminal equipment judges whether the random number is successfully sent, if so, the step S3 is executed, otherwise, the step D2 is executed;
step D2: and the terminal equipment judges whether the number of times of sending the random number is equal to the preset number of times of failed retransmission, if so, the number of times of sending the random number is updated, the step S2 is returned, and if not, the terminal equipment is disconnected from the Bluetooth key.
Wherein, between the step S4 and the step S5, the method further comprises:
and the terminal equipment judges whether data are received within preset time, if so, step S5 is carried out, and if not, the connection with the Bluetooth key is disconnected. The invention provides a system for controlling data interaction, which comprises a terminal device and a Bluetooth key, wherein the terminal device comprises:
the generation display module is used for generating and displaying the random number after the terminal equipment is connected with the Bluetooth key;
the first sending module is used for sending the random number to the Bluetooth key;
the first receiving module is used for receiving the data returned by the Bluetooth key;
the first judging module is used for judging whether the data received by the first receiving module is a preset value or not;
the first interaction module is used for starting normal data interaction with the Bluetooth key when the first judgment module judges that the Bluetooth key is the Bluetooth key;
the first disconnection module is used for disconnecting the terminal equipment from the Bluetooth key when the first judgment module judges that the terminal equipment is not connected with the Bluetooth key;
the bluetooth key includes:
a second receiving module, configured to receive the random number sent by the terminal device;
the display module is used for displaying the random number received by the second receiving module and prompting a user to confirm;
the detection module is used for detecting whether the key is pressed down;
the second sending module is used for returning corresponding data to the terminal equipment when the detection module detects that the key is pressed;
and the second interaction module is used for carrying out normal data interaction with the terminal equipment.
Wherein, the terminal equipment still includes:
the second judgment module is used for judging whether the Bluetooth module supports the low-power consumption key, if so, the third judgment module is triggered, and if not, an error is reported, and the operation is finished;
the third judging module is used for judging whether connection with the Bluetooth key is established or not, if so, the generating and displaying module is triggered, and if not, the connection judging module is triggered;
and the connection judging module is used for initiating connection to the Bluetooth key and judging whether the connection is successful, if so, triggering the generation display module, otherwise, reporting an error and ending.
Wherein, the terminal equipment still includes:
the judgment prompting module is used for judging whether the Bluetooth of the user is started, if so, triggering the registration module, otherwise, prompting the user to manually start the Bluetooth, and triggering the registration module after the Bluetooth is started;
and the registration module is used for instantiating the Bluetooth configuration file callback class and registering the callback function after the Bluetooth is started.
The connection judging module is specifically configured to initiate a connection to the bluetooth key through a first function, call a first callback function, and judge whether the connection is successful through a third parameter of the first callback function, if so, trigger the generation display module, otherwise, report an error, and end.
Wherein, the terminal equipment still includes:
the first acquisition module is used for acquiring the monitoring characteristic value of the Bluetooth key;
and the fourth judgment module is used for judging whether to start receiving the data notification, if so, the generation display module is triggered, and otherwise, the first disconnection module is triggered.
Wherein, the terminal equipment still includes:
the setting module is used for setting the time for waiting for the key pressing of the user;
the first disconnection module is further configured to disconnect the bluetooth key when the terminal device detects that data returned by the bluetooth key is not received within the time of waiting for the user to press the key.
Wherein, the terminal equipment still includes:
the acquisition setting module is used for acquiring the data writing characteristic value of the Bluetooth key and setting a data writing mode;
a fifth judging module, configured to judge whether the number of times of sending the random number is less than a preset number of times of failed retransmission, if so, trigger the first sending module, and otherwise, trigger the first disconnection module;
and the sixth judging module is used for judging whether the random number is successfully sent, if so, waiting for receiving the data returned by the Bluetooth key, otherwise, updating the random number sending times and triggering the first sending module.
Wherein, the terminal equipment still includes:
the acquisition setting module is used for acquiring the data writing characteristic value of the Bluetooth key and setting a data writing mode;
the seventh judging module is used for judging whether the random number is successfully sent, if so, waiting for receiving the data returned by the Bluetooth key, and otherwise, triggering the eighth judging module;
the eighth judging module is configured to judge whether the number of times of sending the random number is equal to a preset number of times of failed retransmission, if so, update the number of times of sending the random number, and trigger the first sending module, otherwise, trigger the first disconnection module.
Wherein, the terminal equipment still includes:
and the ninth judging module is used for judging whether data are received within preset time, if so, the first judging module is triggered, and otherwise, the first disconnecting module is triggered.
The invention provides a device for controlling data interaction, which comprises:
the receiving module is used for receiving the random number sent by the terminal equipment;
the display module is used for displaying the random number received by the receiving module and prompting a user to confirm;
the detection module is used for detecting whether the key is pressed down;
the sending module is used for returning corresponding data to the terminal equipment when the detection module detects that the key is pressed;
and the interaction module is used for carrying out normal data interaction with the terminal equipment.
The invention provides a working method of equipment for controlling data interaction, which comprises the following steps:
step P1: the equipment for controlling data interaction receives the random number sent by the terminal equipment and then displays the random number and prompts a user to confirm the random number;
step P2: when the equipment for controlling data interaction detects that the key is pressed down, corresponding data are returned to the terminal equipment;
step P3: and the equipment for controlling data interaction performs normal data interaction with the terminal equipment.
Compared with the prior art, the invention has the following advantages:
according to the technical scheme, the process of comparing the random number by the user is added, so that the Bluetooth key in the hand of the user can be connected by the target terminal equipment, the interference of other equipment is prevented, and the safety of normal data interaction between the terminal equipment and the Bluetooth key is improved.
Drawings
Fig. 1 is a flowchart of a method for controlling data interaction according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for controlling data interaction according to a second embodiment of the present invention;
fig. 3 is a block diagram of a system for controlling data interaction according to a third embodiment of the present invention;
fig. 4 is a block diagram of an apparatus for controlling data interaction according to a fourth embodiment of the present invention;
fig. 5 is a flowchart of a method for controlling a data interaction device according to a fifth embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
An embodiment of the present invention provides a method for controlling data interaction, as shown in fig. 1, including:
step S1: after the terminal equipment establishes connection with the Bluetooth key, generating and displaying a random number;
step S2: the terminal equipment sends the random number to the Bluetooth key and waits for receiving data returned by the Bluetooth key;
step S3: the Bluetooth key receives the random number and then displays the random number and prompts a user to confirm the random number;
in this embodiment, if the random number displayed on the bluetooth key is the same as the random number displayed on the terminal device, the user presses the enter key, and if the random number is not the same, the user presses the cancel key;
specifically, in this embodiment, the bluetooth key does not process data sent by the terminal device if the bluetooth key receives the data sent by the terminal device while waiting for the key information of the user;
step S4: when the Bluetooth key detects that the key is pressed down, corresponding data is returned to the terminal equipment;
specifically, the corresponding data in this embodiment may be key information or other data corresponding to the key information one to one;
preferably, in this embodiment, between step S4 and step S5, the method further includes: the terminal equipment judges whether data are received within preset time, if so, step S5 is carried out, otherwise, the connection with the Bluetooth key is disconnected;
step S5: the terminal equipment judges whether the received data is a preset value, if so, normal data interaction with the Bluetooth key is started, and if not, the connection with the Bluetooth key is disconnected;
in this embodiment, if the terminal device determines that the received data is the predetermined value, success information may be further prompted, and if the received data is not the predetermined value, failure information may be further prompted.
Example two
An embodiment of the present invention provides a method for controlling data interaction, as shown in fig. 2, including:
step 101: the terminal equipment judges whether the terminal equipment supports the low-power-consumption Bluetooth key, if so, the step 102 is executed, otherwise, an error is reported, and the operation is finished;
step 102: the terminal equipment judges whether the Bluetooth of the terminal equipment is opened, if so, the step 103 is executed, otherwise, the user is prompted to manually start the Bluetooth, and when the Bluetooth is opened, the step 103 is executed;
preferably, in this embodiment, when the bluetooth is not turned on after the preset time period, the terminal device reports an error, and the process is ended;
step 103: the terminal equipment instantiates a Bluetooth configuration file callback class and registers a callback function;
in this embodiment, the bluetooth profile callback class specifically includes: a bluetoothgattcalback () class; the callback functions comprise a first callback function, a second callback function, a third callback function, a fourth callback function and a fifth callback function; specifically, the method comprises the following steps:
the first callback function is onConnectionStateChange (bluetooth gatt, int status, int newState), and is used for judging the connection state, wherein the third parameter newState represents connection or disconnection, and the second parameter status represents whether connection or disconnection is successful;
the second callback function is onservices discovered (bluetooth gatt, int status) for obtaining service;
the third callback function is onCharacteristics write (Bluetooth Gartt, Bluetooth Gartchatteric communication, int status) for judging whether the data is successfully sent;
the fourth callback function is onCharacteriodicalchanged (Bluetooth Gartt, Bluetooth Garttchastical charateristic) and is used for receiving data returned by the Bluetooth key;
the fifth callback function is onDescriptorWrite (Bluetooth Gattgatt, Bluetooth GattDescriptor descriptor, int status): the device is used for judging whether the monitoring is successfully opened;
specifically, in this embodiment, step 103 includes: defining an internal class GattCallback, which inherits to a Bluetooth GattCallback () virtual base class and covers a first callback function, a second callback function, a third callback function, a fourth callback function and a fifth callback function in the virtual base class;
step 104: the terminal equipment judges whether the connection with the Bluetooth key is established, if so, step 106 is executed, otherwise, step 105 is executed;
in this embodiment, the terminal device determines whether the connection identifier is set, if so, the terminal device is already connected with the bluetooth key, otherwise, the terminal device is not connected with the bluetooth key;
step 105: and the terminal equipment initiates connection to the Bluetooth key and judges whether the connection is successful, if so, step 106 is executed, otherwise, an error is reported, and the process is finished.
Specifically, in this embodiment, the terminal device initiates a connection to the bluetooth Key through the first function, and calls back the first callback function, and determines whether the connection is successful through the third parameter of the first callback function, if so, step 106 is executed, otherwise, an error is reported, and the process is ended;
in this embodiment, after the terminal device is successfully connected with the bluetooth key, the connection identifier is set;
specifically, the first function is: connectitgatt (Context, borolan autoConnect, bluetooth gattcallback callback);
step 106: the terminal equipment acquires a monitoring characteristic value of the Bluetooth key;
specifically, in this embodiment, the terminal device calls a system function to obtain a monitoring characteristic value of the currently connected bluetooth key, and starts monitoring through the second function;
the second function in this embodiment is specifically setcharateristic notification (bluetooth garttcharateristic characteristics, bootean enable);
in this embodiment, step 106 specifically includes: the method comprises the steps that a terminal device calls a Bluetooth gateway (UUID _ SERVICE) to acquire a SERVICE corresponding to a UUID _ SERVICE value, and then the SERVICE calls a Bluetooth gateway (UUID _ CHAR _ NOTIF) to acquire a feature value corresponding to the UUID _ CHAR _ NOTIF, namely a notification feature value of a currently connected Bluetooth key;
step 107: the terminal equipment judges whether to start the data receiving notification, if so, step 108 is executed, otherwise, the connection with the Bluetooth key is disconnected;
specifically, in this embodiment, the terminal device determines whether to start the received data notification according to a third parameter in the fifth callback function, if the status is bluetooth gatt.
Step 108: the terminal equipment generates and displays a random number with a preset length, and sets time for waiting for a user to press keys;
specifically, in this embodiment, the preset length is 6 bits;
in this embodiment, the timeout time is set to 3 seconds, and if the user presses a key overtime, the terminal device actively or passively disconnects;
step 109: the terminal equipment acquires the data writing characteristic value of the Bluetooth key and sets a data writing mode;
in this embodiment, the setting of the write data specifically includes: setting a data writing mode as WRITE _ TYPE _ DEFAULT through a third function; specifically, the third function is setWriteType (int writeType);
specifically, in this embodiment, step 109 includes: the method comprises the steps that a terminal device calls a Bluetooth gateway (UUID _ SERVICE) to obtain a SERVICE corresponding to a UUID _ SERVICE value, and then the SERVICE calls a Bluetooth gateway (UUID _ CHAR _ WRITE) to obtain a characteristic value corresponding to the UUID _ CHAR _ WRITE, namely a WRITE data characteristic value of a currently connected Bluetooth Key;
step 110: the terminal equipment sets the number of times of failed retransmission, initializes the number of times of currently transmitted random numbers, initializes a transmission result mark and sets the time of waiting for the transmission result;
specifically, in this embodiment, the number of times of failed retransmission is set as a first value, the number of times of initializing random number transmission is set as a second value, the flag of initializing transmission result is false, and the time of waiting for transmission result is set as 2 s; preferably, the first value is 5 and the second value is 0;
step 111: the terminal equipment judges whether the number of times of sending the random number is less than the number of times of failure retransmission, if so, step 112 is executed, otherwise, the connection with the Bluetooth Key is disconnected;
step 112: the terminal equipment updates and sends the random number times, sends the random number to the Bluetooth key and waits for receiving a result returned by the Bluetooth key;
in this embodiment, the terminal device writes the random number into the write data feature value through a fourth function, and then sends the random number to the bluetooth key through a fifth function, specifically, the fourth function is setValue; the fifth function is writecharateristic (Bluetooth GarttCharacteristic characteristics);
in the embodiment, the terminal equipment acquires the result returned by the Bluetooth key by calling the fourth callback function; before the fourth callback function is called, the method further comprises: the terminal equipment judges whether a data writing mode is set or not, if so, a fourth callback function is called to obtain a result returned by the Bluetooth key, and if not, an error is reported, and the process is finished;
step 113: the terminal equipment judges whether the random number is successfully sent, if so, the step 114 is executed, otherwise, the step 111 is returned;
in this embodiment, the terminal device determines whether the random number is successfully transmitted according to the transmission result identifier, specifically, sets a transmission result flag according to a parameter value of the third callback function, where the random number is successfully transmitted if the transmission result flag is true, and otherwise, the random number is failed to be transmitted;
step 114: after receiving the random number, the Bluetooth key displays the random number and prompts a user to confirm;
specifically, in this embodiment, the user compares whether the random number displayed on the mobile phone is consistent with the random number displayed on the bluetooth key, if so, presses the enter key, otherwise, presses the cancel key;
step 115: when the Bluetooth key detects that the key is pressed down, corresponding data is returned to the terminal equipment;
in the embodiment, for example, when the user presses the confirmation key, the bluetooth key returns to the terminal device 10, and when the user presses the cancel key, the bluetooth key returns to the terminal device 20;
in this embodiment, when the bluetooth key does not receive the user key information within the waiting time for the user key, the bluetooth key disconnects from the terminal device.
Step 116: the terminal equipment judges whether data returned by the Bluetooth key is received within the key pressing time of the user, if so, step 117 is executed, otherwise, the connection between the terminal equipment and the Bluetooth key is disconnected, and overtime information is prompted;
step 117: the terminal equipment judges whether the data returned by the Bluetooth key is a preset value, if so, successful information is prompted, normal data interaction with the Bluetooth key is started, and if not, the connection with the Bluetooth key is disconnected, and failed information is prompted;
in this embodiment, the terminal device calls back the fourth callback function, calls the sixth function according to the first parameter (i.e., the monitoring characteristic value) of the fourth callback function to obtain the data returned by the bluetooth key, and if the bluetooth key returns to 10, the connection is successful, otherwise, the connection fails. Specifically, the fourth callback function is: onCharacteriodcChanged (), the first parameter is: characteriostic, the sixth function is getValue ().
In this embodiment, step 111 may be executed when step 113 determines no, that is, when step 113 determines no, the following steps are executed: the terminal equipment judges whether the number of times of sending the random number is equal to the number of times of failed retransmission, if so, the terminal equipment is disconnected from the Bluetooth key, otherwise, the step 112 is returned;
after the terminal equipment such as a mobile phone and the like is connected with the Bluetooth key, the terminal equipment sends a random number (generally 6 bits) to the Bluetooth key, the Bluetooth key receives and displays the random number, a user compares the random number displayed by the Bluetooth key with the random number displayed by the terminal, if the random number is consistent with the random number displayed by the terminal, the user presses a confirmation key to start normal data interaction, and if the random number is not consistent with the random number, the user presses a cancel key to disconnect the connection between the terminal equipment and the Bluetooth key. Therefore, the data interaction between the terminal equipment and the Bluetooth key can be ensured to be safe through the participation of the user.
EXAMPLE III
An embodiment of the present invention provides a system for controlling data interaction, as shown in fig. 3, including a terminal device 20 and a bluetooth key30, where the terminal device 20 includes:
the generation display module 201 is used for generating and displaying a random number after the terminal equipment establishes connection with the Bluetooth key;
a first sending module 202, configured to send the random number to the bluetooth key 30;
the first receiving module 203 is used for receiving data returned by the Bluetooth key 30;
a first judging module 204, configured to judge whether the data received by the first receiving module 203 is a predetermined value;
the first interaction module 205 is configured to start normal data interaction with the bluetooth key30 when the first determination module 204 determines that the bluetooth key30 is yes;
a first disconnection module 206 configured to disconnect the terminal device 20 from the bluetooth key30 when the first determination module 204 determines no;
bluetooth key30 includes:
a second receiving module 301, configured to receive a random number sent by the terminal device 20;
a display module 302, configured to display the random number received by the second receiving module 301 and prompt the user to confirm;
a detecting module 303, configured to detect whether a key is pressed;
the keys in the embodiment comprise a confirmation key and a cancel key;
a second sending module 304, configured to return corresponding data to the terminal device 20 when the detection module 303 detects that the key is pressed;
the corresponding data in this embodiment may be key values or other data corresponding to the key values one to one;
and a second interaction module 305, configured to perform normal data interaction with the terminal device 20.
In this embodiment, the terminal device 20 further includes:
the second judgment module is used for judging whether the Bluetooth module supports the low-power consumption key, if so, the third judgment module is triggered, and if not, an error is reported, and the operation is finished;
the third judging module is used for judging whether the connection with the Bluetooth key is established, if so, the display generating module 201 is triggered, and if not, the connection judging module is triggered;
and the connection judging module is used for initiating connection to the Bluetooth key and judging whether the connection is successful, if so, the display generating module 201 is triggered, and if not, an error is reported and the process is finished.
Specifically, in this embodiment, the connection determining module is specifically configured to initiate a connection to the bluetooth key through the first function, call the first callback function, and determine whether the connection is successful through the third parameter of the first callback function, if so, trigger the generation display module 201, otherwise, report an error, and end.
In this embodiment, the terminal device 20 further includes:
the judgment prompting module is used for judging whether the Bluetooth of the user is started, if so, triggering the registration module, otherwise, prompting the user to manually start the Bluetooth, and triggering the registration module after the Bluetooth is started;
and the registration module is used for instantiating the callback class of the Bluetooth configuration file and registering the callback function after the Bluetooth is started.
In this embodiment, the terminal device 20 further includes:
the first acquisition module is used for acquiring the monitoring characteristic value of the Bluetooth key;
and a fourth judging module, configured to judge whether to start receiving the data notification, if so, trigger the connection judging module, and otherwise trigger the generation and display module 201.
In this embodiment, the terminal device 20 further includes:
the setting module is used for setting the time for waiting for the key pressing of the user;
the first disconnection module 206 is further configured to disconnect the bluetooth key when the terminal device detects that data returned by the bluetooth key is not received within the time of waiting for the user to press the key.
In this embodiment, the terminal device 20 further includes: the setting module is used for setting the time for waiting for the key pressing of the user;
bluetooth key30 also includes: and the second disconnection module is used for disconnecting the connection with the terminal equipment when the Bluetooth key does not receive the key information of the user within the time of waiting for the key pressing of the user.
In this embodiment, the terminal device 20 further includes:
the acquisition setting module is used for acquiring the data writing characteristic value of the Bluetooth key and setting a data writing mode;
a fifth judging module, configured to judge whether the number of times of sending the random number is less than a preset number of times of failed retransmission, if so, trigger the first sending module 202, and otherwise trigger the first disconnecting module 206;
and a sixth judging module, configured to judge whether the random number is successfully sent, if so, wait to receive data returned by the bluetooth key, otherwise, update the number of times of sending the random number, and trigger the first sending module 202.
The sixth determining module in this embodiment is specifically configured to determine whether the random number is successfully sent according to the sending result identifier, wait to receive data returned by the bluetooth key if the sending identifier is a preset value, and otherwise update the number of times of sending the random number, and trigger the first sending module 202.
In this embodiment, the terminal device 20 further includes:
the acquisition setting module is used for acquiring the data writing characteristic value of the Bluetooth key and setting a data writing mode;
the seventh judging module is used for judging whether the random number is successfully sent, if so, waiting for receiving data returned by the Bluetooth key, and otherwise, triggering the eighth judging module;
specifically, the seventh determining module in this embodiment is specifically configured to determine whether the random number is successfully sent according to the sending result identifier, wait to receive data returned by the bluetooth key if the sending identifier is a preset value, and trigger the eighth determining module if the sending identifier is not a preset value;
an eighth determining module, configured to determine whether the number of times of sending the random number is equal to a preset number of times of failed retransmission, if so, update the number of times of sending the random number, and trigger the first sending module 202, otherwise, trigger the first disconnecting module 206.
The terminal device 20 in this embodiment may further include: a ninth determining module, configured to determine whether data is received within a preset time, if so, trigger the first determining module 204, otherwise, trigger the first disconnecting module 206.
Example four
The fourth embodiment of the invention provides equipment for controlling data interaction, and particularly the equipment is a Bluetooth key. As shown in fig. 4, the bluetooth key includes:
a receiving module 401, configured to receive a random number sent by a terminal device;
a display module 402, configured to display the random number received by the receiving module 401 and prompt the user to confirm;
a detecting module 403, configured to detect whether a key is pressed;
a sending module 404, configured to return corresponding data to the terminal device when the detecting module 403 detects that the key is pressed;
and the interaction module 405 is configured to perform normal data interaction with the terminal device.
EXAMPLE five
The fifth embodiment of the present invention provides a working method of a device for controlling data interaction, where in this embodiment, the device is a bluetooth key. As shown in fig. 5, the working method of the bluetooth key includes:
step P1: the Bluetooth key receives the random number sent by the terminal equipment and then displays the random number and prompts a user to confirm the random number;
specifically, in this embodiment, the user compares whether the random number displayed on the mobile phone is consistent with the random number displayed on the bluetooth key, if so, presses the enter key, otherwise, presses the cancel key; if the Bluetooth key receives the data sent by the terminal equipment in the process of waiting for the key information of the user, the Bluetooth key does not process the data;
step P2: when the Bluetooth key detects that the key is pressed down, corresponding data is returned to the terminal equipment;
step P3: and normal data interaction is carried out between the Bluetooth key and the terminal equipment.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (16)
1. A method of controlling data interaction, comprising:
step S1: after the terminal equipment establishes connection with the Bluetooth key, generating and displaying a random number;
step S2: the terminal equipment sends the random number to the Bluetooth key and waits for receiving data returned by the Bluetooth key;
step S3: the Bluetooth key receives the random number and then displays the random number and prompts a user to confirm the random number;
step S4: when the Bluetooth key detects that the key is pressed down, corresponding data is returned to the terminal equipment;
step S5: the terminal equipment judges whether the received data is a preset value, if so, normal data interaction with the Bluetooth key is started, and if not, the connection with the Bluetooth key is disconnected;
the step S1 is preceded by:
step A1: the terminal equipment judges whether the terminal equipment supports the low-power-consumption Bluetooth key, if so, the step A2 is executed, otherwise, an error is reported, and the operation is finished;
step A2: the terminal equipment judges whether the connection with the Bluetooth key is established, if so, the step S1 is executed, otherwise, the step A3 is executed;
step A3: and the terminal equipment initiates connection to the Bluetooth key and judges whether the connection is successful, if so, step S1 is executed, otherwise, an error is reported, and the operation is finished.
2. The method of claim 1, wherein between the step a1 and the step a2 comprises:
step P1: the terminal equipment judges whether the Bluetooth of the terminal equipment is started, if so, the step P2 is executed, otherwise, the user is prompted to manually start the Bluetooth, and when the Bluetooth is started, the step P2 is executed;
step P2: and the terminal equipment instantiates the Bluetooth configuration file callback class and registers the callback function.
3. The method according to claim 2, wherein the step a3 specifically comprises: and the terminal equipment initiates connection to the Bluetooth key through a first function, calls a first callback function, judges whether the connection is successful or not through a third parameter of the first callback function, if so, executes the step S1, otherwise, reports an error, and ends.
4. The method of claim 1, wherein between the step a3 and the step S1 comprises:
step B1: the terminal equipment acquires the monitoring characteristic value of the Bluetooth key;
step B2: and the terminal equipment judges whether to start data receiving notification, if so, the step S1 is executed, and if not, the connection with the Bluetooth key is disconnected.
5. The method of claim 4, wherein the step S1 further comprises: the terminal equipment sets the time for waiting for the key pressing of the user;
after the step B1, the method further comprises: and when the terminal equipment detects that the data returned by the Bluetooth key is not received within the time of waiting for the key pressing of the user, the terminal equipment is disconnected from the Bluetooth key.
6. The method of claim 1, wherein between the step S1 and the step S2 comprises:
step C1: the terminal equipment acquires the data writing characteristic value of the Bluetooth key and sets a data writing mode;
step C2: the terminal equipment judges whether the number of times of sending the random number is less than the preset number of times of failed retransmission, if so, step S2 is executed, otherwise, the terminal equipment is disconnected from the Bluetooth key;
between the step S2 and the step S3: and the terminal equipment judges whether the random number is successfully transmitted, if so, the step S3 is executed, otherwise, the random number transmitting times is updated, and the step S2 is returned.
7. The method of claim 1, wherein between the step S1 and the step S2 comprises: the terminal equipment acquires the data writing characteristic value of the Bluetooth key and sets a data writing mode;
between the step S2 and the step S3:
step D1: the terminal equipment judges whether the random number is successfully sent, if so, the step S3 is executed, otherwise, the step D2 is executed;
step D2: and the terminal equipment judges whether the number of times of sending the random number is equal to the preset number of times of failed retransmission, if so, the number of times of sending the random number is updated, the step S2 is returned, and if not, the terminal equipment is disconnected from the Bluetooth key.
8. The method of claim 1, wherein between the step S4 and the step S5 further comprising:
and the terminal equipment judges whether data are received within preset time, if so, step S5 is carried out, and if not, the connection with the Bluetooth key is disconnected.
9. A system for controlling data interaction is characterized by comprising a terminal device and a Bluetooth key, wherein the terminal device comprises:
the generation display module is used for generating and displaying the random number after the terminal equipment is connected with the Bluetooth key;
the first sending module is used for sending the random number to the Bluetooth key;
the first receiving module is used for receiving the data returned by the Bluetooth key;
the first judging module is used for judging whether the data received by the first receiving module is a preset value or not;
the first interaction module is used for starting normal data interaction with the Bluetooth key when the first judgment module judges that the Bluetooth key is the Bluetooth key;
the first disconnection module is used for disconnecting the terminal equipment from the Bluetooth key when the first judgment module judges that the terminal equipment is not connected with the Bluetooth key;
the bluetooth key includes:
a second receiving module, configured to receive the random number sent by the terminal device;
the display module is used for displaying the random number received by the second receiving module and prompting a user to confirm;
the detection module is used for detecting whether the key is pressed down;
the second sending module is used for returning corresponding data to the terminal equipment when the detection module detects that the key is pressed;
the second interaction module is used for carrying out normal data interaction with the terminal equipment;
the second judgment module is used for judging whether the Bluetooth module supports the low-power consumption key, if so, the third judgment module is triggered, and if not, an error is reported, and the operation is finished;
the third judging module is used for judging whether connection with the Bluetooth key is established or not, if so, the generating and displaying module is triggered, and if not, the connection judging module is triggered;
and the connection judging module is used for initiating connection to the Bluetooth key and judging whether the connection is successful, if so, triggering the generation display module, otherwise, reporting an error and ending.
10. The system of claim 9, wherein the terminal device further comprises:
the judgment prompting module is used for judging whether the Bluetooth of the user is started, if so, triggering the registration module, otherwise, prompting the user to manually start the Bluetooth, and triggering the registration module after the Bluetooth is started;
and the registration module is used for instantiating the Bluetooth configuration file callback class and registering the callback function after the Bluetooth is started.
11. The system of claim 10, wherein the connection determining module is specifically configured to initiate a connection to the bluetooth key through a first function, call a first callback function, and determine whether the connection is successful through a third parameter of the first callback function, if so, trigger the generation display module, otherwise, report an error, and end.
12. The system of claim 9, wherein the terminal device further comprises:
the first acquisition module is used for acquiring the monitoring characteristic value of the Bluetooth key;
and the fourth judgment module is used for judging whether to start receiving the data notification, if so, the generation display module is triggered, and otherwise, the first disconnection module is triggered.
13. The system of claim 12, wherein the terminal device further comprises:
the setting module is used for setting the time for waiting for the key pressing of the user;
the first disconnection module is further configured to disconnect the bluetooth key when the terminal device detects that data returned by the bluetooth key is not received within the time of waiting for the user to press the key.
14. The system of claim 9, wherein the terminal device further comprises:
the acquisition setting module is used for acquiring the data writing characteristic value of the Bluetooth key and setting a data writing mode;
a fifth judging module, configured to judge whether the number of times of sending the random number is less than a preset number of times of failed retransmission, if so, trigger the first sending module, and otherwise, trigger the first disconnection module;
and the sixth judging module is used for judging whether the random number is successfully sent, if so, waiting for receiving the data returned by the Bluetooth key, otherwise, updating the random number sending times and triggering the first sending module.
15. The system of claim 9, wherein the terminal device further comprises:
the acquisition setting module is used for acquiring the data writing characteristic value of the Bluetooth key and setting a data writing mode;
the seventh judging module is used for judging whether the random number is successfully sent, if so, waiting for receiving the data returned by the Bluetooth key, and otherwise, triggering the eighth judging module;
the eighth judging module is configured to judge whether the number of times of sending the random number is equal to a preset number of times of failed retransmission, if so, update the number of times of sending the random number, and trigger the first sending module, otherwise, trigger the first disconnection module.
16. The system of claim 9, wherein the terminal device further comprises:
and the ninth judging module is used for judging whether data are received within preset time, if so, the first judging module is triggered, and otherwise, the first disconnecting module is triggered.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610423079.8A CN106211355B (en) | 2016-06-15 | 2016-06-15 | Equipment and system for controlling data interaction and working method thereof |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610423079.8A CN106211355B (en) | 2016-06-15 | 2016-06-15 | Equipment and system for controlling data interaction and working method thereof |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106211355A CN106211355A (en) | 2016-12-07 |
CN106211355B true CN106211355B (en) | 2019-12-20 |
Family
ID=57453292
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610423079.8A Active CN106211355B (en) | 2016-06-15 | 2016-06-15 | Equipment and system for controlling data interaction and working method thereof |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106211355B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11751260B2 (en) | 2017-06-24 | 2023-09-05 | Kaha Pte. Ltd. | Apparatus and method of identifying for pairing one or more devices with a master device |
CN108681408A (en) * | 2018-05-02 | 2018-10-19 | 广州市品众电子科技有限公司 | A kind of method and bluetooth keyboard for realizing that bluetooth keyboard is connect with game of mobile terminal |
CN112965358B (en) * | 2019-11-28 | 2023-01-20 | Oppo广东移动通信有限公司 | Wearable device, control method, and computer-readable storage medium |
CN110913380B (en) * | 2019-12-19 | 2023-09-22 | 飞天诚信科技股份有限公司 | Method and device for communication with Bluetooth equipment based on applet platform |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104967971A (en) * | 2015-06-26 | 2015-10-07 | 飞天诚信科技股份有限公司 | Method achieving bluetooth automatic return connection in Android system |
CN105450269A (en) * | 2015-12-21 | 2016-03-30 | 飞天诚信科技股份有限公司 | Method and device for realizing safe interaction and pairing authentication between Bluetooth devices |
CN105472776A (en) * | 2015-11-17 | 2016-04-06 | 飞天诚信科技股份有限公司 | Method for establishing Bluetooth connection and Bluetooth smart key device |
CN105517110A (en) * | 2015-11-24 | 2016-04-20 | 飞天诚信科技股份有限公司 | Method and apparatus for connecting bluetooth device |
CN105577688A (en) * | 2016-01-30 | 2016-05-11 | 飞天诚信科技股份有限公司 | Binding method and apparatus based on Bluetooth device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103428000A (en) * | 2013-08-27 | 2013-12-04 | 深圳市文鼎创数据科技有限公司 | Information authentication method and system |
CN105430603A (en) * | 2015-12-03 | 2016-03-23 | 北京握奇智能科技有限公司 | Secure connection method and system for Bluetooth equipment |
-
2016
- 2016-06-15 CN CN201610423079.8A patent/CN106211355B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104967971A (en) * | 2015-06-26 | 2015-10-07 | 飞天诚信科技股份有限公司 | Method achieving bluetooth automatic return connection in Android system |
CN105472776A (en) * | 2015-11-17 | 2016-04-06 | 飞天诚信科技股份有限公司 | Method for establishing Bluetooth connection and Bluetooth smart key device |
CN105517110A (en) * | 2015-11-24 | 2016-04-20 | 飞天诚信科技股份有限公司 | Method and apparatus for connecting bluetooth device |
CN105450269A (en) * | 2015-12-21 | 2016-03-30 | 飞天诚信科技股份有限公司 | Method and device for realizing safe interaction and pairing authentication between Bluetooth devices |
CN105577688A (en) * | 2016-01-30 | 2016-05-11 | 飞天诚信科技股份有限公司 | Binding method and apparatus based on Bluetooth device |
Also Published As
Publication number | Publication date |
---|---|
CN106211355A (en) | 2016-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107257540B (en) | Method and device for realizing pairing of Bluetooth equipment and mobile equipment | |
CN104270732B (en) | Configuration method and device for call forwarding | |
CN106211355B (en) | Equipment and system for controlling data interaction and working method thereof | |
CN105139204B (en) | A kind of method and system carrying out safety certification | |
CN110944406B (en) | Link establishment method of sidelink and terminal | |
CN107770762B (en) | Method and device for establishing Bluetooth connection | |
KR101316007B1 (en) | System for calling emergency using earphone jack button of smart phone and method therefor | |
CN111464994B (en) | Method and system for realizing public search of Bluetooth equipment | |
CN105246074A (en) | Method and device for establishing connections | |
US8503998B2 (en) | Wireless communication terminal and wireless communication method | |
CN104247484A (en) | Terminal device, communication method, program, and communication system | |
CN104486761A (en) | Terminal communication method and device | |
CN108446574B (en) | Data query method, terminal and computer readable storage medium | |
CN110572508A (en) | Address book synchronization method and device, storage medium and electronic equipment | |
CN106412481B (en) | Reminding method, device and terminal based on VoLTE video calling | |
CN105827785A (en) | Method for establishing call connection, called terminal, and calling terminal | |
CN101826967A (en) | Data card and dial-up networking method | |
CN103413091B (en) | The method for supervising of malicious act and device | |
CN104796488A (en) | Information push method and device, terminal and server | |
CN109451143B (en) | Call method and mobile terminal | |
CN105491225A (en) | Control method and electronic apparatus | |
CN112583920B (en) | Push method, push device, electronic equipment and storage medium | |
CN107071859B (en) | It is connected to the network processing method, device and terminal | |
CN105898753B (en) | Short message processing method and electronic equipment | |
CN107222633A (en) | A kind of sales statistics method of testing, device, terminal |
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 | ||
OL01 | Intention to license declared | ||
OL01 | Intention to license declared |