/** If an ID -Request from a sensor is received the conroller will send an id to the sensor */ private void answerIDRequest() { logger.debug("ID Request received"); int newId = getFreeId(); givenIds.add(newId); MySensorsMessage newMsg = new MySensorsMessage(255, 255, 3, 0, 4, newId + ""); mysCon.addMySensorsOutboundMessage(newMsg); }
/* (non-Javadoc) * @see org.eclipse.smarthome.core.thing.binding.BaseThingHandler#initialize() */ public void initialize() { logger.debug("Initialization of the MySensors Bridge"); MySensorsBridgeConfiguration configuration = getConfigAs(MySensorsBridgeConfiguration.class); if (getThing().getThingTypeUID().equals(THING_TYPE_BRIDGE_SER)) { mysCon = new MySensorsSerialConnection(configuration.serialPort, 115200); } else if (getThing().getThingTypeUID().equals(THING_TYPE_BRIDGE_ETH)) { int tcpPort = Integer.parseInt(configuration.tcpPort); mysCon = new MySensorsIpConnection(configuration.ipAddress, tcpPort); } if (mysCon.connected) { mysCon.start(); mysCon.addUpdateListener(this); updateStatus(ThingStatus.ONLINE); } else { updateStatus(ThingStatus.OFFLINE); } // Start discovery service MySensorsDiscoveryService discoveryService = new MySensorsDiscoveryService(this); discoveryService.activate(); }
/* (non-Javadoc) * @see org.eclipse.smarthome.core.thing.binding.BaseThingHandler#dispose() */ public void dispose() { if (mysCon != null) mysCon.stopReader(); }