Skip to content

Commit

Permalink
[Tizen] Add system info module to check platform properties (#26325)
Browse files Browse the repository at this point in the history
* [Tizen] Add system info module to check platform properties

* change to integer type from double

---------

Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
  • Loading branch information
wootak-jung authored and pull[bot] committed Feb 17, 2024
1 parent 493fa6c commit 3427040
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 3 deletions.
5 changes: 5 additions & 0 deletions config/tizen/chip-gn/platform/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ pkg_config("glib") {
]
}

pkg_config("capi-system-info") {
packages = [ "capi-system-info" ]
}

if (chip_mdns == "platform") {
pkg_config("nsd-dns-sd") {
packages = [ "nsd-dns-sd" ]
Expand Down Expand Up @@ -64,6 +68,7 @@ source_set("tizen") {
":dlog",
":glib",
":capi-appfw-preference",
":capi-system-info",
]

if (chip_mdns == "platform") {
Expand Down
17 changes: 14 additions & 3 deletions src/platform/Tizen/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

#include "CHIPDevicePlatformEvent.h"
#include "ChipDeviceScanner.h"
#include "SystemInfo.h"

namespace chip {
namespace DeviceLayer {
Expand Down Expand Up @@ -619,6 +620,7 @@ int BLEManagerImpl::StartBLEAdvertising()
Ble::ChipBLEDeviceIdentificationInfo deviceIdInfo = {
0x0,
};
PlatformVersion version;

if (sInstance.mAdvReqInProgress)
{
Expand Down Expand Up @@ -667,9 +669,18 @@ int BLEManagerImpl::StartBLEAdvertising()
VerifyOrExit(ret == BT_ERROR_NONE,
ChipLogError(DeviceLayer, "bt_adapter_le_add_advertising_service_data() failed. ret: %d", ret));

ret = bt_adapter_le_set_advertising_flags(
mAdvertiser, BT_ADAPTER_LE_ADVERTISING_FLAGS_GEN_DISC | BT_ADAPTER_LE_ADVERTISING_FLAGS_BREDR_UNSUP);
VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_adapter_le_set_advertising_flags() failed. ret: %d", ret));
err = SystemInfo::GetPlatformVersion(version);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(DeviceLayer, "GetPlatformVersion() failed. %s", ErrorStr(err)));
if (version.mMajor >= 7 && version.mMinor >= 5)
{
ret = bt_adapter_le_set_advertising_flags(
mAdvertiser, BT_ADAPTER_LE_ADVERTISING_FLAGS_GEN_DISC | BT_ADAPTER_LE_ADVERTISING_FLAGS_BREDR_UNSUP);
VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_adapter_le_set_advertising_flags() failed. ret: %d", ret));
}
else
{
ChipLogProgress(DeviceLayer, "setting function of advertising flags is available from tizen 7.5 or later");
}

ret = bt_adapter_le_set_advertising_device_name(mAdvertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, true);
VerifyOrExit(ret == BT_ERROR_NONE,
Expand Down
2 changes: 2 additions & 0 deletions src/platform/Tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ static_library("Tizen") {
"PlatformManagerImpl.h",
"PosixConfig.cpp",
"PosixConfig.h",
"SystemInfo.cpp",
"SystemInfo.h",
"SystemPlatformConfig.h",
"SystemTimeSupport.cpp",
]
Expand Down
5 changes: 5 additions & 0 deletions src/platform/Tizen/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <platform/Tizen/DeviceInstanceInfoProviderImpl.h>

#include "PosixConfig.h"
#include "SystemInfo.h"
#include "platform/internal/GenericPlatformManagerImpl.h"
#include "platform/internal/GenericPlatformManagerImpl.ipp"
#include "platform/internal/GenericPlatformManagerImpl_POSIX.h"
Expand Down Expand Up @@ -119,6 +120,10 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()

mStartTime = System::SystemClock().GetMonotonicTimestamp();

Internal::PlatformVersion version;
ReturnErrorOnFailure(Internal::SystemInfo::GetPlatformVersion(version));
ChipLogProgress(DeviceLayer, "Tizen Version: %d.%d", version.mMajor, version.mMinor);

return CHIP_NO_ERROR;
}

Expand Down
62 changes: 62 additions & 0 deletions src/platform/Tizen/SystemInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "SystemInfo.h"

#include <iostream>

#include <system_info.h>
#include <tizen.h>

#include <lib/support/logging/CHIPLogging.h>

using namespace std;

namespace chip {
namespace DeviceLayer {
namespace Internal {

SystemInfo SystemInfo::sInstance;

CHIP_ERROR SystemInfo::GetPlatformVersion(PlatformVersion & version)
{
char * platformVersion;
int ret;

if (sInstance.mMajor > 0)
{
version.mMajor = sInstance.mMajor;
version.mMinor = sInstance.mMinor;
return CHIP_NO_ERROR;
}

ret = system_info_get_platform_string("http://tizen.org/feature/platform.version", &platformVersion);
if (ret != SYSTEM_INFO_ERROR_NONE)
{
ChipLogError(DeviceLayer, "system_info_get_platform_string() failed. %s", get_error_message(ret));
return CHIP_ERROR_INTERNAL;
}

sInstance.mMajor = version.mMajor = (uint8_t)(platformVersion[0] - '0');
sInstance.mMinor = version.mMinor = (uint8_t)(platformVersion[2] - '0');
free(platformVersion);
return CHIP_NO_ERROR;
}

} // namespace Internal
} // namespace DeviceLayer
} // namespace chip
46 changes: 46 additions & 0 deletions src/platform/Tizen/SystemInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

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

namespace chip {
namespace DeviceLayer {
namespace Internal {

struct PlatformVersion
{
uint8_t mMajor;
uint8_t mMinor;
};

class SystemInfo
{
public:
static CHIP_ERROR GetPlatformVersion(PlatformVersion & version);

private:
static SystemInfo sInstance;
uint8_t mMajor = 0;
uint8_t mMinor = 0;
};

} // namespace Internal
} // namespace DeviceLayer
} // namespace chip

0 comments on commit 3427040

Please sign in to comment.