diff --git a/pi4j-spring-boot/src/main/java/com/pi4j/spring/boot/ContextConditions.java b/pi4j-spring-boot/src/main/java/com/pi4j/spring/boot/ContextConditions.java index ad24dd4..9f42844 100644 --- a/pi4j-spring-boot/src/main/java/com/pi4j/spring/boot/ContextConditions.java +++ b/pi4j-spring-boot/src/main/java/com/pi4j/spring/boot/ContextConditions.java @@ -1,7 +1,6 @@ package com.pi4j.spring.boot; import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; public class ContextConditions extends AnyNestedCondition { @@ -9,23 +8,4 @@ public ContextConditions() { super(ConfigurationPhase.REGISTER_BEAN); } - /** - * TODO are these still needed? Can't we use Pi4jActuatorConfiguration.boardInfo ? - */ - @ConditionalOnProperty(prefix = "os", name = "arch", havingValue = "armv6l") - static class Armv6l { - } - - @ConditionalOnProperty(prefix = "os", name = "arch", havingValue = "armv7l") - static class Armv7l { - } - - @ConditionalOnProperty(prefix = "os", name = "arch", havingValue = "armv8l") - static class Armv8l { - } - - @ConditionalOnProperty(prefix = "os", name = "arch", havingValue = "aarch64") - static class Aarch64 { - } - } diff --git a/pi4j-spring-boot/src/main/java/com/pi4j/spring/boot/Pi4jActuatorConfiguration.java b/pi4j-spring-boot/src/main/java/com/pi4j/spring/boot/Pi4jActuatorConfiguration.java index 857717e..25e6e4f 100644 --- a/pi4j-spring-boot/src/main/java/com/pi4j/spring/boot/Pi4jActuatorConfiguration.java +++ b/pi4j-spring-boot/src/main/java/com/pi4j/spring/boot/Pi4jActuatorConfiguration.java @@ -37,17 +37,20 @@ public void contribute(Builder builder) { builder.withDetail("os.architecture", os.getArchitecture()); builder.withDetail("os.version", os.getVersion()); builder.withDetail("os.architecture", os.getArchitecture()); + var boardModel = boardInfo.getBoardModel(); builder.withDetail("board.name", boardModel.getName()); builder.withDetail("board.description", boardModel.getLabel()); builder.withDetail("board.model.label", boardModel.getModel().getLabel()); builder.withDetail("board.cpu.label", boardModel.getCpu().getLabel()); builder.withDetail("board.soc", boardModel.getSoc().name()); + var java = boardInfo.getJavaInfo(); builder.withDetail("java.version", java.getVersion()); builder.withDetail("java.runtime", java.getRuntime()); builder.withDetail("java.vendor", java.getVendor()); builder.withDetail("java.vendor.version", java.getVendorVersion()); + var boardReading = BoardInfoHelper.getBoardReading(); builder.withDetail("reading.volt.value", boardReading.getVoltValue()); builder.withDetail("reading.temperature.celsius", boardReading.getTemperatureInCelsius()); @@ -56,26 +59,50 @@ public void contribute(Builder builder) { try { // TODO https://github.com/Pi4J/pi4j-springboot/issues/11 - //builder.withDetail("pi4jPlatforms", context.platforms().all()); + builder.withDetail("platform.name", context.platform().name()); + builder.withDetail("platform.value", context.platform().describe().value().toString()); } catch (Exception ex) { - logger.error("Could not return the Pi4J Platforms: {}", ex.getMessage()); + logger.error("Could not return the Pi4J Default Platform: {}", ex.getMessage()); } + try { // TODO https://github.com/Pi4J/pi4j-springboot/issues/11 - //builder.withDetail("pi4jDefaultPlatform", context.platform()); + for (var entry : context.platforms().all().entrySet()) { + builder.withDetail("platform." + getAsKeyName(entry.getKey()) + ".name", entry.getValue().name()); + builder.withDetail("platform." + getAsKeyName(entry.getKey()) + ".description", entry.getValue().description()); + builder.withDetail("platform." + getAsKeyName(entry.getKey()) + ".value", entry.getValue().describe().value().toString()); + } } catch (Exception ex) { - logger.error("Could not return the Pi4J Default Platform: {}", ex.getMessage()); + logger.error("Could not return the Pi4J Platforms: {}", ex.getMessage()); } + try { // TODO https://github.com/Pi4J/pi4j-springboot/issues/11 - //builder.withDetail("pi4jProviders", context.providers().all()); + for (var entry : context.providers().all().entrySet()) { + builder.withDetail("provider." + getAsKeyName(entry.getKey()) + ".name", entry.getValue().name()); + builder.withDetail("provider." + getAsKeyName(entry.getKey()) + ".description", entry.getValue().description()); + builder.withDetail("provider." + getAsKeyName(entry.getKey()) + ".type.name", entry.getValue().type().name()); + } } catch (Exception ex) { logger.error("Could not return the Pi4J Providers: {}", ex.getMessage()); } + try { - builder.withDetail("pi4jRegistry", context.registry().all()); + for (var entry : context.registry().all().entrySet()) { + builder.withDetail("registry." + getAsKeyName(entry.getKey()) + ".name", entry.getValue().name()); + builder.withDetail("registry." + getAsKeyName(entry.getKey()) + ".config.name", entry.getValue().config().name()); + builder.withDetail("registry." + getAsKeyName(entry.getKey()) + ".config.name", entry.getValue().config().platform()); + builder.withDetail("registry." + getAsKeyName(entry.getKey()) + ".config.provider", entry.getValue().config().provider()); + builder.withDetail("registry." + getAsKeyName(entry.getKey()) + ".type.name", entry.getValue().type().name()); + builder.withDetail("registry." + getAsKeyName(entry.getKey()) + ".description", entry.getValue().description()); + builder.withDetail("registry." + getAsKeyName(entry.getKey()) + ".value", entry.getValue().describe().value().toString()); + } } catch (Exception ex) { logger.error("Could not return the Pi4J Registry: {}", ex.getMessage()); } } + + private String getAsKeyName(String key) { + return key.toLowerCase().trim().replace(" ", "-"); + } }