Skip to content

Commit

Permalink
TSBM-278 Implemented configurationinformationprovider.
Browse files Browse the repository at this point in the history
This provides information from the build environemnt of the SmartBridge.
  • Loading branch information
n-nievergeld committed Aug 14, 2024
1 parent 51b6a6f commit e8411a6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 42 deletions.
2 changes: 0 additions & 2 deletions src/platform/renesas/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ static_library("renesas") {
"RenesasConfig.h",
"ConfigurationManagerImpl.cpp",
"ConfigurationManagerImpl.h",
"ConfigurationManagerNetif.cpp",
"ConfigurationManagerNetif.h",
"ConnectivityManagerImpl.cpp",
"ConnectivityManagerImpl.h",
"DiagnosticDataProviderImpl.cpp",
Expand Down
44 changes: 33 additions & 11 deletions src/platform/renesas/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance()
return sInstance;
}

ConfigurationManagerImpl::ConfigurationManagerImpl()
: m_provider(nullptr)
{ }

CHIP_ERROR ConfigurationManagerImpl::Init()
{
CHIP_ERROR err;
Expand Down Expand Up @@ -127,11 +131,6 @@ CHIP_ERROR ConfigurationManagerImpl::StoreBootReason(uint32_t bootReason)
return WriteConfigValue(RenesasConfig::kConfigKey_BootReason, bootReason);
}

void ConfigurationManagerImpl::RegisterNetif(struct netif* netif)
{
m_netif = netif;
}

bool ConfigurationManagerImpl::CanFactoryReset(void)
{
// Implement InitiateFactoryReset first before enabling
Expand Down Expand Up @@ -224,19 +223,42 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
// Implement factory reset
}

ConfigurationManager & ConfigurationMgrImpl()
void ConfigurationManagerImpl::RegisterInformationProvider(ConfigurationInformationProvider& provider)
{
return ConfigurationManagerImpl::GetDefaultInstance();
assert(m_provider == nullptr);
m_provider = &provider;
}

CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf)
{
if (m_netif != nullptr && buf != nullptr)
if (m_provider != nullptr)
{
memcpy(buf, m_netif->hwaddr, m_netif->hwaddr_len);
return CHIP_NO_ERROR;
return m_provider->GetMacAddress(buf);
}
return CHIP_ERROR_INTERNAL;
}

CHIP_ERROR ConfigurationManagerImpl::GetSoftwareVersion(uint32_t & softwareVer)
{
if (m_provider != nullptr)
{
return m_provider->GetSoftwareVersion(softwareVer);
}
return CHIP_ERROR_INTERNAL;
}

CHIP_ERROR ConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize)
{
if (m_provider != nullptr)
{
return m_provider->GetSoftwareVersionString(buf, bufSize);
}
return CHIP_ERROR_NOT_IMPLEMENTED;
return CHIP_ERROR_INTERNAL;
}

ConfigurationManager & ConfigurationMgrImpl()
{
return ConfigurationManagerImpl::GetDefaultInstance();
}

} // namespace DeviceLayer
Expand Down
11 changes: 6 additions & 5 deletions src/platform/renesas/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma once

#include <platform/internal/GenericConfigurationManagerImpl.h>
#include "ConfigurationInformationProvider.h"

#include "RenesasConfig.h"
struct netif;
Expand All @@ -44,12 +45,12 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
CHIP_ERROR StoreBootReason(uint32_t bootReason) override;
CHIP_ERROR GetCountryCode(char * buf, size_t bufSize, size_t & codeLen) override;
CHIP_ERROR StoreCountryCode(const char * code, size_t codeLen) override;
void RegisterNetif(struct netif* netif);

CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override;

CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override;
CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize) override;
void RegisterInformationProvider(ConfigurationInformationProvider& provider);
private:

ConfigurationManagerImpl();
CHIP_ERROR Init(void) override;
bool CanFactoryReset(void) override;
void InitiateFactoryReset(void) override;
Expand All @@ -72,7 +73,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp

static void DoFactoryReset(intptr_t arg);

struct netif* m_netif;
ConfigurationInformationProvider* m_provider;
};

/**
Expand Down
12 changes: 0 additions & 12 deletions src/platform/renesas/ConfigurationManagerNetif.cpp

This file was deleted.

12 changes: 0 additions & 12 deletions src/platform/renesas/ConfigurationManagerNetif.h

This file was deleted.

0 comments on commit e8411a6

Please sign in to comment.