* Create User32Ex with some mappings missing in JNA's User32 * Create WindowMessageHandler for subscribing to device change messages The class, when run as a Runnable, creates an invisible window and uses that to listen for device change events for USB devices and serial ports. It listens in a blocking message loop, so it's necessary to call terminate() for the loop to exit and the run() method to exit. Results are sent to subscribing WindowMessageListeners. * Refactor WindowsUsbSerialDiscovery to use a different approach to gathering device information The previous implementation scanned the registry for USB devices on a fixed interval. This implementation changes most of the core logic, using SetupAPI as the primary source of information instead of the registry. That allows it to process less information to get to the information of interest, in addition to only "discovering" devices that are currently connected to the computer. The registry keeps the entries for all devices that have previously been connected as well, which would also be "discovered" with the previous implementation. In addition, this implementation uses WindowMessageHandler to receive device change messages from Windows, making regular scanning unnecessary. If the WindowMessageHandler fails for some reason, the implementation will fall back to scanning on an interval, but this scanning is still using SetupAPI to acquire the data. * Various thread-safety and consistency fixes - UsbAddonFinder: Remove unused Set and fix concurrency behavior. ConcurrentHashMap is unsuitable here because it doesn't allow locking the full map, which is needed during "merging" and when resolving suggested add-ons. - DeltaUsbSerialScanner: Make lastScanResult thread-safe. - Ser2NetUsbSerialDiscovery: Make lastScanResult thread-safe, reduce the scope of locking to reduce contention and lessen how many locks are held at once. Make notifyListeners volatile for thread-safe access, and stop reacting to jmdns serviceAdded events. jmdns first fires serviceAdded when the service has just been discovered, but most of the information hasn't yet been gathered, and then fires serviceResolved once all the data has been registered. The data received in serviceAdded is incomplete and rarely useful, at best it's a "heads-up, this device might be resolved soon". - UsbSerialDiscovery: Correct JavaDoc - UsbSerialDiscoveryService: Minor logging tweaks, only log "Discovered new" the first time the device is "discovered". Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
openHAB Core
This project contains core bundles of the openHAB runtime.
Building and running the project is fairly easy if you follow the steps detailed below.
Please note that openHAB Core is not a product itself, but a framework to build solutions on top. It is picked up by the main openHAB distribution.
This means that what you build is primarily an artifact repository of OSGi bundles that can be used within smart home products.
1. Prerequisites
The build infrastructure is based on Maven. If you know Maven already then there won't be any surprises for you. If you have not worked with Maven yet, just follow the instructions and everything will miraculously work ;-)
What you need before you start:
- Java SE Development Kit 21
- Maven 3 from https://maven.apache.org/download.html
Make sure that the mvn command is available on your path
2. Checkout
Checkout the source code from GitHub, e.g. by running:
git clone https://github.com/openhab/openhab-core.git
3. Building with Maven
To build this project from the sources, Maven takes care of everything:
- set
MAVEN_OPTSto-Xms512m -Xmx1024m - change into the openhab-core directory (
cd openhab-core) - run
mvn clean spotless:apply installto compile and package all sources
If there are tests that are failing occasionally on your local build, run mvn -DskipTests=true clean install instead to skip them.
For an even quicker build, run mvn clean install -T1C -DskipChecks -DskipTests -Dspotless.check.skip=true.
How to contribute
If you want to become a contributor to the project, please read about contributing and check our guidelines first.