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

Sync csa branch with main #270

Merged
merged 15 commits into from
Feb 6, 2025
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
11 changes: 6 additions & 5 deletions .github/workflows/examples-nrfconnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,12 @@ jobs:
nrfconnect nrf7002dk_nrf5340_cpuapp all-clusters-app \
examples/all-clusters-app/nrfconnect/build/nrfconnect/zephyr/zephyr.elf \
/tmp/bloat_reports/
# Disable native build until next release
# - name: Run unit tests for Zephyr native_posix_64 platform
# if: github.event_name == 'push' || steps.changed_paths.outputs.tests == 'true' || steps.changed_paths.outputs.nrfconnect == 'true'
# run: |
# scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target nrf-native-posix-64-tests build"
- name: Run unit tests for Zephyr native_posix_64 platform
if: github.event_name == 'push' || steps.changed_paths.outputs.tests == 'true' || steps.changed_paths.outputs.nrfconnect == 'true'
run: |
# Temporarily fix link issue
sed -i '151s/<LINK_FLAGS> //' /opt/NordicSemiconductor/nrfconnect/zephyr/cmake/linker/ld/target.cmake
scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target nrf-native-posix-64-tests build"
- name: Uploading Failed Test Logs
uses: actions/upload-artifact@v4
if: ${{ failure() && !env.ACT }}
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
platforms = mw320
[submodule "third_party/silabs/matter_support"]
path = third_party/silabs/matter_support
url = https://github.com/SiliconLabs/sdk_support.git
url = https://github.com/SiliconLabsSoftware/matter_support.git
branch = main
platforms = silabs,silabs_docker
[submodule "third_party/silabs/simplicity_sdk"]
Expand Down
47 changes: 35 additions & 12 deletions docs/platforms/android/android_building.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ There are following Apps on Android
- [Linux](#linux)
- [MacOS](#macos)
- [ABIs and TARGET_CPU](#abis-and-target_cpu)
- [Gradle & JDK Version](#gradle--jdk-version)
- [Gradle \& JDK Version](#gradle--jdk-version)
- [Kotlin Version](#kotlin-version)
- [Preparing for build](#preparing-for-build)
- [Building Android CHIPTool from scripts](#building-android-chiptool-from-scripts)
- [Building Android CHIPTool from Android Studio](#building-android-chiptool-from-android-studio)
Expand All @@ -45,7 +46,7 @@ directory.
You need Android SDK 26 & NDK 23.2.8568313 downloaded to your machine. Set the
`$ANDROID_HOME` environment variable to where the SDK is downloaded and the
`$ANDROID_NDK_HOME` environment variable to point to where the NDK package is
downloaded. The build also requires `kotlinc` to be in your `$PATH`.
downloaded.

1. Install [Android Studio](https://developer.android.com/studio)
2. Install NDK:
Expand Down Expand Up @@ -97,22 +98,44 @@ architecture:

### Gradle & JDK Version

We are using Gradle 7.1.1 for all android project which does not support Java 17
(https://docs.gradle.org/current/userguide/compatibility.html) while the default
JDK version on MacOS for Apple Silicon is 'openjdk 17.0.1' or above.
All Android projects utilize Gradle version 7.3.3 and JDK version 17.0.

Using JDK bundled with Android Studio will help with that.
For developer using openjdk-17-jdk in MacOS, the JAVA_HOME environment variable
can be configured as follows via `sdkman`:

Android Studio Dolphin and below:
```
sdk install java 17.0.4.1-tem
```

For developer using openjdk-17-jdk in Linux, the JAVA_HOME environment variable
can be configured as follows:

```shell
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home/
```
sudo apt-get install openjdk-17-jdk
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
```

Android Studio Electric Eel 2022.1.1 and above:
<a name="kotlin"></a>

```shell
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home/
### Kotlin Version

The build requires `kotlinc` to be in your `$PATH`.

For Linux:

```
cd /usr/lib
wget -q https://github.com/JetBrains/kotlin/releases/download/v2.1.10/kotlin-compiler-2.1.10.zip
unzip kotlin-compiler-*.zip
rm kotlin-compiler-*.zip
rm -f kotlinc/bin/*.bat
export PATH=$PATH:/usr/lib/kotlinc/bin
```

For MacOS:

```
sdk install kotlin 2.1.10
```

<hr>
Expand Down
4 changes: 4 additions & 0 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ config("config") {
defines += [ "CONFIG_USE_LOCAL_STORAGE" ]
}

if (config_enable_https_requests) {
defines += [ "CONFIG_ENABLE_HTTPS_REQUESTS" ]
}

cflags = [ "-Wconversion" ]
}

Expand Down
1 change: 1 addition & 0 deletions examples/chip-tool/chip-tool.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ declare_args() {
config_use_interactive_mode = true
config_enable_yaml_tests = true
config_use_local_storage = true
config_enable_https_requests = true
}
94 changes: 75 additions & 19 deletions examples/chip-tool/commands/dcl/HTTPSRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <lib/support/logging/CHIPLogging.h>
#include <system/SystemError.h>

#ifdef CONFIG_ENABLE_HTTPS_REQUESTS
#if (CHIP_CRYPTO_OPENSSL || CHIP_CRYPTO_BORINGSSL)
#include <netdb.h>
#include <openssl/ssl.h>
Expand All @@ -36,6 +37,7 @@
#define USE_CHIP_CRYPTO 1
#endif
#endif //(CHIP_CRYPTO_OPENSSL || CHIP_CRYPTO_BORINGSSL)
#endif // CONFIG_ENABLE_HTTPS_REQUESTS

namespace {
constexpr const char * kHttpsPrefix = "https://";
Expand Down Expand Up @@ -71,9 +73,18 @@ class HTTPSSessionHolder
private:
CHIP_ERROR LogNotImplementedError() const
{
#ifndef CONFIG_ENABLE_HTTPS_REQUESTS
ChipLogError(chipTool, "HTTPS requests are disabled via build configuration (config_enable_https_requests=false).");
#elif !(CHIP_CRYPTO_OPENSSL || CHIP_CRYPTO_BORINGSSL)
ChipLogError(chipTool,
"HTTPS requests are not available because neither OpenSSL nor BoringSSL is enabled. Contributions for "
"alternative implementations are welcome!");
#elif !defined(SHA256_DIGEST_LENGTH)
ChipLogError(chipTool,
"HTTPS requests are not available because SHA256_DIGEST_LENGTH is not defined, meaning response integrity "
"verification via SHA-256 digest checking cannot be performed.");
#endif

return CHIP_ERROR_NOT_IMPLEMENTED;
}
};
Expand All @@ -86,17 +97,55 @@ constexpr const char * kErrorSSLContextCreate = "Failed to create SSL context
constexpr const char * kErrorSSLObjectCreate = "Failed to create SSL object";
constexpr const char * kErrorSSLHandshake = "SSL handshake failed";
constexpr const char * kErrorDigestMismatch = "The response digest does not match the expected digest";
class AddressInfoHolder
{
public:
AddressInfoHolder(std::string & hostname, uint16_t port)
{
struct addrinfo hints = {};
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
int err = getaddrinfo(hostname.c_str(), std::to_string(port).c_str(), &hints, &mRes);
#if CHIP_ERROR_LOGGING
constexpr const char * kErrorGetAddressInfo = "Failed to get address info: ";
VerifyOrDo(nullptr != mRes, ChipLogError(chipTool, "%s%s", kErrorGetAddressInfo, gai_strerror(err)));
#else
(void) err;
#endif
}

~AddressInfoHolder()
{
if (mRes != nullptr)
{
freeaddrinfo(mRes);
}
}

bool HasInfo() const { return mRes != nullptr; }
struct addrinfo * Get() const { return mRes; }

private:
struct addrinfo * mRes = nullptr;
};

class HTTPSSessionHolder
{
public:
HTTPSSessionHolder(){};

~HTTPSSessionHolder()
{
VerifyOrReturn(nullptr != mContext);
SSL_free(mSSL);
SSL_CTX_free(mContext);
close(mSock);
if (nullptr != mContext)
{
SSL_free(mSSL);
SSL_CTX_free(mContext);
}

if (mSock >= 0)
{
close(mSock);
}

#if !defined(OPENSSL_IS_BORINGSSL)
EVP_cleanup();
Expand Down Expand Up @@ -137,23 +186,30 @@ class HTTPSSessionHolder
private:
CHIP_ERROR InitSocket(std::string & hostname, uint16_t port, int & sock)
{
auto * server = gethostbyname(hostname.c_str());
VerifyOrReturnError(nullptr != server, CHIP_ERROR_NOT_CONNECTED);

sock = socket(AF_INET, SOCK_STREAM, 0);
VerifyOrReturnError(sock >= 0, CHIP_ERROR_NOT_CONNECTED);

struct sockaddr_in server_addr;
memset(&server_addr, 0, sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
memcpy(&server_addr.sin_addr.s_addr, server->h_addr, (size_t) server->h_length);
AddressInfoHolder addressInfoHolder(hostname, port);
VerifyOrReturnError(addressInfoHolder.HasInfo(), CHIP_ERROR_NOT_CONNECTED);

int rv = connect(sock, (struct sockaddr *) &server_addr, sizeof(server_addr));
VerifyOrReturnError(rv >= 0, CHIP_ERROR_POSIX(errno),
ChipLogError(chipTool, "%s%s:%u", kErrorConnection, hostname.c_str(), port));
auto * res = addressInfoHolder.Get();
for (struct addrinfo * p = res; p != nullptr; p = p->ai_next)
{
sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
if (sock < 0)
{
continue; // Try the next address
}

if (connect(sock, p->ai_addr, p->ai_addrlen) != 0)
{
close(sock);
sock = -1;
continue; // Try the next address
}

return CHIP_NO_ERROR;
}

return CHIP_NO_ERROR;
ChipLogError(chipTool, "%s%s:%u", kErrorConnection, hostname.c_str(), port);
return CHIP_ERROR_NOT_CONNECTED;
}

CHIP_ERROR InitSSL(int sock)
Expand Down
4 changes: 4 additions & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ executable("darwin-framework-tool") {
"${chip_root}/examples/chip-tool/commands/common/Commands.cpp",
"${chip_root}/examples/chip-tool/commands/common/Commands.h",
"${chip_root}/examples/chip-tool/commands/common/HexConversion.h",
"${chip_root}/examples/chip-tool/commands/dcl/DCLClient.cpp",
"${chip_root}/examples/chip-tool/commands/dcl/DisplayTermsAndConditions.cpp",
"${chip_root}/examples/chip-tool/commands/dcl/JsonSchemaMacros.cpp",
"${chip_root}/examples/common/websocket-server/WebSocketServer.cpp",
"${chip_root}/examples/common/websocket-server/WebSocketServer.h",
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
Expand Down Expand Up @@ -220,6 +223,7 @@ executable("darwin-framework-tool") {
"commands/configuration/ResetMRPParametersCommand.mm",
"commands/configuration/SetMRPParametersCommand.h",
"commands/configuration/SetMRPParametersCommand.mm",
"commands/dcl/HTTPSRequest.mm",
"commands/delay/Commands.h",
"commands/delay/SleepCommand.h",
"commands/delay/SleepCommand.mm",
Expand Down
Loading
Loading