-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tizen] Add system info module to check platform properties (#26325)
* [Tizen] Add system info module to check platform properties * change to integer type from double --------- Signed-off-by: Wootak Jung <[email protected]>
- Loading branch information
1 parent
f9339cc
commit dbf2430
Showing
6 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |