[go: up one dir, main page]

CN110913380B - Method and device for communication with Bluetooth equipment based on applet platform - Google Patents

Method and device for communication with Bluetooth equipment based on applet platform Download PDF

Info

Publication number
CN110913380B
CN110913380B CN201911315493.7A CN201911315493A CN110913380B CN 110913380 B CN110913380 B CN 110913380B CN 201911315493 A CN201911315493 A CN 201911315493A CN 110913380 B CN110913380 B CN 110913380B
Authority
CN
China
Prior art keywords
applet
data
bluetooth
identifier
function
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911315493.7A
Other languages
Chinese (zh)
Other versions
CN110913380A (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 CN201911315493.7A priority Critical patent/CN110913380B/en
Publication of CN110913380A publication Critical patent/CN110913380A/en
Application granted granted Critical
Publication of CN110913380B publication Critical patent/CN110913380B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/03Protecting confidentiality, e.g. by encryption
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/04Key management, e.g. using generic bootstrapping architecture [GBA]
    • H04W12/041Key generation or derivation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/14Direct-mode setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W8/00Network data management
    • H04W8/18Processing of user or subscriber data, e.g. subscribed services, user preferences or user profiles; Transfer of user or subscriber data
    • H04W8/183Processing at user equipment or user record carrier
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Databases & Information Systems (AREA)
  • Telephone Function (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention discloses a method and a device for communication with Bluetooth equipment based on an applet; the method comprises the following steps: the device acquires a Bluetooth device identifier and communication data in a communication instruction; calling a starting attention characteristic value change function of the applet platform; when the seventh successful callback function is called back by the applet platform, calling the monitoring characteristic value change function monitoring characteristic value change of the applet platform; calling a sending function of the applet platform to send an acquiring length limiting instruction to the Bluetooth equipment; when the monitoring characteristic value change callback function is called back by the applet platform, acquiring length limitation data from the monitoring characteristic value change callback function; calling a sending function of the applet platform according to the length limit data to send communication data to the Bluetooth equipment; when the monitoring characteristic value change callback function is called back by the applet platform, acquiring third return data from the monitoring characteristic value change callback function; and sending the third return data to the application applet, and ending.

Description

Method and device for communication with Bluetooth equipment based on applet platform
Technical Field
The invention relates to the field of communication, in particular to a method and a device for communication with Bluetooth equipment based on an applet platform.
Background
The applet (MiniProgram) is an application which can be used without downloading, and the daily living users reach two hundred million through development of nearly two years; the method has been expanded to various fields such as subways, public transport services and the like, and social effects are continuously improved.
However, at present, a user cannot directly communicate with the bluetooth device by using an applet, that is, when the user uses the bluetooth device, the user must first install native software on the mobile device, then communicate with the bluetooth device through the native software on the mobile device, which is cumbersome and troublesome in the communication process, and occupies the memory of the mobile device.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a method and a device for communicating with Bluetooth equipment based on an applet platform.
The invention provides a method for communicating with Bluetooth equipment based on an applet platform, which comprises the following steps:
step S11: the device receives a communication instruction sent by an application applet, and obtains a Bluetooth equipment identifier and communication data in the communication instruction; connecting Bluetooth equipment, and calling a starting attention feature value change function of the applet platform by taking Bluetooth equipment identification, preset equipment service identification and preset equipment feature identification as parameters;
Step S12: when the seventh successful callback function is called back by the applet platform, the device calls the monitoring characteristic value change function monitoring characteristic value change of the applet platform; the Bluetooth equipment identification, the equipment service identification and the equipment characteristic identification are used as parameters to call a sending function of the applet platform to send an acquiring length limiting instruction to the Bluetooth equipment;
step S13: when the monitoring characteristic value change callback function is called back by the applet platform, the device acquires length limitation data from the monitoring characteristic value change callback function; according to the length limiting data, calling a sending function of the applet platform by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters to send communication data to the Bluetooth equipment;
step S14: when the monitoring characteristic value change callback function is called back by the applet platform, the device acquires third return data from the monitoring characteristic value change callback function; and sending the third return data to the application applet, and ending.
The invention also provides a device for communicating with the Bluetooth equipment based on the applet platform, which comprises a receiving and acquiring module, a connection calling module, a calling and transmitting module, an acquiring and calling module and an acquiring and transmitting module:
The receiving and acquiring module is used for receiving a communication instruction sent by the application applet and acquiring a Bluetooth device identifier and communication data in the communication instruction;
the connection calling module is used for connecting with the Bluetooth equipment calling module and calling a starting attention feature value change function of the applet platform by taking the Bluetooth equipment identifier, the preset equipment service identifier and the preset equipment feature identifier acquired by the receiving and acquiring module as parameters;
the calling and sending module is used for calling the monitoring characteristic value change function monitoring characteristic value change of the applet platform when the seventh successful callback function is called back by the applet platform; transmitting a length restriction acquiring instruction to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier acquired by the receiving and acquiring module as the transmitting functions of the parameter calling applet platform;
the acquisition calling module is used for acquiring length limitation data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function is called back by the applet platform; according to the length limit data acquired by the receiving and acquiring module, the Bluetooth equipment identification, the equipment service identification and the equipment characteristic identification are taken as parameters to call a sending function of the applet platform to send communication data to the Bluetooth equipment;
The acquisition and transmission module is used for acquiring third return data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function is called back by the applet platform; and sending the third return data to the application applet, and ending.
Compared with the prior art, the invention has the following advantages: the invention provides a method and a device for communication with Bluetooth equipment based on an applet platform; the user can conveniently and rapidly communicate with the Bluetooth equipment through the application applet, the device and the applet platform, so that the client requirements are met, and the development of society is adapted; the device sends related data to the Bluetooth equipment according to the length limit data of the Bluetooth equipment, so that errors caused by the fact that the sent data do not accord with the length limit of the Bluetooth equipment are avoided, the communication error rate between the device and the Bluetooth equipment is reduced, and the device is more rapid; after the Bluetooth device is successfully connected, the Bluetooth device identification, the preset device service identification and the preset device characteristic identification are directly used as parameters to call the related function of the applet platform to communicate with the Bluetooth device, and the communication process is simple and convenient.
Drawings
Fig. 1 is a flowchart of a method for communicating with a bluetooth device based on an applet platform according to a first embodiment of the invention;
Fig. 2 is a flowchart of a method for communicating with a bluetooth device based on an applet platform according to a second embodiment of the invention;
fig. 3 is a block diagram of an apparatus for communicating with a bluetooth device based on an applet platform according to a third embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
The embodiment of the invention provides a method for communicating with Bluetooth equipment based on an applet platform; the application applet includes, but is not limited to, a mobile banking applet, the method of which is shown in FIG. 1, including the steps of:
step D11: the device receives a communication instruction sent by an application applet, and obtains a Bluetooth equipment identifier and communication data in the communication instruction; connecting Bluetooth equipment, and calling a starting attention feature value change function of the applet platform by taking Bluetooth equipment identification, preset equipment service identification and preset equipment feature identification as parameters;
Optionally, after step D11, the method further includes:
step D11-01: when the fifth successful callback function is called back by the applet platform, the device acquires a device service list from the fifth successful callback function, judges whether a preset device service identifier exists in the device service list, and if yes, executes the step D11-02; otherwise, the error reporting is finished;
step D11-02: when the sixth successful callback function is called back by the applet platform, the device acquires a device feature list from the sixth successful callback function, judges whether a preset device feature identifier exists in the device feature list, and if yes, executes a step D12; otherwise, the error reporting is finished.
Optionally, in step D11, a bluetooth device is connected, specifically:
step D11-21: the device calls an initialized Bluetooth function of the applet platform;
step D11-22: when the first successful callback function is called back by the applet platform, the device calls a Bluetooth device scanning function of the applet platform to start the Bluetooth device to scan the Bluetooth device;
step D11-23: when the second successful callback function is called back by the applet platform, the device calls a monitoring event function of the applet platform to monitor the event of the scanned new Bluetooth device, receives a Bluetooth device identifier returned by the monitoring event callback function of the applet platform, judges whether the returned Bluetooth device identifier is consistent with the Bluetooth device identifier in the communication instruction, if yes, calls a scanning stopping function of the applet platform to stop scanning the Bluetooth device, and executes the step D11-24, otherwise, the error reporting is finished;
Step D11-24: when the third successful callback function is called back by the applet platform, the device calls a Bluetooth connection function of the applet platform by taking the Bluetooth equipment identifier as a parameter to send a connection instruction to the Bluetooth equipment;
step D11-25: when the fourth successful callback function is called back by the applet platform, the device calls the starting attention feature value change function of the applet platform by taking the Bluetooth device identifier, the preset device service identifier and the preset device feature identifier as parameters.
Step D12: when the seventh successful callback function is called back by the applet platform, the device calls the monitoring characteristic value change function monitoring characteristic value change of the applet platform; the Bluetooth equipment identification, the equipment service identification and the equipment characteristic identification are used as parameters to call a sending function of the applet platform to send an acquiring length limiting instruction to the Bluetooth equipment;
step D13: when the monitoring characteristic value change callback function is called back by the applet platform, the device acquires length limitation data from the monitoring characteristic value change callback function; according to the length limiting data, calling a sending function of the applet platform by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters to send communication data to the Bluetooth equipment;
Optionally, in step D13, the sending function of the applet platform is called with the bluetooth device identifier, the device service identifier and the device feature identifier as parameters according to the length limitation data to send communication data to the bluetooth device, including the following steps:
step D13-01: the device determines the number of the sub communication data as small communication data packets according to the length limit data; acquiring a small communication data packet;
step D13-02: the device calls a sending function of the applet platform to send small communication data packets to the Bluetooth equipment by taking the Bluetooth equipment identification, the equipment service identification and the equipment characteristic identification as parameters;
step D13-03: the device judges whether the next small communication data packet can be acquired, if so, the device acquires the next small communication data packet and returns to the step D13-02; otherwise, step D14 is performed.
Step D14: when the monitoring characteristic value change callback function is called back by the applet platform, the device acquires third return data from the monitoring characteristic value change callback function; and sending the third return data to the application applet, and ending.
Optionally, in this embodiment, the communication instruction is specifically a first signature instruction; the communication data is data to be signed;
step D11 is preceded by:
step D01: when receiving data to be signed of a user, an application applet acquires a Bluetooth device identifier of a Bluetooth device bound with a user account; generating a first signature instruction according to the data to be signed and the Bluetooth equipment identifier, and sending the first signature instruction to the device;
In step D11, the device receives a communication instruction sent by the applet, and obtains a bluetooth device identifier and communication data in the communication instruction, which specifically includes: the device receives a first signature instruction sent by an application applet; analyzing the first signature instruction to obtain data to be signed and a Bluetooth equipment identifier; in step D14, after sending the third return data to the applet, the method further includes: step D15: the application applet receives third return data; sending the third return data to the signature verification server, determining the type of the fourth return data when the fourth return data returned by the signature verification server is received, and displaying that the signature verification is successful when the fourth return data is the signature verification success information, and ending;
further, in step D13, after the device obtains the length limitation data from the listening feature value change callback function, the method further includes the following steps:
step D13-11: the device calls a sending function of the applet platform according to the length limit data and sends a command for acquiring a session key to the Bluetooth equipment through a Bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet platform, acquiring first encrypted return data from the monitoring characteristic value change callback function; decrypting the first encrypted return data using the preset key to obtain a first session key; encrypting the acquired random number instruction by using the first session key to acquire random number instruction ciphertext data, and calling a transmitting function of the applet platform according to the length limit data to transmit the random number instruction ciphertext data to Bluetooth equipment through a Bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet platform, acquiring random number encryption data from the monitoring characteristic value change callback function; decrypting the random number encrypted data using the first session key to obtain random number data;
Step D13-12: the device prompts a user to input a device password, when the device password input by the user is received, the exclusive-or data is obtained according to the device password and the random number data, the exclusive-or data is encrypted by using the first session key to obtain exclusive-or encrypted data, and a sending function of the applet platform is called according to the length limiting data to send the exclusive-or encrypted data to Bluetooth equipment through a Bluetooth communication channel;
step D13-13: when the monitoring characteristic value change callback function is called, the device acquires second encrypted return data from the monitoring characteristic value change callback function; decrypting the second encrypted return data by using the first session key to obtain second return data, and when the second return data is the successful information of the verification device password, calling a sending function of the applet platform to send communication data to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier as parameters according to the length limiting data;
according to the length limiting data, the Bluetooth equipment identification, the equipment service identification and the equipment characteristic identification are taken as parameters to call a sending function of the applet platform to send communication data to the Bluetooth equipment, specifically: the device encrypts data to be signed by using the first session key to generate a second signature instruction, and calls a sending function of the applet platform to send the second signature instruction to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier as parameters according to the length limiting data;
Step D14 is specifically as follows: when the monitoring characteristic value change callback function is called back by the applet platform, the device acquires third encrypted return data from the monitoring characteristic value change callback function; and decrypting the third encrypted return data by using the first session key to obtain third return data, sending the third return data to the application applet, and ending.
Optionally, step D11 is replaced with steps D11-61: the device receives a connection instruction sent by an application applet, and obtains a Bluetooth equipment identifier in the communication instruction; according to the Bluetooth equipment identifier, connecting the Bluetooth equipment, and when the connection is successful, acquiring data to be signed from the application applet; and calling a starting attention characteristic value change function of the applet platform by taking the Bluetooth equipment identifier, the preset equipment service identifier and the preset equipment characteristic identifier as parameters.
Optionally, in this embodiment, the applet platform is a payment device or a WeChat.
Example two
The second embodiment of the invention provides a method for communicating with Bluetooth equipment based on an applet platform; the application applet includes, but is not limited to, a mobile banking applet, the method of which is shown in fig. 2, including the steps of:
step 201: when the application applet receives the signature data, the application applet acquires a Bluetooth device identifier of the Bluetooth device bound with the user account; generating a first signature instruction according to the data to be signed and the Bluetooth equipment identifier, and sending the first signature instruction to the device;
Optionally, the data to be signed includes a transfer account number and a transfer amount;
for example, data to be signed
<? xml version = \ "1.0\" encoding = \ "utf-8\"? < SignData > < TradeTypename= \Cross-line transfer
"> IncitiyTransferTradeType > < Timestamp 1457513379314</Timestamp > < Fields > < PayerAccount NamentNamentame = \" PayerAccount Name = \ "> Shen Jun </PayerAccount Name > < PayerAccount Noname = \" PayerAccount Account = \ 621511111111111111</PayerAccount No > < TrsAccount Name = \ "amount = \1.00 </TrsAccount > < PayeeAccount NamentNamentame = \" > qq </PayeAccount Name > < PayeAccount Noname = \ "collection account: \1111111 </1111111 > </SignData >;
the bluetooth device identification includes 6 bytes, 0x060504030201;
step 202: the device receives and analyzes the first signature instruction to obtain data to be signed and a Bluetooth equipment identifier; invoking the initialized Bluetooth function of the applet platform, and executing step 203 when the first successful callback function of the device is called back by the applet platform;
optionally, the bluetooth device identifier uniquely identifies the bluetooth device, including a bluetooth device name and/or a bluetooth device serial number and/or a MAC address of the bluetooth device;
Optionally, the applet platform comprises a WeChat or a payment instrument;
for example, the device receives a first signature instruction, and obtains a Bluetooth device identifier from the first signature instruction; invoking an initialized Bluetooth function wx.openBluetooth adapter of the applet platform, and executing step 203 when a first successful callback function success: function (res) is called back by the applet platform;
optionally, the step further includes: when the first failure callback function of the device is called back by the applet platform, the device calls a display loading function of the applet platform to display prompt user information;
for example, when the first failure callback function fail: function (res) of the device is called back by the applet platform, the device calls the display loading function wx.showloading display "please turn on bluetooth" of the applet platform; for another example, the prompt user information is "bluetooth initialization failure";
the bluetooth device identifier includes 6 bytes, 060504030201;
step 203: the device records the current time as the first time; invoking a starting Bluetooth equipment scanning function of the applet platform to scan the Bluetooth equipment, and executing step 204 when the second successful callback function of the device is called back by the applet platform;
optionally, the device invokes a start bluetooth device scanning function wx.startbluetooth device discovery of the applet platform to scan the bluetooth device, and when a second success callback function success: function (res) is called back by the applet platform, step 204 is performed;
Step 204: the device calls a monitoring event function of the applet platform to monitor the event of the scanned new Bluetooth device, receives a Bluetooth device identifier returned by the monitoring event callback function of the applet platform, judges whether the returned Bluetooth device identifier is consistent with the Bluetooth device identifier in the signature instruction, if so, executes step 206, otherwise, executes step 205;
optionally, in this step, after the device calls the listening event function of the applet platform to listen to the event of the scanned new bluetooth device, the method further includes: when the applet platform scans new Bluetooth equipment, the device receives the Bluetooth equipment identification returned by the callback function of the monitoring event of the applet platform;
for example, the device invokes the monitor event function wx.onbluetooth device found of the applet platform to monitor the event of the scanned new bluetooth device, receives the bluetooth device identifier returned by the monitor event callback function of the applet platform, and determines whether the returned bluetooth device identifier is consistent with the bluetooth device identifier in the signature instruction, if yes, step 206 is executed, otherwise step 205 is executed;
for example, the bluetooth device identification is lt_2300000000123;
step 205: the device records the current time as a second time; judging whether the difference value between the second time and the first time is larger than the first preset time, if so, displaying the scanning overtime, and ending; otherwise, returning to the step 204;
For example, the first preset time includes 6 bytes, which is 20 seconds;
step 206: the device calls a stopping scanning function of the applet platform to stop scanning the Bluetooth device, and when a third successful callback function of the device is called back by the applet platform, step 207 is executed;
optionally, the step further includes: when the third failure callback function of the device is called back by the applet platform, the device calls a display loading function of the applet platform to display prompt user information;
for example, when the third failure callback function of the device is called back by the applet platform, the device invokes the display load function wx.showload display "in connection" of the applet platform;
for example, the device invokes the stop scan function wx.stopluetooth devices discover of the applet platform to stop scanning the bluetooth device, and when the third successful callback function is called back by the applet platform, step 207 is performed;
step 207: the device uses the Bluetooth equipment identifier as a parameter to call a Bluetooth connection function of the applet platform to initiate Bluetooth connection to the Bluetooth equipment; executing step 208 when the fourth successful callback function of the device is called back by the applet platform;
optionally, the step further includes: when the fourth failure callback function of the device is called back by the applet platform, the device calls a display loading function of the applet platform to display prompt user information;
For example, when the fourth failure callback function of the device is called back by the applet platform, the device calls the display loading function wx.showloading display "communication exception" of the applet platform;
for example, the device uses the bluetooth device identifier as a parameter to call a bluetooth connection function wx.createbble connection of the applet platform to initiate bluetooth connection to the bluetooth device; when the fourth successful callback function is called back by the applet platform, executing step 208;
for example, the bluetooth device identification includes 6 bytes, 060504030201:
step 208: the device calls a device service function of the applet platform by taking the Bluetooth device identifier as a parameter; when the fifth successful callback function of the device is called back by the applet platform, acquiring a device service list from the fifth successful callback function;
optionally, in this step, after the device calls the device service function of the applet platform with the bluetooth device identifier as a parameter, the method further includes: the applet platform receives a device service list returned by the Bluetooth device; calling a fifth successful callback function of the device;
optionally, the step further includes: when the fifth failure callback function of the device is called back by the applet platform, the device calls a display loading function of the applet platform to display prompt user information;
For example, when the fifth failure callback function of the device is called back by the applet platform, the device calls the display loading function wx.showloading display "communication exception" of the applet platform;
for example, the device invokes a scan service function wx.getbledeviceservices scan device service identifier of the applet platform with the bluetooth device identifier as a parameter; executing step 209 when the fifth successful callback function of the device is called back by the applet platform;
for example, the bluetooth device identification includes 6 bytes, 060504030201;
the list of device services is
46540001000100C30000465453414645;
46540002-0001-00C3-0000-465453414645;
Step 209: the device judges whether the acquired equipment service list has preset equipment service identifiers, if yes, the step 210 is executed, otherwise, error information is sent to the application applet, and the step 209-01 is executed;
step 209-01: the application applet receives and displays the error information and ends;
for example, the preset device service identifier is 0x46540001000100C30000465453414645;
the list of device services is 0x46540001000100C30000465453414645;46540002000100C30000465453414645;
step 210: the device calls the device feature function of the applet platform by taking the Bluetooth device identifier and the preset device service identifier as parameters, and obtains a device feature list from a sixth successful callback function of the device, and step 211 is executed;
Optionally, in this step, after the device calls the device feature function of the applet platform with the bluetooth device identifier and the preset device service identifier as parameters, the device further includes: the applet platform receives a device feature list returned by the Bluetooth device; calling a sixth successful callback function of the device;
optionally, the method specifically comprises the following steps: the device calls the acquired device characteristic function of the applet platform by taking the Bluetooth device identifier and the preset device service identifier as parameters; when a sixth successful callback function of the device is called back by the applet platform, acquiring a device feature list from the sixth successful callback function;
for example, the device calls the acquired device feature function wx.getbLEDEVECIC dynamics of the applet platform with the Bluetooth device identification and the preset device service identification as parameters; when a sixth successful callback function of the device is called back by the applet platform, acquiring a device feature list from a sixth parameter of the sixth successful callback function;
for example, the preset device service identifier includes 6 bytes, 46540003000100C30000465453414645;
the bluetooth device identification includes 6 bytes, 0x060504030201;
the list of device features is 0x46540003000100C30000465453414645;
46540004000100C30000465453414645;
Step 211: the device judges whether the acquired equipment characteristic list has preset equipment characteristic identifiers or not, if yes, the step 212 is executed, otherwise, error information is sent to the application applet, and the step 211-01 is executed;
step 211-01: the application applet receives and displays the error information and ends;
for example, the preset device feature identification is 0x46540003000100C30000465453414645;
step 212: the device calls a starting attention characteristic value change function of the applet platform by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters; executing step 213 when the seventh successful callback function of the device is called back by the applet platform;
for example, the device invokes a startup attention feature value change function wx.notify blechacteracteristicvalue change of the applet platform with the bluetooth device identity, the device service identity, and the device feature identity as parameters; executing step 213 when the seventh successful callback function is called back by the applet platform;
optionally, the step further includes: when the seventh failure callback function is called back by the applet platform, the device calls a display loading function of the applet platform to display prompt user information;
for example, when the seventh failure callback function is called back by the applet platform, the device invokes the display load function wx.showload display "enable failure" of the applet platform;
Step 213: the device calls a monitoring characteristic value change function of the applet platform by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters; monitoring a feature value change callback function to wait to be called back by the applet platform;
for example, the device invokes a listening feature value change function wx.onBLE Charabacterial value change of the applet platform with the Bluetooth device identifier, the device service identifier and the device feature identifier as parameters; the monitoring characteristic value change callback function of the device waits to be called back by the applet platform;
step 214: the device uses Bluetooth equipment identification, equipment service identification and equipment characteristic identification as parameters to call a sending function of the applet platform to send a length restriction acquiring instruction to the Bluetooth equipment; when the monitoring characteristic value change callback function of the device is called back by the applet platform, acquiring length limitation data from the monitoring characteristic value change callback function;
optionally, in this step, after the apparatus uses the bluetooth device identifier, the device service identifier, and the device feature identifier as parameters to call a sending function of the applet platform to send an acquiring length limitation instruction to the bluetooth device, the apparatus further includes: the applet platform receives length limitation data returned by the Bluetooth equipment; calling a monitoring characteristic value change callback function of the device;
Step 215: the device calls a sending function of the applet platform according to the length limiting data, sends a session key obtaining instruction to the Bluetooth device through a Bluetooth communication channel, and obtains first encrypted return data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function of the device is called back by the applet platform; decrypting the first encrypted return data using the preset key to obtain a first session key;
optionally, in this step, after the device calls the sending function of the applet platform according to the length limitation data to send the instruction for obtaining the session key to the bluetooth device through the bluetooth communication channel, the device further includes: the method comprises the steps that an applet platform receives first encrypted return data returned by Bluetooth equipment; calling a monitoring characteristic value change callback function of the device;
for example, the get session key instruction is 0x64080000000003000000000046674a82a0;
the first encrypted return data is 0x b a b6b5 b e c 716a 6b322 a c7a476b a f 4d7a6b6c4d666e6d636 e4d c666d f 746a6d 316a b b f a304a a377a372b a5a a34767a d a 2a f f f7a 0a776 a the c6f6f 4f c 754d 2b446a6d a4b 6b a6f 0a b b b 2a e a746a b 540a 474d6d c2f426f4b6e a377a 436d6c 6a586e 0a c6f a b d d 305a6a4f4e4d 7a2b a 4e d6a 6b a732b656c a a a;
The preset key is 0x87BD32B2AD198BD1368F76B26B42849B;
the first session key is 0x6A0D946F5978ECBF5FCD787AB1DE602AE72584EEF40DBFBD37A8809D904769245CB0149F1D88669F443DAB67EA6225F48A09D04A66AB2B096025393A8E2B34796E0E 6455D40172B770C5E5E 646C99DFABD692808CFD192F432508CAED917BABAC01B20FE30539E9AC3E23A9EBE9B 23A6950CBBC91ACF0CF5F 888B496F10840E454E544552534146452D4553504B9000;
step 216: the device encrypts and acquires a random number instruction by using a first session key to acquire random number instruction ciphertext data, and calls a transmitting function of the applet platform according to the length limit data to transmit the random number instruction ciphertext data to Bluetooth equipment through a Bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet platform, acquiring random number encryption data from the monitoring characteristic value change callback function; decrypting the random number encrypted data by using the session key to obtain random number data;
optionally, in this step, after the device calls the sending function of the applet platform according to the length limitation data to send the instruction for obtaining the random number to the bluetooth device through the bluetooth communication channel, the device further includes: the applet platform receives random number encryption data returned by the Bluetooth equipment; calling a monitoring characteristic value change callback function of the device;
For example, the device invokes a send function wx.writeblechactericikvalue of the applet platform to send an instruction to obtain a random number to the bluetooth device through the bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet platform, acquiring random number encryption data from the monitoring characteristic value change callback function; decrypting the random number encrypted data by using the session key to obtain random number data;
for example, the get random number instruction is 0x0084000008;
obtaining random number instruction ciphertext data as 0x6f0a000000000900000000868679484562cb2796;
the random number data is 0x8011000000010900000000b56f9441701335965233641ab3541da013;
the random number data is 0x547F1add 21EFDC89000;
step 217: the device prompts a user to input a device password, when the device password input by the user is received, the exclusive-or data is obtained according to the device password and the random number data, the exclusive-or data is encrypted by using the first session key to obtain exclusive-or encrypted data, and a sending function of the applet platform is called according to the length limiting data to send the exclusive-or encrypted data to Bluetooth equipment through a Bluetooth communication channel;
optionally, in this step, after the sending function of the applet platform is called according to the length limitation data to send the xor encrypted data to the bluetooth device through the bluetooth communication channel, the method further includes: the applet platform receives second encrypted return data returned by the Bluetooth equipment; calling a monitoring characteristic value change callback function of the device;
For example, the device prompts a user to input a device password, when the device password input by the user is received, exclusive-or data is obtained according to the device password and random number data, the exclusive-or data is encrypted by using a session key to obtain exclusive-or encrypted data, and a sending function wx.writeblechacterial value of the applet platform is called according to the length limiting data to send the exclusive-or encrypted data to the Bluetooth device through a Bluetooth communication channel;
for example, the random number data is 0x547F1add 21EFDC89000;
exclusive or data 0x00200B118001F26472E0065CAF32CF069a01B9E00C68FCEA89FDE56326A3DEA3C734a572A7F469CD7F463DBB47BE391FE389800B5969F5AE581BD26A7EA2C356992CBAF4BEFB2E5D4a08943C331E45E61CB1376896F5C33104505122B5FA2FF21F14FAD18EACFD90C92052165a98865EDEF0a31AAE98a78659CD919989CE98927E26B3a 445.
The exclusive or encrypted data is 0x6f8a000000000b00000000436de664a21feed6406c5062400db2e39a86ebba 9fd48772883c0e85b16f6 aefmc 7623f30fc1a2827709da01fd69529c1bb4e4cdcf83bbb1dbd feca5f5c693fcc84b769bd570281b cc7728be42e86c1f 26a3cbc2b21765ae1a412ee671b32b3625cc3d58f9cfe52ac093fa7467bc521773230564cd8cc 54952a6baa dc3071d77911528;
Step 218: when the monitoring characteristic value change callback function of the device is called back by the applet platform, the device acquires second encrypted return data from the monitoring characteristic value change callback function; decrypting the second encrypted return data using the first session key to obtain second return data, and when the second return data is authentication device password success information, performing step 219;
optionally, before this step, the method further includes: the applet platform receives second encrypted return data returned by the Bluetooth equipment; calling a monitoring characteristic value change callback function of the device;
for example, when the monitoring characteristic value change callback function of the device is called back by the applet platform, the device acquires second encrypted return data from the monitoring characteristic value change callback function; decrypting the second encrypted return data using the first session key to obtain second return data, and executing step 218 when the second return data is authentication device password success information;
for example, the second encrypted return data is 0x8009000000010b000000006992dd3c375aeb3f20
The first session key is 0x0x6A0D946F5978ECBF5FCD787AB1DE602AE72584EEF40DBFBD37a8809D904769245CB0149F1D88669F443DAB67EA6225F48a09D04a66AB2B096025393A8E2B34796E0E53E6455D40172B770C5E 9E646C99DFABD692808CFD192F432508C 79C aed917BABAC01B20FE30539E9AC3E23A9EBE9B 23a6950CBBC91ACF0CF5F2B888B496F10840E454E544552534146452D4553504B9000;
The second return data is 0x9000;
verifying that the equipment password success information is 0x9000;
step 219: the device encrypts data to be signed by using the first session key to generate a second signature instruction, and calls a sending function of the applet platform according to the length limiting data to send the second signature instruction to the Bluetooth equipment through the Bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet platform, acquiring third encrypted return data from the monitoring characteristic value change callback function; decrypting the third encrypted return data using the first session key to obtain third return data;
optionally, after the sending function of the applet platform is called according to the length limitation data to send the second signature instruction to the bluetooth device through the bluetooth communication channel in this step, the method further includes: the applet platform receives third encrypted return data returned by the Bluetooth equipment; calling a monitoring characteristic value change callback function of the device;
optionally, the sending function of the applet platform is called according to the length limitation data to send a second signature instruction to the bluetooth device through the bluetooth communication channel, specifically:
step 219-01: the device determines the second signature instruction as the number of small communication data packets according to the length limit data; acquiring a small communication data packet;
Step 219-02: the device calls a sending function of the applet platform to send small communication data packets to the Bluetooth equipment by taking the Bluetooth equipment identification, the equipment service identification and the equipment characteristic identification as parameters;
step 219-03: the device judges whether the next small communication data packet can be acquired, if so, the device acquires the next small communication data packet and returns to the step 219-02; otherwise, step 220 is performed.
For example, the device encrypts data to be signed by using the first session key to generate a second signature instruction, and calls a sending function wx.writeBLE Charabacteria value of the applet platform according to the length-limited data to send the second signature instruction to the Bluetooth device through the Bluetooth communication channel; when the monitoring characteristic value change callback function is called back by the applet platform, the device acquires third encrypted return data from the monitoring characteristic value change callback function; decrypting the third encrypted return data using the first session key to obtain third return data; sending third return data to the applet;
for example, the data to be signed is 0x102A90800001903C3F786D6C20766572
73696F6E3D22312E302220656E636F64696E673D227574662D38223F3E3C5369676E446174613E3C547261646554797065206E616D653D22E8B7A8E8A18CE8BDACE8B4A6223E496E636974795472616E736665723C2F5472616465547970653E3C54696D657374616D703E313435373531333337393331343C2F54696D657374616D703E3C4669656C64733E3C50617965724163636F756E744E616D65206E616D653D22E4BB98E6ACBEE688B7E5908D3A20223EE6B288E4BF8A3C2F50617965724163636F756E744E616D653E3C50617965724163636F756E744E6F206E616D653D22E4BB98E6ACBEE8B4A6E688B73A20223E3632313531313131313131313131313131313C2F50617965724163636F756E744E6F3E3C547273416D6F756E74206E616D653D22E98791E9A29D3A20223E312E30303C2F547273416D6F756E743E3C50617965654163636F756E744E616D65206E616D653D22E694B6E6ACBEE688B7E5908D3A20223E71713C2F50617965654163636F756E744E616D653E3C5061796565416363;
The second signature instruction is 0x6f9a e cb 71f7cf0c40a86 bfcb0ca0e0e1fba 2 8518 fc8da1f5e 934b5490e9e669da b26c 072e 64fcc5d39a05915cc09bc3df2f2b84fc59fc95fe0460d6df2b23d abff3c3d11ebdcf680cc3a9a52bcad2332af29b23b61ed7427a7846a803abfb5c9dd5f4c51083af d 17c3b9 1945a0f9b0c4276e dd20c51eac cb8b23d6568a54a 71180c3704e 131200ad6145ab1b 7b 22ba2da2df963dc1995a202 b3b faad5a271a3737d ce98f639a3e8a61bac b7702d41b0f d 4fcccdcd7fa41e373f65 c 6e 6 42064fd0ac f864a48 b3d7a1643c7d925bf b348a658db 4f01d ebf4d05f8d 94cc30 cecfb4947c8dbb ebaa 1574f01d 43f2c1add8f 7a0d7d8f 98f 9fd9d56772a6f1652cf161a 894fd 2f 8942f 9e ce0e wear 5e fab 7c159a2f89;
The third encrypted return data is 0x8089000000012200000000de850702ebb3907261d74121c0fd78def372e591a655b5bbc e 56b2c9bef6339e5c36bb8c52c68646a13fb899958d3fc62bd4b6db51aaf33c0c9 c272011194e2cc77eec5d7bd6dc7fc773 aaebec 8aa0772ca7715e9a273f 1eba991dba7491940b0cef 01a1d60c9ef5a37cb76ce87ea2ca79051276c61b53995af9ac7674cc6b04eb79a89995;
the third return data is 0x0AF51EB 15508 a92C07FC9185FDA07AA87a6366C 2B1C9212BCA84D5749257E4439B01057E4C0B5353C9DF310CBBB17054167C0681766E1A8D2457DCF671B4748E4EB74AE2348ADC5CCB65FEBD781B6B3458D92BE4C70CB02970a89879238C56646CD181411F152BE201862CEEFF8285CF30CD26B91150C3A7D52A1C8937B02B9000;
step 220: the application applet receives third return data; sending the third return data to the signature verification server, determining the type of the fourth return data when the fourth return data returned by the signature verification server is received, and displaying that the signature verification is successful when the fourth return data is the signature verification success information, and ending; when the fourth returned data is the label verification failure information, the label verification failure is displayed, and the process is finished;
optionally, in this embodiment, the process that the device obtains the data to be signed from the applet may further be implemented by the following steps:
Step 201 is replaced with step 251: when the application applet receives the user signature operation, the application applet acquires a Bluetooth device identifier of the Bluetooth device bound with the user account; transmitting a Bluetooth equipment identifier to the device; step 252 is performed;
step 252: the device receives a Bluetooth equipment identifier; connecting with the Bluetooth equipment according to the Bluetooth equipment identifier; when the connection is successful, returning connection success information to the application applet;
step 253: the application applet receives the connection success information, acquires the data to be signed and sends the data to be signed to the device;
step 254: the device receives the data to be signed and performs step 208.
Example III
The third embodiment of the invention provides a device for communicating with Bluetooth equipment based on an applet platform; the application applet includes, but is not limited to, a mobile banking applet, as shown in fig. 3, the apparatus includes a receive acquisition module 301, a connect call module 302, a call transmission module 303, an acquire call module 304, and an acquire transmission module 305:
the receiving and acquiring module 301 is configured to receive a communication instruction sent by an applet, and acquire a bluetooth device identifier and communication data in the communication instruction;
the connection calling module 302 is configured to connect to the bluetooth device calling module, and is configured to call a start-up attention feature value change function of the applet platform with the bluetooth device identifier, the preset device service identifier, and the preset device feature identifier acquired by the receiving and acquiring module 301 as parameters;
Optionally, the connection invocation module 302 includes a connection unit; the connection unit is used for connecting the Bluetooth equipment;
the connection unit comprises a first calling subunit, a second calling subunit, a third calling subunit, a fourth calling subunit, an error reporting subunit and a sending subunit;
correspondingly, the first calling subunit is used for calling an initialized Bluetooth function of the applet platform; when the first successful callback function is called back by the applet platform, a Bluetooth device scanning function is started to scan Bluetooth devices by calling the applet platform;
correspondingly, when the second successful callback function is called back by the applet platform, the second calling subunit is used for calling a monitoring event function of the applet platform to monitor the event of the scanned new Bluetooth device, receiving a Bluetooth device identifier returned by the monitoring event callback function of the applet platform, judging whether the returned Bluetooth device identifier is consistent with the Bluetooth device identifier in the communication instruction, and triggering a third calling subunit if the returned Bluetooth device identifier is consistent with the Bluetooth device identifier in the communication instruction; otherwise, triggering an error-reporting subunit;
correspondingly, the error reporting subunit is used for ending error reporting;
correspondingly, the third calling subunit is used for calling a scanning stopping function of the applet platform to stop scanning the Bluetooth device and triggering the sending subunit;
Correspondingly, the sending subunit is used for calling a Bluetooth connection function of the applet platform to send a connection instruction to the Bluetooth device by taking the Bluetooth device identifier as a parameter when the third successful callback function is called back by the applet platform;
correspondingly, the fourth calling subunit is configured to call the start-up attention feature value change function of the applet platform with the bluetooth device identifier, the preset device service identifier and the preset device feature identifier as parameters when the fourth successful callback function is called back by the applet platform.
The calling and sending module 303 calls the monitoring characteristic value change function monitoring characteristic value change of the applet platform when the seventh successful callback function is called back by the applet platform; transmitting a length restriction acquisition instruction to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device feature identifier acquired by the receiving and acquiring module 301 as the transmitting functions of the parameter calling applet platform;
the acquiring and calling module 304 is configured to acquire length limitation data from the monitoring feature value change callback function when the monitoring feature value change callback function is called back by the applet platform; according to the length limit data acquired by the receiving and acquiring module 301, the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier are taken as parameters to call a sending function of the applet platform to send communication data to the Bluetooth equipment;
Optionally, the acquisition calling module 304 includes a sending unit;
correspondingly, the sending unit is configured to call a sending function of the applet platform to send communication data to the bluetooth device with the bluetooth device identifier, the device service identifier and the device feature identifier as parameters according to the length limitation data acquired by the acquisition and call module 304;
the transmitting unit comprises a determination and acquisition subunit,
Correspondingly, a determining and acquiring subunit is configured to determine, according to the length limitation data, the number of small communication data packets as the sub communication data; acquiring a small communication data packet;
correspondingly, the sending subunit is used for calling a sending function of the applet platform by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters to send a small communication data packet to the Bluetooth equipment;
correspondingly, the judging subunit is used for judging whether the next small communication data packet can be acquired or not, and if so, the acquiring subunit is triggered; otherwise, triggering the acquisition and transmission module 305;
correspondingly, the acquisition subunit is configured to acquire the next small communication data packet, and trigger the sending subunit.
The acquiring and sending module 305 is configured to acquire third return data from the monitoring feature value change callback function when the monitoring feature value change callback function is called back by the applet platform; and sending the third return data to the application applet, and ending.
Optionally, in this embodiment, the apparatus further includes an acquisition judgment module and a first error reporting module; the acquisition judging module comprises a first acquisition unit;
accordingly, the call transmitting module 303 includes a second call unit; the second calling unit is used for calling the monitoring characteristic value change function monitoring characteristic value change of the applet platform when the seventh successful callback function is called back by the applet platform;
correspondingly, the acquiring and judging module is used for acquiring a device service list from the fifth successful callback function when the fifth successful callback function is called back by the applet platform; judging whether a preset equipment service identifier exists in the equipment service list or not; if yes, triggering a first acquisition unit; otherwise, triggering a first error reporting module;
correspondingly, the acquiring and judging module is further used for acquiring a device feature list from the sixth successful callback function when the sixth successful callback function is called back by the applet platform, judging whether a preset device feature identifier exists in the device feature list, and triggering a second calling unit if the preset device feature identifier exists in the device feature list; otherwise, triggering a first error reporting module;
correspondingly, the first error reporting module is used for reporting the error to end;
correspondingly, the first obtaining unit is configured to obtain the device feature list from the sixth successful callback function when the sixth successful callback function is called back by the applet platform.
Optionally, in this embodiment, the communication instruction is specifically a first signature instruction; the communication data is data to be signed; the system where the device is located also comprises an application applet; the application applet comprises an acquisition generation and transmission module and a receiving and determining display module;
correspondingly, the acquisition generation and transmission module is used for receiving the data to be signed of the user; when receiving data to be signed of a user, acquiring a Bluetooth device identifier of a Bluetooth device bound with a user account; generating a first signature instruction according to the data to be signed and the Bluetooth equipment identifier, and sending the first signature instruction to the device;
correspondingly, the receiving and acquiring module 301 is specifically configured to receive a first signature instruction sent by the applet; analyzing the first signature instruction to obtain data to be signed and a Bluetooth equipment identifier;
accordingly, the receiving and determining display module is configured to receive the third return data sent by the acquiring and sending module 305; sending the third return data to the signature verification server, determining the type of the fourth return data when the fourth return data returned by the signature verification server is received, and displaying that the signature verification is successful when the fourth return data is the signature verification success information, and ending;
further, the device also comprises a transmission acquisition encryption module, an encryption transmission module and a prompt encryption transmission module
Further, correspondingly, a sending and obtaining decryption module is configured to invoke a sending function of the applet platform according to the length limitation data obtained by the obtaining and sending module 305 to send a command for obtaining the session key to the bluetooth device through the bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet platform, acquiring first encrypted return data from the monitoring characteristic value change callback function; decrypting the first encrypted return data using the preset key to obtain a first session key;
further, correspondingly, the encryption sending module is used for encrypting the random number acquisition instruction by using the first session key obtained by the transmission acquisition decryption module to obtain the random number acquisition instruction ciphertext data, and calling a sending function of the applet platform according to the length limitation data to send the random number acquisition instruction ciphertext data to the Bluetooth equipment through the Bluetooth communication channel;
further correspondingly, an encryption module is obtained and used for obtaining random number encryption data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function of the device is called back by the applet platform; decrypting the random number encrypted data using the first session key to obtain random number data;
further, correspondingly, a prompting encryption sending module is used for prompting a user to input a device password, when the device password input by the user is received, the exclusive-or data is obtained according to the device password and the random number data, the exclusive-or data is encrypted by using a first session key to obtain exclusive-or encrypted data, and a sending function of a small program platform is called according to the length limiting data to send the exclusive-or encrypted data to Bluetooth equipment through a Bluetooth communication channel;
Further correspondingly, the obtaining decryption sending module is used for obtaining second encrypted return data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function is called; decrypting the second encrypted return data by using the first session key to obtain second return data, and when the second return data is the successful information of the verification device password, calling a sending function of the applet platform to send communication data to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier as parameters according to the length limiting data;
further correspondingly, the acquisition invocation module 304 includes a sending unit;
further, correspondingly, a sending unit is configured to call a sending function of the applet platform to send communication data to the bluetooth device with the bluetooth device identifier, the device service identifier and the device feature identifier as parameters according to the length limitation data acquired by the acquisition and call module 304;
further, the sending unit is specifically configured to encrypt the data to be signed by using the first session key obtained by the sending and obtaining decryption module to generate a second signature instruction, and call a sending function of the applet platform to send the second signature instruction to the bluetooth device by using the bluetooth device identifier, the device service identifier and the device feature identifier as parameters according to the length limitation data;
Further, correspondingly, the obtaining and sending module 305 is specifically configured to obtain third encrypted return data from the monitoring feature value change callback function when the monitoring feature value change callback function is called back by the applet platform; and decrypting the third encrypted return data by using the first session key obtained by the sending acquisition decryption module to obtain third return data, sending the third return data to the application applet, and ending.
Optionally, in this embodiment, the apparatus further includes an acquire connection call module 302; the acquiring connection calling module 302 is configured to receive a connection instruction sent by an application applet, and acquire a bluetooth device identifier in the communication instruction; according to the Bluetooth equipment identifier, connecting the Bluetooth equipment, and when the connection is successful, acquiring data to be signed from the application applet; and calling a starting attention characteristic value change function of the applet platform by taking the Bluetooth equipment identifier, the preset equipment service identifier and the preset equipment characteristic identifier as parameters.
Optionally, in this embodiment, the applet platform is a payment device or a WeChat.
The present invention is not limited to the above-mentioned embodiments, and any changes or substitutions that can be easily understood by those skilled in the art within the scope of the present invention are intended to be included in the scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims (16)

1. A method for communicating with a bluetooth device based on an applet, wherein the applet is an applet, the method comprising the steps of:
step S11: a device for communicating with Bluetooth equipment based on the applet receives a communication instruction sent by the applet, and obtains a Bluetooth equipment identifier and communication data in the communication instruction; connecting Bluetooth equipment, and calling a starting attention characteristic value change function of the applet by taking Bluetooth equipment identification, preset equipment service identification and preset equipment characteristic identification as parameters;
step S12: when the seventh successful callback function is called back by the small program, the device calls the monitoring characteristic value change of the monitoring characteristic value change function of the small program; calling a sending function of the applet by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters to send a length limiting acquiring instruction to the Bluetooth equipment;
step S13: when the monitoring characteristic value change callback function is called back by the applet, the device acquires length limitation data from the monitoring characteristic value change callback function; calling a sending function of the applet to send communication data to the Bluetooth equipment by taking the Bluetooth equipment identification, the equipment service identification and the equipment characteristic identification as parameters according to the length limit data;
Step S14: when the monitoring characteristic value change callback function is called back by the small program, the device acquires third return data from the monitoring characteristic value change callback function; sending third return data to the applet, ending;
the communication instruction is specifically a first signature instruction; the communication data is data to be signed;
the device calls a sending function of the applet to send a second signature instruction to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier as parameters according to the length limit data.
2. The method according to claim 1, further comprising, after the step S11:
step S11-01: when the fifth successful callback function is called back by the applet, the device acquires a device service list from the fifth successful callback function, judges whether a preset device service identifier exists in the device service list, and if yes, executes step S11-02; otherwise, the error reporting is finished;
step S11-02: when the sixth successful callback function is called back by the applet, the device acquires a device feature list from the sixth successful callback function, judges whether a preset device feature identifier exists in the device feature list, and if yes, executes step S12; otherwise, the error reporting is finished.
3. The method according to claim 1, wherein the step S11 is preceded by:
step S01: when receiving data to be signed of a user, the applet acquires a Bluetooth device identifier of a Bluetooth device bound with a user account; generating a first signature instruction according to the data to be signed and the Bluetooth equipment identifier, and sending the first signature instruction to the device;
in step S11, the device receives a communication instruction sent by the applet, and obtains a bluetooth device identifier and communication data in the communication instruction, which specifically includes: the device receives a first signature instruction sent by the applet; analyzing the first signature instruction to obtain data to be signed and a Bluetooth equipment identifier;
in the step S14, after the sending the third return data to the applet, the method further includes:
step S15: the applet receives third return data; and sending the third return data to the signature verification server, determining the type of the fourth return data when the fourth return data returned by the signature verification server is received, and displaying that the signature verification is successful when the fourth return data is the signature verification success information, and ending.
4. A method according to claim 3, wherein in step S13, after the device obtains the length limitation data from the listening feature value change callback function, the method further comprises the steps of:
Step S13-11: the device calls a sending function of the applet according to the length limit data and sends a command for acquiring a session key to Bluetooth equipment through a Bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet, acquiring first encrypted return data from the monitoring characteristic value change callback function; decrypting the first encrypted return data using the preset key to obtain a first session key; encrypting the acquired random number instruction by using the first session key to acquire random number instruction ciphertext data, and calling a transmitting function of the applet according to the length limiting data to transmit the random number instruction ciphertext data to Bluetooth equipment through a Bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet, acquiring random number encryption data from the monitoring characteristic value change callback function; decrypting the random number encrypted data using the first session key to obtain random number data;
step S13-12: the device prompts a user to input a device password, when the device password input by the user is received, exclusive-or data is obtained according to the device password and random number data, the exclusive-or data is encrypted by using a first session key to obtain exclusive-or encrypted data, and a sending function of the applet is called according to length limiting data to send the exclusive-or encrypted data to Bluetooth equipment through a Bluetooth communication channel;
Step S13-13: when the monitoring characteristic value change callback function is called, the device acquires second encrypted return data from the monitoring characteristic value change callback function; decrypting the second encrypted return data by using the first session key to obtain second return data, and calling a sending function of the applet to send communication data to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier as parameters according to the length limiting data when the second return data is the successful information of the verification device password;
the method comprises the steps of calling a sending function of the applet to send communication data to Bluetooth equipment by taking Bluetooth equipment identification, equipment service identification and equipment characteristic identification as parameters according to length limit data, wherein the sending function comprises the following specific steps: the device encrypts data to be signed by using the first session key to generate a second signature instruction, and calls a sending function of the applet to send the second signature instruction to Bluetooth equipment by taking Bluetooth equipment identification, equipment service identification and equipment characteristic identification as parameters according to the length limiting data;
the step S14 specifically includes: when the monitoring characteristic value change callback function is called back by the small program, the device acquires third encrypted return data from the monitoring characteristic value change callback function; and decrypting the third encrypted return data by using the first session key to obtain third return data, sending the third return data to the applet, and ending.
5. The method according to claim 1, wherein step S11 is replaced by steps S11-61: the device receives a connection instruction sent by the applet and acquires a Bluetooth equipment identifier in the connection instruction; according to the Bluetooth equipment identifier, connecting the Bluetooth equipment, and when the connection is successful, acquiring data to be signed from the applet; and calling the starting attention characteristic value change function of the applet by taking the Bluetooth equipment identifier, the preset equipment service identifier and the preset equipment characteristic identifier as parameters.
6. The method according to claim 1, wherein in the step S11, the connecting bluetooth device is specifically:
step S11-21: the device calls an initialized Bluetooth function of the applet;
step S11-22: when the first successful callback function is called back by the small program, the device calls a Bluetooth device scanning function of starting the small program to scan Bluetooth devices;
step S11-23: when the second successful callback function is called back by the small program, the device calls a monitoring event function of the small program to monitor the event of the scanned new Bluetooth device, receives the Bluetooth device identifier returned by the monitoring event callback function of the small program, judges whether the returned Bluetooth device identifier is consistent with the Bluetooth device identifier in the communication instruction, if so, calls a stopping scanning function of the small program to stop scanning the Bluetooth device, and executes the steps S11-24, otherwise, the error reporting is finished;
Step S11-24: when the third successful callback function is called back by the small program, the device calls a Bluetooth connection function of the small program by taking the Bluetooth equipment identifier as a parameter to send a connection instruction to the Bluetooth equipment;
step S11-25: when the fourth successful callback function is called back by the small program, the device calls the starting attention feature value change function of the small program by taking the Bluetooth device identifier, the preset device service identifier and the preset device feature identifier as parameters.
7. The method according to claim 1, wherein in the step S13, the transmitting function of the applet is called to transmit communication data to the bluetooth device according to the length limitation data with bluetooth device identifier, device service identifier and device feature identifier as parameters, and the method comprises the steps of:
step S13-01: the device determines the number of the sub communication data as small communication data packets according to the length limit data; acquiring a small communication data packet;
step S13-02: the device calls a sending function of the applet to send a small communication data packet to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier as parameters;
step S13-03: the device judges whether the next small communication data packet can be acquired, if so, the device acquires the next small communication data packet and returns to the step S13-02; otherwise, step S14 is performed.
8. The method of claim 1, wherein the applet is a payment instrument or a WeChat.
9. The device for communicating with the Bluetooth equipment based on the applet is characterized in that the applet is an application applet, and comprises a receiving and acquiring module, a connecting and calling module, a calling and transmitting module, an acquiring and calling module and an acquiring and transmitting module:
the receiving and acquiring module is used for receiving the communication instruction sent by the applet and acquiring the Bluetooth equipment identifier and communication data in the communication instruction;
the connection calling module is used for connecting with the Bluetooth equipment calling module and calling the starting attention characteristic value change function of the applet by taking the Bluetooth equipment identifier, the preset equipment service identifier and the preset equipment characteristic identifier which are acquired by the receiving and acquiring module as parameters;
the calling and sending module is used for calling the monitoring characteristic value change function monitoring characteristic value change of the applet when the seventh successful callback function is called back by the applet; the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier which are acquired by the receiving and acquiring module are used as parameters to call a sending function of the applet to send an acquiring length limiting instruction to the Bluetooth equipment;
The acquisition calling module is used for acquiring length limitation data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function is called back by the applet; calling a sending function of the applet to send communication data to Bluetooth equipment by taking the Bluetooth equipment identification, the equipment service identification and the equipment characteristic identification as parameters according to the length limit data acquired by the receiving and acquiring module;
the acquisition and transmission module is used for acquiring third return data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function is called back by the applet; sending third return data to the applet, ending;
the communication instruction is specifically a first signature instruction; the communication data is data to be signed;
and the acquisition and calling module is also used for calling the sending function of the applet to send a second signature instruction to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier as parameters according to the length limit data.
10. The apparatus of claim 9, further comprising an acquisition determination module and a first error reporting module; the acquisition judging module comprises a first acquisition unit;
The call sending module comprises a second call unit; the second calling unit is used for calling the monitoring characteristic value change function monitoring characteristic value change of the applet when the seventh successful callback function is called back by the applet;
the acquiring and judging module is used for acquiring a device service list from the fifth successful callback function when the fifth successful callback function is called back by the applet; judging whether a preset equipment service identifier exists in the equipment service list or not; if yes, triggering the first acquisition unit; otherwise, triggering the first error reporting module;
the acquiring and judging module is further configured to acquire a device feature list from the sixth successful callback function when the sixth successful callback function is called back by the applet, judge whether a preset device feature identifier exists in the device feature list, and if yes, trigger the second calling unit; otherwise, triggering the first error reporting module;
the first error reporting module is used for reporting the error;
the first obtaining unit is configured to obtain a device feature list from the sixth successful callback function when the sixth successful callback function is called back by the applet.
11. The apparatus of claim 9, wherein the system in which the apparatus is located further comprises the applet; the applet comprises an acquisition, generation and transmission module and a receiving and determining display module;
The acquisition generation sending module is used for receiving the data to be signed of the user; when receiving data to be signed of a user, acquiring a Bluetooth device identifier of a Bluetooth device bound with a user account; generating a first signature instruction according to the data to be signed and the Bluetooth equipment identifier, and sending the first signature instruction to the device;
the receiving and acquiring module is specifically configured to receive a first signature instruction sent by the applet; analyzing the first signature instruction to obtain data to be signed and a Bluetooth equipment identifier;
the receiving and determining display module is used for receiving the third return data sent by the acquisition and sending module; and sending the third return data to the signature verification server, determining the type of the fourth return data when the fourth return data returned by the signature verification server is received, and displaying that the signature verification is successful when the fourth return data is the signature verification success information, and ending.
12. The apparatus of claim 11, further comprising a transmit acquire decrypt module, an encrypt transmit module, an acquire encrypt module, a hint encrypt transmit module, an acquire decrypt transmit module;
the sending acquisition decryption module is used for calling a sending function of the applet according to the length limit data acquired by the acquisition sending module and sending a command for acquiring a session key to the Bluetooth equipment through a Bluetooth communication channel; when the monitoring characteristic value change callback function of the device is called back by the applet, acquiring first encrypted return data from the monitoring characteristic value change callback function; decrypting the first encrypted return data using the preset key to obtain a first session key;
The encryption transmission module is used for encrypting the random number acquisition instruction by using the first session key obtained by the transmission acquisition decryption module to obtain random number acquisition instruction ciphertext data, and calling a transmission function of the applet according to the length limitation data to transmit the random number acquisition instruction ciphertext data to Bluetooth equipment through a Bluetooth communication channel;
the acquisition encryption module is used for acquiring random number encryption data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function of the device is called back by the applet; decrypting the random number encrypted data using the first session key to obtain random number data;
the prompting encryption sending module is used for prompting a user to input a device password, obtaining exclusive-or data according to the device password and random number data when the device password input by the user is received, encrypting the exclusive-or data by using a first session key to obtain exclusive-or encrypted data, calling a sending function of the applet according to the length limiting data, and sending the exclusive-or encrypted data to Bluetooth equipment through a Bluetooth communication channel;
the acquisition decryption sending module is used for acquiring second encrypted return data from the monitoring characteristic value change callback function when the monitoring characteristic value change callback function is called; decrypting the second encrypted return data by using the first session key to obtain second return data, and calling a sending function of the applet to send communication data to the Bluetooth device by taking the Bluetooth device identifier, the device service identifier and the device characteristic identifier as parameters according to the length limiting data when the second return data is the successful information of the verification device password;
The acquisition calling module comprises a sending unit;
the sending unit is used for calling the sending function of the applet to send communication data to the Bluetooth equipment by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters according to the length limit data acquired by the acquisition and calling module;
the sending unit is specifically configured to encrypt data to be signed by using the first session key obtained by the sending acquisition decryption module to generate a second signature instruction, and call a sending function of the applet to send the second signature instruction to the bluetooth device according to the length limitation data by using the bluetooth device identifier, the device service identifier and the device feature identifier as parameters;
the acquiring and transmitting module is specifically configured to acquire third encrypted return data from the monitoring feature value change callback function when the monitoring feature value change callback function is called back by the applet; and decrypting the third encrypted return data by using the first session key obtained by the sending acquisition decryption module to obtain third return data, sending the third return data to the applet, and ending.
13. The apparatus of claim 9, further comprising a get connection invocation module;
The acquisition connection calling module is used for receiving a connection instruction sent by the applet and acquiring a Bluetooth equipment identifier in the connection instruction; according to the Bluetooth equipment identifier, connecting the Bluetooth equipment, and when the connection is successful, acquiring data to be signed from the applet; and calling the starting attention characteristic value change function of the applet by taking the Bluetooth equipment identifier, the preset equipment service identifier and the preset equipment characteristic identifier as parameters.
14. The apparatus of claim 9, wherein the connection invocation module comprises a connection unit; the connection unit is used for connecting with Bluetooth equipment;
the connection unit comprises a first calling subunit, a second calling subunit, a third calling subunit, a fourth calling subunit, an error reporting subunit and a sending subunit;
the first calling subunit is used for calling the initialized Bluetooth function of the applet; when the first successful callback function is called back by the small program, the starting Bluetooth equipment scanning function of the small program is called to scan the Bluetooth equipment;
the second calling subunit is configured to, when the second successful callback function is called by the applet, call a monitoring event function of the applet to monitor an event of the scanned new bluetooth device, receive a bluetooth device identifier returned by the monitoring event callback function of the applet, and determine whether the returned bluetooth device identifier is consistent with the bluetooth device identifier in the communication instruction, if so, trigger the third calling subunit; otherwise, triggering the error reporting subunit;
The error reporting subunit is used for ending error reporting;
the third calling subunit is used for calling a scanning stopping function of the applet to stop scanning the Bluetooth device and triggering the sending subunit;
the sending subunit is used for calling a Bluetooth connection function of the applet to send a connection instruction to the Bluetooth device by taking the Bluetooth device identifier as a parameter when the third successful callback function is called back by the applet;
and the fourth calling subunit is used for calling the starting attention feature value change function of the applet by taking the Bluetooth equipment identifier, the preset equipment service identifier and the preset equipment feature identifier as parameters when the fourth successful callback function is called back by the applet.
15. The apparatus of claim 9, wherein the fetch invoke module comprises a transmit unit;
the sending unit is used for calling the sending function of the applet to send communication data to the Bluetooth equipment by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters according to the length limit data acquired by the acquisition and calling module;
the sending unit comprises a determining and acquiring subunit, a sending subunit and a judging subunit;
The determining and acquiring subunit is used for determining the number of the small communication data packets as the sub communication data according to the length limiting data; acquiring a small communication data packet;
the sending subunit is used for calling a sending function of the applet to send a small communication data packet to the Bluetooth equipment by taking the Bluetooth equipment identifier, the equipment service identifier and the equipment characteristic identifier as parameters;
the judging subunit is configured to judge whether a next small communication data packet can be acquired, and if yes, trigger the acquiring subunit; otherwise, triggering the acquisition and transmission module;
the obtaining subunit is further configured to obtain a next small communication data packet, and trigger the sending subunit.
16. The apparatus of claim 9, wherein the applet is a payment instrument or a WeChat.
CN201911315493.7A 2019-12-19 2019-12-19 Method and device for communication with Bluetooth equipment based on applet platform Active CN110913380B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911315493.7A CN110913380B (en) 2019-12-19 2019-12-19 Method and device for communication with Bluetooth equipment based on applet platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911315493.7A CN110913380B (en) 2019-12-19 2019-12-19 Method and device for communication with Bluetooth equipment based on applet platform

Publications (2)

Publication Number Publication Date
CN110913380A CN110913380A (en) 2020-03-24
CN110913380B true CN110913380B (en) 2023-09-22

Family

ID=69826543

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911315493.7A Active CN110913380B (en) 2019-12-19 2019-12-19 Method and device for communication with Bluetooth equipment based on applet platform

Country Status (1)

Country Link
CN (1) CN110913380B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113886056B (en) * 2021-12-09 2022-03-18 飞天诚信科技股份有限公司 Method and system for accessing Bluetooth equipment under MAC OS system
CN115484343B (en) * 2022-09-08 2024-06-21 上海术理智能科技有限公司 Method for preventing data transmission loss of android mobile phone and Bluetooth equipment based on WeChat applet
CN115883276B (en) * 2022-10-27 2024-09-06 绵阳美菱制冷有限责任公司 Intelligent household electrical appliance safety control method based on small program

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105518692A (en) * 2014-03-12 2016-04-20 腾讯科技(深圳)有限公司 Method and device for controlling peripheral devices via a social networking platform
CN106102058A (en) * 2016-05-30 2016-11-09 飞天诚信科技股份有限公司 A kind of identity identifying method and device
CN106211355A (en) * 2016-06-15 2016-12-07 飞天诚信科技股份有限公司 A kind of control the equipment of data interaction, system and method for work thereof
CN107071709A (en) * 2017-04-06 2017-08-18 飞天诚信科技股份有限公司 A kind of matching method and device with bluetooth equipment
CN108966195A (en) * 2018-07-31 2018-12-07 深圳市信恳智能电子股份有限公司 Wireless gyroscope software implementation method based on wechat small routine
CN109511103A (en) * 2018-11-20 2019-03-22 Oppo(重庆)智能科技有限公司 Thermometry, device, terminal device and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160005032A1 (en) * 2012-11-28 2016-01-07 Hoverkey Ltd. Method and system of providing authentication of user access to a computer resource via a mobile device using multiple separate security factors
WO2018164955A1 (en) * 2017-03-06 2018-09-13 Rivetz Corp. Device enrollment protocol
US11343095B2 (en) * 2017-09-19 2022-05-24 Microsoft Technology Licensing, Llc Cryplet binding key graph

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105518692A (en) * 2014-03-12 2016-04-20 腾讯科技(深圳)有限公司 Method and device for controlling peripheral devices via a social networking platform
CN106102058A (en) * 2016-05-30 2016-11-09 飞天诚信科技股份有限公司 A kind of identity identifying method and device
CN106211355A (en) * 2016-06-15 2016-12-07 飞天诚信科技股份有限公司 A kind of control the equipment of data interaction, system and method for work thereof
CN107071709A (en) * 2017-04-06 2017-08-18 飞天诚信科技股份有限公司 A kind of matching method and device with bluetooth equipment
CN108966195A (en) * 2018-07-31 2018-12-07 深圳市信恳智能电子股份有限公司 Wireless gyroscope software implementation method based on wechat small routine
CN109511103A (en) * 2018-11-20 2019-03-22 Oppo(重庆)智能科技有限公司 Thermometry, device, terminal device and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
小程序蓝牙模块教程;zhangxingdong;《CSDN》;20181207;1-4 *

Also Published As

Publication number Publication date
CN110913380A (en) 2020-03-24

Similar Documents

Publication Publication Date Title
CN110913380B (en) Method and device for communication with Bluetooth equipment based on applet platform
TWI634771B (en) Wisdom device and method and device for establishing Bluetooth connection between devices
CN108712382B (en) Digital identity authentication method and system based on secure two-dimensional code
CN109583898B (en) Intelligent terminal and method for payment based on TEE and block chain
CN109672523B (en) Information encryption method, device and equipment based on filter and readable storage medium
US10423958B2 (en) Method, apparatus and system for voice verification
CN112311544B (en) Method and system for communication between server and authenticator
CN112291774B (en) Method and system for communicating with authenticator
US20090300360A1 (en) Application setting terminal, application executing terminal, and setting information managing server
CN105450269A (en) Method and device for realizing safe interaction and pairing authentication between Bluetooth devices
CN109145628B (en) Data acquisition method and system based on trusted execution environment
CN110380856B (en) Terminal device and voice information processing method and device thereof, and storage medium
WO2011020350A1 (en) Client terminal for providing service, wireless terminal and binding implementation method
CN104852800B (en) Data transmission method and device
JP2012027887A (en) Server, terminal, program and service providing method
EP1681648B1 (en) Communication device and digital signature generation method
CN112702733B (en) Card reading terminal and working method thereof
CN115296822B (en) Method and system for realizing service processing
CN108513272B (en) Short message processing method and device
CN116032548B (en) Access authentication method and device of Internet of things, terminal equipment and gateway equipment
EP2754262A1 (en) Authentication method
CN111132163B (en) Authentication method and system for wireless security equipment and application program
CN112131597B (en) A method, device and intelligent device for generating encrypted information
EP3086583B1 (en) Wireless terminal network locking method and system
CN114842981A (en) A health data reporting and health data query method and device

Legal Events

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