WO2023020187A1 - 数据获取方法、装置、电子设备及存储介质 - Google Patents
数据获取方法、装置、电子设备及存储介质 Download PDFInfo
- Publication number
- WO2023020187A1 WO2023020187A1 PCT/CN2022/106771 CN2022106771W WO2023020187A1 WO 2023020187 A1 WO2023020187 A1 WO 2023020187A1 CN 2022106771 W CN2022106771 W CN 2022106771W WO 2023020187 A1 WO2023020187 A1 WO 2023020187A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- service data
- server
- identifier
- client
- specified
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 108
- 230000004044 response Effects 0.000 claims description 6
- 230000001960 triggered effect Effects 0.000 claims description 2
- 230000008569 process Effects 0.000 abstract description 22
- 230000006870 function Effects 0.000 description 9
- 238000012545 processing Methods 0.000 description 9
- 238000004891 communication Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 230000008859 change Effects 0.000 description 4
- 238000007726 management method Methods 0.000 description 4
- 238000001514 detection method Methods 0.000 description 2
- 238000000605 extraction Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000000737 periodic effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/146—Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
Definitions
- the present application relates to the technical field of communications, and more specifically, to a data acquisition method, device, electronic device, and storage medium.
- the client needs to obtain the services provided by the server before using the services provided by the server.
- the GATT client needs to initiate a service discovery process to the GATT server to discover service data in the GATT server.
- GATT Generic Attribute Profile
- the present application proposes a data acquisition method, device, electronic device, and storage medium, so as to improve the above problems.
- the present application provides a method for obtaining data, which is applied to a client, and the method includes: establishing a connection between the client and a server, where a specified identifier is stored in the server, and the specified identifier is used for Identifying the first service data in the server, the first service data is fixed service data; if the first service data previously obtained from the server based on the specified identifier is locally stored, based on the specified The specified identifier acquires second service data from the server, and the second service data is service data other than the first service data in the server; combine the second service data with the local The first service data is used as the acquired service data of the server.
- the present application provides a method for obtaining data, which is applied to a server.
- the method includes: establishing a connection between the server and a client, and storing a specified identifier in the server, and the specified identifier is used for identifying the first service data in the server, where the first service data is fixed service data; in response to an acquisition request sent by the client corresponding to the specified identifier, obtaining the first service data from the server Two service data, the acquisition request is sent by the client after determining that the first service data previously obtained from the server based on the specified identifier is locally stored; sending the second service data to the client end, so that the client uses the second service data and the local first service data as the acquired service data of the server.
- the present application provides a data acquisition device, which runs on a client, and the device includes: a connection management unit, configured to establish a connection with a server, where a specified identifier is stored in the server, and the specified identifier It is used to identify the first service data in the server, and the first service data is fixed service data; the first data acquisition unit is used to store the first service data from the service based on the specified identifier in advance.
- the first service data obtained by the terminal, and the second service data obtained from the server based on the specified identifier, the second service data is service data in the server other than the first service data; the second a data acquiring unit, configured to use the second service data and the local first service data as the acquired service data of the server.
- the present application provides a data acquisition device that runs on a server, the device includes: a connection management unit, configured to establish a connection with a client, the server stores a specified identifier, and the specified identifier used to identify the first service data in the server, the first service data is fixed service data; the data search unit is used to respond to the acquisition request sent by the client and corresponding to the specified identifier, Obtaining second service data from the server, the acquisition request is sent by the client after determining that the first service data previously obtained from the server based on the specified identifier is locally stored; the data sending unit, and sending the second service data to the client, so that the client uses the second service data and the local first service data as the acquired service data of the server.
- a connection management unit configured to establish a connection with a client, the server stores a specified identifier, and the specified identifier used to identify the first service data in the server, the first service data is fixed service data
- the data search unit is used to respond to the acquisition request sent by the client and
- the present application provides an electronic device, including one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, The one or more programs are configured to perform the methods described above.
- the present application provides a computer-readable storage medium, wherein program code is stored in the computer-readable storage medium, wherein the above method is executed when the program code is running.
- FIG. 1 shows a schematic diagram of an application scenario of a data acquisition method proposed in an embodiment of the present application
- FIG. 2 shows a schematic diagram of another application scenario of a data acquisition method proposed in the embodiment of the present application
- FIG. 3 shows a flow chart of a data acquisition method proposed in an embodiment of the present application
- FIG. 4 shows a schematic diagram of service data stored by the server in the embodiment of the present application
- FIG. 5 shows a flow chart of a data acquisition method proposed by another embodiment of the present application.
- FIG. 6 shows a flow chart of a data acquisition method proposed in yet another embodiment of the present application.
- FIG. 7 shows a flow chart of a data acquisition method proposed in another embodiment of the present application.
- FIG. 8 shows a flow chart of a data acquisition method proposed in another embodiment of the present application.
- FIG. 9 shows a flow chart of a data acquisition method proposed in another embodiment of the present application.
- FIG. 10 shows a structural block diagram of a data acquisition device proposed in an embodiment of the present application.
- Fig. 11 shows a structural block diagram of a data acquisition device proposed in another embodiment of the present application.
- Fig. 12 shows a structural block diagram of an electronic device proposed by the present application
- Fig. 13 is a storage unit for storing or carrying program codes for realizing the data acquisition method according to the embodiment of the present application according to the embodiment of the present application.
- some electronic devices may be configured with a server, and the other electronic device may have a client that can establish a connection with the server.
- the client first needs to obtain the service provided by the server.
- GATT Generic Attribute Profile
- the GATT client needs to initiate a service discovery process to the GATT server to discover the service data in the GATT server, so as to obtain the services that the GATT server can provide.
- the inventor proposes a data acquisition method, device, electronic device and storage medium provided by the present application. Determine whether the first service data obtained from the server based on the specified identifier has been pre-stored locally, and if so, directly obtain the first service data from the server based on the specified identifier and remove the first service data from the server. Service data other than data (second service data), so that the second service data and the local first service data are used as the acquired service data of the server.
- the client when the server distinguishes the service data into the first service data and the second service data, the client can obtain the first service data from the server in advance to store locally, and then make subsequent Every time you need to obtain the service data corresponding to the server, you can only use the specified identifier corresponding to the server to obtain the second service data, thereby reducing the need to obtain data from the server during each service data acquisition process
- the amount of data improves the efficiency of obtaining service data from the server.
- an application scenario involved in the embodiment of the present application includes an electronic device 100 and an electronic device 200 .
- the electronic device 100 runs a server
- the electronic device 200 runs a client.
- the client in the electronic device 200 may be a GATT client
- the server in the electronic device 100 may be a GATT server.
- the types of the first electronic device and the second electronic device shown in FIG. 1 are only exemplary.
- the second electronic device can also be a wireless earphone 210 in addition to the smart phone shown in FIG. 1 .
- the first electronic device can also be a tablet computer or a computer.
- the second electronic device can also be devices such as smart bracelets and smart watches.
- a data acquisition method provided by the embodiment of the present application, the method includes:
- the client establishes a connection with the server, the server stores a specified identifier, the specified identifier is used to identify the first service data in the server, and the first service data is fixed service data.
- the server after the server starts running, it can start sending broadcast data. After receiving the broadcast data sent by the server, the client can establish a connection with the server that sent the broadcast data.
- the server may store service data used to identify the fixed service.
- the specified identifier of the data (first service data).
- the client is a GATT client
- the server is a GATT server
- a database corresponding to the GATT server is set with a specified feature, and the value of the specified feature is used to record the specified identifier.
- there is a separately established identity storage file in the server and the identity storage file is used to store the specified identity.
- the service data in the server can be understood as data related to the service provided by the server, or can be understood as data used to describe the provided service.
- the service data may include a service (service name), a feature corresponding to the service, and a feature descriptor corresponding to the feature.
- the feature can be used to describe the function of the corresponding service
- the feature descriptor can be used to describe how the corresponding function is used and whether it is scalable.
- the services, features, and feature descriptors included in the service data in the server are respectively identified. For example, in the GATT server, the service, feature, and feature descriptor each correspond to a handle as their respective identifiers.
- the identifiers corresponding to the services, features, and feature descriptors are arranged in a certain order.
- the server includes service 1 , service 2 and service 3 .
- Service 1 corresponds to Feature 1
- Feature 1 corresponds to Feature Descriptor 1.
- Service 2 corresponds to Feature 2
- Feature 2 corresponds to Feature Descriptor 2.
- Service 3 corresponds to feature 3
- feature 3 corresponds to feature descriptor 3.
- the ID corresponding to service 1 is 0x0001, the ID corresponding to feature 1 is 0x0002, and the ID corresponding to feature descriptor 1 is 0x0003.
- the ID corresponding to service 2 is 0x0004, the ID corresponding to feature 2 is 0x0005, and the ID corresponding to feature descriptor 2 is 0x0006.
- the identifier corresponding to service 3 is 0x0007, the identifier corresponding to feature 3 is 0x0008, and the identifier corresponding to feature descriptor 3 is 0x0009.
- the number of services included in the server shown in FIG. 4 is only exemplary, and the server may include fewer or more services than those shown in FIG. 4 .
- Service 1 and Service 2 may be included, or services other than Service 1, Service 2, and Service 3 may be included.
- the number of features corresponding to each service may not be limited to one as shown in FIG. 4 , for example, there may be multiple features corresponding to a service.
- the style of the logo shown in FIG. 4 is only exemplary, and the logo in this embodiment of the present application may also have other styles.
- the storage location of the service data at the server end may be directly used as the corresponding identifier.
- the storage addresses in the server are sequentially sorted adjacently, so the storage address of the service data is used as an identifier, and the service data can still be sorted based on the storage address.
- part of the service data may be fixed, and the part of the service data that is fixed may be classified based on their corresponding identifiers.
- the service data may be divided into first service data and second service data by corresponding identifiers of the service data.
- the first service data represents fixed service data
- the second service data represents service data that may change.
- the specified identifier may include a start identifier and an end identifier, wherein the start identifier is used to identify the start position of the first service data, and the end identifier is used to represent the end position of the first service data.
- the determined first service data includes service 2, feature 2, feature descriptor 2, service 3, feature 3, and feature descriptor 3, then the corresponding The specified identifiers include 0x0004 and 0x0009, where 0x0004 is the start identifier and 0x0009 is the end identifier.
- the first service data can be determined starting from the service data with the highest corresponding identifier among the service data included in the server, and the first service data is determined sequentially along the order of identifiers from small to large until the first detection of The service data is not constant, and the identifier of the previous service data that is detected for the first time as the service data that is not constant is used as the designated identifier.
- the identifier 0x0001 corresponding to service 1 is the highest-ranked identifier
- the fixed service data will be determined sequentially starting from 0x0001.
- the first detected non-fixed service data is service 3
- 0x0006 will be used as the specified identifier.
- the fixed service data shown in the embodiment of the present application can be understood as service data that does not change within a specified time period on the device where the server is located.
- the specified time period may be a life cycle of the device where the server is located, or a certain operation period of the device where the server is located.
- the life cycle can be understood as the time when the device can be used. For example, if a device is used for two years, then the life cycle of the device is two years.
- the operation period may be a period set by the user, for example, the user may set one week as one operation period, or one month as one operation period.
- the client after the client obtains the specified identifier from the server for the first time, it can determine which specific service data in the server are the first service data according to the specified identifier. Furthermore, the first service data is stored locally on the client.
- the client after the client establishes a connection with the server, it can first obtain the designated identifier corresponding to the server, and then determine whether the first service data identified by the obtained designated identifier has been stored this time according to the obtained designated identifier , if it has already been stored, the second service data can be directly obtained from the server based on the specified identifier.
- the client after the client establishes a connection with the server, it further includes: if the first service data obtained from the server based on the specified identifier is not locally stored, obtaining the corresponding service data from the server from the server. the service data; storing the first service data in the service data corresponding to the server locally.
- S130 Use the second service data and the local first service data as the acquired service data of the server.
- the client after obtaining the second service data returned by the server, the client can combine the second service data with the first service data, and then use the combined service data as the obtained The service data corresponding to the server.
- combining the second service data and the first service data may be understood as sorting the second service data and the first service data in a predetermined order. It can be understood that all service data in the server are arranged in a certain order. However, in this embodiment of the application, the client will separately store the first service data in the service data corresponding to the server locally, so that the first service data and the second service data may be obtained separately, then it can By uniformly sorting the second service data and the first service data in a predetermined order, the order of the service data finally acquired by the client is consistent with the original order in the server.
- the predetermined order is the arrangement order of the service data in the server.
- the client after the client establishes a connection with the server, it further includes: if the first service data acquired from the server based on the specified identifier is not locally stored, obtaining the service from the server The service data corresponding to the terminal; storing the first service data in the service data corresponding to the server locally.
- the client may discover the server through the broadcast data sent by the server, and establish a connection with the server. If the connection is established for the first time, the specified identifier can be obtained from the server after the connection is established, and the first service data can be obtained based on the specified identifier.
- the broadcast data sent by the server may carry the device identifier of the device where the server is located.
- the client may store the first service data in correspondence with the device identifier.
- the client After the client obtains the device ID from the broadcast data sent by the server, it can check whether there is the device ID locally to determine whether there is a specified ID stored locally based on the specified ID (the specified ID stored by the server in the device to which the device ID belongs). ID) the first service data acquired from the server. Wherein, if it is found that the device identifier is stored locally, it is determined that the first service data previously acquired from the server based on the specified identifier is stored locally.
- the client after the client establishes a connection with the server, the client further determines whether the first service data acquired from the server based on the specified identifier has been pre-stored locally, if Otherwise, the service data (second service data) in the server other than the first service data (second service data) in the server is directly obtained from the server based on the specified identifier, so as to combine the second service data with the local first service data
- a service data is used as the acquired service data of the server.
- the client when the server distinguishes the service data into the first service data and the second service data, the client can obtain the first service data from the server in advance to store locally, and then make subsequent Every time you need to obtain the service data corresponding to the server, you can only use the specified identifier corresponding to the server to obtain the second service data, thereby reducing the need to obtain data from the server during each service data acquisition process
- the amount of data improves the efficiency of obtaining service data from the server.
- a data acquisition method provided by the embodiment of the present application, the method includes:
- S210 The client establishes a connection with the server, the server stores a specified identifier, the specified identifier is used to identify the first service data in the server, and the first service data is fixed service data.
- S220 If the first service data previously obtained from the server based on the specified identifier is stored locally, read the specified identifier from the local, where the local specified identifier is the first service data acquired from the server in advance. Obtain from the server when serving data.
- the client when the client obtains the specified identifier from the server for the first time and stores the first service data identified by the specified identifier locally, it can also perform the obtained specified identifier with the first service data. Corresponding storage, and then make the specified identifier also be stored locally on the client. Then, after the client establishes a connection with the server, if it is determined that the first service data obtained from the server based on the specified identifier is locally stored, it will directly read the specified identifier locally.
- S230 Obtain second service data from the server based on locally reading the specified identifier.
- the obtaining the second service data from the server based on locally reading the specified identifier includes: if the locally read specified identifier is consistent with the specified identifier stored in the server, then based on the local The second service data is obtained from the server by reading the specified identifier.
- the fixed service data in the server may refer to service data that will not change within a certain period of time. Then after the end of the current period, the fixed service data in the next period may change.
- the client can combine the specified identifier stored locally with the Compare with the specified ID stored in the server.
- the designated ID read locally is ID 1
- the designated ID stored in the server is also ID 1
- the designated ID read locally is consistent with the designated ID stored in the server.
- the designated ID read locally is ID 2
- the designated ID stored in the server is ID 1
- the designated ID read locally is not consistent with the designated ID stored in the server.
- the client may have established connections with various servers, and the designated identifiers corresponding to different servers may be the same. Then in this way, the client can store the specified identifier and the device identifier (the device identifier of the device where the server is located) correspondingly, so as to distinguish the specified identifiers corresponding to different servers.
- the specified identifier stored locally by the client may be as shown in the following table.
- the client determines to read the specified identifier locally Consistent with the specified ID stored in the server. If the specified ID read locally is ID 2 and the device ID is Device 2, and the specified ID obtained from the server is ID 2 and the device ID is ID 1, then the client determines to read the specified ID locally and the service The specified ID stored in the client is inconsistent.
- the server in the device 2 it can be further determined that the first service data corresponding to the server in the device 2 has actually changed, so that the specified identifier used to identify the first service data has also changed, and, after determining that the server In the case that the corresponding first service data has actually changed, all the service data corresponding to the server needs to be reacquired from the server.
- S240 Use the second service data and the local first service data as the acquired service data of the server.
- This embodiment provides a data acquisition method, so that when the server distinguishes service data into first service data and second service data, the client can acquire the first
- the service data is stored locally, so that in the subsequent process of obtaining the service data corresponding to the server, the second service data can be obtained only through the corresponding designated identifier of the server, thereby reducing the cost of each service data.
- the amount of data that needs to be acquired from the server during the acquisition process improves the efficiency of acquiring service data from the server.
- the specified identifier when the first service data is stored, the specified identifier will be correspondingly stored locally, so that when the second service data is acquired based on the specified identifier, the specified identifier can be obtained directly locally. Furthermore, it is beneficial to increase the speed of triggering the server to search for the second service data.
- a data acquisition method provided by the embodiment of the present application, the method includes:
- S310 The client establishes a connection with the server, where a specified identifier is stored in the server, and the specified identifier is used to identify the first service data in the server, and the first service data is fixed service data;
- S320 If the first service data previously obtained from the server based on the designated identifier is locally stored, determine a service data query range based on the designated identifier, and the service data query range is a range corresponding to the second service data.
- the designated identifier is the last identifier in the designated identifier interval
- the start identifier of the designated identifier interval is the first identifier in the server end
- the designated identifier interval is the The interval where the identifier corresponding to the first service data is located
- the determining the service data query range based on the specified identifier includes: taking the range where the identifiers sorted after the specified identifier is located as the service data query range. That is to say, in the case that the first service data is counted from the first identifier, the designated identifier is the last identifier among the identifiers corresponding to the service data included in the first service data.
- the designated identifier is the largest identifier among the identifiers corresponding to the service data included in the first service data. For example, please refer to FIG. 4 again. In this manner, if the designated identifier is 0x0006, then the determined service data query range is from 0x0007 to the last identifier.
- the client will use the range from the first identifier on the server to the start identifier, and the range after the end identifier as the service data query scope.
- the client will use the range from the first identifier on the server to the start identifier, and the range after the end identifier as the service data query scope.
- the start identifier is 0x0004 and the end identifier is 0x0006
- the determined service data query range will include 0x0001 (the first identifier) to 0x0003, and include 0x0007 after the range.
- the designated identifier is the last identifier in the designated identifier interval
- the start identifier of the designated identifier interval is the first identifier in the server end
- the designated identifier interval is the The interval where the identifier corresponding to the first service data is located
- the determining the service data query range based on the specified identifier includes: taking the range where the identifiers sorted after the specified identifier is located as the service data query range.
- S330 Trigger the server to search for service data based on the service data query range, so as to obtain the found second service data, the second service data is the first service data in the server except service data.
- S340 Use the second service data and the local first service data as the acquired service data of the server.
- This embodiment provides a data acquisition method, so that when the server distinguishes service data into first service data and second service data, the client can acquire the first
- the service data is stored locally, so that in the subsequent process of obtaining the service data corresponding to the server, the second service data can be obtained only through the corresponding designated identifier of the server, thereby reducing the cost of each service data.
- the amount of data that needs to be acquired from the server during the acquisition process improves the efficiency of acquiring service data from the server.
- the client can further determine the service data query range according to the specified identifier, so that the server can directly obtain the service data based on the service data query range determined by the client, further improving the efficiency.
- a data acquisition method provided by the embodiment of the present application, the method includes:
- S410 The client establishes a connection with the server, where a specified identifier is stored in the server, and the specified identifier is used to identify first service data in the server, and the first service data is fixed service data;
- the device identifier is information used to identify the uniqueness of the device.
- the device identification there may be multiple implementation manners for the device identification.
- the device identification can be implemented through the network address corresponding to the device.
- the network address of the device can be used as the device identifier of the device.
- the device where the server is located sends wireless data through Bluetooth communication.
- the wireless data sent based on the Bluetooth communication will carry the Bluetooth address of the device, and then the client can use the Bluetooth address carried in the wireless data as the device identifier of the device.
- the Bluetooth address is a public address, so that the Bluetooth address of the device is fixed.
- the device identifier can be a random number generated based on a specified protocol, and the random number generated each time can be different, so that the device identifiers corresponding to different devices can be unique.
- the server sends wireless data every time, it can add the random number as the device identification to the wireless data sent, so that the client receiving the wireless data can know which server the current wireless data is from sent by the end.
- the client can obtain the device identifier in a predetermined way.
- the predetermined method configured by the client is to obtain the network address carried in the wireless data as the device identifier, then after the client obtains the wireless data sent by the server, it can directly perform The extraction of the network address is used as the device identification of the device where the server is located.
- the predetermined method configured by the client is to obtain the random number carried in the wireless data as the device identification, then after the client obtains the wireless data sent by the server, it can directly perform The extraction of the random number is used as the device identification of the device where the server is located.
- the client may also acquire the device identifier in an adaptive manner.
- the server may adopt different identification methods. For example, although the wireless data sent by the device may carry a network address, some devices use a random network address (random network address), which may make the network addresses of different devices the same. In this case, there is no way for the network address to uniquely identify the device.
- random network address random network address
- the client can first detect the type of network address used in the wireless data; if it detects that the network address is a fixed type of network address, it will directly use the obtained network address as the sending The device identification of the device for the wireless data; if it is detected that the network address is a random type of network address, then further detect whether the wireless data carries a random number generated based on a specified protocol; if a random number generated based on a specified protocol is detected , then use the random number generated based on the specified protocol as the device identifier of the device sending the wireless data. If no random number generated based on the specified protocol is detected, all service data is directly obtained from the server as service data corresponding to the server.
- the client may store the device identifier and the first service data correspondingly.
- the client when storing the first service data, may store the device identifier and the first service data correspondingly. Then, the client detects whether the service data corresponding to the device identifier is stored locally. It can actually be understood that the client determines whether there is the first service data obtained from the server locally. Moreover, the first service data is service data identified by a specified identifier in the wireless data where the device identifier is located.
- S450 If the service data corresponding to the device identifier is stored locally, determine that the first service data previously acquired from the server based on the specified identifier is stored locally.
- S460 If the first service data previously obtained from the server based on the specified identifier is locally stored, acquire second service data from the server based on the specified identifier, and the second service data is the Service data other than the first service data in the server.
- S470 Use the second service data and the local first service data as the acquired service data of the server.
- This embodiment provides a data acquisition method, so that when the server distinguishes service data into first service data and second service data, the client can acquire the first
- the service data is stored locally, so that in the subsequent process of obtaining the service data corresponding to the server, the second service data can be obtained only through the corresponding designated identifier of the server, thereby reducing the cost of each service data.
- the amount of data that needs to be acquired from the server during the acquisition process improves the efficiency of acquiring service data from the server.
- the first service data and the device identifier of the device where the server is located will be stored correspondingly, so that when it is determined that the service data corresponding to the device identifier is stored , it can be directly determined that the first service data of the server is stored.
- a data acquisition method provided by the embodiment of the present application is applied to the server, and the method includes:
- S510 The server establishes a connection with the client, and a specified identifier is stored in the server, and the specified identifier is used to identify the first service data in the server, and the first service data is fixed service data.
- S520 Obtain second service data from the server in response to an acquisition request sent by the client and corresponding to the specified identifier, where the acquisition request is determined locally stored by the client in advance based on the specified identifier.
- the first service data obtained from the server is sent later.
- the obtaining the second service data from the server in response to the obtaining request sent by the client and corresponding to the specified identifier includes:
- S530 Send the second service data to the client, so that the client uses the second service data and the local first service data as the acquired service data of the server.
- the client before the client obtains the specified identifier from the server, the client can first check whether a credit relationship has been established with the server. If the credit relationship has been established, it can directly follow the established The service acquisition method corresponding to the establishment of the credit relationship is used to acquire the service in the server. If the credit relationship is not established, the subsequent acquisition of the specified identifier from the server can be performed. Wherein, if a trust relationship has been established between the client and the server, it means that identity authentication has been performed between the client and the server.
- the process shown in Figure 9 includes:
- the GATT client acquires the broadcast data sent by the GATT server.
- S620 The GATT client establishes a connection with the GATT server.
- S630 The GATT client detects whether it is the first time to establish a connection with the server.
- the GATT client may have multiple ways to detect whether it is the first time to establish a connection with the server.
- the method of detecting whether the service data corresponding to the device identifier of the device where the GATT server is located can be detected locally in the foregoing embodiments.
- the service data corresponding to the device identifier is stored locally, it is determined that it is not the first A connection, otherwise, if the service data corresponding to the device identification is not stored locally, it is determined to be the first connection.
- the specified identifier obtained from the broadcast data is consistent with the specified identifier stored locally, Then it is determined that it is not the first connection. On the contrary, if it is detected that the specified identifier obtained from the broadcast data is consistent with the specified identifier stored locally, or if the specified identifier has not been stored locally, it is determined that it is the first connection.
- the service data in the server may be arranged in a certain order. For example, as shown in FIG. 4 , the service data whose corresponding identifier is 0x0001 is the first service data among all the service data of the server. Then, when the GATT client determines that it is the first time to establish a connection with the GATT server, it will trigger to start searching for services from the service data identified as 0x0001 in the GATT server.
- S641 Obtain the specified identifier from the specified characteristic in the database of the GATT server.
- the specified identifier may be stored in the form of a feature in the service data, and the feature stored with the specified identifier may be used as the specified feature.
- S642 The GATT client locally stores the first service data among the searched service data.
- the GATT client When the GATT client determines that it is the first time to establish a connection with the GATT server, the GATT client will actually search all the service data in the GATT server to find all the services in the GATT server data. then for convenience
- the GATT client triggers a service search starting from the first service data after the specified identifier, so as to obtain the second service data.
- the designated identifier represents the identifier corresponding to the last service data in the way of fixed data detection starting from the first service data.
- the specified identifier is an identifier with the largest corresponding identifier in the fixed service data.
- the ordering of the service data is equivalent to the ordering of the identifiers corresponding to the service data. For example, please refer to Figure 4, if the fixed service data is determined starting from 0x0001, and the determined fixed service data includes service 1, feature 1, feature descriptor 1, service 2, feature 2, and feature description character 2. Then, among the fixed and constant service data, the one with the largest corresponding identifier is 0x0006, and the determined specified identifier is 0x0006.
- the first service data stored locally will include service 1, feature 1, feature descriptor 1, service 2, feature 2, and feature descriptor 2 .
- the service data search will start from 0x0007.
- processing manner after obtaining the first service data and the second service data can refer to the contents in the foregoing embodiments.
- a data acquisition device 600 provided by the embodiment of the present application runs on a client, and the device 600 includes:
- the connection management unit 610 is configured to establish a connection with a server, where a designated identifier is stored in the server, and the designated identifier is used to identify first service data in the server, and the first service data is fixed Changed service data.
- the first data acquiring unit 620 is configured to acquire second service data from the server based on the specified identifier if the first service data previously acquired from the server based on the specified identifier is locally stored, the The second service data is service data in the server other than the first service data.
- the second data acquiring unit 630 is configured to use the second service data and the local first service data as the acquired service data of the server.
- the first data acquisition unit 620 is specifically configured to read the specified identifier locally if the first service data obtained from the server based on the specified identifier in advance is stored locally, wherein the local The specified identifier is acquired from the server when the first service data is acquired from the server in advance; the second service data is acquired from the server based on reading the specified identifier locally.
- the first data acquisition unit is specifically configured to obtain the second service from the server based on locally reading the specified identifier if the specified identifier read locally is consistent with the specified identifier stored in the server. data.
- the first data acquisition unit 620 is specifically configured to determine the service data query range based on the specified identifier if the first service data previously acquired from the server based on the specified identifier is locally stored, and the The service data query range is the range corresponding to the second service data; the server is triggered to search for service data based on the service data query range, so as to obtain the found second service data.
- the specified identifier is the last identifier in the specified identifier interval
- the start identifier of the specified identifier interval is the first identifier in the server
- the specified identifier interval is the first identifier in the specified identifier interval.
- An interval where the identifier corresponding to the service data is located; the first data acquisition unit 620 is specifically configured to use the range where the identifiers sorted after the specified identifier is located as the service data query range.
- the first data obtaining unit 620 is also specifically configured to obtain the device identifier of the device where the server is located; if there is locally stored service data corresponding to the device identifier, it is determined that the locally stored The first service data obtained from the server.
- the second data obtaining unit 630 is further configured to obtain the first service data obtained from the server end based on the specified identifier locally if the first service data obtained from the server end is not stored locally.
- the client is a GATT client
- the server is a GATT server
- the database corresponding to the GATT server is provided with specified features, and the value of the specified features is used to record the specified identifier .
- a data acquisition device 700 provided by the embodiment of the present application runs on a client, and the device 700 includes:
- the connection management unit 710 is configured to establish a connection with the client.
- the specified identifier is stored in the server, and the specified identifier is used to identify the first service data in the server.
- the first service data is fixed Changed service data.
- the data search unit 720 is configured to obtain the second service data from the server in response to the obtaining request sent by the client and corresponding to the specified identifier, where the obtaining request is determined locally stored by the client. Sending after the first service data obtained from the server based on the specified identifier.
- the data search unit 720 is specifically configured to respond to the acquisition request sent by the client and corresponding to the specified identifier, obtain the service data query range from the acquisition request, and query the service data in the server.
- the service data corresponding to the service data query range is used as the second service data.
- a data sending unit 730 configured to send the second service data to the client, so that the client uses the second service data and local first service data as the obtained service terminal service data.
- the client after the client establishes a connection with the server, the client further determines whether the first service data acquired from the server based on the specified identifier has been pre-stored locally, if Otherwise, the service data (second service data) in the server other than the first service data (second service data) in the server is directly obtained from the server based on the specified identifier, so as to combine the second service data with the local first service data A service data is used as the acquired service data of the server.
- the client when the server distinguishes the service data into the first service data and the second service data, the client can obtain the first service data from the server in advance to store locally, and then make subsequent Every time you need to obtain the service data corresponding to the server, you can only use the specified identifier corresponding to the server to obtain the second service data, thereby reducing the need to obtain data from the server during each service data acquisition process
- the amount of data improves the efficiency of obtaining service data from the server.
- each functional module in each embodiment of the present application may be integrated into one processing module, each module may exist separately physically, or two or more modules may be integrated into one module.
- the above-mentioned integrated modules can be implemented in the form of hardware or in the form of software function modules.
- the electronic device 100 includes one or more (only one is shown in the figure) processors 102 , a memory 104 and a wireless module 106 coupled to each other.
- the memory 104 stores programs capable of executing the contents of the foregoing embodiments, and the processor 102 can execute the programs stored in the memory 104 .
- the processor 102 may include one or more processing cores.
- the processor 102 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes or executes instructions, programs, code sets or instruction sets stored in the memory 104, and calls data stored in the memory 104 to execute Various functions of the electronic device 100 and processing data.
- the processor 102 may adopt at least one of Digital Signal Processing (Digital Signal Processing, DSP), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA), and Programmable Logic Array (Programmable Logic Array, PLA). implemented in the form of hardware.
- DSP Digital Signal Processing
- FPGA Field-Programmable Gate Array
- PLA Programmable Logic Array
- the processor 102 may integrate one or a combination of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU), a modem, and the like.
- CPU Central Processing Unit
- GPU Graphics Processing Unit
- the CPU mainly handles the operating system, user interface and application programs, etc.
- the GPU is used to render and draw the displayed content
- the modem is used to handle wireless communication. It can be understood that the above modem may also not be integrated into the processor 102, but implemented by a communication chip alone.
- the memory 104 may include random access memory (Random Access Memory, RAM), and may also include read-only memory (Read-Only Memory). Memory 104 may be used to store instructions, programs, codes, sets of codes, or sets of instructions.
- a data acquisition device may be stored in the memory 104 .
- the data acquisition device may be the aforementioned device 600 or device 700 .
- the memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.) , instructions for implementing the following method embodiments, and the like.
- the storage data area can also store data created by the terminal 100 during use (such as phonebook, audio and video data, chat record data) and the like.
- the wireless module 106 is used to receive and send electromagnetic waves, realize mutual conversion between electromagnetic waves and electrical signals, and communicate with communication networks or other devices, such as audio playback devices.
- the wireless module 106 may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption/decryption chips, Subscriber Identity Module (SIM) cards, memory, etc. .
- SIM Subscriber Identity Module
- the wireless module 106 can communicate with various networks such as the Internet, intranet, wireless network or communicate with other devices through the wireless network.
- the wireless network mentioned above may include a cellular telephone network, a wireless local area network or a metropolitan area network.
- the wireless module 106 can perform information exchange with the base station.
- FIG. 13 shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application.
- Program codes are stored in the computer-readable medium 1100, and the program codes can be invoked by a processor to execute the methods described in the foregoing method embodiments.
- the computer readable storage medium 1100 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
- the computer-readable storage medium 1100 includes a non-transitory computer-readable storage medium (non-transitory computer-readable storage medium).
- the computer-readable storage medium 1100 has a storage space for program code 1110 for executing any method steps in the above methods. These program codes can be read from or written into one or more computer program products.
- Program code 1110 may, for example, be compressed in a suitable form.
- the client after the client establishes a connection with the server, the client further determines whether the local data based on the specified identifier has been stored in advance.
- the first service data obtained by the server if any, directly obtains service data (second service data) in the server other than the first service data (second service data) from the server based on the specified identifier, so as to The second service data and the local first service data are used as the acquired service data of the server.
- the client when the server distinguishes the service data into the first service data and the second service data, the client can obtain the first service data from the server in advance to store locally, and then make subsequent Every time you need to obtain the service data corresponding to the server, you can only use the specified identifier corresponding to the server to obtain the second service data, thereby reducing the need to obtain data from the server during each service data acquisition process
- the amount of data improves the efficiency of obtaining service data from the server.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
Abstract
本申请实施例公开了一种数据获取方法、装置、电子设备及存储介质。方法包括:客户端与服务端建立连接,服务端中存储有指定标识,指定标识用于标识服务端中的第一服务数据,第一服务数据为固定不变的服务数据;若本地存储有预先基于指定标识从服务端获取的第一服务数据,基于指定标识从服务端中获取第二服务数据;将第二服务数据和本地的第一服务数据作为获取到的服务端对应的服务数据。从而使得客户端可以预先通过从服务端中存储的指定标识来获取得到第一服务数据以存储在本地,继而使得在后续每次需要获取服务端对应的服务数据的过程中,可以只用通过服务端对应的指定标识去获取第二服务数据,进而提升了从服务端获取服务数据的效率。
Description
相关申请的交叉引用
本申请要求于2021年8月20日提交的申请号为202110963350.8的中国申请的优先权,其在此出于所有目的通过引用将其全部内容并入本文。
本申请涉及通信技术领域,更具体地,涉及一种数据获取方法、装置、电子设备及存储介质。
在一些场景中客户端在使用服务端中所提供的服务之前,需要先获取到服务端中所提供的服务。例如,在基于GATT(Generic Attribute Profile)协议的通信中,GATT客户端需要向GATT服务端发起服务发现流程来发现GATT服务端中的服务数据。但是,在相关的服务获取中的还存在效率有待提升的问题。
发明内容
鉴于上述问题,本申请提出了一种数据获取方法、装置、电子设备及存储介质,以实现改善上述问题。
第一方面,本申请提供了一种数据获取方法,应用于客户端,所述方法包括:所述客户端与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,所述第二服务数据为所述服务端中除所述第一服务数据以外的服务数据;将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
第二方面,本申请提供了一种数据获取方法,应用于服务端,所述方法包括:所述服务端与客户端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;响应于客户端发送的与所述指定标识对应的获取请求,从所述服务端中获取第二服务数据,所述获取请求为所述客户端在确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据后发送;将所述第二服务数据发送给所述客户端,以用于使所述客户端将所述第二服务数据和本地的第一服务数据作为获取到的所述服务端的服务数据。
第三方面,本申请提供了一种数据获取装置,运行于客户端,所述装置包括:连接管理单元,用于与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;第一数据获取单元,用于若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,所述第二服务数据为所述服务端中除所述第一服务数据以外的服务数据;第二数据获取单元,用于将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
第四方面,本申请提供了一种数据获取装置,运行于服务端,所述装置包括:连接管理单元,用于与客户端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;数据查找单元,用于响应于客户端发送的与所述指定标识对应的获取请求,从所述服务端中获取第二服务数据,所述获取请求为所述客户端在确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据后发送;数据发送单元,用于将所述第二服务数据发送给所述客户端,以用于使所述客户端将所述第二服务数据和本地的第一服务数据作为获取到的所述服务端的服务数据。
第五方面,本申请提供了一种电子设备,包括一个或多个处理器以及存储器;一个或多个程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行上述的方法。
第六方面,本申请提供的一种计算机可读存储介质,所述计算机可读存储介质中存储有程序代码,其中,在所述程序代码运行时执行上述的方法。
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了本申请实施例提出的数据获取方法的一种应用场景的示意图;
图2示出了本申请实施例提出的一种数据获取方法的另一种应用场景的示意图;
图3示出了本申请实施例提出的一种数据获取方法的流程图;
图4示出了本申请实施例中服务端所存储的服务数据的示意图;
图5示出了本申请另一实施例提出的一种数据获取方法的流程图;
图6示出了本申请再一实施例提出的一种数据获取方法的流程图;
图7示出了本申请又一实施例提出的一种数据获取方法的流程图;
图8示出了本申请又一实施例提出的一种数据获取方法的流程图;
图9示出了本申请又一实施例提出的一种数据获取方法的流程图;
图10示出了本申请实施例提出的一种数据获取装置的结构框图;
图11示出了本申请又一实施例提出的一种数据获取装置的结构框图;
图12示出了本申请提出的一种电子设备的结构框图;
图13是本申请实施例的用于保存或者携带实现根据本申请实施例的数据获取方法的程序代码的存储单元。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
通常一些电子设备为了向另外的电子设备提供服务,在电子设备中可以配置有服务端,而在该另外的电子设备中则建立有可以与该服务端建立连接的客户端。其中,在客户端使用服务端中所提供的服务之前,客户端需要先获取到服务端中所提供的服务。例如,在基于GATT(Generic Attribute Profile)协议的通信中,GATT客户端需要向GATT服务端发起服务发现流程来发现GATT服务端中的服务数据,以实现获取到GATT服务端所能提供的服务。
但是,发明人在研究中发现,在相关的服务数据获取方式中的还存在效率有待提升的问题。例如,发明人发现,若客户端在与服务端建立连接后,客户端检测到与所建立 连接的服务端之间未建立授信关系,则客户端会发起服务数据发现流程以获取服务端中所有的服务数据。也就是说,在没有建立授信关系的情况下,在每次的服务数据获取过程中,客户端会将服务端中所有的服务数据均获取一遍,进而就造成服务数据的获取流程耗时较长,进而影响效率。
因此,为了改善上述问题,发明人提出了本申请所提供的一种数据获取方法、装置、电子设备及存储介质,通过从服务端中获取标识服务端中的第一服务数据指定标识后,进一步的确定本地是否已经预先存储有基于所述指定标识从所述服务端获取的第一服务数据,若有则直接基于所述指定标识从所述服务端中获取服务端中除所述第一服务数据以外的服务数据(第二服务数据),以将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
从而通过上述方式使得在服务端将服务数据区分为第一服务数据以及第二服务数据的情况下,使得客户端可以预先通过从服务端中获取第一服务数据以存储在本地,继而使得在后续每次需要获取服务端对应的服务数据的过程中,可以只用通过服务端对应的指定标识去获取第二服务数据,进而减少了每次服务数据的获取过程中需要从服务端中进行数据获取的数据量,提升了从服务端获取服务数据的效率。
下面先对本申请实施例所涉及的一种应用场景进行介绍。
如图1所示,本申请实施例所涉及的一种应用场景中包括有电子设备100和电子设备200。其中,电子设备100中运行有服务端,电子设备200中运行有客户端。其中,电子设备200中的客户端可以为GATT客户端,对应的,电子设备100中的服务端可以为GATT服务端。
再者,图1中所示第一电子设备和第二电子设备的类型只是示例性的。例如,如图2所示,第二电子设备除了可以为图1中所示的智能手机外还可以为无线耳机210。再者,第一电子设备除了可以为图1中所示的智能手机外,还可以为平板电脑以及计算机等设备。再者,第二电子设备除了可以为图1、图2中所示的设备外,还可以为智能手环、智能手表等设备。
下面将结合附图具体描述本申请的各实施例。
请参阅图3,本申请实施例提供的一种数据获取方法,所述方法包括:
S110:所述客户端与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据。
其中,服务端在开始运行后,可以开始发送广播数据。客户端在接收到服务端所发送的广播数据后,则可以与发送广播数据的服务端建立连接。
再者,在本申请实施例中,为了使得与服务端建立连接的客户端能够获取到服务端中有哪些服务数据是固定不变的,在服务端中可以存储有用于标识固定不变的服务数据(第一服务数据)的指定标识。
可选的,所述客户端为GATT客户端,所述服务端为GATT服务端,所述GATT服务端对应的数据库中设置有指定特征,所述指定特征的值用于记录所述指定标识。可选的,在服务端中有单独建立的标识存储文件,该标识存储文件用于存储指定标识。
其中,需要说明的是,服务端中的服务数据可以理解为与服务端所提供的服务有关的数据,或者可以理解为用于对所提供的服务进行描述的数据。可选的,服务数据可以包括有服务(服务的名称),该服务所对应的特征以及特征所对应的特征描述符。其中,特征可以用于描述所对应的服务所具有的功能,而特征描述符则可以用于描述所对应功能如何使用以及是否具有可扩展性等。在服务端中服务数据所包括的服务、特征以及特征描述符各自对应有标识。例如,在GATT服务端中,服务、特征以及特征描述符各自对应有handle来作为各自的标识。并且,在一些情况下,服务、特征以及特征描述符各自所对应的标识是按照一定的顺序排列的。示例性的,如图4所示,服务端中包括有服务1、服务2以及服务3。其中,服务1对应有特征1,特征1对应有特征描述符1。服务2对应有特征2,特征2对应有特征描 述符2。服务3对应有特征3,特征3对应有特征描述符3。服务1对应的标识为0x0001,特征1对应的标识为0x0002,特征描述符1对应的标识为0x0003。服务2对应的标识为0x0004,特征2对应的标识为0x0005,特征描述符2对应的标识为0x0006。服务3对应的标识为0x0007,特征3对应的标识为0x0008,特征描述符3对应的标识为0x0009。
需要说明的是,图4中所示的服务端中所包括的服务的数量只是示例性的,在服务端中可以包括有比图4中所示的服务更少或者更多的服务。例如,可以仅包括服务1和服务2,也可以包括服务1、服务2以及服务3以外的服务。类似的,对于每个服务所对应的特征的数量也可以不仅仅限于图4中所示的1个,例如,服务所对应的特征可以有多个。再者,图4中所示的标识的样式也只是示例性的,本申请实施例的标识也可以有其他的样式。例如,可以直接将服务数据在服务端的存储位置作为对应的标识。需要说明的是,作为一种方式,在服务端中的存储地址是依次相邻排序的,那么将服务数据的存储地址作为标识,依然可以实现基于存储地址对服务数据进行排序。
其中,在服务端中所包括的服务数据中,部分服务数据可能固定不变的,对于固定不变的这部分服务数据,则可以基于其所对应的标识划分出来。例如,可以通过服务数据对应标识,将服务数据划分为第一服务数据和第二服务数据。其中,第一服务数据则表征固定不变的服务数据,第二服务数据则表征可能会进行变化的服务数据。
可选的,指定标识可以包括有开始标识和截止标识,其中,开始标识用于标识第一服务数据的开始位置,而截止标识则用于表征第一服务数据的结束位置。如图4中所示,基于图4中所示的情况下,若确定的第一服务数据包括服务2、特征2、特征描述符2、服务3、特征3以及特征描述符3,那么所对应的指定标识则包括0x0004以及0x0009,其中,0x0004为开始标识,0x0009为截止标识。可选的,可以从服务端包括的服务数据中,所对应的标识排序最靠前的服务数据开始确定第一服务数据,并且是沿标识由小到大的顺序进行依次确定,直到首次检测到不是固定不变的服务数据,进而将该首次检测到不是固定不变的服务数据的前一个服务数据的标识作为指定标识。例如,请再参阅图4,其中服务1对应的标识0x0001为排序最靠前的标识,进而会从0x0001开始依次确定固定不变的服务数据,若首先检测到的不是固定不变的服务数据为服务3,那么则可以确定第一服务数据包括标识0x0001、标识0x0002、标识0x0003、标识0x0004、标识0x0005以及标识0x0006所对应的服务数据。从而会将0x0006作为指定标识。
再者,需要说明的是,本申请实施例中所示的固定不变的服务数据可以理解为在服务端所在设备在指定时间周期内不会变化的服务数据。其中,该指定时间周期可以为服务端所在设备的生命周期,也可以是服务端所在设备的某一个运行周期。其中,生命周期可以理解为设备可以会被使用的时间。例如,某个设备会使用两年,那么该设备的生命周期则为两年。其中,运行周期可以为用户设定的周期,例如,用户可以设定一个星期为一个运行周期,也可以设定一个月为一个运行周期。
S120:若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,所述第二服务数据为所述服务端中除所述第一服务数据以外的服务数据。
需要说明的是,在本申请实施例中,在客户端从服务端第一次获取到该指定标识后,则可以根据该指定标识来确定服务端中具体有哪些服务数据是第一服务数据,进而将第一服务数据存储在客户端本地。
对应的,客户端在与服务端建立连接后,则可以先获取到服务端对应的指定标识,然后根据获取的指定标识确定本次是否已经存储有所获取的指定标识所标识的第一服务数据,若已经存储有,则可以直接基于该指定标识从服务端去获取第二服务数据。
作为一种方式,客户端与服务端建立连接之后还包括:若本地未存储有基于所述指定标识从所述服务端获取的第一服务数据,则从所述服务端获取所述服务端对应的服务数据;将所述服务端对应的服务数据中的第一服务数据存储在本地。
S130:将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
在本申请实施例中,那么客户端在获取到服务端返回的第二服务数据后,则可以将第二服务数据和第一服务数据进行组合,进而将组合后的服务数据作为获取到的所述服务端对应的服务数据。
其中,将第二服务数据和第一服务数据进行组合可以理解为,将第二服务数据和第一服务数据统一按既定顺序进行排序。可以理解的是,服务端中的所有服务数据都是按照一定的顺序排列的。但是,在本申请实施例中,客户端会单独将服务端对应的服务数据中的第一服务数据存储在本地,进而使得第一服务数据和第二服务数据可能是分别进行获取的,则可以通过将第二服务数据和第一服务数据统一按既定顺序进行排序,使得客户端最终所获取到的服务数据的顺序和服务端中本来的顺序是一致的。其中,既定顺序则为服务端中服务数据的排列顺序。
作为一种方式,所述客户端与服务端建立连接之后还包括:若本地未存储有基于所述指定标识从所述服务端获取的第一服务数据,则从所述服务端获取所述服务端对应的服务数据;将所述服务端对应的服务数据中的第一服务数据存储在本地。
需要说明的是,作为一种方式,客户端可以是通过服务端所发送的广播数据来发现服务端,并与服务端建立连接。若是第一次建立连接,则在建立连接后可以从服务端中获取指定标识,并基于指定标识再获取第一服务数据。其中,服务端中所发送的广播数据中可以携带有服务端所在设备的设备标识。客户端在存储服务端的第一服务数据时,可以将第一服务数据与该设备标识进行对应存储。从而使得客户端在从服务端发送的广播数据中获取得到设备标识后,通过查询本地是否有该设备标识来确定本地是否存储有预先基于指定标识(设备标识所属设备中的服务端所存储的指定标识)从所述服务端获取的第一服务数据。其中,若查询到本地存储有设备标识,则确定本地存储有预先基于指定标识从所述服务端获取的第一服务数据。
本实施例提供的一种数据获取方法,在客户端与服务端建立连接后,客户端进一步的确定本地是否已经预先存储有基于所述指定标识从所述服务端获取的第一服务数据,若有则直接基于所述指定标识从所述服务端中获取服务端中除所述第一服务数据以外的服务数据(第二服务数据),以将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
从而通过上述方式使得在服务端将服务数据区分为第一服务数据以及第二服务数据的情况下,使得客户端可以预先通过从服务端中获取第一服务数据以存储在本地,继而使得在后续每次需要获取服务端对应的服务数据的过程中,可以只用通过服务端对应的指定标识去获取第二服务数据,进而减少了每次服务数据的获取过程中需要从服务端中进行数据获取的数据量,提升了从服务端获取服务数据的效率。
请参阅图5,本申请实施例提供的一种数据获取方法,所述方法包括:
S210:所述客户端与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据。
S220:若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,从本地读取所述指定标识,其中,本地的指定标识为在预先从所述服务端获取第一服务数据时从所述服务端中获取。
需要说明的是,在客户端第一次从服务端中获取得到指定标识,并将指定标识所标识的第一服务数据存储在本地时,也可以将获取到的指定标识与第一服务数据进行对应存储,继而使得将指定标识也存储在客户端本地。那么,客户端在与服务端建立连接后,若确定本地存储有基于所述指定标识从所述服务端获取的第一服务数据,则会直接从本地进行指定标识的读取。
S230:基于本地读取所述指定标识从所述服务端中获取第二服务数据。
作为一种方式,所述基于本地读取所述指定标识从所述服务端中获取第二服务数据,包括:若本地读取所述指定标识与服务端中存储的指定标识一致,则基于本地读取所述指定标识从所述服务端中获取第二服务数据。
需要说明的是,服务端中的固定不变的服务数据可以是指的在一定周期时间内不会变换的服务数据。那么在当前周期时间结束后,在下一个周期时间内固定不变的服务数据则可能会有变化,那么为了使得客户端可以更好的自适应上述周期变化,客户端可以将本地存储的指定标识与服务端中存储的指定标识进行比对。
示例性的,若本地读取的指定标识为标识1,且服务端中存储的指定标识也为标识1,那么则从本地读取的指定标识与服务端中存储的指定标识是一致的。若本地读取的指定标识为标识2,且服务端中存储的指定标识为标识1,那么则从本地读取的指定标识与服务端中存储的指定标识不是一致的。
再者,需要说明的是,客户端可能会和多种服务端建立过连接,并且,不同服务端各自所对应的指定标识可能是相同的。那么在这种方式中,客户端可以将指定标识以及设备标识(服务端所在设备的设备标识)进行对应的存储,以区别不同服务端各自所对应的指定标识。示例性的,客户端在本地存储的指定标识可以如下表所示。
ID | 指定标识 | 设备标识 |
1 | 标识1 | 设备1 |
2 | 标识2 | 设备2 |
3 | 标识3 | 设备3 |
其中,若从本地读取的指定标识为标识2,设备标识为设备2,且从服务端获取到的指定标识为标识2,设备标识为标识2,则客户端确定本地读取所述指定标识与服务端中存储的指定标识一致。若从本地读取的指定标识为标识2,设备标识为设备2,且从服务端获取到的指定标识为标识2,设备标识为标识1,则客户端确定本地读取所述指定标识与服务端中存储的指定标识不一致。并且,在这种情况下,还可以进一步的确定设备2中服务端对应第一服务数据实际已经发生变化,从而用于标识第一服务数据的指定标识也发生了变化,并且,在确定服务端对应第一服务数据实际已经发生变化的情况下,服务端对应的服务数据则需要全部从服务端中重新获取。
S240:将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
本实施例提供的一种数据获取方法,从而通过上述方式使得在服务端将服务数据区分为第一服务数据以及第二服务数据的情况下,使得客户端可以预先通过从服务端中获取第一服务数据以存储在本地,继而使得在后续每次需要获取服务端对应的服务数据的过程中,可以只用通过服务端对应的指定标识去获取第二服务数据,进而减少了每次服务数据的获取过程中需要从服务端中进行数据获取的数据量,提升了从服务端获取服务数据的效率。并且,在本实施例中,在存储第一服务数据时还会对应的将指定标识存储在本地,从而使得后续在基于指定标识获取第二服务数据时,可以直接从本地进行指定标识的获取,进而有利于提升触发服务端对第二服务数据进行搜索的速度。
请参阅图6,本申请实施例提供的一种数据获取方法,所述方法包括:
S310:所述客户端与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;
S320:若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识确定服务数据查询范围,所述服务数据查询范围为第二服务数据对应的范围。
其中,如前述实施例介绍可知,在本申请实施例中,指定标识可以有多种实施方式。而对于不同的实施方式的指定标识,则所对应的确定的数据查询范围也可能会有不同。
作为一种方式,所述指定标识为指定标识区间中排序在最后的一个标识,所述指定 标识区间的开始标识为所述服务端中的排序最前的一个标识,所述指定标识区间为所述第一服务数据对应的标识所在的区间;所述基于所述指定标识确定服务数据查询范围,包括:将排序在所述指定标识之后的标识所在范围作为服务数据查询范围。也就是说,在第一服务数据是从排序在最前标识开始起算的情况下,指定标识为第一服务数据所包括的服务数据对应的标识中,排序在最后的标识。并且,在服务数据对应的标识都是从小到大进行排序的情况下,指定标识则为第一服务数据所包括的服务数据对应的标识中,最大的一个标识。示例性的,请再参阅图4,在这种方式中若指定标识为0x0006,那么所确定的服务数据查询范围则为0x0007到最后一个标识。
作为另外一种方式,指定标识会包括有开始标识和截止标识,那么则客户端会将服务端中的排序最前的一个标识到开始标识之间的范围,以及截止标识之后的范围作为服务数据查询范围。示例性的,请再参阅图4,在这种方式中若开始标识为0x0004,截止标识为0x0006,那么所确定的服务数据查询范围会包括0x0001(排序最前的一个标识)到0x0003,以及包括0x0007之后的范围。
作为一种方式,所述指定标识为指定标识区间中排序在最后的一个标识,所述指定标识区间的开始标识为所述服务端中的排序最前的一个标识,所述指定标识区间为所述第一服务数据对应的标识所在的区间;所述基于所述指定标识确定服务数据查询范围,包括:将排序在所述指定标识之后的标识所在范围作为服务数据查询范围。
S330:触发所述服务端基于所述服务数据查询范围进行服务数据查找,以获取到查找到的第二服务数据,所述第二服务数据为所述服务端中除所述第一服务数据以外的服务数据。
S340:将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
本实施例提供的一种数据获取方法,从而通过上述方式使得在服务端将服务数据区分为第一服务数据以及第二服务数据的情况下,使得客户端可以预先通过从服务端中获取第一服务数据以存储在本地,继而使得在后续每次需要获取服务端对应的服务数据的过程中,可以只用通过服务端对应的指定标识去获取第二服务数据,进而减少了每次服务数据的获取过程中需要从服务端中进行数据获取的数据量,提升了从服务端获取服务数据的效率。并且,在本实施例中客户端还可以进一步的根据指定标识确定出服务数据查询范围,从而使得服务端能够直接基于客户端所确定的服务数据查询范围进行服务数据的获取,进一步的提升了获取效率。
请参阅图7,本申请实施例提供的一种数据获取方法,所述方法包括:
S410:所述客户端与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;
S420:获取服务端所在设备的设备标识。
其中,设备标识为用于对设备的唯一性进行标识的信息。在本申请实施例中,设备标识可以有多种的实施方式。
作为一种方式,设备标识可以通过设备所对应的网络地址来实施。在这种方式下,可以将设备的网络地址作为设备的设备标识。例如,若服务端所在设备是通过蓝牙通信的方式发送无线数据。那么基于蓝牙通信的方式所发送的无线数据中会携带有设备的蓝牙地址,进而客户端可以将无线数据中所携带的蓝牙地址作为设备的设备标识。其中,在采用蓝牙地址作为设备标识的情况下,蓝牙地址为public类型的地址,以便使得设备的蓝牙地址是固定不变的。
作为另外一种方式,设备标识可以为基于指定协议生成的随机数,并且每次生成的随机数可以不同,从而使得不同设备对应的设备标识可以是唯一的。在服务端每次发送无线数据的时候,可以将该作为设备标识的随机数增加到所发送的无线数据中,从而使得接收到该无线数据的客户端可以了解到当前的无线数据是由哪个服务端发送的。
那么在设备标识可以有多种实施方式的情况下,客户端则可以采用既定的方式来获取得到设备标识。
可选的,若客户端所配置的既定方式为通过获取无线数据中所携带的网络地址来作为设备标识,那么客户端在获取得到服务端发送的无线数据后,则可以直接从无线数据中进行网络地址的提取,以作为服务端所在设备的设备标识。可选的,若客户端所配置的既定方式为通过获取无线数据中所携带的随机数来作为设备标识,那么客户端在获取得到服务端发送的无线数据后,则可以直接从无线数据中进行随机数的提取,以作为服务端所在设备的设备标识。
再则,客户端也可以通过自适应的方式来进行设备标识的获取。需要说明的是,不同的服务端在对自己所在设备进行标识时,所采用的标识方式可能是不同的。例如,虽然设备所发送的无线数据中都可能会携带有网络地址,但是有个的设备采用的为随机网络地址(random类型的网络地址),进而就可能使得不同设备的网络地址是相同的,那么在这种情况下,网络地址就没有办法很好的对设备进行唯一性标识。
作为一种方式,客户端在获取设备标识的过程中,可以先检测无线数据中采用的网络地址的类型;若检测到网络地址为固定类型的网络地址,则直接将获取到的网络地址作为发送该无线数据的设备的设备标识;若检测到网络地址为随机类型的网络地址,则进一步的检测无线数据中是否携带有基于指定协议生成的随机数;若检测到有基于指定协议生成的随机数,则将该基于指定协议生成的随机数作为发送该无线数据的设备的设备标识。若未检测到有基于指定协议生成的随机数,则直接从服务端中获取所有服务数据作为所述服务端对应的服务数据。
需要说明的是,在本申请实施例中,客户端在获取到从服务端中获取得到第一服务数据之后,可以将设备标识与第一服务数据进行对应存储。
S430:检测本地是否存储有所述设备标识对应的服务数据。
如前述内容接介绍,客户端在存储第一服务数据时,是可以将设备标识与第一服务数据进行对应存储。那么客户端检测本地是否存储有所述设备标识对应的服务数据则实际可以理解为,客户端确定本地是否有基于从所述服务端获取的第一服务数据。并且,该第一服务数据是由设备标识所在无线数据中的指定标识所标识的服务数据。
S440:若本地未存储有与所述设备标识对应的服务数据,则确定本地未存储有预先基于所述指定标识从所述服务端获取的第一服务数据。
S450:若本地存储有与所述设备标识对应的服务数据,则确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据。
S460:若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,所述第二服务数据为所述服务端中除所述第一服务数据以外的服务数据。
S470:将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
本实施例提供的一种数据获取方法,从而通过上述方式使得在服务端将服务数据区分为第一服务数据以及第二服务数据的情况下,使得客户端可以预先通过从服务端中获取第一服务数据以存储在本地,继而使得在后续每次需要获取服务端对应的服务数据的过程中,可以只用通过服务端对应的指定标识去获取第二服务数据,进而减少了每次服务数据的获取过程中需要从服务端中进行数据获取的数据量,提升了从服务端获取服务数据的效率。并且,在本实施例中在存储第一服务数据的过程中,会将第一服务数据、服务端所在设备的设备标识进行对应的存储,从而在确定存储有设备标识对应的服务数据的情况下,可以直接确定存储有该服务端的第一服务数据。
请参阅图8,本申请实施例提供的一种数据获取方法,应用于服务端,所述方法包括:
S510:所述服务端与客户端建立连接,所述服务端中存储有指定标识,所述指定标 识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据。
S520:响应于客户端发送的与所述指定标识对应的获取请求,从所述服务端中获取第二服务数据,所述获取请求为所述客户端在确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据后发送。
作为一种方式,所述响应于客户端发送的与所述指定标识对应的获取请求,从所述服务端中获取第二服务数据,包括:
响应于客户端发送的与所述指定标识对应的获取请求,从所述获取请求中获取服务数据查询范围,在所述服务端中查询所述服务数据查询范围对应的服务数据作为第二服务数据。
S530:将所述第二服务数据发送给所述客户端,以用于使所述客户端将所述第二服务数据和本地的第一服务数据作为获取到的所述服务端的服务数据。
需要说明的是,在本申请实施例中,在客户端从服务端获取指定标识之前,客户端可以先检测与服务端之间是否已经建立授信关系,若已经建立授信关系,则可以直接按照已经建立授信关系所对应的服务获取方式进行服务端中的服务获取。若未建立授信关系,则可以执行后续的从服务端获取指定标识。其中,若客户端与服务端之间已经建立授信关系,则表征客户端和服务端之间已经进行了身份认证。
下面再通过一个示例来对本申请实施例所涉及的一个实际场景的流程进行介绍。如图9所示,图9所示的流程包括:
S610:GATT客户端获取GATT服务端发送的广播数据。
S620:GATT客户端与GATT服务端建立连接。
S630:GATT客户端检测是否与该服务端是第一次建立连接。
其中,GATT客户端检测是否与该服务端是第一次建立连接的方式可以有多种。例如,可以采用前述实施例中的检测本地是否存储有与GATT服务端所在设备的设备标识对应的服务数据的方式进行检测,对应的,若本地存储有设备标识对应的服务数据,则确定不是第一次连接,反之,若本地未存储有设备标识对应的服务数据,则确定是第一次连接。再例如,也可以采用检测从广播数据中获取的指定标识与本地存储的指定标识是否一致的方式进行检测,对应的,若检测到从广播数据中获取的指定标识与本地存储的指定标识一致,则确定不是第一次连接,反之,若检测到从广播数据中获取的指定标识与本地存储的指定标识一致,或者,本地并未存储过指定标识,则确定是第一次连接。
S640:若是第一次连接,GATT客户端触发从服务端的所有服务数据中排序在最前的一个服务数据开始进行服务搜索。
其中,服务端中的服务数据可以是按照一定的顺序排列的。例如,如图4中,对应的标识为0x0001的服务数据则为服务端的所有服务数据中排序在最前的一个服务数据。那么在GATT客户端在确定是与该GATT服务端为第一次建立连接的情况下,则会触发开始从GATT服务端中标识为0x0001的服务数据进行服务搜索。
S641:从GATT服务端的数据库中指定特征中获取指定标识。
需要说明的是,在本实施例中,可以将指定标识以服务数据中的特征的形式进行存储,并将存储有指定标识的特征作为指定特征。
S642:GATT客户端将搜索到的服务数据中第一服务数据存储在本地。
在GATT客户端在确定是与该GATT服务端为第一次建立连接的情况下,GATT客户端实际会是对GATT服务端中的所有服务数据均搜索一遍,从而发现GATT服务端中的所有服务数据。那么为了便于
S650:若不是第一次连接,GATT客户端触发从本地读取第一服务数据。
S651:GATT客户端触发从指定标识后的第一个服务数据开始进行服务搜索,以得到第二服务数据。
需要说明的是,在图9所示的实施例中,指定标识表征的是从排序在最前的一个服 务数据开始进行固定数据检测的方式中,对应的排序最后的一个服务数据所对应的标识。也可以理解为指定标识是固定不变的服务数据中对应的标识最大的一个标识。其中,服务数据的排序等同于服务数据对应的标识的排序。例如,请在参阅图4,若从0x0001开始确定固定不变的服务数据,并且,确定的固定不变的服务数据包括服务1、特征1、特征描述符1、服务2、特征2以及特征描述符2。那么在确定的不变的固定不变的服务数据中,对应的标识最大的一个标识则为0x0006,那么所确定的指定标识为0x0006。那么在GATT客户端确定与GATT服务端第一次建立连接后,所存储在本地的第一服务数据则会包括服务1、特征1、特征描述符1、服务2、特征2以及特征描述符2。那么再后续的非首次建立连接后,则会从0x0007开始进行服务数据的搜索。
其中,在得到第一服务数据和第二服务数据之后的处理方式可以参见前述实施例中的内容。
请参阅图10,本申请实施例提供的一种数据获取装置600,运行于客户端,所述装置600包括:
连接管理单元610,用于与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据。
第一数据获取单元620,用于若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,所述第二服务数据为所述服务端中除所述第一服务数据以外的服务数据。
第二数据获取单元630,用于将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
作为一种方式,第一数据获取单元620,具体用于若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,从本地读取所述指定标识,其中,本地的指定标识为在预先从所述服务端获取第一服务数据时从所述服务端中获取;基于本地读取所述指定标识从所述服务端中获取第二服务数据。可选的,第一数据获取单元,具体用于若本地读取所述指定标识与服务端中存储的指定标识一致,则基于本地读取所述指定标识从所述服务端中获取第二服务数据。
作为一种方式,第一数据获取单元620,具体用于若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识确定服务数据查询范围,所述服务数据查询范围为第二服务数据对应的范围;触发所述服务端基于所述服务数据查询范围进行服务数据查找,以获取到查找到的第二服务数据。可选的,所述指定标识为指定标识区间中排序在最后的一个标识,所述指定标识区间的开始标识为所述服务端中的排序最前的一个标识,所述指定标识区间为所述第一服务数据对应的标识所在的区间;第一数据获取单元620,具体用于将排序在所述指定标识之后的标识所在范围作为服务数据查询范围。
作为一种方式,第一数据获取单元620,还具体用于获取服务端所在设备的设备标识;若本地存储有与所述设备标识对应的服务数据,则确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据。
作为一种方式,作为一种方式,第二数据获取单元630,还用于若本地未存储有基于所述指定标识从所述服务端获取的第一服务数据,则从所述服务端获取所述服务端对应的服务数据;将所述服务端对应的服务数据中的第一服务数据存储在本地。
作为一种方式,所述客户端为GATT客户端,所述服务端为GATT服务端,所述GATT服务端对应的数据库中设置有指定特征,所述指定特征的值用于记录所述指定标识。
请参阅图11,本申请实施例提供的一种数据获取装置700,运行于客户端,所述装置700包括:
连接管理单元710,用于与客户端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务 数据。
数据查找单元720,用于响应于客户端发送的与所述指定标识对应的获取请求,从所述服务端中获取第二服务数据,所述获取请求为所述客户端在确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据后发送。
作为一种方式,数据查找单元720,具体用于响应于客户端发送的与所述指定标识对应的获取请求,从所述获取请求中获取服务数据查询范围,在所述服务端中查询所述服务数据查询范围对应的服务数据作为第二服务数据。
数据发送单元730,用于将所述第二服务数据发送给所述客户端,以用于使所述客户端将所述第二服务数据和本地的第一服务数据作为获取到的所述服务端的服务数据。
本实施例提供的一种数据获取装置,在客户端与服务端建立连接后,客户端进一步的确定本地是否已经预先存储有基于所述指定标识从所述服务端获取的第一服务数据,若有则直接基于所述指定标识从所述服务端中获取服务端中除所述第一服务数据以外的服务数据(第二服务数据),以将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。从而通过上述方式使得在服务端将服务数据区分为第一服务数据以及第二服务数据的情况下,使得客户端可以预先通过从服务端中获取第一服务数据以存储在本地,继而使得在后续每次需要获取服务端对应的服务数据的过程中,可以只用通过服务端对应的指定标识去获取第二服务数据,进而减少了每次服务数据的获取过程中需要从服务端中进行数据获取的数据量,提升了从服务端获取服务数据的效率。
需要说明的是,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本申请所提供的几个实施例中,模块相互之间的耦合可以是电性。另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
下面将结合图12对本申请提供的一种电子设备进行说明。
请参阅图12,基于上述的数据获取方法、装置,本申请实施例还提供的另一种可以执行前述数据获取方法的电子设备100。电子设备100包括相互耦合的一个或多个(图中仅示出一个)处理器102、存储器104以及无线模块106。其中,该存储器104中存储有可以执行前述实施例中内容的程序,而处理器102可以执行该存储器104中存储的程序。
其中,处理器102可以包括一个或者多个处理核。处理器102利用各种接口和线路连接整个电子设备100内的各个部分,通过运行或执行存储在存储器104内的指令、程序、代码集或指令集,以及调用存储在存储器104内的数据,执行电子设备100的各种功能和处理数据。可选地,处理器102可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器102可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责显示内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器102中,单独通过一块通信芯片进行实现。
存储器104可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。存储器104可用于存储指令、程序、代码、代码集或指令集。例如,存储器104中可以存储有数据获取装置。该数据获取装置可以为前述的装置600或者装置700。存储器104可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现下述各个方法实施例的指令等。存储数据区还可以存储终端100在使用中所创建的数据(比如电话本、音视频数据、聊天记录数据)等。
所述无线模块106用于接收以及发送电磁波,实现电磁波与电信号的相互转换,从而与通讯网络或者其他设备进行通讯,例如和音频播放设备进行通讯。所述无线模块106可包括各种现有的用于执行这些功能的电路元件,例如,天线、射频收发器、数字信号处理器、加密/解密芯片、用户身份模块(SIM)卡、存储器等等。所述无线模块106可与各种网络如互联网、企业内部网、无线网络进行通讯或者通过无线网络与其他设备进行通讯。上述的无线网络可包括蜂窝式电话网、无线局域网或者城域网。例如,无线模块106可以与基站进行信息交互。
请参考图13,其示出了本申请实施例提供的一种计算机可读存储介质的结构框图。该计算机可读介质1100中存储有程序代码,所述程序代码可被处理器调用执行上述方法实施例中所描述的方法。
计算机可读存储介质1100可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。可选地,计算机可读存储介质1100包括非易失性计算机可读介质(non-transitory computer-readable storage medium)。计算机可读存储介质1100具有执行上述方法中的任何方法步骤的程序代码1110的存储空间。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。程序代码1110可以例如以适当形式进行压缩。
综上所述,本申请提供的一种数据获取方法、装置、电子设备及存储介质,在客户端与服务端建立连接后,客户端进一步的确定本地是否已经预先存储有基于所述指定标识从所述服务端获取的第一服务数据,若有则直接基于所述指定标识从所述服务端中获取服务端中除所述第一服务数据以外的服务数据(第二服务数据),以将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
从而通过上述方式使得在服务端将服务数据区分为第一服务数据以及第二服务数据的情况下,使得客户端可以预先通过从服务端中获取第一服务数据以存储在本地,继而使得在后续每次需要获取服务端对应的服务数据的过程中,可以只用通过服务端对应的指定标识去获取第二服务数据,进而减少了每次服务数据的获取过程中需要从服务端中进行数据获取的数据量,提升了从服务端获取服务数据的效率。
最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不驱使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。
Claims (20)
- 一种数据获取方法,其特征在于,应用于客户端,所述方法包括:所述客户端与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,所述第二服务数据为所述服务端中除所述第一服务数据以外的服务数据;将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
- 根据权利要求1所述的方法,其特征在于,所述若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,包括:若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,从本地读取所述指定标识,其中,本地的指定标识为在预先从所述服务端获取第一服务数据时从所述服务端中获取;基于本地读取所述指定标识从所述服务端中获取第二服务数据。
- 根据权利要求2所述的方法,其特征在于,所述基于本地读取所述指定标识从所述服务端中获取第二服务数据,包括:若本地读取所述指定标识与服务端中存储的指定标识一致,则基于本地读取所述指定标识从所述服务端中获取第二服务数据。
- 根据权利要求1所述的方法,其特征在于,所述若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,包括:若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识确定服务数据查询范围,所述服务数据查询范围为第二服务数据对应的范围;触发所述服务端基于所述服务数据查询范围进行服务数据查找,以获取到查找到的第二服务数据。
- 根据权利要求4所述的方法,其特征在于,所述指定标识为指定标识区间中排序在最后的一个标识,所述指定标识区间的开始标识为所述服务端中的排序最前的一个标识,所述指定标识区间为所述第一服务数据对应的标识所在的区间;所述基于所述指定标识确定服务数据查询范围,包括:将排序在所述指定标识之后的标识所在范围作为服务数据查询范围。
- 根据权利要求1-5任一所述的方法,其特征在于,所述若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据之前还包括:获取服务端所在设备的设备标识;若本地存储有与所述设备标识对应的服务数据,则确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据。
- 根据权利要求6所述的方法,其特征在于,所述设备标识为基于指定协议生成的随机数,并且每次生成的随机数不同。
- 根据权利要求6所述的方法,其特征在于,所述设备标识为设备的网络地址。
- 根据权利要求6所述的方法,其特征在于,根据权利要求6所述的方法,其特征在于,所述获取服务端所在设备的设备标识,包括:检测所述服务端发送的无线数据中采用的网络地址的类型;若检测到所述网络地址为固定类型的网络地址,则将获取到的网络地址作为发送所述无线数据的设备的设备标识。
- 根据权利要求9所述的方法,其特征在于,所述方法还包括:若检测到所述网络地址为随机类型的网络地址,则检测所述无线数据中是否携带有基于指定协议生成的随机数;若检测到有基于指定协议生成的随机数,则将所述基于指定协议生成的随机数作为发送所述无线数据的设备的设备标识。
- 根据权利要求1-10任一所述的方法,其特征在于,所述客户端与服务端建立连接之后还包括:若本地未存储有基于所述指定标识从所述服务端获取的第一服务数据,则从所述服务端获取所述服务端对应的服务数据;将所述服务端对应的服务数据中的第一服务数据存储在本地。
- 根据权利要求1-10任一所述的方法,其特征在于,所述客户端为GATT客户端,所述服务端为GATT服务端,所述GATT服务端对应的数据库中设置有指定特征,所述指定特征的值用于记录所述指定标识。
- 根据权利要求1-12任一所述的方法,其特征在于,所述将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据,包括:将所述第二服务数据和所述第一服务数据进行组合;将组合后的服务数据作为获取到的所述服务端的服务数据。
- 根据权利要求1-12任一所述的方法,其特征在于,所述客户端与服务端建立连接,包括:所述客户端通过服务端所发送的广播数据来发现服务端,并与所述服务端建立连接。
- 一种数据获取方法,其特征在于,应用于服务端,所述方法包括:所述服务端与客户端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;响应于客户端发送的与所述指定标识对应的获取请求,从所述服务端中获取第二服务数据,所述获取请求为所述客户端在确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据后发送;将所述第二服务数据发送给所述客户端,以用于使所述客户端将所述第二服务数据和本地的第一服务数据作为获取到的所述服务端的服务数据。
- 根据权利要求5所述的方法,其特征在于,所述响应于客户端发送的与所述指定标识对应的获取请求,从所述服务端中获取第二服务数据,包括:响应于客户端发送的与所述指定标识对应的获取请求,从所述获取请求中获取服务数据查询范围,在所述服务端中查询所述服务数据查询范围对应的服务数据作为第二服务数据。
- 一种数据获取装置,其特征在于,运行于客户端,所述装置包括:连接管理单元,用于与服务端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;第一数据获取单元,用于若本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据,基于所述指定标识从所述服务端中获取第二服务数据,所述第二服务数据为所述服务端中除所述第一服务数据以外的服务数据;第二数据获取单元,用于将所述第二服务数据和本地的所述第一服务数据作为获取到的所述服务端的服务数据。
- 一种数据获取装置,其特征在于,运行于服务端,所述装置包括:连接管理单元,用于与客户端建立连接,所述服务端中存储有指定标识,所述指定标识用于标识所述服务端中的第一服务数据,所述第一服务数据为固定不变的服务数据;数据查找单元,用于响应于客户端发送的与所述指定标识对应的获取请求,从所述服务端中获取第二服务数据,所述获取请求为所述客户端在确定本地存储有预先基于所述指定标识从所述服务端获取的第一服务数据后发送;数据发送单元,用于将所述第二服务数据发送给所述客户端,以用于使所述客户端将所述第二服务数据和本地的第一服务数据作为获取到的所述服务端的服务数据。
- 一种电子设备,其特征在于,包括一个或多个处理器以及存储器;一个或多个程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行权利要求1-14任一所述的方法。
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有程序代码,其中,在所述程序代码被处理器运行时执行权利要求1-14任一所述的方法。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110963350.8 | 2021-08-20 | ||
CN202110963350.8A CN113691610B (zh) | 2021-08-20 | 2021-08-20 | 数据获取方法、装置、电子设备及存储介质 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023020187A1 true WO2023020187A1 (zh) | 2023-02-23 |
Family
ID=78581099
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/106771 WO2023020187A1 (zh) | 2021-08-20 | 2022-07-20 | 数据获取方法、装置、电子设备及存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113691610B (zh) |
WO (1) | WO2023020187A1 (zh) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113691610B (zh) * | 2021-08-20 | 2024-04-09 | Oppo广东移动通信有限公司 | 数据获取方法、装置、电子设备及存储介质 |
CN113691609B (zh) * | 2021-08-20 | 2024-04-09 | Oppo广东移动通信有限公司 | 数据获取方法、装置、电子设备及存储介质 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180357274A1 (en) * | 2017-06-07 | 2018-12-13 | Sap Se | Dynamic, variable-data attribute data service |
CN112286896A (zh) * | 2020-11-19 | 2021-01-29 | 北京百家科技集团有限公司 | 一种日志文件处理方法、装置、计算机设备和存储介质 |
CN112311720A (zh) * | 2019-07-23 | 2021-02-02 | 腾讯科技(深圳)有限公司 | 数据的传输方法及装置 |
CN113691609A (zh) * | 2021-08-20 | 2021-11-23 | Oppo广东移动通信有限公司 | 数据获取方法、装置、电子设备及存储介质 |
CN113691610A (zh) * | 2021-08-20 | 2021-11-23 | Oppo广东移动通信有限公司 | 数据获取方法、装置、电子设备及存储介质 |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101350841A (zh) * | 2007-07-17 | 2009-01-21 | 华为技术有限公司 | 媒体资源访问关系建立方法及通讯系统及相关设备 |
CN104683459B (zh) * | 2015-02-13 | 2018-05-11 | 华为技术有限公司 | 一种发送业务数据的方法和存储系统 |
CN105553954B (zh) * | 2015-12-09 | 2020-01-21 | 百度在线网络技术(北京)有限公司 | 数据处理方法及系统 |
CN105704252B (zh) * | 2016-04-26 | 2019-05-07 | 青岛海信电器股份有限公司 | 低功耗蓝牙设备数据传输方法及装置 |
CN108170723B (zh) * | 2017-12-07 | 2020-09-29 | 维沃移动通信有限公司 | 一种网页资源获取方法、终端设备、服务器及系统 |
CN110049503B (zh) * | 2018-01-15 | 2022-07-15 | 中国移动通信有限公司研究院 | 一种获取数据的方法和设备 |
CN110830538B (zh) * | 2018-08-13 | 2022-06-14 | 华为技术有限公司 | 一种消息传输方法、装置及存储介质 |
CN109120851B (zh) * | 2018-09-21 | 2020-09-22 | 维沃移动通信有限公司 | 一种图像处理方法、装置及电子设备 |
-
2021
- 2021-08-20 CN CN202110963350.8A patent/CN113691610B/zh active Active
-
2022
- 2022-07-20 WO PCT/CN2022/106771 patent/WO2023020187A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180357274A1 (en) * | 2017-06-07 | 2018-12-13 | Sap Se | Dynamic, variable-data attribute data service |
CN112311720A (zh) * | 2019-07-23 | 2021-02-02 | 腾讯科技(深圳)有限公司 | 数据的传输方法及装置 |
CN112286896A (zh) * | 2020-11-19 | 2021-01-29 | 北京百家科技集团有限公司 | 一种日志文件处理方法、装置、计算机设备和存储介质 |
CN113691609A (zh) * | 2021-08-20 | 2021-11-23 | Oppo广东移动通信有限公司 | 数据获取方法、装置、电子设备及存储介质 |
CN113691610A (zh) * | 2021-08-20 | 2021-11-23 | Oppo广东移动通信有限公司 | 数据获取方法、装置、电子设备及存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN113691610A (zh) | 2021-11-23 |
CN113691610B (zh) | 2024-04-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2023020253A1 (zh) | 数据获取方法、装置、电子设备及存储介质 | |
JP6726426B2 (ja) | 端末間のログイン不要方法及び装置 | |
CN107679560B (zh) | 数据传输方法、装置、移动终端及计算机可读存储介质 | |
WO2023020187A1 (zh) | 数据获取方法、装置、电子设备及存储介质 | |
EP3413594B1 (en) | Methods for connecting communication devices, terminal device and server system | |
US20160239540A1 (en) | Data Query Method and Apparatus, Server, and System | |
CN109714716B (zh) | 数据包转发方法、装置及移动终端 | |
WO2020228038A1 (zh) | 域名处理方法、装置、电子设备以及存储介质 | |
CN110267314B (zh) | 切换网络切片的方法及装置 | |
WO2020156255A1 (zh) | 支付方法、装置、系统、移动终端、支付机具及服务器 | |
CN107666662B (zh) | 一种终端识别方法和接入点 | |
CN105141789B (zh) | 陌生号码标记方法和装置 | |
CN110166823B (zh) | 投屏方法及相关装置 | |
CN111338710A (zh) | 应用程序控制方法、装置、电子设备及存储介质 | |
CN109725543B (zh) | 设备控制码配置方法、装置、云服务器及网络系统 | |
CN108901035B (zh) | 物联网终端的识别方法和装置 | |
WO2020258101A1 (zh) | 用户相似度计算方法、装置、服务端及存储介质 | |
WO2021237431A1 (zh) | 数据处理方法、装置、处理设备以及数据存储系统 | |
WO2020043059A1 (zh) | 显示业务标识的方法、装置及存储介质 | |
CN106912032B (zh) | 一种信息处理方法、系统、客户端和服务器 | |
CN107332967A (zh) | 联系人显示方法、装置、移动终端及计算机可读存储介质 | |
CN106341861B (zh) | 一种识别无线接入点的方法、服务器及系统 | |
CN107370863B (zh) | 一种基于蓝牙连接的连接信息更新方法及装置 | |
CN112738789A (zh) | Sim卡加锁方法、装置、存储介质及电子设备 | |
CN112188591A (zh) | 网络接入方法、装置、计算机设备和存储介质 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22857500 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 22857500 Country of ref document: EP Kind code of ref document: A1 |