Skip to content

Instantly share code, notes, and snippets.

@sbcd90
Last active October 17, 2016 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbcd90/36c719b9cf1b3f9757a300ba8702768e to your computer and use it in GitHub Desktop.
Save sbcd90/36c719b9cf1b3f9757a300ba8702768e to your computer and use it in GitHub Desktop.
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