This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 686ad9855f chore: Worked on improving the Discovery example
686ad9855f is described below

commit 686ad9855f1c6edbc2ceeb0ecb7ad6e3f1ce6434
Author: Christofer Dutz <[email protected]>
AuthorDate: Thu Oct 19 12:42:47 2023 +0200

    chore: Worked on improving the Discovery example
---
 plc4j/examples/hello-discovery/pom.xml                            | 8 +++++---
 .../apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java | 8 +++-----
 plc4j/examples/hello-discovery/src/main/resources/logback.xml     | 2 ++
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/plc4j/examples/hello-discovery/pom.xml 
b/plc4j/examples/hello-discovery/pom.xml
index 0920afd85f..1f88bff146 100644
--- a/plc4j/examples/hello-discovery/pom.xml
+++ b/plc4j/examples/hello-discovery/pom.xml
@@ -51,8 +51,10 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>log4j-over-slf4j</artifactId>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-core</artifactId>
+      <!-- Overriding the default of "test" -->
+      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>ch.qos.logback</groupId>
@@ -67,7 +69,7 @@
         <artifactId>maven-dependency-plugin</artifactId>
         <configuration>
           <usedDependencies combine.children="append">
-            <usedDependency>org.slf4j:log4j-over-slf4j</usedDependency>
+            <usedDependency>ch.qos.logback:logback-core</usedDependency>
           </usedDependencies>
         </configuration>
       </plugin>
diff --git 
a/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java
 
b/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java
index 0c89513883..b62b8ca5f5 100644
--- 
a/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java
+++ 
b/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java
@@ -47,24 +47,22 @@ public class HelloDiscovery {
         PlcDriverManager plcDriverManager = PlcDriverManager.getDefault();
         Set<String> driverCodes = plcDriverManager.listDrivers();
         for (String driverCode : driverCodes) {
-            logger.info("Executing Discovery for Driver: {}", driverCode);
             PlcDriver driver = plcDriverManager.getDriver(driverCode);
 
             // Check if this driver supports discovery.
             if(driver.getMetadata().canDiscover()) {
+                logger.info("Executing Discovery for Driver: {}", driverCode);
                 PlcDiscoveryRequest discoveryRequest = 
driver.discoveryRequestBuilder().build();
                 PlcDiscoveryResponse discoveryResponse = 
discoveryRequest.executeWithHandler(
                     discoveryItem -> logger.info("Intercepted discovery of 
device with name: {} with connection url: {}",
                         discoveryItem.getName(), 
discoveryItem.getConnectionUrl())).get();
-                if(discoveryResponse.getResponseCode() == PlcResponseCode.OK) {
+                /*if(discoveryResponse.getResponseCode() == 
PlcResponseCode.OK) {
                     logger.info("Discovery finished successfully:");
                     for (PlcDiscoveryItem discoveryItem : 
discoveryResponse.getValues()) {
                         logger.info("Found device with name: {} with 
connection url: {}",
                             discoveryItem.getName(), 
discoveryItem.getConnectionUrl());
                     }
-                }
-            } else {
-                logger.info("This driver doesn't support discovery");
+                }*/
             }
         }
     }
diff --git a/plc4j/examples/hello-discovery/src/main/resources/logback.xml 
b/plc4j/examples/hello-discovery/src/main/resources/logback.xml
index 16b83b4882..56da3bbc5b 100644
--- a/plc4j/examples/hello-discovery/src/main/resources/logback.xml
+++ b/plc4j/examples/hello-discovery/src/main/resources/logback.xml
@@ -27,6 +27,8 @@
     </encoder>
   </appender>
 
+  <logger name="org.apache.plc4x.java.examples.hellodiscovery.HelloDiscovery" 
level="info"/>
+
   <root level="warn">
     <appender-ref ref="STDOUT" />
   </root>

Reply via email to