meta-gbmc-staging: dbus-sensors: gpiosensor: Place initialized flag in object interface

Since the existing code has the `initialized` flag in the GPIOPresence
class directly, which is not supposed to keep `initialized` true for the
entire lifetime of the object, we move it under ObjIfaces to keep the
life cycle of the flag same as the object interface.

Therefore, we can avoid the issue reproduced by
1. Waiting for the sensor of GPIOStatus to be initialized
   (Waiting for `initialized` to be true)
2. cp /usr/share/entity-manager/configurations/mobo.json mobo.json.bak
   (Back up the original configuration file)
3. rm -r /usr/share/entity-manager/configurations/mobo.json
   (Remove the configuration file as new change of the configuration to
   gpiosensor)
4. ipmitool power cycle
   (Trigger the gpiosensor to receive the new config without restarting
   the service, `initialized` is still true)
5. cp mobo.json.bak /usr/share/entity-manager/configurations/mobo.json
   (Restore the original configuration file)
6. ipmitool power cycle
   (Trigger the gpiosensor to receive the new config without restarting
   the service, `initialized` is still true, which misleading the
   service that the objects have been created, skipping the
   initialization of the interfaces, causing none of the sensors are
   exposed on dbus)

Tested:
[After this change]
:~# ipmitool sensor list
BMC_P0_SLOT0_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BMC_P0_SLOT1_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BMC_P0_SLOT2_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BP_12V_CAB_PRSNT | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
CPLD_BMC_M2_PRSN | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
CPU_PROCHOT      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
FAN_BRD_CABLE    | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
FAN_P54V_CABLE   | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
HSBP_CABLE       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
NCSI_PRSNT       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_ALL_FAN       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P3V3_STBY_HSB | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P3V3_STBY_U2  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_DDR_ABD  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_DDR_EFH  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE0      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE1      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE2      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_00_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_01_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_02_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_03_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
THERMTRIP        | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
...

:~# busctl tree xyz.openbmc_project.GPIOStatus
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/inventory
      `- /xyz/openbmc_project/inventory/item
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT0_PRS
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT1_PRS
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT2_PRS
        |- /xyz/openbmc_project/inventory/item/BP_12V_CAB_PRSNT
        |- /xyz/openbmc_project/inventory/item/CPLD_BMC_M2_PRSN
        |- /xyz/openbmc_project/inventory/item/CPU_PROCHOT
        |- /xyz/openbmc_project/inventory/item/FAN_BRD_CABLE
        |- /xyz/openbmc_project/inventory/item/FAN_P54V_CABLE
        |- /xyz/openbmc_project/inventory/item/HSBP_CABLE
        |- /xyz/openbmc_project/inventory/item/NCSI_PRSNT
        |- /xyz/openbmc_project/inventory/item/PG_ALL_FAN
        |- /xyz/openbmc_project/inventory/item/PG_P12V_DDR_ABD
        |- /xyz/openbmc_project/inventory/item/PG_P12V_DDR_EFH
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE0
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE1
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE2
        |- /xyz/openbmc_project/inventory/item/PG_P3V3_STBY_HSBP
        |- /xyz/openbmc_project/inventory/item/PG_P3V3_STBY_U2
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_00_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_01_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_02_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_03_CABLE
        `- /xyz/openbmc_project/inventory/item/THERMTRIP
:~# cp /usr/share/entity-manager/configurations/mobo.json mobo.json.bak
:~# rm -r /usr/share/entity-manager/configurations/mobo.json
:~# ipmitool power cycle
Chassis Power Control: Cycle
:~# cp mobo.json.bak /usr/share/entity-manager/configurations/mobo.json
:~# ipmitool power cycle
Chassis Power Control: Cycle
:~# ipmitool sensor list
BMC_P0_SLOT0_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BMC_P0_SLOT1_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BMC_P0_SLOT2_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BP_12V_CAB_PRSNT | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
CPLD_BMC_M2_PRSN | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
CPU_PROCHOT      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
FAN_BRD_CABLE    | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
FAN_P54V_CABLE   | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
HSBP_CABLE       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
NCSI_PRSNT       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_ALL_FAN       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P3V3_STBY_HSB | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P3V3_STBY_U2  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_DDR_ABD  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_DDR_EFH  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE0      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE1      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE2      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_00_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_01_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_02_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_03_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
THERMTRIP        | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
:~# busctl tree xyz.openbmc_project.GPIOStatus
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/inventory
      `- /xyz/openbmc_project/inventory/item
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT0_PRS
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT1_PRS
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT2_PRS
        |- /xyz/openbmc_project/inventory/item/BP_12V_CAB_PRSNT
        |- /xyz/openbmc_project/inventory/item/CPLD_BMC_M2_PRSN
        |- /xyz/openbmc_project/inventory/item/CPU_PROCHOT
        |- /xyz/openbmc_project/inventory/item/FAN_BRD_CABLE
        |- /xyz/openbmc_project/inventory/item/FAN_P54V_CABLE
        |- /xyz/openbmc_project/inventory/item/HSBP_CABLE
        |- /xyz/openbmc_project/inventory/item/NCSI_PRSNT
        |- /xyz/openbmc_project/inventory/item/PG_ALL_FAN
        |- /xyz/openbmc_project/inventory/item/PG_P12V_DDR_ABD
        |- /xyz/openbmc_project/inventory/item/PG_P12V_DDR_EFH
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE0
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE1
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE2
        |- /xyz/openbmc_project/inventory/item/PG_P3V3_STBY_HSBP
        |- /xyz/openbmc_project/inventory/item/PG_P3V3_STBY_U2
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_00_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_01_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_02_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_03_CABLE
        `- /xyz/openbmc_project/inventory/item/THERMTRIP

[Before this change]
:~# ipmitool sensor list
BMC_P0_SLOT0_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BMC_P0_SLOT1_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BMC_P0_SLOT2_PRS | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
BP_12V_CAB_PRSNT | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
CPLD_BMC_M2_PRSN | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
CPU_PROCHOT      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
FAN_BRD_CABLE    | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
FAN_P54V_CABLE   | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
HSBP_CABLE       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
NCSI_PRSNT       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_ALL_FAN       | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P3V3_STBY_HSB | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P3V3_STBY_U2  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_DDR_ABD  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_DDR_EFH  | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE0      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE1      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
PG_P12V_PE2      | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_00_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_01_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_02_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
SLIMSAS_03_CABLE | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
THERMTRIP        | 0x0        | discrete   | 0x0100| na        | na        | na        | na        | na        | na
...
:~# busctl tree xyz.openbmc_project.GPIOStatus
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/inventory
      `- /xyz/openbmc_project/inventory/item
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT0_PRS
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT1_PRS
        |- /xyz/openbmc_project/inventory/item/BMC_P0_SLOT2_PRS
        |- /xyz/openbmc_project/inventory/item/BP_12V_CAB_PRSNT
        |- /xyz/openbmc_project/inventory/item/CPLD_BMC_M2_PRSN
        |- /xyz/openbmc_project/inventory/item/CPU_PROCHOT
        |- /xyz/openbmc_project/inventory/item/FAN_BRD_CABLE
        |- /xyz/openbmc_project/inventory/item/FAN_P54V_CABLE
        |- /xyz/openbmc_project/inventory/item/HSBP_CABLE
        |- /xyz/openbmc_project/inventory/item/NCSI_PRSNT
        |- /xyz/openbmc_project/inventory/item/PG_ALL_FAN
        |- /xyz/openbmc_project/inventory/item/PG_P12V_DDR_ABD
        |- /xyz/openbmc_project/inventory/item/PG_P12V_DDR_EFH
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE0
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE1
        |- /xyz/openbmc_project/inventory/item/PG_P12V_PE2
        |- /xyz/openbmc_project/inventory/item/PG_P3V3_STBY_HSBP
        |- /xyz/openbmc_project/inventory/item/PG_P3V3_STBY_U2
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_00_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_01_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_02_CABLE
        |- /xyz/openbmc_project/inventory/item/SLIMSAS_03_CABLE
        `- /xyz/openbmc_project/inventory/item/THERMTRIP
:~# cp /usr/share/entity-manager/configurations/mobo.json mobo.json.bak
:~# rm -r /usr/share/entity-manager/configurations/mobo.json
:~# ipmitool power cycle
Chassis Power Control: Cycle
:~# cp mobo.json.bak /usr/share/entity-manager/configurations/mobo.json
:~# ipmitool power cycle
Chassis Power Control: Cycle
:~# ipmitool sensor list
BMC_P0_SLOT0_PRS | na         | discrete   | na    | na        | na        | na        | na        | na        | na
BMC_P0_SLOT1_PRS | na         | discrete   | na    | na        | na        | na        | na        | na        | na
BMC_P0_SLOT2_PRS | na         | discrete   | na    | na        | na        | na        | na        | na        | na
BP_12V_CAB_PRSNT | na         | discrete   | na    | na        | na        | na        | na        | na        | na
CPLD_BMC_M2_PRSN | na         | discrete   | na    | na        | na        | na        | na        | na        | na
CPU_PROCHOT      | na         | discrete   | na    | na        | na        | na        | na        | na        | na
FAN_BRD_CABLE    | na         | discrete   | na    | na        | na        | na        | na        | na        | na
FAN_P54V_CABLE   | na         | discrete   | na    | na        | na        | na        | na        | na        | na
HSBP_CABLE       | na         | discrete   | na    | na        | na        | na        | na        | na        | na
NCSI_PRSNT       | na         | discrete   | na    | na        | na        | na        | na        | na        | na
PG_ALL_FAN       | na         | discrete   | na    | na        | na        | na        | na        | na        | na
PG_P3V3_STBY_HSB | na         | discrete   | na    | na        | na        | na        | na        | na        | na
PG_P3V3_STBY_U2  | na         | discrete   | na    | na        | na        | na        | na        | na        | na
PG_P12V_DDR_ABD  | na         | discrete   | na    | na        | na        | na        | na        | na        | na
PG_P12V_DDR_EFH  | na         | discrete   | na    | na        | na        | na        | na        | na        | na
PG_P12V_PE0      | na         | discrete   | na    | na        | na        | na        | na        | na        | na
PG_P12V_PE1      | na         | discrete   | na    | na        | na        | na        | na        | na        | na
PG_P12V_PE2      | na         | discrete   | na    | na        | na        | na        | na        | na        | na
SLIMSAS_00_CABLE | na         | discrete   | na    | na        | na        | na        | na        | na        | na
SLIMSAS_01_CABLE | na         | discrete   | na    | na        | na        | na        | na        | na        | na
SLIMSAS_02_CABLE | na         | discrete   | na    | na        | na        | na        | na        | na        | na
SLIMSAS_03_CABLE | na         | discrete   | na    | na        | na        | na        | na        | na        | na
THERMTRIP        | na         | discrete   | na    | na        | na        | na        | na        | na        | na
...
:~# busctl tree xyz.openbmc_project.GPIOStatus
Only root object discovered.

Fusion-Link:
platform5: https://fusion2.corp.google.com/6892e471-137d-3958-86e0-b0060d895eb6
platform15: https://fusion2.corp.google.com/dbfae27e-b364-30f4-b47e-0a7cb12c2c2c
platform18: https://fusion2.corp.google.com/bd1ca786-08d5-37a0-a38b-21dff73a4dd8
platform17: https://fusion2.corp.google.com/408db29e-ac3e-32b6-b544-4d82cbfef12f
platform11+ext: https://fusion2.corp.google.com/e712c5fd-99af-3677-8bc3-98ecfd2d95bd
platform11: https://fusion2.corp.google.com/79a535aa-2e11-3c96-93ad-aba145035c57

Platforms-Affected: All
Google-Bug-Id: 489214332
Change-Id: I1c2c253df4a8a5a217aa1ce09e4e6a89fc5b7e29
Signed-off-by: Brian Chiang <chiang.brian@inventec.corp-partner.google.com>
diff --git a/recipes-phosphor/sensors/dbus-sensors/0015-dbus-sensors-gpiosensor-Publish-interface-after-the-.patch b/recipes-phosphor/sensors/dbus-sensors/0015-dbus-sensors-gpiosensor-Publish-interface-after-the-.patch
index 02090fb..edf57c6 100644
--- a/recipes-phosphor/sensors/dbus-sensors/0015-dbus-sensors-gpiosensor-Publish-interface-after-the-.patch
+++ b/recipes-phosphor/sensors/dbus-sensors/0015-dbus-sensors-gpiosensor-Publish-interface-after-the-.patch
@@ -1,4 +1,4 @@
-From 2bb8422abbe1cb5b49d4381410621f01d101f147 Mon Sep 17 00:00:00 2001
+From 20d2d7819bb4afe4f3ff19eb5710c3bc321b52f5 Mon Sep 17 00:00:00 2001
 From: Brian Chiang <chiang.brian@inventec.com>
 Date: Fri, 26 Sep 2025 10:08:15 +0800
 Subject: [PATCH] dbus-sensors: gpiosensor: Publish interface after the Present
@@ -96,58 +96,98 @@
 Google-Bug-Id: 441433977
 Signed-off-by: Brian Chiang <chiang.brian@inventec.corp-partner.google.com>
 ---
- include/GPIOPresenceSensor.hpp |  1 +
- src/GPIOPresenceSensor.cpp     | 16 ++++++++++++++--
+ include/GPIOPresenceSensor.hpp | 35 +++++++++++++++++++++++++++++++++-
+ src/GPIOPresenceSensor.cpp     | 16 ++++++++++++----
  src/GPIOPresenceSensorMain.cpp |  3 ---
- 3 files changed, 15 insertions(+), 5 deletions(-)
+ 3 files changed, 46 insertions(+), 8 deletions(-)
 
 diff --git a/include/GPIOPresenceSensor.hpp b/include/GPIOPresenceSensor.hpp
-index 5b74adb..286b1c5 100644
+index fa32a20..7cfe3a6 100644
 --- a/include/GPIOPresenceSensor.hpp
 +++ b/include/GPIOPresenceSensor.hpp
-@@ -124,6 +124,7 @@ class GPIOPresence
-     std::unordered_map<std::string, ::gpiod::line> gpioLines;
-     // default polling rate.
-     int pollRate;
-+    bool initialized = false;
- };
+@@ -102,9 +102,42 @@ class GPIOPresence
+   private:
+     struct ObjIfaces
+     {
+-        std::unique_ptr<sdbusplus::asio::dbus_interface> statusIfc;
++        ObjIfaces(
++            std::unique_ptr<sdbusplus::asio::dbus_interface> statusIfc,
++            std::unique_ptr<sdbusplus::asio::dbus_interface> associationIfc,
++            const Config& config) :
++            associationIfc(std::move(associationIfc)), config(config),
++            statusIfc(std::move(statusIfc))
++        {}
++
++        // Must be called before updatePresent().
++        void initializeStatusIfc(bool present)
++        {
++            statusIfc->register_property(Properties::propertyPresent,
++                                         present);
++            statusIfc->initialize();
++            statusIfcInitialized = true;
++        }
++
++        // initializeStatusIfc() must be called first.
++        void updatePresent(bool present)
++        {
++            statusIfc->set_property(Properties::propertyPresent, present);
++        }
++
++        bool isStatusIfcInitialized() const
++        {
++            return statusIfcInitialized;
++        }
++
+         std::unique_ptr<sdbusplus::asio::dbus_interface> associationIfc;
+         Config config;
++
++      private:
++        std::unique_ptr<sdbusplus::asio::dbus_interface> statusIfc;
++        // Flag to indicate if the interface is initialized and present
++        // property is set.
++        bool statusIfcInitialized = false;
+     };
  
- } // namespace gpiopresencesensing
+     void addInputLine(std::string_view lineLabel);
 diff --git a/src/GPIOPresenceSensor.cpp b/src/GPIOPresenceSensor.cpp
-index 3061590..82b08cf 100644
+index 2d48491..cf7e043 100644
 --- a/src/GPIOPresenceSensor.cpp
 +++ b/src/GPIOPresenceSensor.cpp
-@@ -108,11 +108,23 @@ void GPIOPresence::startUpdateLoop(bool forceUpdate)
+@@ -30,8 +30,10 @@ void GPIOPresence::addObj(
+     std::string_view objPath, const Config& config)
+ {
+     std::cerr << "New objPath added " << objPath << std::endl;
+-    objIfaces[std::string(objPath)] = {std::move(statusIfc),
+-                                       std::move(associationIfc), config};
++    auto [it, inserted] = objIfaces.emplace(std::string(objPath),
++                      ObjIfaces(std::move(statusIfc),
++                                std::move(associationIfc), config));
++    assert(inserted);
+ }
+ 
+ void GPIOPresence::removeObj(std::string_view objPath)
+@@ -96,8 +98,14 @@ void GPIOPresence::startUpdateLoop(bool forceUpdate)
                  std::cout << "Cable " << config.name << " change state to "
                            << (present ? "connected" : "disconnected")
                            << std::endl;
 -                obj.second.statusIfc->set_property(
 -                    gpiopresencesensing::Properties::propertyPresent, present);
-+                if(!initialized)
++                if (!obj.second.isStatusIfcInitialized())
 +                {
-+                    obj.second.statusIfc->register_property(
-+                        gpiopresencesensing::Properties::propertyPresent, present);
-+                    obj.second.statusIfc->initialize();
++                    obj.second.initializeStatusIfc(present);
 +                }
 +                else
 +                {
-+                    obj.second.statusIfc->set_property(
-+                        gpiopresencesensing::Properties::propertyPresent, present);
++                    obj.second.updatePresent(present);
 +                }
                  config.present = present;
              }
          }
-+        // By this time the interface should already be created because of the
-+        // forceUpdate = true from the main.
-+        initialized = true;
-         startUpdateLoop(/*forceUpdate=*/false);
-     });
- }
 diff --git a/src/GPIOPresenceSensorMain.cpp b/src/GPIOPresenceSensorMain.cpp
-index f3e81b2..a6741f8 100644
+index 576f3c0..5c2848e 100644
 --- a/src/GPIOPresenceSensorMain.cpp
 +++ b/src/GPIOPresenceSensorMain.cpp
-@@ -265,10 +265,7 @@ int main()
+@@ -247,10 +247,7 @@ int main()
              objPath, gpiopresencesensing::interfaces::statusIfc);
          std::cout << "Adding status interface: " << config.name
                    << " at path: " << objPath.str << std::endl;