OpenMTC/doc/training/onem2m-examples/onem2m-example-6b.py

20 lines
467 B
Python
Raw Normal View History

2017-11-07 13:41:38 +00:00
# Example 6b: Notify OneM2MRequest with data
from openmtc_onem2m.transport import OneM2MRequest
import json
sensor_data = {"type": "temperature",
"value": 15 }
data_string = json.dumps(sensor_data)
request = OneM2MRequest("create",
to="onem2m",
pc=data_string,
ty="application/json")
2019-01-10 10:10:02 +00:00
print(request.to)
2017-11-07 13:41:38 +00:00
#>>> onem2m
2019-01-10 10:10:02 +00:00
print(request.pc)
2017-11-07 13:41:38 +00:00
#>>> {"type": "temperature", "value": 15}