Py4J-based agricultural Internet of Things equipment access method, equipment and medium

The Py4J interface receives agricultural IoT device data in Java network components, calls the Python protocol method module for decoding and encoding, and generates JSON format messages, solving the problems of high device access cost and cumbersome docking process, and achieving efficient and stable device access and management.

CN120301926APending Publication Date: 2025-07-11浪潮(山东)农业互联网有限公司 +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510375919.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-27
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

The existing agricultural IoT device access method is costly and the docking process is cumbersome, resulting in high labor costs and complex environmental dependence, making it difficult to achieve efficient and simplified equipment access.

Method used

Using a Py4J-based method, the device data is received through Java network components, and the Python-side protocol method module is called to decode and encode it, generate common messages on the Internet of Things platform, and transmit it through JSON format to isolate the environment dependence of different devices.

Benefits of technology

It reduces the cost of equipment access, simplifies the docking process, improves the real-time and accuracy of data reception, ensures the standardization and compatibility of data formats, realizes remote control and real-time management of target devices, and improves the efficiency of equipment docking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120301926A_ABST
    Figure CN120301926A_ABST
Patent Text Reader

Abstract

The invention discloses an agricultural Internet of Things equipment access method and equipment based on Py4J, and a medium, and belongs to the technical field of agricultural Internet of Things equipment access. The method comprises the following steps: receiving original data based on a Java network component, extracting a protocol identifier, and transmitting the protocol identifier to a data analysis service module; calling a Py4J communication interface based on the data analysis service module, and activating a protocol method module according to a protocol identifier; the protocol-based method module decodes the original data to generate an Internet of Things platform general message, calls the general message back to the data analysis service module and then transmits the general message to the Internet of Things platform; when the Internet of Things platform issues a control instruction, calling a Py4J communication interface, activating an encoding method, and encoding the control instruction into an equipment message; and sending the equipment message to the target agricultural Internet of Things equipment through the Java network component based on the data analysis service module. According to the method, the equipment access cost is reduced, the docking process is simplified, and the equipment access cost can be reduced and the docking process can be simplified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of agricultural Internet of Things device access, and particularly relates to a method, device, and medium for accessing agricultural Internet of Things devices based on Py4J. Background Art

[0002] In the field of agricultural Internet of Things, there are a wide variety of devices, and each device has its own unique communication protocol and data format. Traditional device access methods are usually based on programming languages such as Java, Go, C#, etc. These methods not only have high docking costs, but also have cumbersome environmental dependencies and are prone to conflicts.

[0003] In addition, due to the complexity of the protocols of agricultural Internet of Things devices, the docking process is also very cumbersome, consuming a large amount of labor costs.

[0004] Therefore, how to reduce the device access cost and simplify the docking process has become an urgent technical problem to be solved. Summary of the Invention

[0005] The embodiments of this application provide a method, device, and medium for accessing agricultural Internet of Things devices based on Py4J to solve the following technical problems: how to reduce the device access cost and simplify the docking process.

[0006] In a first aspect, the embodiments of this application provide a method for accessing agricultural Internet of Things devices based on Py4J, which is applied to an Internet of Things platform. The method includes: receiving the raw data reported by agricultural Internet of Things devices based on a preset Java network component, extracting the protocol identifier in the raw data, and transmitting the raw data to a preset data parsing service module; calling the Py4J communication interface based on the data parsing service module, and activating the corresponding protocol method module on the Python side according to the protocol identifier; wherein the protocol method module includes a decoding method and an encoding method; decoding the raw data based on the activated protocol method module to generate a general message for the Internet of Things platform, and calling back the general message to the data parsing service module through the Py4J communication interface; encapsulating the general message into a JSON format according to the Internet of Things platform protocol based on the data parsing service module, and transmitting it to the Internet of Things platform; when the Internet of Things platform issues a control instruction, calling the Py4J communication interface based on the data parsing service module to activate the encoding method that matches the protocol identifier of the target device, and encoding the control instruction into a device message; sending the device message to the target agricultural Internet of Things device through the Java network component based on the data parsing service module.

[0007] In an implementation manner of the present application, based on a preset Java network component, the original data reported by agricultural Internet of Things devices is received, the protocol identifier in the original data is extracted, and the original data is transmitted to a preset data parsing service module, which specifically includes: calling the MQTT protocol parsing method on the Python side through the Py4J interface to denoise, extract fields and verify the original data stream; caching the verified standardized data stream to a preset shared memory address, and generating a Py4J call request including the protocol identifier and the cache address; triggering the protocol matching process of the data parsing service module based on the request.

[0008] In an implementation manner of the present application, based on the data parsing service module, the Py4J communication interface is called, and the corresponding protocol method module on the Python side is activated according to the protocol identifier, which specifically includes: calling the Pandas library on the Python side to parse the temperature and humidity fields in the original data, and extracting the device identifier through the regular expression engine; mapping the parsed data fields into key-value pair format according to the Internet of Things platform protocol to generate a general message in JSON structure; returning the general message to the cache queue of the data parsing service module through the Py4J interface.

[0009] In an implementation manner of the present application, the original data is decoded based on the activated protocol method module to generate a general message for the Internet of Things platform, and the general message is called back to the data parsing service module through the Py4J communication interface, which specifically includes: performing a decoding operation on the original data based on the decoding method of the activated protocol method module, including steps such as data parsing and format conversion; converting the decoded data into the general message format for the Internet of Things platform to obtain data recognizable by the platform; calling back the general message for the Internet of Things platform to the data parsing service module through the Py4J communication interface to obtain subsequent data transmission and processing.

[0010] In an implementation manner of the present application, based on the data parsing service module, the general message is encapsulated into JSON format according to the Internet of Things platform protocol and transmitted to the Internet of Things platform, which specifically includes: based on the data parsing service module, calling the data encapsulation algorithm on the Python side to convert the general message into a JSON format compatible with the Internet of Things platform protocol; transmitting the converted general message in JSON format to the Internet of Things platform to obtain data reception and processing by the platform; performing confirmation and update operations on the general message based on the feedback of the Internet of Things platform to obtain the final data result.

[0011] In an implementation manner of the present application, when the Internet of Things platform issues a control instruction, the Py4J communication interface is called based on the data parsing service module to activate the encoding method matching the protocol identifier of the target device, and the control instruction is encoded into a device message, which specifically includes: when the Internet of Things platform issues a control instruction, the control instruction is received based on the data parsing service module, and the device protocol identifier in the control instruction is extracted; the Py4J communication interface is called based on the data parsing service module to generate a Py4J call request including the protocol identifier; the request is sent to the Python side through the Py4J communication interface to activate the encoding method matching the protocol identifier; based on the activated encoding method, the general message corresponding to the control instruction is encoded into a device message format to obtain data recognizable by the device.

[0012] In an implementation manner of the present application, the device message is sent to the target agricultural Internet of Things device through the Java network component based on the data parsing service module, which specifically includes: calling the data encapsulation method of the Python side based on the data parsing service module to convert the device message into a format compatible with the protocol of the target agricultural Internet of Things device; sending the converted device message to the target agricultural Internet of Things device through the Java network component to obtain the reception and processing of the device; based on the feedback of the device, confirmation and update operations are performed on the device message to obtain the final data result.

[0013] In an implementation manner of the present application, the method further includes: parsing the Python code file uploaded by the user to generate a virtual environment configuration file including the protocol identifier, the list of dependent libraries and their versions; based on the configuration file, creating an isolated Python running environment for each protocol identifier through the venv tool and loading the corresponding versions of the dependent libraries in the environment; registering the decoding / encoding methods in different virtual environments to the protocol binding table of the data parsing service module through the Py4J service, and allocating an independent thread pool for each protocol identifier to achieve parallel parsing.

[0014] Second aspect, an embodiment of the present application further provides an agricultural Internet of Things device access device based on Py4J, characterized in that the device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: receive the original data reported by the agricultural Internet of Things device based on a preset Java network component, extract the protocol identifier in the original data, and transmit the original data to a preset data parsing service module; call the Py4J communication interface based on the data parsing service module, and activate the corresponding protocol method module on the Python side according to the protocol identifier; wherein, the protocol method module includes a decoding method and an encoding method; decode the original data based on the activated protocol method module to generate a general message for the Internet of Things platform, and callback the general message to the data parsing service module through the Py4J communication interface; encapsulate the general message into the JSON format according to the Internet of Things platform protocol based on the data parsing service module, and transmit it to the Internet of Things platform; when the Internet of Things platform issues a control instruction, call the Py4J communication interface based on the data parsing service module, activate the encoding method matching the protocol identifier of the target device, and encode the control instruction into a device message; send the device message to the target agricultural Internet of Things device through the Java network component based on the data parsing service module.

[0015] Third aspect, an embodiment of the present application further provides a non-volatile computer storage medium for agricultural Internet of Things device access based on Py4J, storing computer-executable instructions, characterized in that the computer-executable instructions are set as: receive the original data reported by the agricultural Internet of Things device based on a preset Java network component, extract the protocol identifier in the original data, and transmit the original data to a preset data parsing service module; call the Py4J communication interface based on the data parsing service module, and activate the corresponding protocol method module on the Python side according to the protocol identifier; wherein, the protocol method module includes a decoding method and an encoding method; decode the original data based on the activated protocol method module to generate a general message for the Internet of Things platform, and callback the general message to the data parsing service module through the Py4J communication interface; encapsulate the general message into the JSON format according to the Internet of Things platform protocol based on the data parsing service module, and transmit it to the Internet of Things platform; when the Internet of Things platform issues a control instruction, call the Py4J communication interface based on the data parsing service module, activate the encoding method matching the protocol identifier of the target device, and encode the control instruction into a device message; send the device message to the target agricultural Internet of Things device through the Java network component based on the data parsing service module.

[0016] An agricultural Internet of Things device access method, device, and medium based on Py4J provided by an embodiment of the present application receive the original data reported by the agricultural Internet of Things device through a Java network component, extract the protocol identifier, and transmit the data to the data parsing service module, thereby ensuring the real-time performance and accuracy of data reception to a certain extent. Through the Py4J communication interface, the present application can call the protocol method module on the Python side, activate the corresponding decoding and encoding methods according to the protocol identifier, and realize the parsing of the original data and the real-time encoding of the control instruction. The decoded general message is called back to the data parsing service module through the Py4J communication interface and encapsulated into the JSON format according to the Internet of Things platform protocol to ensure the standardization and compatibility of the data format to a certain extent. At the same time, the control instruction can be encoded into a device message and sent to the target device through the Java network component, realizing the remote control and real-time management of the target device. In addition, the venv tool is also used to isolate the environmental dependencies when different devices are docked, improving the stability and reliability of agricultural Internet of Things device message processing. In summary, the present application simplifies the device docking process, fully utilizes the advantages of Python in data processing, and improves the device docking efficiency without sacrificing the stability of the Java Internet of Things platform. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application, form a part of the present application, and the illustrative embodiments and descriptions thereof of the present application are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:

[0018] Figure 1 It is a flowchart of an agricultural Internet of Things device access method based on Py4J provided by an embodiment of the present application;

[0019] Figure 2 It is a schematic diagram of the internal structure of an agricultural Internet of Things device access device based on Py4J provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] To make the objectives, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0021] An embodiment of the present application provides an agricultural Internet of Things device access method, device, and medium based on Py4J to solve the following technical problems: how to reduce the device access cost and simplify the docking process.

[0022] The technical solutions proposed in the embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0023] Figure 1 The following is a flow chart of an agricultural Internet of Things device access based on Py4J provided by the embodiments of the present application. As Figure 1 shown, an agricultural Internet of Things device access method based on Py4J provided by the embodiments of the present application specifically includes the following steps:

[0024] Step 1: Receive the original data reported by the agricultural Internet of Things device based on a preset Java network component, extract the protocol identifier in the original data, and transmit the original data to a preset data parsing service module.

[0025] The Java network component, as the front-end receiving module, is responsible for continuously listening and receiving the original data streams reported by various agricultural Internet of Things devices (such as temperature and humidity sensors, soil humidity monitors, light intensity meters). The above devices may adopt different communication protocols (such as Modbus, HTTP, TCP / IP). Therefore, when receiving data, it is first necessary to extract specific protocol identifier information from the original data frame. The above identifier is used to determine the data parsing strategy subsequently to ensure that the data can be correctly parsed. After extraction, the Java network component transmits the original data and its protocol identifier to the data parsing service module together.

[0026] Step 11: Call the MQTT protocol parsing method on the Python side through the Py4J interface to denoise, extract fields, and verify the original data stream.

[0027] Py4J, as the bridge between Java and Python, plays a key role in this step. When the original data enters the data parsing service module, for the data of agricultural Internet of Things devices using the MQTT protocol, the MQTT protocol parsing method deployed in the Python environment is called through the Py4J interface. The above method first denoises the original data stream to remove invalid or incorrect data generated during network transmission or device acquisition. Subsequently, according to the MQTT protocol specification, key field information such as device ID, timestamp, sensor type, and measurement value is extracted from the denoised data. Finally, the above fields are verified to ensure the integrity, accuracy, and consistency of the data to a certain extent.

[0028] Step 12: Cache the standardized data stream that passes the verification to a preset shared memory address, and generate a Py4J call request including the protocol identifier and the cache address.

[0029] The verified standardized data stream is temporarily stored in a pre-configured shared memory address.

[0030] The use of shared memory is to improve the data transmission efficiency between different service modules and reduce the performance loss caused by frequent I / O operations.

[0031] Meanwhile, a Py4J call request is generated, which contains the protocol identifier of the original data and the cache address of the standardized data stream. This request will be sent to the data parsing service module to trigger the subsequent protocol matching process.

[0032] Step 13: Trigger the protocol matching process of the data parsing service module based on the request.

[0033] After receiving the Py4J call request containing the protocol identifier and cache address, the data parsing service module starts the protocol matching process. According to the protocol identifier, the above process selects the corresponding parsing algorithm or rule set from the preset protocol library to further parse the standardized data stream in the shared memory.

[0034] In a specific example, various agricultural Internet of Things devices are deployed in the field, and the above devices report the collected original data to the Java network component through a wireless network (such as LoRa, NB-IoT).

[0035] The Java network component listens for and receives the above data in real time, and at the same time extracts the protocol identifier (such as Modbus protocol identifier, HTTP protocol identifier) from the data frame.

[0036] For the data of agricultural Internet of Things devices using the MQTT protocol, the Java network component calls the MQTT protocol parsing method on the Python side through the Py4J interface. The above method first performs denoising processing on the original data stream to remove invalid or incorrect data.

[0037] Then, key field information such as device ID, timestamp, sensor type, and measurement value is extracted from the denoised data.

[0038] Finally, the above fields are verified to ensure the integrity, accuracy, and consistency of the data to a certain extent.

[0039] The standardized data stream that passes the verification is cached to the preset shared memory address. Meanwhile, a Py4J call request is generated, which contains the protocol identifier of the original data and the cache address of the standardized data stream. After receiving the above request, the data parsing service module selects the corresponding parsing algorithm or rule set from the preset protocol library to further parse the standardized data stream in the shared memory. The parsed data is transmitted to the data analysis module for generating agricultural production decision support information.

[0040] For example, based on the data from the temperature and humidity sensors, it is determined whether the current field environment is suitable for crop growth, and corresponding irrigation and ventilation suggestions are given. At the same time, the above data is also stored in the database for subsequent agricultural production data analysis and mining.

[0041] Step 2: Based on the data parsing service module, call the Py4J communication interface and activate the corresponding protocol method module on the Python side according to the protocol identifier; among them, the protocol method module includes a decoding method and an encoding method.

[0042] After the data parsing service module receives the raw data and its protocol identifier, the above module interacts with the Python side through the Py4J communication interface.

[0043] As a bridge between Java and Python, Py4J enables the Java side to seamlessly call the functional modules on the Python side.

[0044] According to the protocol identifier extracted from the raw data, the data parsing service module activates the corresponding protocol method module pre-configured on the Python side. The above protocol method module is designed specifically for processing data of specific protocols and includes a decoding method and an encoding method.

[0045] The decoding method is used to parse the raw data according to the specifications of a specific protocol and extract meaningful data fields; the encoding method is used to encapsulate the processed data according to the specifications of the target protocol for subsequent transmission or storage.

[0046] Step 21: Call the Pandas library on the Python side to parse the temperature and humidity fields in the raw data, and extract the device identifier through the regular expression engine.

[0047] After the protocol method module is activated, first call the Pandas library on the Python side to parse the temperature and humidity fields in the raw data.

[0048] As a data processing tool, the Pandas library can process structured data and extract the required field information. At the same time, in order to accurately identify the data source, the raw data is also scanned through the regular expression engine to extract the device identifier. The regular expression engine can match string patterns to ensure the accurate extraction of the device identifier to a certain extent.

[0049] Step 22: Map the parsed data fields into key-value pair format according to the Internet of Things platform protocol to generate a general message in JSON structure.

[0050] The parsed data fields need to be formatted according to the requirements of the Internet of Things platform protocol so that they can be recognized and processed by the platform.

[0051] In this step, the above fields are mapped into key-value pair format, and a general message in JSON structure is generated.

[0052] As a lightweight data interchange format, JSON has the advantages of being easy to read, write, and parse, and is widely used in the Internet of Things field.

[0053] By generating a general message in JSON structure, the conversion of different protocol data into a unified format is achieved, facilitating subsequent data transmission, storage, and analysis.

[0054] Step 23: The general message is sent back to the cache queue of the data parsing service module through the Py4J interface.

[0055] After generating the general message in JSON structure, it is sent back to the cache queue of the data parsing service module through the Py4J interface.

[0056] As a buffer between the data parsing service module and subsequent processing modules, the cache queue can temporarily store the processed data, improving throughput and stability.

[0057] Data transmission through the Py4J interface ensures communication between the Java side and the Python side, enabling the general message to reach the cache queue quickly and accurately for use by subsequent processing modules.

[0058] In a specific example, various agricultural Internet of Things devices are deployed in the field. These devices upload the collected raw data to the Java network component through a wireless network. The Java network component listens for and receives the above data in real time, and at the same time extracts the protocol identifier from the data frame.

[0059] After receiving the raw data and its protocol identifier, the data parsing service module calls the protocol method module on the Python side through the Py4J communication interface. According to the protocol identifier, the corresponding protocol method module is activated. The above module includes decoding methods and encoding methods. The decoding method is used to parse the temperature and humidity fields in the raw data and extract the device identifier through a regular expression engine.

[0060] The parsed data fields are mapped into key-value pair format, and a general message in JSON structure is generated. This process ensures that data of different protocols can be uniformly formatted, facilitating subsequent data transmission and storage.

[0061] The generated general JSON-structured messages are returned to the cache queue of the data parsing service module through the Py4J interface. The cache queue temporarily stores the above messages for further processing by subsequent processing modules (such as the data analysis module and the storage module). The subsequent processing modules retrieve the general messages from the cache queue and perform further processing (such as data analysis and storage). Finally, the processed data is transmitted to the Internet of Things platform for use in agricultural production decision support.

[0062] Step 3: Decode the original data based on the activated protocol method module to generate general messages for the Internet of Things platform, and call back the general messages to the data parsing service module through the Py4J communication interface.

[0063] After the protocol method module is activated, the data decoding phase is entered.

[0064] Using the decoding method in the protocol method module, perform a decoding operation on the original data to convert it into a general message format recognizable by the Internet of Things platform.

[0065] After completing the decoding, call back the generated general messages to the data parsing service module through the Py4J communication interface for subsequent data transmission and processing.

[0066] Step 31: Based on the decoding method of the activated protocol method module, perform a decoding operation on the original data, including data parsing and format conversion steps.

[0067] The decoding method parses the original data field by field according to the specifications of a specific protocol.

[0068] During the parsing process, the decoding method first identifies each field in the original data, such as temperature, humidity, and device identifier, and parses them according to the syntax rules of the protocol. After parsing, the decoding method converts the original data into an internal data format, such as key-value pair format, for subsequent processing.

[0069] Step 32: Convert the decoded data into the general message format for the Internet of Things platform to obtain data recognizable by the platform.

[0070] Although the decoded data has been correctly represented internally, in order to be recognized and processed by the Internet of Things platform, it still needs to be converted into the general message format of the platform.

[0071] This step usually involves arranging the data fields in the order and format required by the platform and adding necessary metadata, such as timestamp and device identifier.

[0072] Through this conversion, data from different sources and different protocols can be presented to the Internet of Things platform in a unified form, improving data interoperability and usability.

[0073] Step 33: Through the Py4J communication interface, the general messages of the Internet of Things platform are called back to the data parsing service module to obtain subsequent data transmission and processing.

[0074] After completing data decoding and format conversion, the generated general messages are called back to the data parsing service module through the Py4J communication interface.

[0075] As a bridge between Java and Python, Py4J ensures efficient and stable data transmission. After receiving the general messages, the data parsing service module passes them to subsequent processing modules, such as the data storage module and the data analysis module, for further processing and application. This step realizes the seamless connection of the data decoding and processing process, improving the overall efficiency and performance.

[0076] In a specific example, various agricultural Internet of Things devices are deployed in the field. These devices upload the collected raw data to the Java network component through a wireless network. The Java network component listens for and receives the above data in real time, and at the same time extracts the protocol identifier from the data frame.

[0077] After receiving the raw data and its protocol identifier, the data parsing service module calls the protocol method module on the Python side through the Py4J communication interface. According to the protocol identifier, the corresponding protocol method module is activated, and the raw data is decoded through its decoding method.

[0078] The decoded data is converted into the general message format of the Internet of Things platform. This process involves arranging the data fields in the order and format required by the platform and adding necessary metadata, such as timestamps and device identifiers. Through this conversion, it is ensured that data from different sources and different protocols can be presented to the Internet of Things platform in a unified form.

[0079] The generated general messages are called back to the data parsing service module through the Py4J communication interface. After receiving the general messages, the data parsing service module passes them to subsequent processing modules, such as the data storage module and the data analysis module, for further processing and application.

[0080] Subsequent processing modules further process the general messages (such as data analysis and storage), and upload the processed data to the Internet of Things platform. The Internet of Things platform provides data support for agricultural production decision-making through the above data, such as crop growth monitoring and pest warning.

[0081] Step 4: Based on the data parsing service module, the general messages are encapsulated into the JSON format according to the Internet of Things platform protocol and transmitted to the Internet of Things platform.

[0082] After the data parsing service module receives the callback general message, it enters the data encapsulation and transmission stage. The general message is encapsulated into the JSON format according to the requirements of the Internet of Things platform protocol and transmitted to the Internet of Things platform through the network.

[0083] This not only ensures the format compatibility of the data but also realizes the real-time transmission of the data and the access to the platform.

[0084] Step 41: Based on the data parsing service module, call the data encapsulation algorithm on the Python side to convert the general message into the JSON format compatible with the Internet of Things platform protocol.

[0085] The data encapsulation algorithm converts the general message into the JSON format according to the specifications of the Internet of Things platform protocol. During the conversion process, the algorithm first identifies each field in the general message, such as temperature, humidity, and device identifier, and names the fields and defines the data types according to the syntax rules of the protocol.

[0086] At the same time, it processes the nested structures and arrays in the data to ensure the correctness and integrity of the JSON format to a certain extent. Through this conversion, it is ensured that the general message can be correctly parsed and processed by the Internet of Things platform.

[0087] Step 42: Transmit the converted general message in JSON format to the Internet of Things platform to obtain the data reception and processing of the platform.

[0088] After completing the data encapsulation, the general message in JSON format is transmitted to the Internet of Things platform through the network channel. During the transmission process, transmission protocols such as HTTP or MQTT are used to ensure the real-time and reliability of the data to a certain extent. After receiving the JSON message, the Internet of Things platform parses, stores, analyzes, and visualizes it to provide data support for agricultural production decision-making.

[0089] Step 43: Based on the feedback from the Internet of Things platform, perform confirmation and update operations on the general message to obtain the final data result.

[0090] After the data is transmitted to the Internet of Things platform, it is necessary to wait for the feedback from the platform.

[0091] The Internet of Things platform processes the JSON message and returns a confirmation message or a processing result.

[0092] According to the feedback from the Internet of Things platform, perform confirmation and update operations on the general message. For example, if the platform finds that the data is abnormal or missing, re-collect, decode, and encapsulate the relevant data and transmit it to the platform again. Through this feedback mechanism, the accuracy and integrity of the data are ensured, and the overall performance and reliability are improved.

[0093] In a specific case, various agricultural Internet of Things devices are deployed in the field. These devices upload the collected raw data to a Java network component through a wireless network. The Java network component listens for and receives the above data in real time, and at the same time extracts the protocol identifier from the data frame. The data parsing service module activates the corresponding protocol method module according to the protocol identifier and decodes the raw data to generate a general message.

[0094] After receiving the general message, the data parsing service module calls the data encapsulation algorithm on the Python side. According to the specifications of the Internet of Things platform protocol, the algorithm converts the general message into JSON format. In this process, the algorithm ensures the correctness and integrity of field naming, data type definition, nested structure, and arrays so that it can be correctly parsed and processed by the Internet of Things platform.

[0095] After completing the data encapsulation, the general message in JSON format is transmitted to the Internet of Things platform through a network channel (such as HTTP or MQTT).

[0096] After receiving the JSON message, the Internet of Things platform parses, stores, analyzes, and visualizes it. According to the feedback of the platform, confirmation and update operations are performed on the general message. For example, if the platform detects abnormal or missing data, the relevant data is recollected, decoded, and encapsulated, and then transmitted to the platform again. This feedback mechanism ensures the accuracy and integrity of the data.

[0097] The Internet of Things platform provides data support for agricultural production decision-making through the received JSON data. For example, real-time monitoring and early warning of temperature and humidity data, and irrigation decision support for soil humidity data. At the same time, the platform also stores the data in a database for subsequent data analysis and mining.

[0098] Step 5: When the Internet of Things platform issues a control instruction, based on the data parsing service module, the Py4J communication interface is called to activate the encoding method that matches the protocol identifier of the target device, and the control instruction is encoded into a device message.

[0099] After the Internet of Things platform issues a control instruction, it enters the control instruction encoding and device message generation stage. The core task of the above stage is to encode the control instruction into a device message according to the protocol requirements of the target device and transmit it to the target device through the network.

[0100] Step 51: When the Internet of Things platform issues a control instruction, based on the data parsing service module, the control instruction is received and the device protocol identifier in the control instruction is extracted.

[0101] When the IoT platform issues a control instruction, the data parsing service module first receives the above control instruction. The control instruction contains the protocol identifier of the target device, and the above identifier is used to determine the communication protocol used by the target device. The data parsing service module extracts the device protocol identifier by parsing the control instruction.

[0102] Step 52: Based on the data parsing service module, call the Py4J communication interface to generate a Py4J call request containing the protocol identifier.

[0103] After extracting the device protocol identifier, the data parsing service module calls the Py4J communication interface. Py4J is a library that allows Java and Python programs to communicate. Through it, the Java side can call the functions and methods of the Python side.

[0104] The data parsing service module generates a Py4J call request containing the protocol identifier, and the above request will be used to activate the encoding method matching the protocol identifier on the Python side.

[0105] Step 53: Send the request to the Python side through the Py4J communication interface to activate the encoding method matching the protocol identifier.

[0106] The data parsing service module sends the generated call request to the Python side through the Py4J communication interface. After receiving the request, the Python side activates the encoding method matching it according to the protocol identifier in the request. The encoding method is predefined according to the communication protocols of different devices and can convert the control instruction into a message format recognizable by the device.

[0107] Step 54: Based on the activated encoding method, encode the general message corresponding to the control instruction into the device message format to obtain data recognizable by the device.

[0108] After activating the encoding method, the Python side uses the above encoding method to encode the general message corresponding to the control instruction into the device message format. During the encoding process, the encoding method performs field mapping, data type conversion, and message structure encapsulation operations on the control instruction according to the protocol specifications of the target device, so as to ensure to a certain extent that the generated device message can be correctly parsed and executed by the target device.

[0109] In a specific example, the IoT platform issues control instructions according to agricultural production requirements, such as instructions to turn on, turn off, or adjust irrigation equipment. The data parsing service module listens for and receives the above control instructions in real time, and at the same time extracts the protocol identifier of the target device from the instructions.

[0110] The data parsing service module calls the Py4J communication interface to generate a Py4J call request containing a protocol identifier. Through the Py4J communication interface, the request is sent to the Python side to activate the encoding method matching the protocol identifier.

[0111] After receiving the Py4J call request, the Python side activates the encoding method matching it according to the protocol identifier in the request. The encoding method encodes the general message corresponding to the control instruction into a device message format, such as Modbus RTU, MQTT, or HTTP protocol format.

[0112] After generating the device message, it is transmitted to the target device through a network channel. After receiving the device message, the target device parses and executes it, such as turning on the irrigation device and adjusting the irrigation amount.

[0113] After executing the control instruction, the target device feeds back the status information to the Internet of Things platform. The Internet of Things platform monitors and gives early warnings about the agricultural production environment in real time through the received status information, such as soil humidity monitoring and temperature and humidity regulation.

[0114] Step 6: Based on the data parsing service module, send the device message to the target agricultural Internet of Things device through the Java network component.

[0115] After the device message is encoded, it enters the device message sending and device feedback processing stage. The core task of the above stage is to send the encoded device message to the target agricultural Internet of Things device through the Java network component, and confirm and update the device message according to the feedback of the device, so as to ensure the accurate execution of the control instruction to a certain extent.

[0116] Step 61: Based on the data parsing service module, call the data encapsulation method on the Python side to convert the device message into a format compatible with the protocol of the target agricultural Internet of Things device.

[0117] After the device message is encoded, the data parsing service module needs to call the data encapsulation method on the Python side to convert the device message into a format compatible with the protocol of the target agricultural Internet of Things device. The data encapsulation method is predefined according to the communication protocols of different devices. It can perform field mapping, data type conversion, and message structure encapsulation operations on the device message, so as to ensure that the generated device message can be correctly parsed and executed by the target device to a certain extent.

[0118] Step 62: Send the converted device message to the target agricultural Internet of Things device through the Java network component to obtain the reception and processing of the device.

[0119] After completing the protocol-compatible format conversion of the device message, the data parsing service module sends the converted device message to the target agricultural Internet of Things device through the Java network component.

[0120] The Java network component is responsible for establishing a network connection with the target device, selecting an appropriate transport protocol, and reliably transmitting the device message to the target device. After receiving the device message, the target device parses and executes it, such as turning on the irrigation device and adjusting the irrigation volume.

[0121] Step 63: Based on the feedback of the device, perform confirmation and update operations on the device message to obtain the final data result.

[0122] After the target device executes the control instruction, it sends the execution result back to the Internet of Things platform. After receiving the feedback from the device, the data parsing service module performs confirmation and update operations on the device message. The confirmation operation is used to verify whether the device message has been successfully executed, and the update operation corrects and optimizes the device message according to the feedback of the device to ensure the accuracy and reliability of subsequent control instructions to a certain extent.

[0123] In a specific example, the data parsing service module calls the data encapsulation method on the Python side to convert the encoded device message into a format compatible with the protocol of the target agricultural Internet of Things device.

[0124] For example, for an irrigation device using the Modbus RTU protocol, the data encapsulation method converts the device message into the message format specified by the Modbus RTU protocol, including the device address, function code, and data field.

[0125] After completing the protocol-compatible format conversion of the device message, the data parsing service module sends the converted device message to the target agricultural Internet of Things device through the Java network component.

[0126] The Java network component establishes a network connection with the target device, selects an appropriate transport protocol (such as TCP / IP), and reliably transmits the device message to the target device.

[0127] After the target device executes the control instruction, it sends the execution result back to the Internet of Things platform. After receiving the feedback from the device, the data parsing service module performs confirmation and update operations on the device message. For example, if the device feedback indicates that the irrigation device has been successfully turned on, the data parsing service module confirms that the device message has been successfully executed; if the device feedback indicates that there is a fault with the irrigation device, the data parsing service module updates the device message according to the fault information, such as sending a fault alarm instruction or adjusting the irrigation volume instruction.

[0128] The Internet of Things platform monitors and gives early warnings about the agricultural production environment in real time based on the received device feedback. For example, by monitoring the feedback data of the soil humidity sensor, the Internet of Things platform determines whether the soil humidity reaches the preset threshold, so as to decide whether to turn on the irrigation device or adjust the irrigation amount.

[0129] In addition, in order to reduce the environmental dependence when different devices are docked, the present application also includes the following methods:

[0130] A1. Analyze the Python code file uploaded by the user to generate a virtual environment configuration file containing protocol identifiers, a list of dependent libraries, and version numbers.

[0131] In the access of agricultural Internet of Things devices, the Python code file uploaded by the user contains decoding and encoding methods for different device protocols. In order to ensure the compatibility and independence between different protocol codes, it is first necessary to analyze the above Python code file to generate a virtual environment configuration file containing protocol identifiers, a list of dependent libraries, and version numbers.

[0132] During the analysis process, analyze the Python code file to extract key information related to the device protocol, such as the protocol identifier, which is usually the identifier defined in the code to distinguish different protocols. At the same time, identify all the dependent libraries imported in the code and determine the version numbers to ensure to a certain extent that the correct versions of the dependent libraries can be loaded when creating a virtual environment later, and avoid problems caused by version conflicts.

[0133] For example, for a soil humidity sensor based on the Modbus protocol, the code file contains the decoding and encoding methods of the Modbus protocol. After parsing, a configuration file containing the Modbus protocol identifier, the required dependent libraries (such as pymodbus) and their version numbers is generated.

[0134] A2. Based on the configuration file, use the venv tool to create an isolated Python running environment for each protocol identifier and load the corresponding version of the dependent libraries in the environment.

[0135] After generating the virtual environment configuration file, use the built-in venv tool of Python to create an independent virtual environment for each protocol identifier. The venv tool can create a virtual environment isolated from the global Python environment, so that the dependent libraries of different protocols exist independently in their respective environments without interference.

[0136] During the process of creating the virtual environment, according to the list of dependent libraries and version numbers listed in the configuration file, use the pip tool to load the above-mentioned dependent libraries in the corresponding virtual environment.

[0137] This step ensures that the dependent libraries required for each protocol are correctly installed and configured in their respective virtual environments, providing a stable environmental foundation for the subsequent execution of decoding and encoding methods.

[0138] For example, for the Modbus protocol, a specified version of the pymodbus library is loaded in its virtual environment to ensure the correct execution of decoding and encoding methods.

[0139] A3. Register the decoding / encoding methods in different virtual environments to the protocol binding table of the data parsing service module through the Py4J service, and allocate an independent thread pool for each protocol identifier to achieve parallel parsing.

[0140] After the creation of the virtual environment and the loading of dependent libraries, the decoding and encoding methods in different virtual environments are registered into the protocol binding table of the data parsing service module through the Py4J service. As a bridge between Python and Java, the Py4J service enables Java code to call functions and methods in Python code.

[0141] During the registration process, an independent thread pool is allocated for each protocol identifier. The configuration of the thread pool is adjusted according to the actual situation to optimize the performance of parallel parsing. By allocating an independent thread pool for each protocol identifier, parallel parsing of device messages of different protocols can be achieved, improving the parsing efficiency and meeting the requirements of multi-device and multi-protocol concurrency in agricultural Internet of Things device access.

[0142] For example, when receiving a device message from a Modbus protocol soil moisture sensor, the data parsing service module finds the corresponding decoding method from the protocol binding table and executes the decoding operation through the thread pool corresponding to the Modbus protocol to achieve parallel parsing and improve the parsing efficiency.

[0143] The above is the method embodiment proposed in this application. Based on the same inventive concept, the embodiments of this application also provide an agricultural Internet of Things device access device based on Py4J, and its structure is as Figure 2 shown.

[0144] Figure 2 This is a schematic diagram of the internal structure of an agricultural Internet of Things device access device based on Py4J provided by the embodiment of this application. As Figure 2 shown, the device includes:

[0145] At least one processor 201;

[0146] And a memory 202 communicatively connected to the at least one processor;

[0147] Among them, the memory 202 stores instructions executable by at least one processor. The instructions are executed by at least one processor 201 to enable at least one processor 201 to:

[0148] Receive the raw data reported by the agricultural Internet of Things device based on a preset Java network component, extract the protocol identifier in the raw data, and transmit the raw data to a preset data parsing service module; Based on the data parsing service module, call the Py4J communication interface, and activate the corresponding protocol method module on the Python side according to the protocol identifier; Wherein, the protocol method module includes a decoding method and an encoding method; Decode the raw data based on the activated protocol method module to generate a general message for the Internet of Things platform, and callback the general message to the data parsing service module through the Py4J communication interface; Based on the data parsing service module, encapsulate the general message into JSON format according to the Internet of Things platform protocol and transmit it to the Internet of Things platform; When the Internet of Things platform issues a control instruction, based on the data parsing service module, call the Py4J communication interface, activate the encoding method matching the protocol identifier of the target device, and encode the control instruction into a device message; Based on the data parsing service module, send the device message to the target agricultural Internet of Things device through the Java network component.

[0149] Some embodiments of the present application provide corresponding to Figure 1 A non-volatile computer storage medium for accessing agricultural Internet of Things devices based on Py4J, storing computer-executable instructions, and the computer-executable instructions are set to:

[0150] Receive the raw data reported by the agricultural Internet of Things device based on a preset Java network component, extract the protocol identifier in the raw data, and transmit the raw data to a preset data parsing service module; Based on the data parsing service module, call the Py4J communication interface, and activate the corresponding protocol method module on the Python side according to the protocol identifier; Wherein, the protocol method module includes a decoding method and an encoding method; Decode the raw data based on the activated protocol method module to generate a general message for the Internet of Things platform, and callback the general message to the data parsing service module through the Py4J communication interface; Based on the data parsing service module, encapsulate the general message into JSON format according to the Internet of Things platform protocol and transmit it to the Internet of Things platform; When the Internet of Things platform issues a control instruction, based on the data parsing service module, call the Py4J communication interface, activate the encoding method matching the protocol identifier of the target device, and encode the control instruction into a device message; Based on the data parsing service module, send the device message to the target agricultural Internet of Things device through the Java network component.

[0151] Each embodiment in this application is described in a progressive manner. For the parts that are the same or similar among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the Internet of Things devices and media, since they are basically similar to the method embodiments, the description is relatively simple, and reference can be made to the corresponding parts of the method embodiments for relevant content.

[0152] The systems and media provided by the embodiments of this application correspond one by one to the methods. Therefore, the systems and media also have beneficial technical effects similar to those of their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the systems and media will not be elaborated here.

[0153] Those skilled in the art should understand that the embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0154] This application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of this application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0155] The above computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the above computer-readable memory generate a manufactured article including an instruction device, and the above instruction device implements the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0156] The above-mentioned computer program instructions can also be loaded into a computer or other programmable data processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0157] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0158] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0159] Computer readable media includes permanent and non-permanent, removable and non-removable media that implement information storage by any method or technology. Information is computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information accessed by a computing device. As defined herein, computer readable media does not include transitory media such as modulated data signals and carrier waves.

[0160] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0161] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. An agricultural Internet of Things device access method based on Py4J, applied to an Internet of Things platform, characterized in that The method includes: Receiving the raw data reported by the agricultural Internet of Things device based on a preset Java network component, extracting the protocol identifier in the raw data, and transmitting the raw data to a preset data parsing service module; Based on the data parsing service module, calling the Py4J communication interface, and activating the corresponding protocol method module on the Python side according to the protocol identifier; wherein, the protocol method module includes a decoding method and an encoding method; Based on the activated protocol method module, decoding the raw data to generate a general message for the Internet of Things platform, and calling back the general message to the data parsing service module through the Py4J communication interface; Based on the data parsing service module, encapsulating the general message into a JSON format according to the Internet of Things platform protocol and transmitting it to the Internet of Things platform; When the Internet of Things platform issues a control instruction, based on the data parsing service module, calling the Py4J communication interface, activating the encoding method that matches the protocol identifier of the target device, and encoding the control instruction into a device message; Based on the data parsing service module, sending the device message to the target agricultural Internet of Things device through the Java network component.

2. The agricultural Internet of Things device access method based on Py4J according to claim 1, wherein Receiving the raw data reported by the agricultural Internet of Things device based on a preset Java network component, extracting the protocol identifier in the raw data, and transmitting the raw data to a preset data parsing service module, specifically including: Calling the MQTT protocol parsing method on the Python side through the Py4J interface to denoise, extract fields, and verify the raw data stream; Caching the standardized data stream that passes the verification to a preset shared memory address, and generating a Py4J call request including the protocol identifier and the cache address; Triggering the protocol matching process of the data parsing service module based on the request.

3. A method for accessing agricultural Internet of Things devices based on Py4J according to claim 1, characterized in that, Based on the data parsing service module, calling the Py4J communication interface, and activating the corresponding protocol method module on the Python side according to the protocol identifier, specifically including: Calling the Pandas library on the Python side to parse the temperature and humidity fields in the raw data, and extracting the device identifier through a regular expression engine; Mapping the parsed data fields into a key-value pair format according to the Internet of Things platform protocol to generate a general message in JSON structure; Returning the general message to the cache queue of the data parsing service module through the Py4J interface.

4. A method for accessing agricultural Internet of Things devices based on Py4J according to claim 1, characterized in that, Based on the activated protocol method module, decoding the raw data to generate a general message for the Internet of Things platform, and calling back the general message to the data parsing service module through the Py4J communication interface, specifically including: Based on the decoding method of the activated protocol method module, performing decoding operations on the raw data, including steps such as data parsing and format conversion; Converting the decoded data into the general message format for the Internet of Things platform to obtain data recognizable by the platform; Through the Py4J communication interface, calling back the general message for the Internet of Things platform to the data parsing service module to obtain subsequent data transmission and processing.

5. A method for accessing agricultural Internet of Things devices based on Py4J according to claim 1, characterized in that, Based on the data parsing service module, encapsulate the general message into JSON format according to the Internet of Things platform protocol and transmit it to the Internet of Things platform, specifically including: Based on the data parsing service module, call the data encapsulation algorithm on the Python side to convert the general message into a JSON format compatible with the Internet of Things platform protocol; Transmit the converted general message in JSON format to the Internet of Things platform to obtain the data reception and processing of the platform; Based on the feedback of the Internet of Things platform, perform confirmation and update operations on the general message to obtain the final data result.

6. The method for accessing agricultural Internet of Things devices based on Py4J according to claim 1, characterized in that When the Internet of Things platform issues a control instruction, based on the data parsing service module, call the Py4J communication interface to activate the encoding method matching the protocol identifier of the target device, and encode the control instruction into a device message, specifically including: When the Internet of Things platform issues a control instruction, based on the data parsing service module, receive the control instruction and extract the device protocol identifier in the control instruction; Based on the data parsing service module, call the Py4J communication interface to generate a Py4J call request including the protocol identifier; Send the request to the Python side through the Py4J communication interface to activate the encoding method matching the protocol identifier; Based on the activated encoding method, encode the general message corresponding to the control instruction into a device message format to obtain data recognizable by the device.

7. A method for accessing agricultural Internet of Things devices based on Py4J according to claim 1, characterized in that, Based on the data parsing service module, send the device message to the target agricultural Internet of Things device through the Java network component, specifically including: Based on the data parsing service module, call the data encapsulation method on the Python side to convert the device message into a format compatible with the protocol of the target agricultural Internet of Things device; Send the converted device message to the target agricultural Internet of Things device through the Java network component to obtain the reception and processing of the device; Based on the feedback of the device, perform confirmation and update operations on the device message to obtain the final data result.

8. A method for accessing agricultural Internet of Things devices based on Py4J according to claim 1, characterized in that, The method further includes: Parse the Python code file uploaded by the user to generate a virtual environment configuration file including protocol identifiers, dependency library lists, and version numbers; Based on the configuration file, use the venv tool to create an isolated Python running environment for each protocol identifier and load the corresponding version of the dependency library in the environment; Register the decoding / encoding methods in different virtual environments to the protocol binding table of the data parsing service module through the Py4J service, and allocate an independent thread pool for each protocol identifier to achieve parallel parsing.

9. An agricultural Internet of Things device access device based on Py4J, characterized in that, The device includes: At least one processor; And a memory communicatively connected to the at least one processor; Wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: Receive the original data reported by the agricultural Internet of Things device based on the preset Java network component, extract the protocol identifier in the original data, and transmit the original data to the preset data parsing service module; Based on the data parsing service module, the Py4J communication interface is called, and the corresponding protocol method module on the Python side is activated according to the protocol identifier; wherein, the protocol method module includes a decoding method and an encoding method; Based on the activated protocol method module, the original data is decoded to generate an IoT platform general message, and the general message is called back to the data parsing service module through the Py4J communication interface; Based on the data parsing service module, the general message is encapsulated into a JSON format according to the IoT platform protocol and transmitted to the IoT platform; When the IoT platform issues a control instruction, based on the data parsing service module, the Py4J communication interface is called to activate the encoding method that matches the protocol identifier of the target device, and the control instruction is encoded into a device message; Based on the data parsing service module, the device message is sent to the target agricultural IoT device through the Java network component.

10. A non-volatile computer storage medium for accessing agricultural Internet of Things devices based on Py4J, storing computer-executable instructions, characterized in that, The computer-executable instructions are set as follows: Based on a preset Java network component, the original data reported by the agricultural IoT device is received, the protocol identifier in the original data is extracted, and the original data is transmitted to a preset data parsing service module; Based on the data parsing service module, the Py4J communication interface is called, and the corresponding protocol method module on the Python side is activated according to the protocol identifier; wherein, the protocol method module includes a decoding method and an encoding method; Based on the activated protocol method module, the original data is decoded to generate an IoT platform general message, and the general message is called back to the data parsing service module through the Py4J communication interface; Based on the data parsing service module, the general message is encapsulated into a JSON format according to the IoT platform protocol and transmitted to the IoT platform; When the IoT platform issues a control instruction, based on the data parsing service module, the Py4J communication interface is called to activate the encoding method that matches the protocol identifier of the target device, and the control instruction is encoded into a device message; Based on the data parsing service module, the device message is sent to the target agricultural IoT device through the Java network component.

Citation Information

Cited By

  • Internet of Things equipment access method, device and system and storage medium

    CN122069296A