Service discovery method and device, electronic device, and storage medium
By searching and feeding back the target response data in the application parameter registration list on the server side, the problem of time waste in the service discovery process in the Bluetooth link is solved, and more efficient data interaction is achieved.
Patent Information
- Application Number
- CN202211437785.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2042-11-15
AI Technical Summary
In a Bluetooth connection, when the server registers a large number of services, especially when many services are not registered by the corresponding applications, the client wastes time in discovering the services, resulting in a longer time for the application to establish a connection and transmit data.
The server obtains the client's target request, searches the application parameter registration list, generates and feeds back target response data to match the client's target application parameters. The client interacts with the server based on the response data, reducing the search time for traversing all application parameters.
The data interaction time of the Bluetooth link is shortened and the data interaction efficiency is improved.
Smart Images

Figure CN115914350B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of communication technologies, and in particular to a service discovery method and device, an electronic device, and a storage medium. Background Art
[0002] Most electronic devices are equipped with Bluetooth functionality. For example, Bluetooth Low Energy (BLE) allows electronic devices to establish a BLE link with other devices. Once a Bluetooth link is established, the application that initiates the request is called the client, and the application that passively receives the request is called the server.
[0003] The BLE link can be established based on the Generic Attribute Profile (GATT). After the BLE link is established, the client begins to discover GATT services. After discovering the services of the other end, it can exchange data through the characteristics of the corresponding services.
[0004] During service discovery, the client must traverse all services on the server (including Include and Characteristic) before data can be transferred. However, when the server has a large number of registered services, especially when many services are not registered by the corresponding application, this discovery process wastes considerable time, resulting in a longer time from establishing a connection to transmitting data. Summary of the Invention
[0005] The present disclosure provides a service discovery method and device, an electronic device, and a storage medium to address the deficiencies of related technologies.
[0006] According to a first aspect of an embodiment of the present disclosure, a service discovery method is provided, applicable to a server, the method comprising:
[0007] Obtaining a target request, wherein the target request contains target application parameters preset in the client;
[0008] Searching for the target application parameter in the application parameter registration list, and obtaining a search result indicating whether the target application parameter is found;
[0009] Generate target response data that includes the search result and matches the target request;
[0010] The target response data is fed back to the client, so that the client exchanges data with the server after the target application parameters are found according to the target response data.
[0011] Optionally, the target application parameters include services, inclusions, and features.
[0012] Optionally, when the target application parameter includes a service, the target response data includes a service response; the service response includes an operation code, an attribute type, result data, and attribute permissions;
[0013] The operation code is the second operation code, the attribute type is the first attribute type, and the result data indicates whether the service is in the registration list.
[0014] Optionally, when the target application parameter includes include, the target response data includes include response; the include response includes an operation code, an attribute type, and result data;
[0015] The operation code is the second operation code, the attribute type is the second attribute type, and the result data indicates whether the inclusion is in the registration list.
[0016] Optionally, when the target application parameters include features, the target response data includes a feature response; the feature response includes an operation code, an attribute type, an attribute permission, a feature UUID, and a feature handle; the operation code is a second operation code, the attribute type is a third attribute type, the attribute permission indicates a data operation type, the feature handle refers to the object of the message to be transmitted, and the feature UUID indicates an identification code of the feature.
[0017] Optionally, the method further includes:
[0018] When receiving the link establishment request sent by the client, a Bluetooth link is established with the client.
[0019] Optionally, the method further includes:
[0020] The search process is stopped after the target application parameters are searched.
[0021] According to a second aspect of an embodiment of the present disclosure, a service discovery method is provided, applicable to a client, the method comprising:
[0022] Get the target application parameters preset in the client;
[0023] generating a target request containing the target application parameter and sending the target request to the server, so that the server searches the application parameter registration list in response to the target request and returns target response data indicating whether the target application parameter is found;
[0024] When the target response data indicates that the target application parameters are found, data is exchanged with the server according to the target application parameters.
[0025] Optionally, the target application parameters include services, inclusions, and features.
[0026] Optionally, when the target application parameter includes a service, the target request includes a service request; the service request includes an operation code, an attribute type and a service parameter UUID; the operation code is a first operation code, and the attribute type is a first attribute type.
[0027] Optionally, when the target application parameter includes inclusion, the target request includes an inclusion request; the inclusion request includes an operation code, an attribute type, and an attribute permission; the operation code is a first operation code, and the attribute type is a second attribute type.
[0028] Optionally, when the target application parameter includes a feature, the target request includes a feature request; the feature request includes an operation code, an attribute type and a feature UUID; the operation code is a first operation code, and the attribute type is a third attribute type.
[0029] Optionally, the method further includes:
[0030] Send a link establishment request, so that the server establishes a Bluetooth link with the client in response to the link establishment request.
[0031] According to a third aspect of an embodiment of the present disclosure, a service discovery device is provided, applicable to a server, the device comprising:
[0032] A target request acquisition module is used to acquire a target request, wherein the target request contains target application parameters preset in the client;
[0033] a search result acquisition module, configured to search for the target application parameter in the application parameter registration list and obtain a search result indicating whether the target application parameter is found;
[0034] A target response acquisition module, configured to generate target response data containing the search result and matching the target request;
[0035] The target response feedback module is used to feed back the target response data to the client, so that the client can interact with the server after the target application parameters are found in the target response data.
[0036] Optionally, the target application parameters include services, inclusions, and features.
[0037] Optionally, when the target application parameter includes a service, the target response data includes a service response; the service response includes an operation code, an attribute type, result data, and attribute permissions;
[0038] The operation code is the second operation code, the attribute type is the first attribute type, and the result data indicates whether the service is in the registration list.
[0039] Optionally, when the target application parameter includes include, the target response data includes include response; the include response includes an operation code, an attribute type, and result data;
[0040] The operation code is the second operation code, the attribute type is the second attribute type, and the result data indicates whether the inclusion is in the registration list.
[0041] Optionally, when the target application parameters include features, the target response data includes a feature response; the feature response includes an operation code, an attribute type, an attribute permission, a feature UUID, and a feature handle; the operation code is a second operation code, the attribute type is a third attribute type, the attribute permission indicates a data operation type, the feature handle refers to the object of the message to be transmitted, and the feature UUID indicates an identification code of the feature.
[0042] Optionally, the device further comprises:
[0043] The Bluetooth link establishing module is used to establish a Bluetooth link with the client upon receiving a link establishment request sent by the client.
[0044] Optionally, the device further comprises:
[0045] The search stop module is used to stop the search process after searching for the target application parameters.
[0046] According to a fourth aspect of an embodiment of the present disclosure, a service discovery device is provided, applicable to a client, the device comprising:
[0047] The target parameter acquisition module is used to obtain the target application parameters preset in the client;
[0048] a target request generating module, configured to generate a target request containing the target application parameters and send the target request to the server, so that the server searches the application parameter registration list in response to the target request and returns target response data indicating whether the target application parameters are found;
[0049] The data interaction module is used to interact with the server according to the target application parameters after the target response data indicates that the target application parameters have been found.
[0050] Optionally, the target application parameters include services, inclusions, and features.
[0051] Optionally, when the target application parameter includes a service, the target request includes a service request; the service request includes an operation code, an attribute type and a service parameter UUID; the operation code is a first operation code, and the attribute type is a first attribute type.
[0052] Optionally, when the target application parameter includes inclusion, the target request includes an inclusion request; the inclusion request includes an operation code, an attribute type, and an attribute permission; the operation code is a first operation code, and the attribute type is a second attribute type.
[0053] Optionally, when the target application parameter includes a feature, the target request includes a feature request; the feature request includes an operation code, an attribute type and a feature UUID; the operation code is a first operation code, and the attribute type is a third attribute type.
[0054] Optionally, the device further comprises:
[0055] The link request sending module is used to send a link establishment request, so that the server side establishes a Bluetooth link with the client side in response to the link establishment request.
[0056] According to a fifth aspect of the embodiments of the present disclosure, there is provided an electronic device, including:
[0057] Memory and processor;
[0058] The memory is used to store a computer program executable by the processor;
[0059] The processor is configured to execute the computer program in the memory to implement the above method.
[0060] According to a sixth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium is provided, which can implement the above-mentioned method when an executable computer program in the storage medium is executed by a processor.
[0061] The technical solutions provided by the embodiments of the present disclosure may have the following beneficial effects:
[0062] In the solution provided by the embodiment of the present disclosure, a target request can be obtained, and the target request contains target application parameters preset in the client; then, the target application parameters are searched in the application parameter registration list to obtain a search result indicating whether the target application parameters are found; thereafter, target response data is generated that contains the search result and matches the target request; finally, the target response data is fed back to the client, so that the client interacts with the server after the target response data indicates that the target application parameters are found. In this way, in this embodiment, the target application parameters can be searched in the application parameter registration list without traversing all the application parameters in the application parameter registration list, which reduces the search time, thereby shortening the data interaction time between two electronic devices via a Bluetooth link, which is conducive to improving the efficiency of data interaction.
[0063] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0065] Figure 1 The figure is a flowchart of a service discovery method according to an exemplary embodiment.
[0066] Figure 2 The figure is a schematic diagram showing a relationship between target application parameters according to an exemplary embodiment.
[0067] Figure 3 The figure is a flowchart of another service discovery method according to an exemplary embodiment.
[0068] Figure 4 The diagram is an interaction diagram between a client and a server according to an exemplary embodiment.
[0069] Figure 5 The diagram is another diagram of interaction between a client and a server according to an exemplary embodiment.
[0070] Figure 6 The figure is a block diagram showing a service discovery device according to an exemplary embodiment.
[0071] Figure 7 The figure is a block diagram showing a service discovery device according to an exemplary embodiment.
[0072] Figure 8 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0073] Exemplary embodiments will be described in detail herein, with examples shown in the accompanying drawings. When the following description refers to the drawings, identical numbers in different drawings represent identical or similar elements, unless otherwise indicated. The exemplary embodiments described below do not represent all embodiments consistent with the present disclosure. Rather, they are merely examples of devices consistent with certain aspects of the present disclosure, as detailed in the appended claims. It should be noted that, unless there is a conflict, the features of the following embodiments and implementations may be combined with each other.
[0074] In order to solve the above technical problems, the embodiments of the present disclosure provide a service discovery method and device, an electronic device, and a storage medium. The above service discovery method can be applied to electronic devices with Bluetooth functions, which may include but are not limited to smart phones, smart watches, smart glasses, car equipment, etc., and can be selected according to specific scenarios, which are not limited here. Considering that data interaction involves two electronic devices, one of which acts as a client (Client) and the other as a server (Server). To facilitate understanding of the scheme of the present disclosure, the present disclosure describes the scheme of the service discovery method with the client and the server as the execution subjects respectively.
[0075] Figure 1 is a flow chart showing a service discovery method according to an exemplary embodiment. Figure 1 , a service discovery method, applied to a server, includes steps 11 to 14.
[0076] In step 11, a target request is obtained, where the target request contains target application parameters preset in the client.
[0077] In this embodiment, the server can establish a Bluetooth link (i.e., a BLE link) with the client. For example, the client can generate a link establishment request and broadcast it. The server can monitor the broadcast signal in the surrounding space. When the link establishment request is received, it can detect the local pairing information. When the client identification code in the link establishment request is in the list of paired devices on the server, the server can establish a Bluetooth link with the client, thus completing the pairing and connection between the server and the client.
[0078] In this embodiment, the server can communicate with the client through the above-mentioned Bluetooth link to obtain the target request. The target request contains the target application parameters preset in the client. In one example, the target application parameters include service, include, and characteristic. It is understandable that the above-mentioned Bluetooth link is established based on the GATT protocol. The relationship between the target application parameters configured in the GATT protocol is as follows: Figure 2 As shown, the server and client may include at least one service component, and each service component may include multiple includes and multiple characteristics.
[0079] In one example, when the target application parameter includes a service, the target request includes a service request (Target Service Request). The service request includes an opcode (1 byte), an attribute type (2 bytes), and a service parameter UUID (2 bytes or 16 bytes).
[0080] In this example, the opcode is the first opcode, used to identify the command type sent by the peer. In the GATT protocol, opcodes are 1 byte, and 0x01 to 0x23, 0x51, and 0xD2 are already occupied. Therefore, the first opcode uses the reserved byte in the opcode. For example, the first opcode value can be 0x25, 0x26, or 0x27. The following scenarios use the first opcode value of 0x25 as an example to describe various solutions.
[0081] In this example, the attribute type is the first attribute type (0x2801), which identifies the type of application parameters sent by the peer, namely the service type. In the GATT protocol, 0x2801 represents a service, 0x2802 represents an include, and 0x2803 represents a characteristic. In this example, the value of the first attribute type is 0x2801. The frame format of the service request in this example is shown in Table 1.
[0082] Table 1 Target Service Request frame format
[0083] opcode(1byte) AttributeType(2 bytes) Service UUID (2 bytes or 16 bytes) 0x25 0x2801
[0084] In one example, when the target application parameter includes Include, the target request includes an Include request (Target Include Request). The Include request includes an opcode (1 byte), an attribute type (2 bytes), and an Include parameter UUID (2 bytes or 16 bytes).
[0085] In this example, the operation code included in the request is the first operation code. For specific content, please refer to the content of the operation code of the service request, which will not be repeated here.
[0086] In this example, the attribute type is the second attribute type, which is used to identify the type of application parameters sent by the peer end, that is, the inclusion type. In this example, the value of the second attribute type is 0x2802.
[0087] In this example, the frame format of the Target Include Request is shown in Table 2.
[0088] Table 2 contains the frame format of the request
[0089] opcode(1byte) AttributeType(2 bytes) Include UUID(2bytes or 16bytes) 0x25 0x2802
[0090] In one example, when the target application parameter includes a characteristic, the target request includes a characteristic request (Target Characteristic Request). The characteristic request includes an opcode (1 byte), an attribute type (2 bytes), and a characteristic parameter UUID (2 bytes or 16 bytes).
[0091] In this example, the operation code in the feature request is the first operation code. For specific content, please refer to the content of the operation code of the service request, which will not be repeated here.
[0092] In this example, the attribute type is the third attribute type, which is used to identify the type of application parameters sent by the peer end, that is, the feature type. In this example, the value of the third attribute type is 0x2803.
[0093] In this example, the frame format of the characteristic request (Target Characteristic Request) is shown in Table 3.
[0094] Table 3 Frame format of feature request
[0095] opcode(1byte) AttributeType(2 bytes) Characteristic UUID (2bytes or 16bytes) 0x25 0x2803
[0096] In this embodiment, after obtaining the target request, the server can obtain the target application parameters in the target request, that is, obtain the operation code corresponding to the target application parameters.
[0097] In step 12, the target application parameter is searched in the application parameter registration list to obtain a search result indicating whether the target application parameter is found.
[0098] In this embodiment, the server registers three application parameters, namely, service, inclusion, and feature, with the system, and stores them in the corresponding application parameter registration lists. In other words, the server is provided with application parameter registration lists, such as service registration list, inclusion registration list, and feature registration list.
[0099] In this embodiment, the server may search for the target application parameter in the application parameter registration list, thereby obtaining a search result indicating whether the target application parameter is found.
[0100] For example, the server can determine the command type based on the opcode in the service request, that is, the first opcode 0x25 indicates a discovery command or a search command. Then, the server can determine which object (service, containment, or feature) to search for based on the attribute type in the service request, that is, when the first attribute type is 0x2801, it indicates a search service (Service); the server can determine whether the service UUID in the service request is in the service registration list. When the service UUID is in the service registration list, the server can obtain the search result of the discovered service; when the service UUID is not in the service registration list, the server can obtain the search result of the undiscovered service.
[0101] For another example, the server can determine the command type based on the opcode in the include request, that is, when the first opcode is 0x25, it indicates a discovery command or a search command. The server can determine which object (service, include, or feature) to search for based on the attribute type in the include request, that is, the second attribute type is 0x2802, which indicates a search for include. The server can determine whether the include UUID in the include request is within the include registration list. When the include UUID is within the include registration list, the server can obtain a search result that the include is found; when the include UUID is not within the include registration list, the server can obtain a search result that the include is not found.
[0102] For another example, the server can determine the command type based on the opcode in the feature request, that is, when the first opcode is 0x25, it indicates a discovery command or a search command. The server can determine which object (service, inclusion, or feature) to search for based on the attribute type in the feature request, that is, the third attribute type is 0x2803, which indicates a search for inclusion (Include). The server can determine whether the inclusion UUID in the feature request is within the feature registration list. When the feature UUID is within the feature registration list, the server can obtain the search result of the discovered feature; when the feature UUID is not within the feature registration list, the server can obtain the search result of the undiscovered feature.
[0103] In step 13, target response data is generated that includes the search result and matches the target request.
[0104] In this embodiment, the server may generate target response data that includes the search result and matches the target request.
[0105] For example, when the target application parameters include services, the target response data includes a service response; the service response includes an opcode (opcode, 1 byte), an attribute type (AttributeType, 2 bytes), result data (result, 1 byte) and an attribute permission (Attribute Permission, 1 byte). Among them, the opcode of the service response is the second opcode (0x26), which is used to indicate that the command type is a response type. The attribute type of the service response is the first attribute type (0x2801), which is used to indicate the service type; the result data of the service response indicates whether this service is in the registration list (for example, 0x00 indicates existence, 0x01 indicates non-existence); the attribute permission of the service response indicates the data interaction type (for example, 0x00 indicates readable, 0x01 indicates writable, 0x02 indicates readable and writable, etc.)
[0106] In this example, the frame format of the service response (Target Service Response) is shown in Table 4.
[0107] Table 4 Frame format of service response
[0108] opcode(1byte) AttributeType(2 bytes) result(1byte) 0x26 0x2801 0x00 / 0x01
[0109] For another example, when the target application parameter includes inclusion, the target response data includes inclusion response; the inclusion response includes an operation code (opcode, 1 byte), an attribute type (AttributeType, 2 bytes), result data (result, 1 byte) and an attribute permission (Attribute Permission, 1 byte). Among them, the operation code of the inclusion response is the second operation code (0x26), which is used to indicate that the command type is a response type. The attribute type of the inclusion response is the second attribute type (0x2802), which is used to indicate the inclusion type. The result data of the inclusion response indicates whether this inclusion is within the registration list (for example, 0x00 indicates existence, and 0x01 indicates non-existence).
[0110] In this example, the frame format of the Target Include Response is shown in Table 5.
[0111] Table 5 contains the frame format of the response
[0112] opcode(1byte) AttributeType (2 bytes) result(1byte) 0x26 0x2802 0x00 / 0x01
[0113] For another example, when the target application parameters include characteristics, the above-mentioned target response data includes a characteristic response; the characteristic response includes an operation code (opcode, 1 byte), an attribute type (AttributeType, 2 bytes), an attribute permission (Attribute Permission, 1 byte), characteristic characteristics (Charcteristic Perperties, 1 byte or 2 bytes), a characteristic UUID (Charcteristic UUID, 1 byte) and a characteristic handle (Characteristic handle, 2 bytes). Among them, the operation code of the characteristic response is the second operation code (0x26), which is used to indicate that the command type is a response type. The attribute type containing the response is the third attribute type (0x2803), which is used to indicate the characteristic type. The attribute permission indicates the data operation type (for example, 0x00 indicates readable, 0x01 indicates writable, 0x02 indicates readable and writable, etc.), the characteristic handle refers to the object of the message to be transmitted, and the characteristic UUID indicates the identification code of the characteristic.
[0114] In this example, the frame format of the target characteristic response is shown in Table 6.
[0115] Table 6 Frame format of feature response
[0116]
[0117] In step 14, the target response data is fed back to the client, so that the client exchanges data with the server after the target application parameters are found based on the target response data.
[0118] In this embodiment, the server can feed the target response data back to the client. After receiving the target response data, the client can obtain the services, contents, and characteristics. It can then establish a data transmission channel based on the services, contents, and characteristics, and use the data transmission channel to exchange data between the server and the client.
[0119] In this embodiment, the server may stop the search process after searching for the target application parameters without traversing all registered application parameters.
[0120] At this point, the solution provided by the embodiment of the present disclosure can obtain a target request, which contains a target application parameter preset in the client; then, the target application parameter is searched in the application parameter registration list to obtain a search result indicating whether the target application parameter is found; thereafter, target response data is generated that contains the search result and matches the target request; finally, the target response data is fed back to the client, so that the client interacts with the server after the target response data indicates that the target application parameter is found. In this way, in this embodiment, the target application parameter can be searched in the application parameter registration list without traversing all the application parameters in the application parameter registration list, which reduces the search time, thereby shortening the data interaction time between two electronic devices via a Bluetooth link, which is conducive to improving data interaction efficiency.
[0121] Figure 3 is a flow chart showing a service discovery method according to an exemplary embodiment. Figure 3 , a service discovery method, applied to a client, includes steps 31 to 33.
[0122] In step 31, target application parameters preset in the client are obtained.
[0123] In this embodiment, see Figure 4 , the client can establish a Bluetooth link (i.e., a BLE link) with the server. For example, the client can generate a link establishment request and broadcast it. The server can monitor the broadcast signal in the surrounding space. When it receives the link establishment request, it can detect the local pairing information. When the client identification code in the link establishment request is in the list of paired devices on the server, the server can establish a Bluetooth link with the client, thus completing the pairing and connection between the server and the client.
[0124] In this embodiment, the client can obtain target application parameters preset in the client. In one example, the target application parameters include service, include, and characteristic. The client can obtain service, include, and characteristic in sequence. Specifically, the client can first obtain service, and then obtain include when it is determined that the service has been registered with the server; and then obtain characteristic when it is determined that the include has been registered with the server.
[0125] In step 32, a target request containing the target application parameters is generated and sent to the server, so that the server searches the application parameter registration list in response to the target request and returns target response data indicating whether the search result of the target application parameters is found.
[0126] In this embodiment, continue to see Figure 4 The client can generate a target request containing target application parameters and send it to the server. The target request can refer to the relevant content of step 11 and will not be repeated here.
[0127] In this embodiment, after receiving the target request, the server can search the application parameter registration list for the corresponding application parameter, such as service, inclusion, or feature, and generate the target response data. The scheme for searching the application parameter and generating the target response data can be found in the relevant content of steps 12 and 13, and will not be repeated here.
[0128] In step 33, when the target response data indicates that the target application parameters are found, data is exchanged with the server according to the target application parameters.
[0129] In this embodiment, after receiving the target response data, the client can determine the service, content and characteristics of the target application parameters and then discover the service. At this time, the client and the server can exchange data based on the characteristics of the service.
[0130] It should be noted that in the related technology, the following process needs to be completed before the client and server interact with each other. Figure 5 ,include:
[0131] The client sends a group-type request (ATT_READ_BY_GROUP_TYPE_REQ) to the server, requesting the server to return the currently registered primary service. After receiving this group-type request, the server searches the service registration list for services with a preset size and returns the search result, which is a frame of data. Similarly, after searching all registered services, the server searches a maximum of 65,535 registered services, but typically far fewer, and returns the search result. Accordingly, the client receives several service response frames, for example, 4 to 10 frames. In the service response, the client can determine whether the service UUID is a registered service on the server. If the service UUID is a registered service, the client then discovers the include within the service, sending a read include command (ATT_READ_BY_TYPE_REQ) and querying the service process type. The server searches for the registered include within the service and returns an include response with a preset size, until the entire include registration list is searched. Consequently, the client receives several more include response frames. After determining the corresponding inclusion, the client will send a read feature instruction (ATT_READ_BY_TYPE_REQ) to enable the server to return the registered features. After determining the characteristics of the service, the client and the server can exchange data based on the characteristics of the service. Based on the above process analysis, before the client and the server interact with each other, the client needs to receive multiple frames of response data (service response, inclusion response, and feature response) in three stages, which consumes more time. In this embodiment, the client and the server can achieve data interaction through 4 request processes and receiving 4 frames of response data, and the service search time is reduced to a quarter of the original time.
[0132] At this point, the solution provided by the disclosed embodiment can obtain the target application parameters preset in the client; generate a target request containing the target application parameters and send it to the server, so that the server searches the application parameter registration list in response to the target request and returns target response data indicating whether the target application parameters are found; when the target response data indicates that the target application parameters are found, data is exchanged with the server based on the target application parameters. In this way, in this embodiment, the client can exchange data with the server by only sending four requests and receiving four response data, shortening the data exchange time and improving data exchange efficiency.
[0133] Based on a service discovery method provided in an embodiment of the present disclosure, the present disclosure also provides a service discovery device, which is applicable to the server. Figure 6 , the device comprises:
[0134] A target request acquisition module 61 is configured to acquire a target request, wherein the target request contains target application parameters preset in the client;
[0135] A search result acquisition module 62 is configured to search for the target application parameter in the application parameter registration list and obtain a search result indicating whether the target application parameter is found;
[0136] A target response acquisition module 63 is configured to generate target response data that includes the search result and matches the target request;
[0137] The target response feedback module 64 is configured to feed back the target response data to the client, so that the client can interact with the server after the target application parameters are found in the target response data.
[0138] Optionally, the target application parameters include services, inclusions, and features.
[0139] Optionally, when the target application parameter includes a service, the target response data includes a service response; the service response includes an operation code, an attribute type, result data, and attribute permissions;
[0140] The operation code is the second operation code, the attribute type is the first attribute type, and the result data indicates whether the service is in the registration list.
[0141] Optionally, when the target application parameter includes include, the target response data includes include response; the include response includes an operation code, an attribute type, and result data;
[0142] The operation code is the second operation code, the attribute type is the second attribute type, and the result data indicates whether the inclusion is in the registration list.
[0143] Optionally, when the target application parameters include features, the target response data includes a feature response; the feature response includes an operation code, an attribute type, an attribute permission, a feature UUID, and a feature handle; the operation code is a second operation code, the attribute type is a third attribute type, the attribute permission indicates a data operation type, the feature handle refers to the object of the message to be transmitted, and the feature UUID indicates an identification code of the feature.
[0144] Optionally, the device further comprises:
[0145] The Bluetooth link establishing module is used to establish a Bluetooth link with the client upon receiving a link establishment request sent by the client.
[0146] Optionally, the device further comprises:
[0147] The search stop module is used to stop the search process after searching for the target application parameters.
[0148] Based on a service discovery method provided in an embodiment of the present disclosure, the present disclosure also provides a service discovery device, which is applicable to a client. Figure 7 , the device comprises:
[0149] The target parameter acquisition module 71 is used to obtain the target application parameters preset in the client;
[0150] a target request generating module 72 for generating a target request containing the target application parameters and sending the target request to the server, so that the server searches the application parameter registration list in response to the target request and returns target response data indicating whether the target application parameters are found;
[0151] The data interaction module 73 is configured to interact with the server according to the target application parameters after the target response data indicates that the target application parameters have been found.
[0152] Optionally, the target application parameters include services, inclusions, and features.
[0153] Optionally, when the target application parameter includes a service, the target request includes a service request; the service request includes an operation code, an attribute type and a service parameter UUID; the operation code is a first operation code, and the attribute type is a first attribute type.
[0154] Optionally, when the target application parameter includes inclusion, the target request includes an inclusion request; the inclusion request includes an operation code, an attribute type, and an attribute permission; the operation code is a first operation code, and the attribute type is a second attribute type.
[0155] Optionally, when the target application parameter includes a feature, the target request includes a feature request; the feature request includes an operation code, an attribute type and a feature UUID; the operation code is a first operation code, and the attribute type is a third attribute type.
[0156] Optionally, the device further comprises:
[0157] The link request sending module is used to send a link establishment request, so that the server side establishes a Bluetooth link with the client side in response to the link establishment request.
[0158] It should be noted that the device embodiment shown in this embodiment matches the content of the above method embodiment. You can refer to the content of the above method embodiment and will not repeat it here.
[0159] Based on a service discovery method provided in an embodiment of the present disclosure, an embodiment of the present disclosure also provides a service discovery system, the system including a vehicle device and an electronic device; the vehicle device displays a screen projection identification code used for this screen projection in response to detecting a trigger operation of the vehicle device; the vehicle device plays an audio file carrying the screen projection identification code at least once; the electronic device starts a screen projection application and turns on the audio acquisition function of the electronic device, and obtains a sound wave signal carrying the screen projection identification code based on the audio acquisition function to obtain a sound wave file, and establishes a screen projection link with the vehicle device according to the screen projection identification code in the sound wave signal; the vehicle device shares the current display content of the electronic device according to the screen projection link.
[0160] It should be noted that the system embodiment shown in this embodiment matches the content of the above-mentioned method embodiment. You can refer to the content of the above-mentioned method embodiment and will not repeat it here.
[0161] Figure 8 8 is a block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 800 may be a smartphone, a computer, a digital broadcast terminal, a tablet device, a medical device, a fitness device, a personal digital assistant, or the aforementioned vehicle device.
[0162] Reference Figure 8 The electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power supply component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , a communication component 816 , and an image acquisition component 818 .
[0163] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. The processing component 802 may include one or more processors 820 to execute computer programs. In addition, the processing component 802 may include one or more modules to facilitate interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
[0164] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include computer programs for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0165] The power supply assembly 806 provides power to various components of the electronic device 800. The power supply assembly 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800. The power supply assembly 806 may include a power chip, and the controller may communicate with the power chip to control the power chip to turn on or off a switching device, thereby enabling or disabling the battery to supply power to the mainboard circuit.
[0166] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the target object. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input information from the target object. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor can not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0167] The audio component 810 is configured to output and / or input audio file information. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a record mode, and a voice recognition mode, the microphone is configured to receive external audio file information. The received audio file information can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting the audio file information.
[0168] The I / O interface 812 provides an interface between the processing component 802 and a peripheral interface module, such as a keyboard, a click wheel, or a button.
[0169] Sensor assembly 814 includes one or more sensors for providing various status assessments for electronic device 800. For example, sensor assembly 814 can detect the open / closed state of electronic device 800, the relative positioning of components, such as the display screen and keypad of electronic device 800. Sensor assembly 814 can also detect changes in the position of electronic device 800 or a component, the presence or absence of contact between a target object and electronic device 800, the orientation or acceleration / deceleration of electronic device 800, and changes in the temperature of electronic device 800. In this example, sensor assembly 814 may include a magnetic sensor, a gyroscope, and a magnetic field sensor, wherein the magnetic field sensor includes at least one of the following: a Hall effect sensor, a thin-film magnetoresistive sensor, or a magnetic fluid acceleration sensor.
[0170] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives broadcast information or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0171] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.
[0172] In an exemplary embodiment, an electronic device is also provided, including:
[0173] Memory and processor;
[0174] The memory is used to store a computer program executable by the processor;
[0175] The processor is configured to execute the computer program in the memory to implement the above method.
[0176] In an exemplary embodiment, a non-transitory computer-readable storage medium is also provided, such as a memory 804 including instructions, and the above-mentioned executable computer program can be executed by the processor. The readable storage medium can be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
[0177] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the disclosure herein. This disclosure is intended to cover any variations, uses, or adaptations that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0178] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A service discovery method, characterized in that: Applicable to the server, the method includes: Obtain a target request, the target request containing target application parameters preset in the client; the target application parameters include services, includes, and features; each parameter of the target application parameters includes a first opcode, the first opcode is used to identify the type of command sent by the peer end; the first opcode is implemented using a reserved byte in the opcode; Searching for the target application parameter in the application parameter registration list, and obtaining a search result indicating whether the target application parameter is found; generating target response data that includes the search result and matches the target request; when the response data includes a service response, an inclusion response, or a feature response, the opcodes of the service response, the inclusion response, and the feature response are all second opcodes, and the second opcode is implemented using a reserved byte in the opcode; The target response data is fed back to the client, so that the client exchanges data with the server after the target application parameters are found according to the target response data.
2. The method according to claim 1, characterized in that When the target application parameter includes a service, the target response data includes a service response; the service response includes an operation code, an attribute type, result data, and attribute permissions; The operation code is the second operation code, the attribute type is the first attribute type, and the result data indicates whether the service is in the registration list.
3. The method according to claim 1, characterized in that When the target application parameter includes include, the target response data includes include response; the include response includes an operation code, an attribute type and result data; The operation code is the second operation code, the attribute type is the second attribute type, and the result data indicates whether the inclusion is in the registration list.
4. The method according to claim 1, wherein When the target application parameter includes a feature, the target response data includes a feature response; the feature response includes an operation code, an attribute type, an attribute permission, a feature UUID, and a feature handle; The operation code is the second operation code, the attribute type is the third attribute type, the attribute permission indicates the data operation type, the feature handle refers to the object of the message to be transmitted, and the feature UUID indicates the identification code of the feature.
5. The method according to claim 1, wherein The method further comprises: When receiving the link establishment request sent by the client, a Bluetooth link is established with the client.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: The search process is stopped after the target application parameters are searched.
7. A service discovery method, characterized in that: Applicable to the client, the method includes: Obtaining target application parameters preset in the client; the target application parameters include services, includes, and features; each parameter of the target application parameters includes a first opcode, the first opcode is used to identify the type of command sent by the peer end; the first opcode is implemented using a reserved byte in the opcode; generating a target request containing the target application parameters and sending the target request to the server, so that the server searches the application parameter registration list in response to the target request and returns target response data indicating whether the target application parameters are found; when the response data includes a service response, an include response, or a feature response, the operation codes of the service response, the include response, and the feature response are all second operation codes, and the second operation code is implemented using a reserved byte in the opcode; When the target response data indicates that the target application parameters are found, data is exchanged with the server according to the target application parameters.
8. The method according to claim 7, characterized in that When the target application parameter includes a service, the target request includes a service request; the service request includes an operation code, an attribute type, and a service parameter UUID; the operation code is a first operation code, and the attribute type is a first attribute type.
9. The method according to claim 7, characterized in that When the target application parameter includes inclusion, the target request includes an inclusion request; the inclusion request includes an operation code, an attribute type, and an attribute permission; the operation code is a first operation code, and the attribute type is a second attribute type.
10. The method according to claim 7, characterized in that When the target application parameter includes a feature, the target request includes a feature request; the feature request includes an operation code, an attribute type, and a feature UUID; the operation code is a first operation code, and the attribute type is a third attribute type.
11. The method according to claim 7, characterized in that The method further comprises: Send a link establishment request, so that the server establishes a Bluetooth link with the client in response to the link establishment request.
12. A service discovery device, characterized in that: Applicable to the server, the device includes: A target request acquisition module is configured to acquire a target request, wherein the target request contains target application parameters preset in the client; the target application parameters include services, includes, and features; each parameter of the target application parameters includes a first opcode, which is used to identify the type of command sent by the peer end; the first opcode is implemented using a reserved byte in the opcode; a search result acquisition module, configured to search for the target application parameter in the application parameter registration list and obtain a search result indicating whether the target application parameter is found; a target response acquisition module, configured to generate target response data containing the search result and matching the target request; when the response data includes a service response, an inclusion response, or a feature response, the opcodes of the service response, the inclusion response, and the feature response are all second opcodes, and the second opcode is implemented using a reserved byte in the opcode; The target response feedback module is used to feed back the target response data to the client, so that the client can interact with the server after the target application parameters are found in the target response data.
13. A service discovery device, characterized in that: Applicable to a client, the device includes: A target parameter acquisition module is configured to acquire target application parameters preset in the client; the target application parameters include services, inclusions, and features; each parameter of the target application parameters includes a first opcode, which is used to identify the type of command sent by the peer end; the first opcode is implemented using a reserved byte in the opcode; a target request generation module, configured to generate a target request containing the target application parameters and send the target request to the server, so that the server searches the application parameter registration list in response to the target request and returns target response data indicating whether the target application parameters are found; when the response data includes a service response, an inclusion response, or a feature response, the operation codes of the service response, the inclusion response, and the feature response are all second operation codes, and the second operation code is implemented using a reserved byte in the opcode; The data interaction module is used to interact with the server according to the target application parameters after the target response data indicates that the target application parameters have been found.
14. An electronic device, characterized in that: include: Memory and processor; The memory is used to store a computer program executable by the processor; The processor is configured to execute the computer program in the memory to implement the method according to any one of claims 1 to 11.
15. A non-transitory computer-readable storage medium, characterized in that When the executable computer program in the storage medium is executed by a processor, the method according to any one of claims 1 to 11 can be implemented.
Citation Information
Patent Citations
Interprocess communication method across host machine, device thereof and system thereof
CN101902458A