Skip to content

Commit 8cc2cf7

Browse files
Sync csa branch with main (#270)
2 parents aedb39b + 48fc426 commit 8cc2cf7

File tree

84 files changed

+1796
-1328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1796
-1328
lines changed

.github/workflows/examples-nrfconnect.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,12 @@ jobs:
193193
nrfconnect nrf7002dk_nrf5340_cpuapp all-clusters-app \
194194
examples/all-clusters-app/nrfconnect/build/nrfconnect/zephyr/zephyr.elf \
195195
/tmp/bloat_reports/
196-
# Disable native build until next release
197-
# - name: Run unit tests for Zephyr native_posix_64 platform
198-
# if: github.event_name == 'push' || steps.changed_paths.outputs.tests == 'true' || steps.changed_paths.outputs.nrfconnect == 'true'
199-
# run: |
200-
# scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target nrf-native-posix-64-tests build"
196+
- name: Run unit tests for Zephyr native_posix_64 platform
197+
if: github.event_name == 'push' || steps.changed_paths.outputs.tests == 'true' || steps.changed_paths.outputs.nrfconnect == 'true'
198+
run: |
199+
# Temporarily fix link issue
200+
sed -i '151s/<LINK_FLAGS> //' /opt/NordicSemiconductor/nrfconnect/zephyr/cmake/linker/ld/target.cmake
201+
scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target nrf-native-posix-64-tests build"
201202
- name: Uploading Failed Test Logs
202203
uses: actions/upload-artifact@v4
203204
if: ${{ failure() && !env.ACT }}

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
platforms = mw320
208208
[submodule "third_party/silabs/matter_support"]
209209
path = third_party/silabs/matter_support
210-
url = https://github.com/SiliconLabs/sdk_support.git
210+
url = https://github.com/SiliconLabsSoftware/matter_support.git
211211
branch = main
212212
platforms = silabs,silabs_docker
213213
[submodule "third_party/silabs/simplicity_sdk"]

docs/platforms/android/android_building.md

+35-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ There are following Apps on Android
2121
- [Linux](#linux)
2222
- [MacOS](#macos)
2323
- [ABIs and TARGET_CPU](#abis-and-target_cpu)
24-
- [Gradle & JDK Version](#gradle--jdk-version)
24+
- [Gradle \& JDK Version](#gradle--jdk-version)
25+
- [Kotlin Version](#kotlin-version)
2526
- [Preparing for build](#preparing-for-build)
2627
- [Building Android CHIPTool from scripts](#building-android-chiptool-from-scripts)
2728
- [Building Android CHIPTool from Android Studio](#building-android-chiptool-from-android-studio)
@@ -45,7 +46,7 @@ directory.
4546
You need Android SDK 26 & NDK 23.2.8568313 downloaded to your machine. Set the
4647
`$ANDROID_HOME` environment variable to where the SDK is downloaded and the
4748
`$ANDROID_NDK_HOME` environment variable to point to where the NDK package is
48-
downloaded. The build also requires `kotlinc` to be in your `$PATH`.
49+
downloaded.
4950

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

9899
### Gradle & JDK Version
99100

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

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

106-
Android Studio Dolphin and below:
106+
```
107+
sdk install java 17.0.4.1-tem
108+
```
109+
110+
For developer using openjdk-17-jdk in Linux, the JAVA_HOME environment variable
111+
can be configured as follows:
107112

108-
```shell
109-
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home/
113+
```
114+
sudo apt-get install openjdk-17-jdk
115+
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
110116
```
111117

112-
Android Studio Electric Eel 2022.1.1 and above:
118+
<a name="kotlin"></a>
113119

114-
```shell
115-
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home/
120+
### Kotlin Version
121+
122+
The build requires `kotlinc` to be in your `$PATH`.
123+
124+
For Linux:
125+
126+
```
127+
cd /usr/lib
128+
wget -q https://github.com/JetBrains/kotlin/releases/download/v2.1.10/kotlin-compiler-2.1.10.zip
129+
unzip kotlin-compiler-*.zip
130+
rm kotlin-compiler-*.zip
131+
rm -f kotlinc/bin/*.bat
132+
export PATH=$PATH:/usr/lib/kotlinc/bin
133+
```
134+
135+
For MacOS:
136+
137+
```
138+
sdk install kotlin 2.1.10
116139
```
117140

118141
<hr>

examples/chip-tool/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ config("config") {
4747
defines += [ "CONFIG_USE_LOCAL_STORAGE" ]
4848
}
4949

50+
if (config_enable_https_requests) {
51+
defines += [ "CONFIG_ENABLE_HTTPS_REQUESTS" ]
52+
}
53+
5054
cflags = [ "-Wconversion" ]
5155
}
5256

examples/chip-tool/chip-tool.gni

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ declare_args() {
2121
config_use_interactive_mode = true
2222
config_enable_yaml_tests = true
2323
config_use_local_storage = true
24+
config_enable_https_requests = true
2425
}

examples/chip-tool/commands/dcl/HTTPSRequest.cpp

+75-19
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <lib/support/logging/CHIPLogging.h>
2929
#include <system/SystemError.h>
3030

31+
#ifdef CONFIG_ENABLE_HTTPS_REQUESTS
3132
#if (CHIP_CRYPTO_OPENSSL || CHIP_CRYPTO_BORINGSSL)
3233
#include <netdb.h>
3334
#include <openssl/ssl.h>
@@ -36,6 +37,7 @@
3637
#define USE_CHIP_CRYPTO 1
3738
#endif
3839
#endif //(CHIP_CRYPTO_OPENSSL || CHIP_CRYPTO_BORINGSSL)
40+
#endif // CONFIG_ENABLE_HTTPS_REQUESTS
3941

4042
namespace {
4143
constexpr const char * kHttpsPrefix = "https://";
@@ -71,9 +73,18 @@ class HTTPSSessionHolder
7173
private:
7274
CHIP_ERROR LogNotImplementedError() const
7375
{
76+
#ifndef CONFIG_ENABLE_HTTPS_REQUESTS
77+
ChipLogError(chipTool, "HTTPS requests are disabled via build configuration (config_enable_https_requests=false).");
78+
#elif !(CHIP_CRYPTO_OPENSSL || CHIP_CRYPTO_BORINGSSL)
7479
ChipLogError(chipTool,
7580
"HTTPS requests are not available because neither OpenSSL nor BoringSSL is enabled. Contributions for "
7681
"alternative implementations are welcome!");
82+
#elif !defined(SHA256_DIGEST_LENGTH)
83+
ChipLogError(chipTool,
84+
"HTTPS requests are not available because SHA256_DIGEST_LENGTH is not defined, meaning response integrity "
85+
"verification via SHA-256 digest checking cannot be performed.");
86+
#endif
87+
7788
return CHIP_ERROR_NOT_IMPLEMENTED;
7889
}
7990
};
@@ -86,17 +97,55 @@ constexpr const char * kErrorSSLContextCreate = "Failed to create SSL context
8697
constexpr const char * kErrorSSLObjectCreate = "Failed to create SSL object";
8798
constexpr const char * kErrorSSLHandshake = "SSL handshake failed";
8899
constexpr const char * kErrorDigestMismatch = "The response digest does not match the expected digest";
100+
class AddressInfoHolder
101+
{
102+
public:
103+
AddressInfoHolder(std::string & hostname, uint16_t port)
104+
{
105+
struct addrinfo hints = {};
106+
hints.ai_family = AF_INET;
107+
hints.ai_socktype = SOCK_STREAM;
108+
int err = getaddrinfo(hostname.c_str(), std::to_string(port).c_str(), &hints, &mRes);
109+
#if CHIP_ERROR_LOGGING
110+
constexpr const char * kErrorGetAddressInfo = "Failed to get address info: ";
111+
VerifyOrDo(nullptr != mRes, ChipLogError(chipTool, "%s%s", kErrorGetAddressInfo, gai_strerror(err)));
112+
#else
113+
(void) err;
114+
#endif
115+
}
116+
117+
~AddressInfoHolder()
118+
{
119+
if (mRes != nullptr)
120+
{
121+
freeaddrinfo(mRes);
122+
}
123+
}
124+
125+
bool HasInfo() const { return mRes != nullptr; }
126+
struct addrinfo * Get() const { return mRes; }
127+
128+
private:
129+
struct addrinfo * mRes = nullptr;
130+
};
131+
89132
class HTTPSSessionHolder
90133
{
91134
public:
92135
HTTPSSessionHolder(){};
93136

94137
~HTTPSSessionHolder()
95138
{
96-
VerifyOrReturn(nullptr != mContext);
97-
SSL_free(mSSL);
98-
SSL_CTX_free(mContext);
99-
close(mSock);
139+
if (nullptr != mContext)
140+
{
141+
SSL_free(mSSL);
142+
SSL_CTX_free(mContext);
143+
}
144+
145+
if (mSock >= 0)
146+
{
147+
close(mSock);
148+
}
100149

101150
#if !defined(OPENSSL_IS_BORINGSSL)
102151
EVP_cleanup();
@@ -137,23 +186,30 @@ class HTTPSSessionHolder
137186
private:
138187
CHIP_ERROR InitSocket(std::string & hostname, uint16_t port, int & sock)
139188
{
140-
auto * server = gethostbyname(hostname.c_str());
141-
VerifyOrReturnError(nullptr != server, CHIP_ERROR_NOT_CONNECTED);
142-
143-
sock = socket(AF_INET, SOCK_STREAM, 0);
144-
VerifyOrReturnError(sock >= 0, CHIP_ERROR_NOT_CONNECTED);
145-
146-
struct sockaddr_in server_addr;
147-
memset(&server_addr, 0, sizeof(server_addr));
148-
server_addr.sin_family = AF_INET;
149-
server_addr.sin_port = htons(port);
150-
memcpy(&server_addr.sin_addr.s_addr, server->h_addr, (size_t) server->h_length);
189+
AddressInfoHolder addressInfoHolder(hostname, port);
190+
VerifyOrReturnError(addressInfoHolder.HasInfo(), CHIP_ERROR_NOT_CONNECTED);
151191

152-
int rv = connect(sock, (struct sockaddr *) &server_addr, sizeof(server_addr));
153-
VerifyOrReturnError(rv >= 0, CHIP_ERROR_POSIX(errno),
154-
ChipLogError(chipTool, "%s%s:%u", kErrorConnection, hostname.c_str(), port));
192+
auto * res = addressInfoHolder.Get();
193+
for (struct addrinfo * p = res; p != nullptr; p = p->ai_next)
194+
{
195+
sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
196+
if (sock < 0)
197+
{
198+
continue; // Try the next address
199+
}
200+
201+
if (connect(sock, p->ai_addr, p->ai_addrlen) != 0)
202+
{
203+
close(sock);
204+
sock = -1;
205+
continue; // Try the next address
206+
}
207+
208+
return CHIP_NO_ERROR;
209+
}
155210

156-
return CHIP_NO_ERROR;
211+
ChipLogError(chipTool, "%s%s:%u", kErrorConnection, hostname.c_str(), port);
212+
return CHIP_ERROR_NOT_CONNECTED;
157213
}
158214

159215
CHIP_ERROR InitSSL(int sock)

examples/darwin-framework-tool/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ executable("darwin-framework-tool") {
189189
"${chip_root}/examples/chip-tool/commands/common/Commands.cpp",
190190
"${chip_root}/examples/chip-tool/commands/common/Commands.h",
191191
"${chip_root}/examples/chip-tool/commands/common/HexConversion.h",
192+
"${chip_root}/examples/chip-tool/commands/dcl/DCLClient.cpp",
193+
"${chip_root}/examples/chip-tool/commands/dcl/DisplayTermsAndConditions.cpp",
194+
"${chip_root}/examples/chip-tool/commands/dcl/JsonSchemaMacros.cpp",
192195
"${chip_root}/examples/common/websocket-server/WebSocketServer.cpp",
193196
"${chip_root}/examples/common/websocket-server/WebSocketServer.h",
194197
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
@@ -220,6 +223,7 @@ executable("darwin-framework-tool") {
220223
"commands/configuration/ResetMRPParametersCommand.mm",
221224
"commands/configuration/SetMRPParametersCommand.h",
222225
"commands/configuration/SetMRPParametersCommand.mm",
226+
"commands/dcl/HTTPSRequest.mm",
223227
"commands/delay/Commands.h",
224228
"commands/delay/SleepCommand.h",
225229
"commands/delay/SleepCommand.mm",

0 commit comments

Comments
 (0)