Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages