Exemplo n.º 1
0
    def __init__(self, broker,
                topic="iot-1/d/%012x/evt/%s/json",
                hostname=None,
                hostport=1883,
                username=None,
                password=None,
                keepalive=60):
        EventSink.__init__(self, broker)
        self._client = Paho()
        self._client.on_connect = \
                lambda mosq, obj, rc: self._on_connect(mosq, obj, rc)
        self._client.on_disconnect = \
                lambda mosq, obj, rc: self._on_disconnect(mosq, obj, rc)
        self._client.on_publish = \
                lambda mosq, obj, mid: self._on_publish(mosq, obj, mid)
        self._topic_format = topic
        self._topic = self._topic_format % (0, "%s")

        self._hostname = hostname
        self._hostport = hostport
        self._username = username
        self._password = password
        self._keepalive = keepalive

        self._loopflag = False
        self._neta = None
Exemplo n.º 2
0
    def __init__(self, broker,
                serialport='/dev/ttyUSB0',
                _baudrate=9600,
                _parity=serial.PARITY_NONE,
                _stopbits=serial.STOPBITS_ONE,
                _bytesize=serial.EIGHTBITS):
        EventSink.__init__(self, broker)
        self._event_type_json_file = "sigfox_event_types.json"

        # Read from event type enum definition file (in JSON format)
        dirname, filename = os.path.split(os.path.abspath(__file__))
        log.debug(dirname)
        type_file = open(dirname + "/" + self._event_type_json_file, "rt")
        type_stream = type_file.read()
        self._type_info = json.loads(type_stream)

        self._serialport = serialport;
        self._baudrate = _baudrate;
        self._parity = _parity;
        self._stopbits = _stopbits;
        self._bytesize = _bytesize;

        self.__is_available = False
        self._ser = None
        self._reconnect_timer = None
        self._reconnect_timeout = 10
Exemplo n.º 3
0
    def __init__(self, broker,
                serialport='/dev/ttyUSB0',
                _baudrate=9600,
                _parity=serial.PARITY_NONE,
                _stopbits=serial.STOPBITS_ONE,
                _bytesize=serial.EIGHTBITS):
        EventSink.__init__(self, broker)
        self._event_type_json_file = "sigfox_event_types.json"

        # Read from event type enum definition file (in JSON format)
        dirname, filename = os.path.split(os.path.abspath(__file__))
        log.debug(dirname)
        type_file = open(dirname + "/" + self._event_type_json_file, "rt")
        type_stream = type_file.read()
        self._type_info = json.loads(type_stream)

        self._serialport = serialport;
        self._baudrate = _baudrate;
        self._parity = _parity;
        self._stopbits = _stopbits;
        self._bytesize = _bytesize;

        self.__is_available = False
        self._ser = None
        self._reconnect_timer = None
        self._reconnect_timeout = 10
Exemplo n.º 4
0
    def __init__(self, broker, relay_port, scan_interval, refresh_socket_conns):
        EventSink.__init__(self, broker)

        ScaleNetworkManager.__init__(self, broker)

        self._neighbors = self.get_neighbors()
        self.batman_interface = self.get_batman_interface()
        self.batman_ip = self.get_interface_ip_address(self.batman_interface)
        self.batman_mac = self.get_interface_mac_address(self.batman_interface)
        self.mesh_host_id = self.batman_ip + "_" + self.batman_mac

        # print self.mesh_host_id
        self.display_neighbors()

        self.scan_interval = scan_interval
        self.refresh_socket_conns = refresh_socket_conns

        self._relay_port = relay_port
        self.last_time_scanned = time.time()
        self.last_time_refreshed = time.time()

        self._neighbor_connections = {}
        if self.batman_is_active():
            self.create_connection_to_neighbors()
Exemplo n.º 5
0
 def __init__(self, scan_interval=10):
     #self._scan_interval = scan_interval
     EventSink.__init__(self)
Exemplo n.º 6
0
	def __init__(self, scan_interval=10):
		#self._scan_interval = scan_interval
		EventSink.__init__(self)