[go: up one dir, main page]

CN115914350B - Service discovery method and device, electronic device, and storage medium - Google Patents

Service discovery method and device, electronic device, and storage medium

Info

Publication number
CN115914350B
CN115914350B CN202211437785.XA CN202211437785A CN115914350B CN 115914350 B CN115914350 B CN 115914350B CN 202211437785 A CN202211437785 A CN 202211437785A CN 115914350 B CN115914350 B CN 115914350B
Authority
CN
China
Prior art keywords
target
response
request
target application
service
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
CN202211437785.XA
Other languages
Chinese (zh)
Other versions
CN115914350A (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.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software 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 Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN202211437785.XA priority Critical patent/CN115914350B/en
Publication of CN115914350A publication Critical patent/CN115914350A/en
Application granted granted Critical
Publication of CN115914350B publication Critical patent/CN115914350B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Mobile Radio Communication Systems (AREA)

Abstract

本公开是关于一种服务发现方法和装置、电子设备、存储介质。该方法包括:获取目标请求,所述目标请求含有客户端中预设的目标应用参数;在应用参数注册列表中查找所述目标应用参数,得到表示是否发现所述目标应用参数的查找结果;生成包含所述查找结果且与所述目标请求相匹配的目标响应数据;将所述目标响应数据反馈给所述客户端,以使所述客户端在所述目标响应数据表征发现目标应用参数后与所述服务端交互数据。本实施例中可以在应用参数注册列表中查找目标应用参数而无需遍历应用参数注册列表中全部应用参数,减少了查找时间,从而缩短两个电子设备通过蓝牙链接进行数据交互时间,有利于提高数据交互效率。

The present disclosure relates to a service discovery method and device, an electronic device, and a storage medium. The method includes: obtaining a target request, wherein the target request contains a target application parameter preset in the client; searching for the target application parameter in the application parameter registration list to obtain a search result indicating whether the target application parameter is found; generating target response data containing the search result and matching the target request; and feeding back the target response data to the client, so that the client interacts with the server after the target response data indicates the discovery of the target application parameter. 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, and is conducive to improving data interaction efficiency.

Description

Service discovery method and device, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of communication, and in particular relates to a service discovery method and device, electronic equipment and a storage medium.
Background
Most of the existing electronic devices are provided with bluetooth functions, and take Bluetooth Low Energy (BLE) as an example, the electronic devices establish BLE links with other devices. After the two electronic devices establish the bluetooth link, the application that actively initiates the request is called a Client (Client), and the application that passively receives the request is called a Server (Server).
The BLE link may be established based on a generic attribute protocol (Generic Attribute Profile, GATT). After the BLE link is established, the Client starts to find the GATT service, and after the service of the opposite end is found, the data can be interacted through the characteristics of the corresponding service.
In the Service discovery process, the Client must traverse all services (including Include and chat) of the Service end before the two parties can perform data transmission. However, when the number of services registered at the Server is large, especially many services are not registered by the corresponding application, the discovery process wastes much time, resulting in a long time for the application to transfer data from establishing a connection.
Disclosure of Invention
The present disclosure provides a service discovery method and apparatus, an electronic device, and a storage medium to solve the deficiencies of the related art.
According to a first aspect of embodiments of the present disclosure, there is provided a service discovery method, applicable to a server, the method including:
acquiring a target request, wherein the target request contains target application parameters preset in a client;
searching the target application parameters in an application parameter registration list to obtain a searching result which indicates whether the target application parameters are found;
generating target response data which contains the search result and is matched with the target request;
And feeding back the target response data to the client so that the client interacts data with the server after the target response data characterizes and discovers target application parameters.
Optionally, the target application parameters include services, inclusion, and features.
Optionally, when the target application parameter comprises a service, the target response data comprises a service response, wherein the service response comprises an operation code, an attribute type, result data and attribute authority;
The operation code is a second operation code, the attribute type is a first attribute type, and the result data indicates whether the service is in the registration list.
Optionally, when the target application parameter comprises an inclusion, the target response data comprises an inclusion response, the inclusion response comprising an opcode, an attribute type, and result data;
The opcode is a second opcode and the attribute type is a second attribute type, and the result data indicates whether this inclusion is within the registry.
Optionally, when the target application parameter includes a feature, the target response data includes a feature response, where the feature response includes an operation code, an attribute type, an attribute authority, 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 authority indicates a data operation type, the feature handle indicates an object of a message to be transmitted, and the feature UUID indicates an identification code of the feature.
Optionally, the method further comprises:
and when receiving a link establishment request sent by a client, establishing a Bluetooth link with the client.
Optionally, the method further comprises:
and stopping the searching process after the target application parameters are searched.
According to a second aspect of embodiments of the present disclosure, there is provided a service discovery method, applicable to a client, the method including:
Acquiring target application parameters preset in a client;
Generating a target request containing the target application parameters and sending the target request to a server, so that the server responds to the target request to search an application parameter registration list and returns target response data which indicates whether the search result of the target application parameters is found;
and after the target response data represent that the target application parameters are found, the data are interacted with the server according to the target application parameters.
Optionally, the target application parameters include services, inclusion, and features.
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.
Optionally, when the target application parameter includes an inclusion, the target request includes an inclusion request, the inclusion request includes an operation code, an attribute type and an attribute authority, the operation code is a first operation code, and the attribute type is a second attribute type.
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.
Optionally, the method further comprises:
and sending a link establishment request to enable the server side to establish a Bluetooth link with the client side in response to the link establishment request.
According to a third aspect of embodiments of the present disclosure, there is provided a service discovery apparatus, adapted to a service side, the apparatus including:
the target request acquisition module is used for acquiring a target request, wherein the target request contains target application parameters preset in a client;
the search result acquisition module is used for searching the target application parameters in the application parameter registration list to obtain a search result which indicates whether the target application parameters are found;
The target response acquisition module is used for generating target response data which contains the search result and is matched with the target request;
And the target response feedback module is used for feeding back the target response data to the client so that the client interacts data with the server after the target response data characterize and discover target application parameters.
Optionally, the target application parameters include services, inclusion, and features.
Optionally, when the target application parameter comprises a service, the target response data comprises a service response, wherein the service response comprises an operation code, an attribute type, result data and attribute authority;
The operation code is a second operation code, the attribute type is a first attribute type, and the result data indicates whether the service is in the registration list.
Optionally, when the target application parameter comprises an inclusion, the target response data comprises an inclusion response, the inclusion response comprising an opcode, an attribute type, and result data;
The opcode is a second opcode and the attribute type is a second attribute type, and the result data indicates whether this inclusion is within the registry.
Optionally, when the target application parameter includes a feature, the target response data includes a feature response, where the feature response includes an operation code, an attribute type, an attribute authority, 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 authority indicates a data operation type, the feature handle indicates an object of a message to be transmitted, and the feature UUID indicates an identification code of the feature.
Optionally, the apparatus further comprises:
and the Bluetooth link establishment module is used for establishing Bluetooth link with the client when receiving the link establishment request sent by the client.
Optionally, the apparatus further comprises:
and the searching and stopping module is used for stopping the searching process after the target application parameters are searched.
According to a fourth aspect of embodiments of the present disclosure, there is provided a service discovery apparatus adapted for use in a client, the apparatus comprising:
the target parameter acquisition module is used for acquiring target application parameters preset in the client;
The target request generation module is used for generating a target request containing the target application parameters and sending the target request to the server side so that the server side responds to the target request to search an application parameter registration list and returns target response data which indicates whether the search result of the target application parameters is found;
And the data interaction module is used for interacting data with the server according to the target application parameters after the target response data indicates that the target application parameters are found.
Optionally, the target application parameters include services, inclusion, and features.
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.
Optionally, when the target application parameter includes an inclusion, the target request includes an inclusion request, the inclusion request includes an operation code, an attribute type and an attribute authority, the operation code is a first operation code, and the attribute type is a second attribute type.
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.
Optionally, the apparatus further comprises:
And the link request sending module is used for sending a link establishment request so that the server side responds to the link establishment request and establishes a Bluetooth link with the client side.
According to a fifth aspect of embodiments of the present disclosure, there is provided an electronic device, comprising:
A memory and a processor;
the memory is used for storing a computer program executable by the processor;
the processor is configured to execute the computer program in the memory to implement the method as described above.
According to a sixth aspect of embodiments of the present disclosure, there is provided a non-transitory computer readable storage medium, which when executed by a processor, is capable of carrying out a method as described above.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects:
According to the scheme provided by the embodiment of the disclosure, a target request can be acquired, the target request contains target application parameters preset in a client, then the target application parameters are searched in an application parameter registration list to obtain a search result which indicates whether the target application parameters are found, then target response data which contains the search result and is matched with the target request is generated, and finally the target response data is fed back to the client so that the client interacts data with the server after the target application parameters are found by the target response data. In this way, in the 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, so that the searching time is reduced, the data interaction time of two electronic devices through Bluetooth links is shortened, and the data interaction efficiency is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 is a flowchart illustrating a service discovery method according to an exemplary embodiment.
FIG. 2 is a schematic diagram illustrating the relationship of one target application parameter, according to an example embodiment.
Fig. 3 is a flow chart illustrating another service discovery method according to an example embodiment.
Fig. 4 is an interaction diagram between a client and a server, according to an example embodiment.
Fig. 5 is an interaction diagram between another client and a server, shown according to an example embodiment.
Fig. 6 is a block diagram illustrating a service discovery apparatus according to an exemplary embodiment.
Fig. 7 is a block diagram illustrating a service discovery apparatus according to an exemplary embodiment.
Fig. 8 is a block diagram of an electronic device, according to an example embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The embodiments described by way of example below are not representative of all embodiments consistent with the present disclosure. Rather, they are merely examples of apparatus consistent with some aspects of the disclosure as detailed in the accompanying claims. The features of the following examples and embodiments may be combined with each other without any conflict.
In order to solve the technical problems, embodiments of the present disclosure provide a service discovery method and apparatus, an electronic device, and a storage medium. The service discovery method may be applied to an electronic device with bluetooth function, and the electronic device may include, but is not limited to, a smart phone, a smart watch, smart glasses, a vehicle device, etc., and may be selected according to a specific scenario, which is not limited herein. Considering that data interaction involves two electronic devices, one of which is a Client (Client) and the other is a Server (Server). In order to facilitate understanding of the solution of the present disclosure, the present disclosure describes the solution of the service discovery method with the client and the server as execution subjects, respectively.
Fig. 1 is a flowchart of a service discovery method according to an exemplary embodiment, referring to fig. 1, and the service discovery method is applied to a server and includes steps 11 to 14.
In step 11, a target request is obtained, where the target request contains target application parameters preset in the client.
In this embodiment, the server may establish a bluetooth link (i.e. BLE link) with the client. For example, the client may generate a link establishment request and broadcast. The server can monitor the broadcast signals of the surrounding space, can detect the local pairing information after receiving the link establishment request, and can establish Bluetooth link with the client when the identification code of the client in the link establishment request is positioned in the paired equipment list in the server, so that the server and the client finish the pairing and connection work.
In this embodiment, the server may communicate with the client through the bluetooth link, so as to obtain the target request. The target request contains target application parameters preset in the client. In one example, the target application parameters Include services (Service), inclusion (Include), and features (feature). It can be appreciated that the bluetooth link is established based on the GATT protocol, and the relationship of the target application parameters configured in the GATT protocol is shown in fig. 2. The server and client may Include at least one Service (Service) composition, each (Service) comprising a plurality of Include (Include) and a plurality of feature (feature) compositions.
In an example, when the target application parameter includes a Service (Service), the target Request includes a Service Request (TARGET SERVICE Request). The Service request includes an opcode (1 byte), an attribute type (AttributeType, 2 bytes), and a Service parameter UUID (Service UUID,2bytes, or 16 bytes).
In this example, the operation code is a first operation code, which is used to identify the type of command issued by the opposite terminal. In the GATT protocol, the opcode is 1 byte, and 0x01 to 0x23, 0x51 and 0xD2 are occupied, so that the reserved bytes in the opcode are adopted as the first operation code, for example, the value of the first operation code is 0x25, 0x26 or 0x27, and the schemes are described by taking the value of the first operation code as 0x25 as an example.
In this example, the attribute type is a first attribute type (0 x 2801) used to identify the type of application parameter sent by the peer, i.e. the service type. In the GATT protocol, 0x2801 is Service,0x2802 is Include, and 0x2803 is feature characacteristic. In this example, the value of the first attribute type is 0x2801. In this example, the frame format of the service request is shown in table 1.
Table 1 frame format of service Request (TARGET SERVICE Request)
opcode(1byte) AttributeType(2bytes) Service UUID (2 bytes or 16 bytes)
0x25 0x2801
In one example, when the target application parameter includes an Include (Include), the target request includes an Include request (Target Include Request). The Include request includes an opcode (1 byte), an attribute type (AttributeType, 2 bytes), and a Include parameter UUID (Include UUID,2bytes, or 16 bytes).
In this example, the operation code included in the request is the first operation code, and the specific content may refer to the content of the operation code of the service request, which is not described herein.
In this example, the attribute type is a second attribute type, which is used to identify the type of the application parameter sent by the peer, i.e. the inclusion type. In this example, the second attribute type has a value of 0x2802.
In this example, the frame format containing the request (Target Include Request) is shown in table 2.
Table 2 contains the requested frame format
opcode(1byte) AttributeType(2bytes) Include UUID (2 bytes or 16 bytes)
0x25 0x2802
In one example, when the target application parameter includes a feature (charcteristic), the target Request includes a feature Request (TARGET CHARACTERISTIC Request). The feature request includes an opcode (1 byte), an attribute type (AttributeType, 2 bytes), and a feature parameter UUID (CHARACTERISTIC UUID,2bytes, or 16 bytes).
In this example, the operation code in the feature request is the first operation code, and the specific content may refer to the content of the operation code of the service request, which is not described herein.
In this example, the attribute type is a third attribute type, which is used to identify the type of the application parameter sent by the peer, i.e. the feature type. In this example, the third attribute type has a value of 0x2803.
In this example, the frame format of the feature Request (TARGET CHARACTERISTIC Request) is shown in table 3.
Table 3 frame format of feature request
opcode(1byte) AttributeType(2bytes) charACTERISTIC UUID (2 bytes or 16 bytes)
0x25 0x2803
In this embodiment, after obtaining the target request, the server may obtain the target application parameter in the target request, that is, obtain the operation code corresponding to the target application parameter.
In step 12, the target application parameter is searched in an application parameter registration list, and a search result indicating whether the target application parameter is found is obtained.
In this embodiment, the server registers three application parameters including and characteristic to the system, so as to store the three application parameters in the corresponding application parameter registration list. Or, the service end is provided with an application parameter registration list, such as a service registration list, a containing registration list and a feature registration list.
In this embodiment, the server may search the target application parameter in the application parameter registration list, so as to obtain a search result indicating whether the target application parameter is found.
For example, the server may determine the command type according to the operation code in the service request, that is, the first operation code 0x25 indicates a discovery command or a search command. The server may then determine which object (Service, inclusion or feature) to look up based on the attribute type in the Service request, i.e., the first attribute type is 0x2801 to indicate that the Service (Service) is looked up, and may determine whether the UUID of the Service in the Service request is located in the Service registration list. When the UUID of the service is not in the service registration list, the service end can obtain the search result of the undiscovered service.
As another example, the server may determine the command type from the opcode contained in the request, i.e., the first opcode is 0x25 indicating a discovery command or a lookup command. The server may determine which object (service, inclusion or feature) to find based on the attribute type in the inclusion request, i.e., a second attribute type of 0x2802 indicates that the inclusion (Include) is found. The server may determine whether the containment UUID in the containment request is located within the containment registration list. When the UUID is not located in the registration list, the server side can obtain the finding result of not finding the inclusion.
For another example, the server may determine the command type based on the opcode in the feature request, i.e., the first opcode is 0x25 indicating a discovery command or a lookup command. The server may determine which object (service, inclusion or feature) to find based on the attribute type in the feature request, i.e., a third attribute type of 0x2803 indicates that the search contains (Include). The server may determine whether the UUID contained in the feature request is located within the feature registration list. When the feature UUID is not in the feature registration list, the server side can obtain the search result of the undiscovered feature.
In step 13, target response data is generated that contains the lookup result and matches the target request.
In this embodiment, the server may generate target response data that includes the search result and matches the target request.
For example, when the target application parameter includes a service, the target response data includes a service response including an operation code (opcode, 1 byte), an attribute type (AttributeType, 2 bytes), result data (result, 1 byte), and attribute authority (Attribute Permission,1 byte). Wherein the operation code of the service response is a second operation code (0 x 26) used for indicating that the command type is a response type. The attribute type of the service response is a first attribute type (0 x 2801) for indicating the service type, the result data of the service response indicates whether the service is located within the registration list (e.g., 0x00 indicates presence, 0x01 indicates absence), the attribute authority of the service response indicates the data interaction type (e.g., 0x00 indicates readability, 0x01 indicates writeability, 0x02 indicates readability and writeability, etc.)
In this example, the frame format of the service Response (TARGET SERVICE Response) is shown in table 4.
Table 4 frame format of service response
opcode(1byte) AttributeType(2bytes) result(1byte)
0x26 0x2801 0x00/0x01
For another example, when the target application parameter includes an include, the target response data includes an include response including an operation code (opcode, 1 byte), an attribute type (AttributeType, 2 bytes), result data (result, 1 byte), and attribute rights (Attribute Permission,1 byte). The operation code containing the response is a second operation code (0 x 26) used for indicating that the command type is the response type. The attribute type of the containment response is a second attribute type (0 x 2802) representing the containment type. The result data for the response is included to indicate whether the inclusion is within the registration list (e.g., 0x00 indicates present, 0x01 indicates absent).
In this example, the frame format containing the response (Target Include Response) is shown in table 5.
Table 5 contains the frame format of the response
opcode(1byte) AttributeType(2bytes) result(1byte)
0x26 0x2802 0x00/0x01
For another example, when the target application parameter includes a feature, the target response data includes a feature response including an operation code (opcode, 1 byte), a property type (AttributeType, 2 bytes), a property right (Attribute Permission,1 byte), a feature trait (CHARCTERISTIC PERPERTIES,1byte, or 2 byte), a property UUID (CHARCTERISTIC UUID,1 byte), and a feature handle (CHARACTERISTIC HANDLE,2 bytes). The operation code of the characteristic response is a second operation code (0 x 26) and is used for indicating that the command type is the response type. The attribute type containing the response is a third attribute type (0 x 2803) for representing the feature type. Attribute rights indicate the type of data operation (e.g., 0x00 indicates readable, 0x01 indicates writable, 0x02 indicates readable and writable, etc.), feature handle indicates the object of the message to be transmitted, and feature UUID indicates the identification code of the feature
In this example, the frame format of the characteristic Response (TARGET CHARACTERISTIC Response) is shown in table 6.
Table 6 frame format of characteristic response
In step 14, the target response data is fed back to the client, so that the client interacts data with the server after the target response data characterizes the discovery of the target application parameters.
In this embodiment, the server may feed back the target response data to the client. And the client can acquire the service, the inclusion and the characteristics after receiving the target response data, then establishes a data transmission channel according to the service, the inclusion and the characteristics, and further establishes the data transmission channel according to the data transmission channel. In this way, the server and the client can interact data through the data transmission channel.
In this embodiment, the server may stop the search process after the target application parameters are searched, without traversing all registered application parameters.
The method comprises the steps of obtaining a target request, wherein the target request comprises target application parameters preset in a client, searching the target application parameters in an application parameter registration list to obtain a searching result which indicates whether the target application parameters are found, generating target response data which comprises the searching result and is matched with the target request, and finally feeding back the target response data to the client so that the client interacts data with the server after the target application parameters are found by the target response data. In this way, in the 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, so that the searching time is reduced, the data interaction time of two electronic devices through Bluetooth links is shortened, and the data interaction efficiency is improved.
Fig. 3 is a flowchart of a service discovery method according to an exemplary embodiment, referring to fig. 3, and the service discovery method is applied to a client, and includes steps 31 to 33.
In step 31, target application parameters preset in the client are obtained.
In this embodiment, referring to fig. 4, the client may establish a bluetooth link (i.e., BLE link) with the server. For example, the client may generate a link establishment request and broadcast. The server can monitor the broadcast signals of the surrounding space, can detect the local pairing information after receiving the link establishment request, and can establish Bluetooth link with the client when the identification code of the client in the link establishment request is positioned in the paired equipment list in the server, so that the server and the client finish the pairing and connection work.
In this embodiment, the client may obtain a target application parameter preset in the client. In one example, the target application parameters Include services (Service), inclusion (Include), and features (feature). The client may sequentially acquire a Service (Service), an inclusion (Include), and a feature (feature), specifically, the client may acquire the Service first, acquire the inclusion when determining that the Service has been registered with the server, and acquire the feature when determining that the inclusion has been registered with the server.
In step 32, a target request containing the target application parameter is generated and sent to a server, so that the server responds to the target request to search an application parameter registration list and returns target response data indicating whether the search result of the target application parameter is found.
In this embodiment, with continued reference to fig. 4, the client may generate and send a target request containing the target application parameters to the server. The target request may refer to the relevant content of step 11, which is not described herein.
In this embodiment, after receiving the target request, the server may search the application parameter registration list for a corresponding application parameter, such as a service, an inclusion or a feature, and generate target response data. The solution for searching the application parameters and generating the target response data may refer to the relevant content of step 12 and step 13, which will not be described herein.
In step 33, after the target response data indicates that the target application parameter is found, data is interacted with the server according to the target application parameter.
In this embodiment, after receiving the target response data, the client may determine to discover the service after sequentially determining the service, the inclusion and the feature in the target application parameter. At this time, the client and the server can perform interaction data according to the service characteristics.
It should be noted that, in the related art, the following process needs to be completed before the client interacts with the server data, see fig. 5, including:
The client sends a set TYPE request (att_read_by_group_type_req) to the server, requesting the server to return to the primary service that is currently registered (PRIMARY SERVICE). After receiving the request of the collection type, the server searches the service in the service registration list according to the preset size, so that a search result is returned, namely, one frame of data is returned. By analogy, after searching through all registered services, the server searches for a maximum of 65535 registered services, typically much less than 65535, and returns the search results. Accordingly, the client receives several frames of service responses, for example, 4-10 frames. In receiving the service response, the client may determine whether the service UUID is a service registered within the server. When the service UUID is a registered service, the client side re-discovers the inclusion (Include) in the service, that is, sends an Include reading instruction (att_read_by_type_req) and inquires about the process TYPE of the service, and the server side searches for the registered inclusion in the service and returns an inclusion response according to a preset size until all the inclusion registration lists are searched, so that the client side receives a plurality of frames of inclusion response data. After determining the corresponding inclusion, the client sends a READ feature instruction (att_read_by_type_req) to return the server to the registered feature. After determining the characteristics of the service, the client and the server can perform data interaction according to the characteristics of the service. Based on the above process analysis, before the client performs data interaction with the server, the client needs to receive multi-frame response data (service response, including response and feature response) in three stages, so that more time is consumed. In this embodiment, the client and the server can implement data interaction through 4 request processes and receive 4 frames of response data, so that the service search time is reduced to one fourth of the original time.
The method and the device for achieving the target application parameters can acquire target application parameters preset in the client, generate a target request containing the target application parameters and send the target request to the server, enable the server to respond to the target request to search an application parameter registration list and return target response data representing whether search results of the target application parameters are found or not, and interact data with the server according to the target application parameters after the target response data represent that the target application parameters are found. Thus, in the embodiment, the client can only send the request for 4 times and receive the response data for 4 times to interact data with the server, so that the data interaction time is shortened, and the data interaction efficiency is improved.
On the basis of the service discovery method provided by the embodiment of the present disclosure, the present disclosure further provides a service discovery device, which is applicable to a service end, and referring to fig. 6, the device includes:
A target request obtaining module 61, configured to obtain a target request, where the target request contains a target application parameter preset in a client;
A search result obtaining module 62, configured to search the application parameter registration list for the target application parameter, to obtain a search result that indicates whether the target application parameter is found;
A target response obtaining module 63, configured to generate target response data that includes the search result and matches the target request;
And the target response feedback module 64 is configured to feed back the target response data to the client, so that the client interacts data with the server after the target response data characterizes and discovers the target application parameters.
Optionally, the target application parameters include services, inclusion, and features.
Optionally, when the target application parameter comprises a service, the target response data comprises a service response, wherein the service response comprises an operation code, an attribute type, result data and attribute authority;
The operation code is a second operation code, the attribute type is a first attribute type, and the result data indicates whether the service is in the registration list.
Optionally, when the target application parameter comprises an inclusion, the target response data comprises an inclusion response, the inclusion response comprising an opcode, an attribute type, and result data;
The opcode is a second opcode and the attribute type is a second attribute type, and the result data indicates whether this inclusion is within the registry.
Optionally, when the target application parameter includes a feature, the target response data includes a feature response, where the feature response includes an operation code, an attribute type, an attribute authority, 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 authority indicates a data operation type, the feature handle indicates an object of a message to be transmitted, and the feature UUID indicates an identification code of the feature.
Optionally, the apparatus further comprises:
and the Bluetooth link establishment module is used for establishing Bluetooth link with the client when receiving the link establishment request sent by the client.
Optionally, the apparatus further comprises:
and the searching and stopping module is used for stopping the searching process after the target application parameters are searched.
On the basis of the service discovery method provided by the embodiment of the present disclosure, the present disclosure further provides a service discovery device, which is applicable to a client, and referring to fig. 7, the device includes:
A target parameter obtaining module 71, configured to obtain target application parameters preset in the client;
a target request generating module 72, configured to generate a target request containing the target application parameter and send the target request to a server, so that the server searches an application parameter registration list in response to the target request and returns target response data that indicates whether the search result of the target application parameter is found;
and the data interaction module 73 is configured to interact data with the server according to the target application parameter after the target response data indicates that the target application parameter is found.
Optionally, the target application parameters include services, inclusion, and features.
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.
Optionally, when the target application parameter includes an inclusion, the target request includes an inclusion request, the inclusion request includes an operation code, an attribute type and an attribute authority, the operation code is a first operation code, and the attribute type is a second attribute type.
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.
Optionally, the apparatus further comprises:
And the link request sending module is used for sending a link establishment request so that the server side responds to the link establishment request and establishes a Bluetooth link with the client side.
It should be noted that, the embodiment of the apparatus shown in this embodiment is matched with the content of the embodiment of the method, and reference may be made to the content of the embodiment of the method, which is not described herein again.
On the basis of the service discovery method provided by the embodiment of the disclosure, the embodiment of the disclosure also provides a service discovery system which comprises vehicle equipment and electronic equipment, wherein the vehicle equipment responds to the detection of the triggering operation of the vehicle equipment to display a screen-throwing identification code used by the screen throwing, the vehicle equipment plays an audio file carrying the screen-throwing identification code at least once, the electronic equipment starts a screen-throwing application program and starts an audio acquisition function of the electronic equipment, an acoustic wave signal carrying the screen-throwing identification code is acquired based on the audio acquisition function to obtain the acoustic wave file, a screen-throwing link is established with the vehicle equipment according to the screen-throwing identification code in the acoustic wave signal, and the vehicle equipment shares the current display content of the electronic equipment according to the screen-throwing link.
It should be noted that, the system embodiment shown in the present embodiment is matched with the content of the method embodiment, and reference may be made to the content of the method embodiment shown above, which is not described herein again.
Fig. 8 is a block diagram of an electronic device, according to an example embodiment. For example, the electronic device 800 may be a smart phone, a computer, a digital broadcast terminal, a tablet device, a medical device, an exercise device, a personal digital assistant, etc., as well as the above-described vehicle devices, etc.
Referring to FIG. 8, an electronic device 800 may include one or more of a processing component 802, a memory 804, a power 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.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 can include one or more processors 820 to execute computer programs. Further, the processing component 802 can include one or more modules that facilitate interactions between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the electronic device 800. Examples of such data include computer programs, contact data, phonebook data, messages, pictures, videos, and the like for any application or method operating on electronic device 800. The memory 804 may be implemented by any type or combination of volatile or nonvolatile memory devices 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 or optical disk.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for 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 the switching device to power the motherboard circuit with or without the battery.
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 a target object. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or sliding action, but also the duration and pressure associated with the touch or sliding operation.
The audio component 810 is configured to output and/or input audio file information. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio file information when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio file information may be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio file information.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be a keyboard, click wheel, keys, etc.
The sensor assembly 814 includes one or more sensors for providing status assessment of various aspects of the electronic device 800. For example, the sensor assembly 814 may detect an on/off state of the electronic device 800, a relative positioning of the components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in position of the electronic device 800 or one of the components, the presence or absence of a target object in contact with the electronic device 800, an orientation or acceleration/deceleration of the electronic device 800, and a change in temperature of the electronic device 800. In this example, the sensor assembly 814 may include a magnetic force sensor, a gyroscope, and a magnetic field sensor, wherein the magnetic field sensor includes at least one of a hall sensor, a thin film magneto-resistive sensor, a magnetic liquid acceleration sensor.
The communication component 816 is configured to facilitate communication between the electronic device 800 and other devices, either wired or wireless. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi,2G, 3G, 4G, 5G, or a combination thereof. In one exemplary embodiment, the communication component 816 receives broadcast information or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 can be implemented by one or more Application Specific Integrated Circuits (ASICs), digital information processors (DSPs), digital information processing devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements.
In an exemplary embodiment, there is also provided an electronic device including:
A memory and a processor;
the memory is used for storing a computer program executable by the processor;
the processor is configured to execute the computer program in the memory to implement the method as described above.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 804 including instructions, the executable computer program being executable by a processor. The readable storage medium may be, among other things, ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any adaptations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (15)

1. A service discovery method, adapted to a server, the method comprising:
The method comprises the steps of obtaining a target request, wherein the target request contains target application parameters preset in a client, the target application parameters comprise services, inclusion and characteristics, each parameter of the target application parameters comprises a first operation code, the first operation code is used for identifying a command type sent by an opposite terminal, and the first operation code is realized by reserved bytes in an opcode;
searching the target application parameters in an application parameter registration list to obtain a searching result which indicates whether the target application parameters are found;
Generating target response data which contains the search result and is matched with the target request, wherein the response data comprises a service response, a containing response or a characteristic response, and the operation codes of the service response, the containing response and the characteristic response are all second operation codes which are realized by reserved bytes in an opcode;
And feeding back the target response data to the client so that the client interacts data with the server after the target response data characterizes and discovers target application parameters.
2. The method of claim 1, wherein when the target application parameter comprises a service, the target response data comprises a service response, the service response comprising an opcode, an attribute type, result data, and attribute rights;
The operation code is a second operation code, the attribute type is a first attribute type, and the result data indicates whether the service is in the registration list.
3. The method of claim 1, wherein when the target application parameter comprises an inclusion, the target response data comprises an inclusion response, the inclusion response comprising an opcode, an attribute type, and result data;
The opcode is a second opcode and the attribute type is a second attribute type, and the result data indicates whether this inclusion is within the registry.
4. The method of claim 1, wherein when the target application parameter comprises a feature, the target response data comprises a feature response, the feature response comprising an opcode, a property type, a property authority, 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 authority represents the data operation type, the feature handle refers to an object of a message to be transmitted, and the feature UUID represents an identification code of a feature.
5. The method according to claim 1, wherein the method further comprises:
and when receiving a link establishment request sent by a client, establishing a Bluetooth link with the client.
6. The method according to any one of claims 1-5, further comprising:
and stopping the searching process after the target application parameters are searched.
7. A service discovery method, adapted for use with a client, the method comprising:
The method comprises the steps of obtaining target application parameters preset in a client, wherein the target application parameters comprise services, inclusion and characteristics, each parameter of the target application parameters comprises a first operation code, the first operation code is used for identifying a command type sent by an opposite terminal, and the first operation code is realized by reserved bytes in an opcode;
Generating a target request containing the target application parameters and sending the target request to a server so that the server responds to the target request to search an application parameter registration list and returns target response data representing whether a search result of the target application parameters is found or not, wherein the response data comprises a service response, a containing response or a characteristic response, the operation codes of the service response, the containing response and the characteristic response are all second operation codes, and the second operation codes are realized by reserved bytes in an opcode;
and after the target response data represent that the target application parameters are found, the data are interacted with the server according to the target application parameters.
8. The method of claim 7, wherein when the target application parameter comprises a service, the target request comprises a service request, the service request comprises 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 of claim 7, wherein when the target application parameter comprises an include, the target request comprises an include request, the include request comprises an operation code, an attribute type, and an attribute authority, the operation code is a first operation code, and the attribute type is a second attribute type.
10. The method of claim 7, wherein when the target application parameter comprises a feature, the target request comprises a feature request, the feature request comprises 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 of claim 7, wherein the method further comprises:
and sending a link establishment request to enable the server side to establish a Bluetooth link with the client side in response to the link establishment request.
12. A service discovery apparatus adapted for use at a server, the apparatus comprising:
the system comprises a target request acquisition module, a target application module and a target application module, wherein the target request contains target application parameters preset in a client, the target application parameters comprise services, inclusion and characteristics, each parameter of the target application parameters comprises a first operation code, the first operation code is used for identifying a command type sent by an opposite terminal, and the first operation code is realized by reserved bytes in an opcode;
the search result acquisition module is used for searching the target application parameters in the application parameter registration list to obtain a search result which indicates whether the target application parameters are found;
The target response acquisition module is used for generating target response data which contains the search result and is matched with the target request, wherein the response data comprises a service response, a containing response or a characteristic response, the operation codes of the service response, the containing response and the characteristic response are all second operation codes, and the second operation codes are realized by reserved bytes in an opcode;
And the target response feedback module is used for feeding back the target response data to the client so that the client interacts data with the server after the target response data characterize and discover target application parameters.
13. A service discovery apparatus adapted for use with a client, the apparatus comprising:
the system comprises a target parameter acquisition module, a target parameter acquisition module and a control module, wherein the target parameter acquisition module is used for acquiring target application parameters preset in a client, the target application parameters comprise services, inclusion and characteristics, each parameter of the target application parameters comprises a first operation code, the first operation code is used for identifying a command type sent by an opposite end, and the first operation code is realized by reserved bytes in an opcode;
The system comprises a target request generation module, a service request generation module and a service request generation module, wherein the target request generation module is used for generating a target request containing the target application parameters and sending the target request to a server side, so that the server side responds to the target request to search an application parameter registration list and returns target response data which indicates whether a search result of the target application parameters is found or not;
And the data interaction module is used for interacting data with the server according to the target application parameters after the target response data indicates that the target application parameters are found.
14. An electronic device, comprising:
A memory and a processor;
the memory is used for storing a computer program executable by the processor;
the processor is configured to execute a computer program in the memory to implement the method according to any one of claims 1-11.
15. A non-transitory computer readable storage medium, characterized in that the method according to any one of claims 1-11 is enabled when an executable computer program in the storage medium is executed by a processor.
CN202211437785.XA 2022-11-15 2022-11-15 Service discovery method and device, electronic device, and storage medium Active CN115914350B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211437785.XA CN115914350B (en) 2022-11-15 2022-11-15 Service discovery method and device, electronic device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211437785.XA CN115914350B (en) 2022-11-15 2022-11-15 Service discovery method and device, electronic device, and storage medium

Publications (2)

Publication Number Publication Date
CN115914350A CN115914350A (en) 2023-04-04
CN115914350B true CN115914350B (en) 2025-10-03

Family

ID=86492720

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211437785.XA Active CN115914350B (en) 2022-11-15 2022-11-15 Service discovery method and device, electronic device, and storage medium

Country Status (1)

Country Link
CN (1) CN115914350B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116723491A (en) * 2023-07-03 2023-09-08 Oppo广东移动通信有限公司 Data interaction method, device, electronic device and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101902458A (en) * 2010-02-21 2010-12-01 中国联合网络通信集团有限公司 Method, device and system for cross-host interprocess communication

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6845393B1 (en) * 1999-06-14 2005-01-18 Sun Microsystems, Inc. Lookup discovery service in a distributed system having a plurality of lookup services each with associated characteristics and services
EP1872525B1 (en) * 2005-04-18 2012-08-01 Research In Motion Limited System and method for discovering wireless mobile applications
CN1859516B (en) * 2005-04-30 2010-09-29 艾威梯技术(北京)有限公司 A method for connecting a bluetooth terminal and multiple bluetooth gateways to call and answer calls
US9794323B2 (en) * 2014-02-12 2017-10-17 Lg Electronics Inc. Method and apparatus for performing object transfer service using bluetooth low energy in wireless communication system
CN105245595B (en) * 2015-09-30 2018-07-31 小米科技有限责任公司 service response method and device
CN107948215A (en) * 2018-01-17 2018-04-20 广州汇智通信技术有限公司 A kind of remote invocation method and device based on UDP communications
EP3750350B1 (en) * 2018-02-06 2022-11-16 Telefonaktiebolaget LM Ericsson (publ) Unique service identifier for a message proxy in a service based architecture
US11457057B2 (en) * 2020-03-11 2022-09-27 Microsoft Technology Licensing, Llc Systems and methods for establishing highly secure and resilient persistent communication connections
CN111756795B (en) * 2020-05-06 2023-04-07 浙江吉利汽车研究院有限公司 Service information management method and device, electronic equipment and storage medium
CN111918262B (en) * 2020-08-15 2024-05-03 北京百瑞互联技术股份有限公司 Method and system for quickly discovering low-power-consumption Bluetooth communication of GATT service
CN114501449B (en) * 2022-01-28 2024-02-09 Oppo广东移动通信有限公司 Information query method, device, electronic equipment and storage medium
CN115065691B (en) * 2022-08-18 2022-11-01 飞天诚信科技股份有限公司 Communication implementation method and device based on android platform

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101902458A (en) * 2010-02-21 2010-12-01 中国联合网络通信集团有限公司 Method, device and system for cross-host interprocess communication

Also Published As

Publication number Publication date
CN115914350A (en) 2023-04-04

Similar Documents

Publication Publication Date Title
US10608988B2 (en) Method and apparatus for bluetooth-based identity recognition
CN105915627A (en) Service request processing method and service request processing device
CN108833585B (en) Information interaction method, device and storage medium
CN114430920B (en) Capability reporting method and device, and capability determining method and device
CN108496341A (en) Method, apparatus, equipment and the base station of edge calculations are realized in cellular network
CN107315791A (en) Static resource caching method, device and computer-readable recording medium
CN106713418B (en) Reset result confirmation method, device, server and mobile terminal
CN109525652B (en) Information sharing method, apparatus, device and storage medium
CN106547547B (en) data acquisition method and device
CN107371052A (en) Equipment control method and device
CN107094094A (en) Networking methods, device and the terminal of application program
CN108848497A (en) Acquisition methods, device, terminal and the computer readable storage medium of list of application
CN112433787B (en) Target object serialization method, device, electronic device and storage medium
CN115914350B (en) Service discovery method and device, electronic device, and storage medium
CN112752328B (en) Network control method, device and storage medium
CN114430410B (en) System access method, device and equipment based on virtual domain name
CN113127216A (en) Service request processing method, device, server and storage medium
CN110908814A (en) Message processing method and device, electronic equipment and storage medium
CN115669115B (en) Information indication method and device, information determination method and device
CN112394915B (en) Protocol calling method, device, system, equipment and medium for hybrid development mode
CN115509580A (en) Data request access method, device, equipment and storage medium
CN115373871A (en) Request processing method and device, electronic equipment and storage medium
CN107070816A (en) Recognition methods, device and the mobile terminal of application
CN115114040B (en) Data transmission method, device, equipment and storage medium
US12192031B2 (en) Invoking device services in preset software frameworks

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