Hi,
I have one X2 that is registered and connected to iDigi.
The goal I want to achieve is to upload one numeric value from X2 to iDigi.
I’m running the following Digi example but the message it returns is :“Uploading device_stats0.xml to iDigi server…
Failed upload.
Please, wait 5 minutes…”
What I’m missing?Is there a better way/example to achieve this goal?
Thanks
“”"
iDigi stats example
THIS EXAMPLE WILL NOT FUNCTION EXCEPT ON DIGI DEVICES
This example sends device statistics to iDigi server every 5 minutes.
They are stored into collection called "device_stats" and will send
a maximum of 10 files.
“”"
imports
import sys, os
import time
import the rci module to get access to the process_request method
import rci
import cStringIO
import this module to push up data files to the iDigi server the device
belongs to
from libs import idigi_data
sys.path.append(“WEB/python/libs.zip”)
constants
collection = “device_stats”
counter = 0
max_files = 10
while True:
# this is the rci request that will return device statistics
request = ’
’
# response will store the response from the rci request
response = rci.process_request(request)
# build XML string of the response
xml = cStringIO.StringIO()
xml.write("")
xml.write("")
xml.write(response)
xml.write("")
data = xml.getvalue()
xml.close()
# build file name
filename = "device_stats" + str(counter) + ".xml"
# push XML response to iDigi
print "Uploading %s to iDigi server..." % filename
try:
success, error, errmsg= idigi_data.send_idigi_data (data, filename, \
collection,
secure=False)
# validate upload
if success:
print "Successful upload.
"
else:
print "Failed upload.
"
except:
print "Failed upload.
"
# increase counter
counter += 1
if counter == max_files:
counter = 0
# wait 5 minutes
print "Please, wait 5 minutes...
"
time.sleep(300)