commit 10/24/15

This commit is contained in:
2015-10-24 00:00:00 -06:00
committed by Anthony Correa
parent ad1b83a3f4
commit 3cac7b0963
5 changed files with 111 additions and 40 deletions

View File

@@ -108,14 +108,16 @@ class Datareporter_Debug3 ():
def __init__(self, path=SCRIPTDIR,
report_url = "http://10.0.1.4:5010/report",
report_image_url = "http://10.0.1.4:5010/photo",
report_image_url = "http://10.0.1.4:5010/upload-file",
com_port_name = "/dev/ttyAMA0",
baud_rate = "9600"):
baud_rate = "9600",
content_type = None):
#TODO communication
self.report_url = report_url
self.report_image_url = report_image_url
self.com_port_name = com_port_name,
self.com_port_name = com_port_name
self.baud_rate = baud_rate
self.content_type = content_type
pass
@@ -138,7 +140,7 @@ class Datareporter_Debug3 ():
print ("%s - Sent Message: %s"% (str(datetime.datetime.now()), message))
elif type == "image":
#todo send image
response = requests.post(self.report_image_url, files={'file': message})
# response = requests.post(self.report_image_url, files={'file': message})
print ("%s - Sent Image: %s"% (str(datetime.datetime.now()), message))
#adding & initializing port object
@@ -157,7 +159,7 @@ class Datareporter_Debug3 ():
inet = self.SimInetGSM(port, logger)
logger.info("attaching GPRS")
if not inet.attachGPRS("internet", "", "", 1):
if not inet.attachGPRS("wholesale", "", "", 1):
logger.error("error attaching GPRS")
return False
@@ -166,13 +168,12 @@ class Datareporter_Debug3 ():
#making HTTP GET request
logger.info("making HTTP POST request")
if not inet.httpPOST_DATA(
"home.ascorrea.com",
5010,
"/photo",
"file={0}".format(message)
"/upload-file",
# content=self.content_type,
parameters="{0}".format(message)
):
logger.error("error making HTTP GET post: {0}".format(inet.errorText))
return False