Ejemplo n.º 1
0
 def requesthandler(msg):
     p = msg.payload; response = None
     if self.server: # only if a server
         if p.name=='Put:Request':
             result = yield dht.put(net, p.dest, p.value, p.nonce, p.expires, p.Ks, p.put)
             response = Message(name='Put:Response', seq=p.seq, result=result)
         elif p.name=='Get:Request':
             result = yield dht.get(net, p.dest, p.maxvalues, p.Kp)
             response = Message(name='Get:Response', seq=p.seq, guid=p.guid, vals=result)
         if response: yield self.net.send(Message(name='Proxy:Response', src=net.node, payload=response), node=msg.src, timeout=5)
Ejemplo n.º 2
0
 def get(self, guid, maxvalues=16, Kp=None, timeout=5):
     '''Get the values for the given guid. The return is an array of tuples (value, nonce, Kp, expires)'''
     if _debug:
         print 'get(guid=%r, maxvalues=%r, Kp=%r, timeout=%r)' % (
             guid, maxvalues, Kp, timeout)
     if self.isSuperNode:
         result = yield dht.get(self.net,
                                guid,
                                maxvalues=maxvalues,
                                Kp=Kp,
                                timeout=timeout)
     else:
         result = yield self.client.get(guid,
                                        maxvalues=maxvalues,
                                        Kp=Kp,
                                        timeout=timeout)
     raise StopIteration(result)
Ejemplo n.º 3
0
 def requesthandler(msg):
     p = msg.payload
     response = None
     if self.server:  # only if a server
         if p.name == 'Put:Request':
             result = yield dht.put(net, p.dest, p.value, p.nonce,
                                    p.expires, p.Ks, p.put)
             response = Message(name='Put:Response',
                                seq=p.seq,
                                result=result)
         elif p.name == 'Get:Request':
             result = yield dht.get(net, p.dest, p.maxvalues, p.Kp)
             response = Message(name='Get:Response',
                                seq=p.seq,
                                guid=p.guid,
                                vals=result)
         if response:
             yield self.net.send(Message(name='Proxy:Response',
                                         src=net.node,
                                         payload=response),
                                 node=msg.src,
                                 timeout=5)
Ejemplo n.º 4
0
 def get(self, guid, maxvalues=16, Kp=None, timeout=5):
     '''Get the values for the given guid. The return is an array of tuples (value, nonce, Kp, expires)'''
     if _debug: print 'get(guid=%r, maxvalues=%r, Kp=%r, timeout=%r)'%(guid, maxvalues, Kp, timeout)
     if self.isSuperNode: result = yield dht.get(self.net, guid, maxvalues=maxvalues, Kp=Kp, timeout=timeout)
     else: result = yield self.client.get(guid, maxvalues=maxvalues, Kp=Kp, timeout=timeout)
     raise StopIteration(result)
Ejemplo n.º 5
0
import time
import datetime
import dht
import max31865
import lsm9ds1
import gvk162

while True:
    start_time = time.time()
    try:
      externalReading = max31865.get()
    except Exception: 
      pass
    
    try:
      internalTemp1, internalHumidity = dht.get(11)
    except Exception:
      pass
    
    try:
      lsm9ds1_readings = lsm9ds1.get()
    except Exception:
      pass

    try:
      accel_x, accel_y, accel_z = lsm9ds1_readings.get('acceleration')
    except Exception:
      pass

    try:
      mag_x, mag_y, mag_z = lsm9ds1_readings.get('magnetometer')