A small example package
Project description
""" 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mqttssop-0.1.0.tar.gz.
File metadata
- Download URL: mqttssop-0.1.0.tar.gz
- Upload date:
- Size: 7.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bf8d9bfdee254060f304cddf4089fc26d0a7f928108908ece81b834fc6a9a5b
|
|
| MD5 |
86b296196db50dcd2222c35e59598126
|
|
| BLAKE2b-256 |
b92fa89c35e38ad479bc92207b19b7400e214e9c70bd057551637aacf3d2a822
|
File details
Details for the file mqttssop-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mqttssop-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
407f12622df8ff89c9a86bfad8b81d9193e7b1188210c5bf02b73760e0ed42c9
|
|
| MD5 |
0b3b7333ecb2cc408659cee588d650ba
|
|
| BLAKE2b-256 |
c8ab5ed606bad752a885735affba2739806084432b5c626d4340e466a7f2618d
|