Device access method, device, electronic device, system and storage medium
By using protocol adapter programs in the Internet of Things platform, the problems of high code coupling and poor platform stability during device access are solved, and the automation and cost savings of device access are realized, and the improvement of the improvement of the Platform stability.
Patent Information
- Application Number
- CN202211027292.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-25
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2042-08-25
AI Technical Summary
In the IoT platform, there is a device protocol adaptation work that requires customized development during the access process of IoT sensing devices, resulting in high code coupling, large workload, long development cycle and high labor costs, and each new device access May affect platform stability.
By downloading and running the protocol adapter, automatically obtaining access tokens and device attribute information, realizing device access, reducing the need for modification and deployment of IoT platform code, reducing code coupling, and combining protocol adapter with Platform decoupling.
It realizes automation of equipment access, reduces workload and labor costs, shortens development cycle, and improves platform stability and robustness.
Smart Images

Figure CN115460299B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to Internet of Things technology, and in particular to a device access method, apparatus, electronic equipment, system and storage medium. Background Art
[0002] When delivering enterprise-oriented (ToB) projects on the IoT platform, it is necessary to implement the access of IoT sensing devices for different application scenarios, such as online fume monitors, smart fire hydrants, smoke alarms, float water level gauges, etc. When IoT sensing devices are connected to the IoT platform, there is generally equipment protocol adaptation work.
[0003] At present, the access of IoT sensing devices is mainly achieved by modifying the IoT platform code. The IoT platform usually includes many functional components, which require professionals to modify the codes of these functional components one by one. After the code of each functional component is modified, component deployment and joint debugging are required. In the process of realizing the present invention, the inventor found that the access method of realizing device access by modifying the code of each component requires customized development of protocol adaptation, high code coupling, large workload, long development cycle and high labor cost; in addition, the access of each new device requires the redeployment of Unicom on the IoT platform, which may affect the deployed services and lead to poor platform stability. Summary of the invention
[0004] The embodiments of the present invention provide a device access method, apparatus, electronic device, system and storage medium, which can reduce the workload of device access, save labor costs and increase the robustness of the platform.
[0005] In a first aspect, an embodiment of the present invention provides a device access method, including:
[0006] Downloading a protocol adapter and running the protocol adapter;
[0007] Obtaining an access token from a device server through the protocol adapter;
[0008] Accessing the device server according to the access token to determine the device to be accessed;
[0009] Acquire the attribute information of the device to be connected from the device server, and report the attribute information of the device to be connected to the Internet of Things platform.
[0010] Optionally, the accessing the device server according to the access token to determine the device to be accessed includes:
[0011] Accessing the device server according to the access token to obtain a target device list;
[0012] The target device list and the connected device list are compared to determine the device to be connected.
[0013] Optionally, accessing the device server according to the access token to obtain a target device list includes:
[0014] Obtaining a device type identifier corresponding to the protocol adapter;
[0015] The device server is accessed according to the access token to obtain a target device list corresponding to the device type identifier.
[0016] Optionally, before comparing the target device list with the connected device list to determine the device to be connected, the method further includes:
[0017] Obtain the connected device list corresponding to the device type identifier.
[0018] Optionally, the target device list includes factory identifications of candidate devices, the connected device list includes factory identifications of connected devices, and comparing the target device list with the connected device list to determine the device to be connected includes:
[0019] The factory identifications of the candidate devices in the target device list and the factory identifications of the connected devices in the connected device list are compared to determine the device to be connected from the candidate devices.
[0020] Optionally, after accessing the device server according to the access token to determine the device to be accessed, the method further includes:
[0021] Creating a platform identifier for the device to be connected;
[0022] The step of reporting the attribute information of the device to be connected to the Internet of Things platform includes:
[0023] The platform identifier and the attribute information of the device to be connected are assembled into information in a target protocol format to obtain target information, and the target information is reported to the Internet of Things platform.
[0024] Optionally, the download protocol adapter includes:
[0025] Querying the first database to determine the protocol adapter that needs to be downloaded;
[0026] The protocol adapter is downloaded from a second database, the type of the first database being different from the type of the second database.
[0027] In a second aspect, an embodiment of the present invention provides a device access apparatus, including:
[0028] A download module, used for downloading the protocol adapter and running the protocol adapter;
[0029] An acquisition module, used for acquiring an access token from a device server through the protocol adapter;
[0030] A determination module, configured to access the device server according to the access token to determine a device to be connected;
[0031] The access module is used to obtain the attribute information of the device to be connected from the device server and report the attribute information of the device to be connected to the Internet of Things platform.
[0032] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the device access method as described in any one of the embodiments of the present invention is implemented.
[0033] In a fourth aspect, an embodiment of the present invention provides a device access system, including a device server, an Internet of Things platform, and an electronic device for executing the device access method as described in any one of the embodiments of the present invention.
[0034] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a device access method as described in any one of the embodiments of the present invention.
[0035] In the embodiment of the present invention, when it is necessary to access a device, it is only necessary to download and run the corresponding protocol adapter program, and the required information is automatically obtained and reported through the protocol adapter program, so that the device access can be achieved. The developer only needs to develop the corresponding protocol adapter program for the device to be accessed, and there is no need to modify the code of each functional component in the Internet of Things platform. Therefore, there is no problem of the components needing to be deployed and debugged again. The protocol adapter program is decoupled from the Internet of Things platform, which reduces the code coupling. The entire access process can be automatically implemented using the protocol adapter program, which reduces the workload of device access and saves labor costs. In addition, since the access device is implemented through the corresponding protocol adapter program, as much general code as possible can be placed in the Internet of Things platform framework, and the protocol adapter program can only focus on the conversion adaptation of the protocol, which can greatly reduce the workload of device protocol adaptation and customization development, shorten the development cycle, and maintain the stability of the platform and increase the robustness of the platform. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flow chart of a device access method provided by an embodiment of the present invention;
[0037] Figure 2is another schematic diagram of a flow chart of a device access method provided by an embodiment of the present invention;
[0038] Figure 3 This is a schematic diagram of a JAR package upload page provided by an embodiment of the present invention;
[0039] Figure 4 is a schematic diagram of a JAR package management page provided by an embodiment of the present invention;
[0040] Figure 5 is an interactive schematic diagram of a device access process provided by an embodiment of the present invention;
[0041] Figure 6 is a structural schematic diagram of a device access apparatus provided by an embodiment of the present invention;
[0042] Figure 7 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0044] Figure 1 The present invention provides a flow chart of a device access method provided in an embodiment of the present invention. The method can be executed by a device access apparatus provided in an embodiment of the present invention. The apparatus can be implemented in software and / or hardware. In a specific embodiment, the apparatus can be integrated into an electronic device, such as a computer, a server, etc. The following embodiments will be described by taking the apparatus integrated into an electronic device as an example. Figure 1 , the method may specifically include the following steps:
[0045] Step 101, download the protocol adapter and run the protocol adapter.
[0046] In the specific implementation, the protocol adapter can be developed in advance by the R&D personnel or developers for the sensing devices that need to be connected. The sensing devices that need to be connected can be the devices used by the enterprise. The enterprise can include but not limited to the fire department, flood control bureau, sanitation bureau, etc. The sensing devices can include but not limited to intelligent fire hydrants, smoke alarms, float water level gauges, unmanned sanitation vehicles, street light control boxes, intelligent manhole covers, berth geomagnetism, etc. Specifically, when a certain type of sensing device needs to be connected to the Internet of Things platform, a protocol adapter corresponding to the type of device can be developed, that is, a device type identifier can correspond to a protocol adapter, which can reduce the development workload. The device type identifier can be a string or array used to identify the device type. Specifically, the protocol adapter can be developed in combination with the device service component that needs to be called for device access and the interface of the device server. The protocol adapter is responsible for providing protocol adaptation when the corresponding type of device is connected. The protocol adaptation process can include token acquisition, device creation, data pulling, etc. The developed protocol adapter is packaged into a script file, such as a JAR (Java Archive) file (i.e., JAR package), and the JAR package is uploaded to the specified database.
[0047] The electronic device can query the designated database periodically (such as daily or weekly) or in real time to determine whether there is a protocol adapter program that needs to be downloaded. If there is a protocol adapter program that needs to be downloaded, the protocol adapter program is downloaded from the designated database. After the downloaded protocol adapter program completes program initialization, the protocol adapter program is started and run. The protocol adapter program that needs to be downloaded can be the latest uploaded program, a program that has not been downloaded, or a program that has been recently updated.
[0048] Step 102: Obtain an access token from a device server through a protocol adapter.
[0049] The device server can be the server of the manufacturer that produces the device to be connected. After starting the downloaded protocol adapter, you can log in to the protocol adapter with your account and password, and then obtain an access token from the device server through the protocol adapter. The token is a temporary key that represents the right to perform certain operations. The token has a validity period. You can bring this token to request data within the validity period without bringing your account and password again.
[0050] Step 103: Access the device server according to the access token to determine the device to be connected.
[0051] Specifically, the electronic device can access the device server with the access token through the protocol adapter program to determine the device to be connected. The determined device to be connected can be one device or a group of devices. For example, after accessing the device server with the access token, the device list fed back by the device server can be obtained, and the device in the device list can be determined as the device to be connected.
[0052] Since the protocol adapter is developed for the device type, one type of device can correspond to a general protocol adapter. In actual applications, according to actual needs, the same type of devices may be connected in different batches, or the same type of devices may be connected intermittently. For example, the fire department first connected 5 smart fire hydrants to the IoT platform, and then found that the number of connected smart fire hydrants was not enough, and 5 more were needed. In this case, these 10 smart fire hydrants were connected in two batches.
[0053] In a specific implementation, if the type of the device to be connected is the same as that of the connected device, it can be achieved by modifying the protocol adapter and part of the data stored in the corresponding device server. For example, the protocol adapter can be updated, and the device list fed back by the server can be modified (the information of the device to be connected is added to the device list). Therefore, after obtaining the device list fed back by the device server, the fed back device list can also be compared with the stored list of connected devices to determine the device to be connected. The device list fed back by the server can include the identification information of all devices (connected devices and non-connected devices), and the list of connected devices can include the identification information of connected devices. The device type identification corresponding to the device list fed back by the server and the device type identification corresponding to the list of connected devices can be the same, that is, the two lists record the identification information of the same type of devices. The identification information of the device can be the name, number, physical address, etc. of the device.
[0054] Step 104: Acquire attribute information of the device to be connected from the device server, and report the attribute information of the device to be connected to the Internet of Things platform.
[0055] Specifically, the attribute information of the device to be connected can be obtained from the device server according to the identification information of the device to be connected. The attribute information of the device to be connected can include the status information, specification information, working parameter information, etc. of the device to be connected. For example, if the device to be connected is a fume detector, its attribute information can include description information of the fume detector's offline status, fume concentration, particulate matter concentration, non-methane total hydrocarbons, current, etc.; if the device to be connected is a dust monitor, its attribute information can include description information of temperature, humidity, noise, etc. The attribute information of the device to be connected can be assembled into information in a specified protocol format and reported to the IoT platform, so that the IoT platform can identify the reported information and accelerate device access.
[0056] In the embodiment of the present invention, when it is necessary to access a device, it is only necessary to download and run the corresponding protocol adapter program, and the required information is automatically obtained and reported through the protocol adapter program, so that the device access can be achieved. The developer only needs to develop the corresponding protocol adapter program for the device to be accessed, and there is no need to modify the code of each functional component in the Internet of Things platform. Therefore, there is no problem of the components needing to be deployed and debugged again. The protocol adapter program is decoupled from the Internet of Things platform, which reduces the code coupling. The entire access process can be automatically implemented using the protocol adapter program, which reduces the workload of device access and saves labor costs. In addition, since the access device is implemented through the corresponding protocol adapter program, as much general code as possible can be placed in the Internet of Things platform framework, and the protocol adapter program can only focus on the conversion adaptation of the protocol, which can greatly reduce the workload of device protocol adaptation and customization development, shorten the development cycle, and maintain the stability of the platform and increase the robustness of the platform.
[0057] The following further illustrates the device access method provided by the embodiment of the present invention. Figure 2 As shown, the method may include the following steps:
[0058] Step 201: query a first database to determine a protocol adapter that needs to be downloaded.
[0059] Specifically, the protocol adapter can be developed by R&D personnel or developers in combination with the device service components that need to be called for device access and the interface of the device server. One type of device can correspond to one protocol adapter, that is, one device type identifier can correspond to one protocol adapter. The developed protocol adapter can be uploaded to the specified database. The device service component can be used to provide and store a list of connected devices during the device access process, and the device server can be used to provide access tokens, device lists, device attribute information, etc. during the device access process.
[0060] Take the protocol adapter for flood control detection equipment (such as float water level gauge) developed by City X as an example. The JAR package upload page can be as follows: Figure 3 As shown, you can click or drag to upload the JAR package. When uploading the JAR package, you can provide the JAR package name (which can be the corresponding type name), data uplink type (that is, data acquisition method), device type identifier, entry class name and other information on the upload page. Figure 4 As shown, a JAR package management page is also provided, on which you can add JAR packages, view JAR package status, start JAR packages, edit JAR packages, delete JAR packages, etc.
[0061] In practical applications, in order to improve data processing efficiency, after the protocol adapter is developed, various information of the protocol adapter can be uploaded to different databases through the upload page. For example, the package file (i.e., JAR package) of the protocol adapter can be uploaded to the file storage database, the information of the protocol adapter that does not need to be frequently queried or used (such as dynamic protocol name, data acquisition method, jar package status, etc.) can be uploaded to the general database, and the information of the protocol adapter that needs to be frequently queried or used (such as device type identification) can be uploaded to the special database. Among them, the file storage database can be, for example, an object storage service (Object Storage Service, OSS) database, the general database can be, for example, a Postgre database, an Oracle database, and the special database can be, for example, a Redis database, an HBase database. The first database in the embodiment of the present invention can be the special database mentioned above, and the second database can be the file storage database mentioned above.
[0062] Step 202: Download the protocol adapter from the second database.
[0063] The electronic device can query the first database regularly (such as every day or every week) or in real time to determine whether there is a protocol adapter program that needs to be downloaded. If there is a protocol adapter program that needs to be downloaded, the protocol adapter program is downloaded from the second database. After the downloaded protocol adapter program completes the program initialization, the protocol adapter program is started and run. The protocol adapter program that needs to be downloaded can be the latest uploaded program that has not been downloaded. In a specific implementation, the information required for starting the protocol adapter program can be stored in the following fields:
[0064] @param deviceService device service component
[0065] @param properties Configuration parameters of the device server
[0066] The configuration parameters of the device server may include address information, connection account, password and other information.
[0067] Step 203: Obtain an access token from the device server through the protocol adapter.
[0068] The device server can be the server of the manufacturer that produces the device to be connected. After starting the downloaded protocol adapter, you can log in to the protocol adapter with your account and password, and then obtain an access token from the device server through the protocol adapter. For example, you can obtain an access token from the device server through the jar.getToken instruction. The token is a temporary key that represents the right to perform certain operations. The token has a valid time. You can bring this token to request data within the valid time without bringing your account and password again.
[0069] Step 204: Obtain the device type identifier corresponding to the protocol adapter.
[0070] Specifically, the corresponding device type identifier may be acquired from the first database.
[0071] Step 205: access the device server according to the access token to obtain a target device list corresponding to the device type identifier.
[0072] The target device list can include the factory identification of all devices (including connected devices and non-connected devices) corresponding to the device type identification. The factory identification is the identification information created by the manufacturer for the device when the device leaves the factory. The factory identification of the same type of devices produced by different manufacturers may be the same. The target device list can be obtained from the device server through the jar.getDeviceList instruction.
[0073] Step 206: Obtain a list of connected devices corresponding to the device type identifier.
[0074] Specifically, the list of connected devices corresponding to the device type identifier can be obtained from the device service component. The device service component can be a service component on an electronic device or a service component on other devices. It is mainly used to access the list of connected devices. The list of connected devices includes the factory identification of the device of the type identified by the device type identifier.
[0075] Step 207: Compare the target device list with the connected device list to determine the device to be connected.
[0076] Specifically, it can be considered that the target device list includes the factory identification of the candidate devices, and the factory identification of the candidate devices in the target device list can be compared with the factory identification of the connected devices in the connected device list to determine the devices to be connected from the candidate devices. For example, if the target device list includes 15 devices of a certain type and the connected device list includes 10 devices of the same type, then the 5 devices whose factory identifications are not in the connected device list can be determined as the devices to be connected.
[0077] Step 208: Create a platform identifier for the device to be connected.
[0078] Since the factory identification of the same type of equipment produced by different manufacturers may be the same, for example, the factory identification assigned by manufacturer A and manufacturer B to the smart fire hydrant is Y, in order to distinguish the devices connected to the Internet of Things platform, in the embodiment of the present invention, after determining the device to be connected, a platform identification belonging to the Internet of Things platform can be created for the device to be connected. When creating a platform identification for the device to be connected, it can be created in combination with the factory identification of the device to be connected, for example, the format of the platform identification of the device to be connected can be deviceId_physicallId; wherein, deviceId can be the id assigned to the device to be connected on the Internet of Things platform, and physicallId can be the factory id of the device to be connected.
[0079] Step 209: Acquire attribute information of the device to be connected from the device server.
[0080] Specifically, the attribute information of the device to be connected can be obtained from the device server according to the factory identification. The attribute information of the device to be connected may include status information, specification information, working parameter information, etc. of the device to be connected. The attribute information of the device to be connected can be obtained from the device server through the jar.getDeviceData instruction.
[0081] Step 210: assemble the platform identification and attribute information of the device to be connected into information in a target protocol format, obtain target information, and report the target information to the Internet of Things platform.
[0082] For example, the platform identification and attribute information of the device to be connected can be assembled into information in the protocol format supported by the IoT platform, and then reported, so that the IoT platform can identify the reported information and accelerate device access.
[0083] In addition, you can also delete devices that have been connected to the Internet of Things platform through the protocol adapter. When deleting devices that have been connected to the Internet of Things platform through the protocol adapter, you can obtain a list of deleted devices from the corresponding device server, generate a device deletion instruction based on the list of deleted devices, and send the device deletion instruction to the Internet of Things platform. The device deletion instruction may include the platform identifier of the device to be deleted, so that the Internet of Things platform deletes the attribute information of the corresponding device according to the platform identifier.
[0084] The following introduces some interfaces defined in the protocol adapter. These interfaces may include a token acquisition interface, a target device list acquisition interface, a deleted device list acquisition interface, and a device attribute information acquisition interface.
[0085] Among them, the definition of the token acquisition interface can be as follows:
[0086] By default, a string device type identifier is passed in and an access token is returned.
[0087] If no access token is required to retrieve data, a null value is returned.
[0088] The definition of the target device list acquisition interface is as follows:
[0089] By default, the following parameters are passed in: device type identifier of character type (string), access token of character type (string), current timestamp of long integer type (long), and the target device list is returned;
[0090] If the target device list is not obtained, an empty list is returned.
[0091] Among them, the current timestamp can be used by the JAR package to adjust the frequency of returning data. The framework calls this interface once every minute.
[0092] The definition of the interface for obtaining the deleted device list can be as follows:
[0093] By default, the following parameters are passed in: device type identifier of character type (string), access token of character type (string), current timestamp of long integer type (long), and a list of deleted devices is returned;
[0094] If the list of deleted devices is not obtained, an empty list is returned.
[0095] Among them, the current timestamp can be used by the JAR package to adjust the frequency of returning data. The framework calls this interface once every minute.
[0096] The definition of the device attribute information acquisition interface can be as follows:
[0097] The following parameters are passed in: device type identifier of character type (string), device factory identifier of character type (string), access token of character type (string), current timestamp of long integer type (long), and the device attribute information is returned.
[0098] The current timestamp can be used by the JAR package to adjust the frequency of returning data, and the data acquisition tasks of different devices in the same batch will pass in the same value.
[0099] In the embodiment of the present invention, when it is necessary to access a device, it is only necessary to download and run the corresponding protocol adapter program, and the required information is automatically obtained and reported through the protocol adapter program, so that the device access can be achieved. The developer only needs to develop the corresponding protocol adapter program for the device to be accessed, and there is no need to modify the code of each functional component in the Internet of Things platform. Therefore, there is no problem of the components needing to be deployed and debugged again. The protocol adapter program is decoupled from the Internet of Things platform, which reduces the code coupling. The entire access process can be automatically implemented using the protocol adapter program, which reduces the workload of device access and saves labor costs. In addition, since the access device is implemented through the corresponding protocol adapter program, as much general code as possible can be placed in the Internet of Things platform framework, and the protocol adapter program can only focus on the conversion adaptation of the protocol, which can greatly reduce the workload of device protocol adaptation and customization development, shorten the development cycle, and maintain the stability of the platform and increase the robustness of the platform.
[0100] The following is a specific example to illustrate the device access method provided by the embodiment of the present invention. Figure 5 As shown in the figure, taking the example of connecting flood prevention detection equipment (such as a float water level gauge) to City X, developers can write a protocol adapter for the flood prevention detection equipment in City X, package the written protocol adapter into a JAR package, upload the JAR package to the OSS database through the terminal (upload page), upload the dynamic protocol name, data acquisition method, jar package status and other information of the protocol adapter that does not need to be frequently queried or used to the DB database, and upload the device type identifier corresponding to the protocol adapter and other information that needs to be frequently queried or used to the Redis database.
[0101] The electronic device can query the Redis database regularly or in real time to determine whether there is a JAR package that needs to be downloaded. When it is determined that there is a JAR package that needs to be downloaded (such as a newly uploaded JAR package, an updated JAR package), the corresponding JAR package can be downloaded from the OSS database to the local computer. Here, the JAR package corresponding to the flood control detection device can be downloaded to the local computer. After completing the initialization of the JAR package, the protocol adapter corresponding to the flood control detection device can be started and run. The electronic device can access the device server through the running protocol adapter to obtain an access token, store the access token in the Redis database, pull the device type identifier corresponding to the protocol adapter from the Redis database (i.e., the device type identifier of the flood control detection device), and access the device server according to the access token to obtain the target device list corresponding to the device type identifier. The target device list includes the factory identifiers of each device whose device type identifier is a flood control detection device. For example, the target device list can include the factory identifiers of 15 float water level gauges, and these 15 float water level gauges can be candidate devices. The electronic device can obtain a list of connected devices corresponding to the flood prevention detection device with a device type identifier from the device server component. The connected device list includes the factory identifiers of the devices of the type identified by the connected device type identifier. For example, the connected device list can include the factory identifiers of 10 float water level gauges, and these 10 float water level gauges can be connected devices.
[0102] The electronic device can compare the target device list with the connected device list, and determine the device whose factory identification exists in the target device list but not in the connected device list as the device to be connected. For example, in the previous example, the five float water level gauges whose factory identification does not exist in the connected device list can be determined as the devices to be connected, and an identification (i.e., platform identification) is created on the Internet of Things platform for each device to be connected. The format of the platform identification can be deviceId_physicallId; wherein, deviceId can be the id assigned to the device to be connected on the Internet of Things platform, and physicalId can be the factory id of the device to be connected, and the platform identification created for each device to be connected is written into the Redis database. Later, the attribute information of these devices to be connected can be obtained from the device server through the access token according to the factory identification of each device to be connected. Continuing with the previous example, the attribute information of these five float water level gauges can be obtained, and the attribute information of these five float water level gauges and the platform identification of these five float water level gauges can be assembled into information in the protocol format supported by the Internet of Things platform, and the assembled information can be reported to the Internet of Things platform, so that the Internet of Things platform can identify the reported information and accelerate the device access.
[0103] Figure 6is a structural diagram of a device access apparatus provided in an embodiment of the present invention, and the apparatus is suitable for executing a device access method provided in an embodiment of the present invention. Figure 6 As shown, the device may specifically include:
[0104] Download module 401, used for downloading the protocol adapter and running the protocol adapter;
[0105] An acquisition module 402 is used to acquire an access token from a device server through the protocol adapter;
[0106] A determination module 403, configured to access the device server according to the access token to determine a device to be connected;
[0107] The access module 404 is used to obtain the attribute information of the device to be connected from the device server, and report the attribute information of the device to be connected to the Internet of Things platform.
[0108] In one embodiment, the determination module 403 is specifically used to:
[0109] Accessing the device server according to the access token to obtain a target device list;
[0110] The target device list and the connected device list are compared to determine the device to be connected.
[0111] In one embodiment, the determining module 403 accesses the device server according to the access token to obtain a target device list, including:
[0112] Obtaining a device type identifier corresponding to the protocol adapter;
[0113] The device server is accessed according to the access token to obtain a target device list corresponding to the device type identifier.
[0114] In one embodiment, before comparing the target device list with the connected device list to determine the device to be connected, the determination module 403 is further configured to:
[0115] Obtain the connected device list corresponding to the device type identifier.
[0116] In one embodiment, the target device list includes factory identifications of candidate devices, and the connected device list includes factory identifications of connected devices. The determination module 403 compares the target device list with the connected device list to determine the device to be connected, including:
[0117] The factory identifications of the candidate devices in the target device list and the factory identifications of the connected devices in the connected device list are compared to determine the device to be connected from the candidate devices.
[0118] In one embodiment, the device further comprises:
[0119] A creation module, used to create a platform identifier for the device to be connected;
[0120] The access module 404 reports the attribute information of the device to be accessed to the Internet of Things platform, including:
[0121] The platform identifier and the attribute information of the device to be connected are assembled into information in a target protocol format to obtain target information, and the target information is reported to the Internet of Things platform.
[0122] In one embodiment, the download module 401 is specifically used for:
[0123] Querying the first database to determine the protocol adapter that needs to be downloaded;
[0124] The protocol adapter is downloaded from a second database, the type of the first database being different from the type of the second database.
[0125] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the functional modules described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0126] The apparatus of the embodiment of the present invention only needs to download and run the corresponding protocol adapter when it needs to access a device. The required information is automatically obtained and reported through the protocol adapter, thereby realizing the access of the device. The developer only needs to develop the corresponding protocol adapter for the device to be accessed, and does not need to modify the code of each functional component in the Internet of Things platform. Therefore, there is no problem of the need to redeploy and debug the components. The protocol adapter is decoupled from the Internet of Things platform, reducing the code coupling. The entire access process can be automatically realized by using the protocol adapter, reducing the workload of device access and saving labor costs. In addition, since the access device is realized through the corresponding protocol adapter, as much general code as possible can be placed in the Internet of Things platform framework, and the protocol adapter can only focus on the conversion adaptation of the protocol, which can greatly reduce the workload of device protocol adaptation and customization development, shorten the development cycle, maintain the stability of the platform, and increase the robustness of the platform.
[0127] An embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the device access method provided in any of the above embodiments is implemented.
[0128] An embodiment of the present invention further provides a device access system, including a device server, an Internet of Things platform, and an electronic device for executing the device access method as described in any one of the embodiments of the present invention.
[0129] An embodiment of the present invention further provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the device access method provided in any of the above embodiments is implemented.
[0130] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 500 of an electronic device suitable for implementing an embodiment of the present invention. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0131] like Figure 7 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the computer system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0132] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0133] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.
[0134] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0135] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0136] The modules and / or units involved in the embodiments of the present invention may be implemented in software or hardware. The modules and / or units described may also be set in a processor. For example, it may be described as follows: a processor includes a download module, an acquisition module, a determination module, and an access module. The names of these modules do not, in some cases, constitute limitations on the modules themselves.
[0137] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: downloading a protocol adapter and running the protocol adapter; obtaining an access token from a device server through the protocol adapter; accessing the device server according to the access token to determine the device to be connected; obtaining the attribute information of the device to be connected from the device server, and reporting the attribute information of the device to be connected to the Internet of Things platform.
[0138] According to the technical solution of the embodiment of the present invention, when it is necessary to access a device, it is only necessary to download and run the corresponding protocol adapter program, and the required information is automatically obtained and reported through the protocol adapter program, so that the device access can be achieved. The developer only needs to develop the corresponding protocol adapter program for the device to be accessed, and there is no need to modify the code of each functional component in the Internet of Things platform. Therefore, there is no problem of the need to redeploy and debug the components. The protocol adapter program is decoupled from the Internet of Things platform, which reduces the code coupling. The entire access process can be automatically implemented using the protocol adapter program, which reduces the workload of device access and saves labor costs. In addition, since the access device is implemented through the corresponding protocol adapter program, as much general code as possible can be placed in the Internet of Things platform framework, and the protocol adapter program can only focus on protocol conversion adaptation, which can greatly reduce the workload of device protocol adaptation and customization development, shorten the development cycle, maintain the stability of the platform, and increase the robustness of the platform.
[0139] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A device access method, characterized in that: include: Downloading a protocol adapter and running the protocol adapter; Obtaining an access token from a device server through the protocol adapter; Accessing the device server according to the access token to determine the device to be connected includes: accessing the device server according to the access token to obtain a target device list, and comparing the target device list with a list of connected devices to determine the device to be connected; Acquire the attribute information of the device to be connected from the device server, and report the attribute information of the device to be connected to the Internet of Things platform.
2. The method according to claim 1, characterized in that The accessing the device server according to the access token to obtain a target device list includes: Obtaining a device type identifier corresponding to the protocol adapter; The device server is accessed according to the access token to obtain a target device list corresponding to the device type identifier.
3. The method according to claim 2, characterized in that Before comparing the target device list with the connected device list to determine the device to be connected, the method further includes: Obtain the connected device list corresponding to the device type identifier.
4. The method according to any one of claims 1 to 3, characterized in that: The target device list includes factory identifications of candidate devices, the connected device list includes factory identifications of connected devices, and comparing the target device list with the connected device list to determine the device to be connected includes: The factory identifications of the candidate devices in the target device list and the factory identifications of the connected devices in the connected device list are compared to determine the device to be connected from the candidate devices.
5. The method according to claim 1, characterized in that After accessing the device server according to the access token to determine the device to be accessed, the method further includes: Creating a platform identifier for the device to be connected; The step of reporting the attribute information of the device to be connected to the Internet of Things platform includes: The platform identifier and the attribute information of the device to be connected are assembled into information in a target protocol format to obtain target information, and the target information is reported to the Internet of Things platform.
6. The method according to claim 1, characterized in that The download protocol adapter comprises: Querying the first database to determine the protocol adapter that needs to be downloaded; The protocol adapter is downloaded from a second database, the type of the first database being different from the type of the second database.
7. A device access apparatus, characterized in that: include: A download module, used for downloading the protocol adapter and running the protocol adapter; An acquisition module, used for acquiring an access token from a device server through the protocol adapter; A determination module, configured to access the device server according to the access token to determine the device to be connected, including: accessing the device server according to the access token to obtain a target device list, and comparing the target device list with a list of connected devices to determine the device to be connected; The access module is used to obtain the attribute information of the device to be connected from the device server and report the attribute information of the device to be connected to the Internet of Things platform.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the device access method according to any one of claims 1 to 6 is implemented.
9. A device access system, characterized in that: It comprises a device server, an Internet of Things platform and an electronic device for executing the device access method as described in any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the device access method as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
SDK plug-in loading method and apparatus, and mobile terminal and storage medium
CN113412468A