Last active
October 17, 2016 20:05
-
-
Save sbcd90/36c719b9cf1b3f9757a300ba8702768e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
import json | |
import random | |
import time | |
min = 20 | |
max = 60 | |
url = "https://iotmmsd774d7966.us2.hana.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/2cf26839-0425-4bb1-bec2-084124331e18" | |
req_headers = { | |
"Content-Type": "application/json;charset=utf-8", | |
"Authorization": "Bearer eeebdfa39719fd4ed4b4daf52e1e94" | |
} | |
while True: | |
temp = random.randint(min, max) | |
pressure = random.randint(min, max) | |
millis = int(round(time.time())) | |
msg = { | |
"mode": "sync", | |
"messageType": "f2a5d107c0748b4502fa", | |
"messages": [ | |
{ | |
"timestamp": millis, | |
"pressure": pressure, | |
"temperature": temp | |
} | |
] | |
} | |
data = urllib.urlencode(msg) | |
print msg | |
print data | |
req = urllib2.Request(url, json.dumps(msg), req_headers) | |
response = urllib2.urlopen(req) | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment