forked from EnvisionIot/enos-device-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModelUpRawSample.py
21 lines (17 loc) · 876 Bytes
/
ModelUpRawSample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from enos.core.MqttClient import MqttClient
from enos.message.upstream.tsl.ModelUpRawRequest import ModelUpRawRequest
from enos.sample.SampleHelper import SampleHelper
def post_model_up_raw():
""" Device can report raw data (such as binary data stream) """
post_model_up_raw_request = ModelUpRawRequest.builder() \
.set_payload(SampleHelper.RAW_PAYLOAD) \
.build()
post_model_up_raw_response = client.publish(post_model_up_raw_request)
print(post_model_up_raw_response.get_payload())
if __name__ == "__main__":
client = MqttClient(SampleHelper.TCP_SERVER_URL, SampleHelper.GW_PRODUCT_KEY_RAW,
SampleHelper.GW_DEVICE_KEY_RAW, SampleHelper.GW_DEVICE_SECRET_RAW)
client.get_profile().set_auto_reconnect(True)
client.setup_basic_logger('INFO')
client.connect() # connect in sync
post_model_up_raw()