Ejemplo n.º 1
0
def receive_sms():
  text = request.args.get('Text')
  _from = request.args.get('From')
  origin,destination = text.split(":")
  if origin == None or destination == None:
    return 'Message does not satify the schema', 404

  response = direction.getDirection(origin, destination)
  sms.send(_from, response)
  return 'Direction sent to ' + _from + '!'
Ejemplo n.º 2
0
def send_sms():
  try:
    text = request.form.get('message')
    if text is not None:
      origin,destination = text.split(":")
    else:
      origin = request.form.get('origin'),
      destination = request.form.get('destination')

    if origin == None or destination == None:
      return 'Message does not satify the schema', 404
    return direction.getDirection(origin, destination)

  except Exception as e:
    print e.message
    return e.message, 404
Ejemplo n.º 3
0
#Processor time management is not required for this project. This is due to the fact that,
#well, weather can't change over a span of several seconds. Hence, fast data collection is 
#not needed.

#The dict below holds the data to be sent over MQTT.
data = {'direction': 180, 
	'temperature': 20,
	'pressure': 103}

#This constant controls frequency of readings
dataInterval = 10;

#Initialisation sequences for the modules
declination = getDeclination() 		#magnetic
calibrationData = init_Pressure()	#pressure
print(declination)

#Infinite loop to collect and send data
while(True):
	time.sleep(dataInterval)

	#Fill the dict with fresh measurements
	data['direction'] = getDirection(declination)	#get wind direction
	pres_data = getPressure(calibrationData)	#get temperature and pressure info
	data['temperature'] = pres_data['temp']
	data['pressure'] = pres_data['pres']

	#Send data over
	sendMQTT(data)