Python implementation of the TATU protocol.
Project description
The TATU protocol is used for communication between sensors and applications
- The protocol is divided into two parts: Requests and Responses
- Those who need to use the TATU library should preferably import it like this: from TATU import TatuReq, TatuRes
- Consider that a device (e.g., sc01) may have several sensors (e.g., humiditySensor, temperatureSensor...)
- The TATU protocol is not case-sensitive, however, creating messages in lowercase should be prioritized.
Request TATU messages:
First example requesting information from only one temperatureSensor sensor embedded in device sc01:
#Object creation
tatuMessage = TatuReq("FLOW",collect="10000",publish="10000",sensor="temperatureSensor",device="sc01")
#The value in tatuMessage.getTatu() should be:
'{"method":"flow", "sensor":"temperatureSensor", "time":{"collect":"10000", "publish":"10000"}}'
#O valor em tatuMessage.getTopic() deverá ser:
'dev/sc01/REQ'
Second example requesting data from only one temperatureSensor embedded in device sc01:
tatuMessage = TatuReq("FLOW",collect="10000",publish="20000",sensor="temperatureSensor",device="sc01")
#The response:
'{"method":"flow", "device":"temperatureSensor", "time":{"collect":"10000", "publish":"20000"}}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/REQ'
Third example requesting data from all sensors of the sc01 device:
tatuMessage = TatuReq("FLOW",collect="10000",publish="10000",sensor=None,device="sc01")
#The response tatuMessage.getTatu():
'{"method":"flow", "device":"sc01", "time":{"collect":"10000", "publish":"10000"}}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/REQ'
Fourth Example requesting that all sensors on device sc01 stop sending new messages (this message does not require a response):
tatuMessage = TatuReq("STOP",collect="10000",publish="10000",sensor=None,device="sc01")
#The response tatuMessage.getTatu()
'{"method":"stop", "device":"sc01"}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/REQ'
Fifth Example requesting that the temperatureSensor of device sc01 stop sending new messages (this message does not require a response):
tatuMessage = TatuReq("STOP",collect="10000",publish="10000",sensor="temperatureSensor",device="sc01")
#The response tatuMessage.getTatu()
'{"method":"stop", "sensor":"temperatureSensor"}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/REQ'
Seventh example requesting an immediate message from the temperatureSensor sensor of device sc01:
tatuMessage = TatuReq("GET",sensor="temperatureSensor",device="sc01")
#The response tatuMessage.getTatu()
'{"method":"get", "sensor":"temperatureSensor"}'
#O valor em tatuMessage.getTopic() deverá ser:
'dev/sc01/REQ'
Eighth example requesting an immediate message from all sensors on device sc01:
tatuMessage = TatuReq("GET",sensor="None",device="sc01")
#The response tatuMessage.getTatu()
'{"method":"get", "device":"sc01"}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/REQ'
Ninth example requesting a TATU message from the temperatureSensor only when a delta variation occurs:
tatuMessage = TatuReq("EVT",sensor="temperatureSensor",device="sc01",delta="2")
#The response tatuMessage.getTatu()
'{"method":"evt", "sensor":"temperatureSensor","delta","2"}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/REQ'
Response TATU messages
First example responding to a message that requested data from only one temperatureSensor sensor embedded in device sc01:
#collect and publish optional params tatuMessage = TatuRes("FLOW",collect="10000",publish="10000",sensor="temperatureSensor",device="sc01",sample="37")
#O valor em tatuMessage.getTatu() deverá ser:
'{"header": {"method": "FLOW", "device": "sc01", "payload": {"sensors": [{"temperatureSensor": ["37"]}]}}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/RES'
Second example responding to a message that requested information from only one temperatureSensor sensor embedded in device sc01:
tatuMessage = TatuRes("FLOW",collect=10000,publish=20000,sensor="temperatureSensor",device="sc01",sample=["37","38"])
#O valor em tatuMessage.getTatu() deverá ser:
'{"header": {"method": "FLOW", "device": "sc01", "payload": {"sensors": [{"temperatureSensor": ["37", "38"]}]}}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/RES'
Third example responding to a request with data from all sensors of the sc01 device:
tatuMessage = TatuRes("FLOW",collect="10000",publish="10000",sensor=None,device="sc01",sensorsList=["humiditySensor","temperatureSensor","soilmoistureSensor","solarradiationSensor","ledActuator"], sensorsValue=[["66"],["31"],["650"],["2291"],["true"]])
#The response tatuMessage.getTatu():
'{"header": {"method": "FLOW", "device": "sc01", "payload": {"sensors": [{"humiditySensor": ["66"]}, {"temperatureSensor": ["31"]}, {"soilmoistureSensor": ["650"]}, {"solarradiationSensor": ["2291"]}, {"ledActuator": ["true"]}]}}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/RES'
Fourth example response to a request for immediate data from the temperatureSensor sensor of device sc01:
tatuMessage = TatuRes("GET",sensor="temperatureSensor",device="sc01",sample="27")
#The response tatuMessage.getTatu()
'{"header":{"method":"GET", "device":"sc01"}, "payload":{"sensors":{"temperatureSensor":["27"]}}}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/RES'
Fifth example, responding with values from all sensors of device sc01:
tatuMessage = TatuRes("GET",sensor="None",device="sc01",sensorsList=["humiditySensor","temperatureSensor","soilmoistureSensor","solarradiationSensor","ledActuator"], sensorsValue=[["66"],["31"],["650"],["2291"],["true"]])
#The response tatuMessage.getTatu()
'{"header": {"method": "get", "device": "sc01", "payload": {"sensors": [{"humiditySensor": ["66"]}, {"temperatureSensor": ["31"]}, {"soilmoistureSensor": ["650"]}, {"solarradiationSensor": ["2291"]}, {"ledActuator": ["true"]}]}}'
#The value in tatuMessage.getTopic() should be:
'dev/sc01/RES'
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 tatu_protocol-1.0.0.tar.gz.
File metadata
- Download URL: tatu_protocol-1.0.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
453905beec5265a3fd8c83eca3115aaa68ecc99f31c8691a8132a9e660abd38c
|
|
| MD5 |
352ab29b752630d42bbc3c88f56ec874
|
|
| BLAKE2b-256 |
efa6a91874ad41d51de5df6a3fa959955a57cddd0ad7bd736298e910f91c5560
|
File details
Details for the file tatu_protocol-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tatu_protocol-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac56c4b83e36b6e6039a5f2d2e97ec4a4a47b5e7de531507d644a7c03a3c64b9
|
|
| MD5 |
1649e6d682530aa315cd326b1705716d
|
|
| BLAKE2b-256 |
5ec882938030aa82684ec0ddc296929718f194d0dbdd56cbd96f67e62bc1844c
|