Metadata-Version: 2.1
Name: mqttSSOP
Version: 0.1.0
Summary: A small example package
Project-URL: Homepage, https://github.com/pypa/sampleproject
Project-URL: Bug Tracker, https://github.com/pypa/sampleproject/issues
Author-email: Pedro Vila Luz <pedro.vila.luz@gmail.com>
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown

"""
In this code, is developed the library in order to have a communication channel 
between the broker and the publisher
"""







"""
How to publish?

The only function needed to publish to a topic is the "publish" function. In this function, it is going to be sent a message
to a broker in order to be forward to the subscribers.

The function return 1 if the message was sent
Else returns 0


######

PARAMETERS:

topic: is the topic that the client wants to subscribe. This topic has to be separated by slashes ( "/" ) and has to be
between 2 and 10 arguments ("toAsset/deviceID/something/something_else")

information: the information is the message or the body that is going to be sent. It has to be a string.

clientID: Client ID is only a way to diferenciate the people that are accessing the information

username: Yet to be implemented

password: Yet to be implemented



WARNING AND ADVICES:

Make sure the information is in double quotes "" and not in single quotes ''

EXAEMPLES:

from mqtt_SSOP import clientPublisher

if __name__ == '__main__':

    clientPublisher.publish("toAsset/123","Ola tudo bem","IDClient")

######

    

"""










"""
Errors:
1-> To much arguments
2-> Couldn't split arguments correctly
3-> The input in the main funciton is not a string
4-> Couldn't read the input
5-> To few arguments in the topic
"""






"""
In this code, is developed the library in order to have a communication channel 
between the broker and the subscriber
"""







"""
How to subscribe?

The only function needed to subscribe to a topic is the "subscribe" function. It recieves the messages from an online broker.
The funtion writes in a dict variable


######

PARAMETERS:

topic: is the topic that the client wants to subscribe. This topic has to be separated by slashes ( "/" ) and has to be
betwenn 2 and 10 arguments ("toAsset/deviceID/something/something_else")

information: the information is the message or the body that is going to be recieved. It has to be a dict and in this dict
there has to be a "lastMessage" parameter where the message is going to be written on. And everytime the message is recived, it changes
the parameter inside the dictionary. If there is no key-value pair with the name "lastMessage", one is created. 

clientID: Client ID is only a way to diferenciate the people that are accessing the information

username: Yet to be implemented

password: Yet to be implemented



WARNING AND ADVICES:

This function stop the process, wating for messages. If you want to continuasy recieve messages without stoping the main
process, you can create a thread and run in a different process. The dictionary, if pass down to the fucntion, is going to be change 
even in the main process. 



EXAMPLES:

from mqtt_SSOP import clientSubscriber
from time import sleep
import threading



if __name__ == '__main__':

    try:
        
        
        message = {
            "lastMessage" : "Not modified",
            "id" : id,
        }

        subThread = threading.Thread(target=lambda : clientSubscriber.subscribe("toAsset/123",message,"something"))
        subThread.start()

        while(1):
            sleep(5)
            print(message)
    

    except KeyboardInterrupt:
        subThread.join()
        print("Processed interrupted! Exiting... ")



######


"""








"""
Errors:
1-> To much arguments
2-> Message to big
3-> Couldn't decode the topic





