# A Reliable Publish-Subscribe Mechanism for Internet of Things-Enabled Smart Greenhouses
## 3 Research Methodology
### Message Standardization  
In this subsection, our overall structure of message standardization in the proposed protocol SGP MQTT is presented, as seen in the magnified portion labeled \"standardized broker\" in Figure 2. The described design involves a publisher node that is directly linked to the MQTT broker. The MQTT broker is responsible for managing many topics, each of which is devoted to specific data. Based on the distinct data types and their respective applications and functionalities, each undergoes various topics between the publisher and subscriber components:  
* Status: The client sends a CONNECT message to the broker to establish a connection. A CONNACK message and a status code are delivered by the broker. Once the connection is established, the broker maintains it until the client sends a disconnect message or the connection is terminated. Therefore, the STATUS topic notifies the server about the device's connectivity status in the greenhouse. * Info: This topic permits the server to be continually kept informed of all modifications in the greenhouse. * Digital Output: This topic obtains all commands for managing the entire components inside the greenhouse, including controlling various sorts of pump devices, fans, and actuators, and even turning the devices on and off. As a result, the greenhouse's controller devices can make a decision relying on this topic. For example, if the controller device is commanded to turn off the heating via this topic, it does so. * Digital Input: As feedback from the tools in the greenhouse. Take turning on the heater as an example, whose command is conveyed to the digital output; the command is performed in the first action, and we only see the message of turning on, even if the heater is burned in the greenhouse. It is worth noting that receiving feedback after executing the order to switch on the heater is critical because it demonstrates the correct execution of the command, allowing us to ensure that the heater is in good working condition, as shown in Figure 3.
* Analog Input: This topic can load data from the system's analog sensors, which may also declare the sensing level of the analog sensor by upgrading the analog sensor's capabilities. * Configuration: When the device in the greenhouse is upgraded or the data sending time is modified, the server will be notified through this topic. * Registration: This topic stores procedures for establishing and adding extra gateways to the broker, as well as withdrawing gateways from the broker. * Alert: Since agricultural products are of particular importance in human consumption, and industry, considering the worst-case situation plays a critical role in preserving crops, and this topic has the task of informing the server in emergencies of the greenhouse. For instance, whenever a device becomes malfunctioning, if there is no Alert topic, the server is not notified of this circumstance. * Wired communication response: Since some sensors support wired protocols such as Modbus and RS485, this topic receives and transmits information from these protocols to the main server or broker. * Local wireless response: Since wireless sensors have found the most use such as ZigBee and Wi-Fi, the data related to the sensors mentioned in this topic are received and transmitted by this topic, which shows a wide range, including the \(CO_{2}\), humidity, soil moisture, and temperature sensors, and so on. The proposed MQTT broker employs a hierarchical categorization mechanism for messages, which enhances the routing and processing of messages on both the broker and server sides. This system entails the specification of topics and payloads, where the subscriber receives updates on specific topics, and the publisher disseminates information accordingly. Our approach implements a uniform communication protocol that decreases the intricacy and processing duration on the server end.