Ejemplo n.º 1
0
def main():
    global outputFile, directory
    try:
        opts, args = getopt.getopt(sys.argv[1:],"ho:",["output="])
    except getopt.GetoptError:
        print '%s -o <outputfile>' % sys.argv[0]
        sys.exit(2)

    for opt, arg in opts:
      if opt == '-h':
         print '%s -o <outputfile>' % sys.argv[0]
         sys.exit()
      elif opt in ("-o", "--output"):
         outputFile = arg

    if outputFile == None:
        print "No output file specified, output to console."

    radio.init()
    OpenThings.init(Devices.CRYPT_PID)

    try:
        dumpDirectory()
        monitor_loop()

    finally:
        radio.finished()
        directory = {"__META": {"time": int(time.time())}}
        dumpDirectory()
Ejemplo n.º 2
0
    def close(self):
        '''Closes connection'''

        radio.finished()
Ejemplo n.º 3
0
            Registry.update(decoded)
            ##trace(decoded)
            Logger.logMessage(decoded)

            # Process any JOIN messages by sending back a JOIN-ACK to turn the LED off
            if len(decoded["recs"]) == 0:
                # handle messages with zero recs in them silently
                print("Empty record:%s" % decoded)
            else:
                # assume only 1 rec in a join, for now
                if decoded["recs"][0]["paramid"] == OpenThings.PARAM_JOIN:
                    mfrid     = OpenThings.getFromMessage(decoded, "header_mfrid")
                    productid = OpenThings.getFromMessage(decoded, "header_productid")
                    sensorid  = OpenThings.getFromMessage(decoded, "header_sensorid")
                    Messages.send_join_ack(radio, mfrid, productid, sensorid)


if __name__ == "__main__":
    
    trace("starting monitor tester")
    radio.init()
    OpenThings.init(Devices.CRYPT_PID)

    try:
        monitor_loop()

    finally:
        radio.finished()

# END
Ejemplo n.º 4
0
def sigterm_handler(_signo, _stack_frame):
    radio.finished()
    directory = {"__META": {"time": int(time.time())}}
    dumpDirectory()
    sys.exit(0)
Ejemplo n.º 5
0

if __name__ == "__main__":

    trace("starting switch tester")
    radio.init()
    OpenThings.init(Devices.CRYPT_PID)

    # Seed the registry with a known device, to simplify tx-only testing
    SENSOR_ID = 0x68B  # captured from a real device
    device_header = OpenThings.alterMessage(
        Messages.REGISTERED_SENSOR,
        header_mfrid=Devices.MFRID,
        header_productid=Devices.PRODUCTID_MIHO005,  # adaptor plus
        header_sensorid=SENSOR_ID)
    Registry.update(device_header)

    sendSwitchTimer = Timer(TX_RATE, 1)  # every n seconds offset by initial 1
    switch_state = 0  # OFF
    radio.receiver()

    try:
        while True:
            switch_sniff_loop()
            switch_toggle_loop()

    finally:
        radio.finished()

# END
Ejemplo n.º 6
0
    def close(self):

        '''Closes connection'''

        radio.finished()