Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basicInformation deviceInfoprovider #17

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 25 additions & 0 deletions src/platform/renesas/ConfigurationInformationProvider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @copyright Copyright 2024, (C) Sensorfy B.V.
*/

#include <lib/core/CHIPError.h>
#include <cstdint>

#pragma once

namespace chip {
namespace DeviceLayer {

class ConfigurationInformationProvider
{
public:
virtual ~ConfigurationInformationProvider() = default;

virtual CHIP_ERROR GetMacAddress(uint8_t* mac) = 0;
virtual CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize) = 0;
virtual CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) = 0;

};

}
}
50 changes: 39 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 @@ -117,6 +121,12 @@ CHIP_ERROR ConfigurationManagerImpl::StoreCountryCode(const char * code, size_t
return err;
}

CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location)
{
location = to_underlying(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationTypeEnum::kIndoorOutdoor);
return CHIP_NO_ERROR;
}

CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason)
{
return ReadConfigValue(RenesasConfig::kConfigKey_BootReason, bootReason);
Expand All @@ -127,11 +137,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 +229,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_NOT_IMPLEMENTED;
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_INTERNAL;
}

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

} // namespace DeviceLayer
Expand Down
12 changes: 7 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,13 @@ 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 GetLocationCapability(uint8_t & location) override;
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 +74,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.