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 #314

Merged
merged 13 commits into from
Mar 5, 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
1 change: 1 addition & 0 deletions .github/workflows/docker_img.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ jobs:
- "-nxp-zephyr"
- "-nrf-platform"
- "-telink"
- "-telink-zephyr_3_3"
- "-ti"
- "-tizen"
- "-openiotsdk"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zap_regeneration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
zap_regeneration:
name: ZAP Regeneration

runs-on: ubuntu-20.04
runs-on: ubuntu-latest
container:
image: ghcr.io/project-chip/chip-build:119
defaults:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zap_templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
zap_templates:
name: ZAP templates generation

runs-on: ubuntu-20.04
runs-on: ubuntu-latest
container:
image: ghcr.io/project-chip/chip-build:119
defaults:
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ stm32/ @STYoannZamaron

telink/ @s07641069
chip-build-telink/ @s07641069
chip-build-telink-zephyr_3_3/ @s07641069

webos/ @joonhaengHeo
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ be useful for quick filtering like `[TC-ABC-1.2]` to tag test changes.
Examples of descriptive titles:

- `[Silabs] Fix compile of SiWx917 if LED and BUTTON are disabled`
- `[Telink] Update build Dockerfile with new Zeprhy SHA: c05c4.....`
- `[Telink] Update build Dockerfile with new Zephyr SHA: c05c4.....`
- `General Commissioning Cluster: use AttributeAccessInterface/CommandHandlerInterface for processing`
- `Scenes Management/CopyScene: set access as manage instead of default to match the spec`
- `Fix build errors due to ChipDeviceEvent default constructor not being available`
Expand Down
1 change: 1 addition & 0 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ config HEAP_MEM_POOL_SIZE
config COMMON_LIBC_MALLOC_ARENA_SIZE
default 20716 if SOC_SERIES_RISCV_TELINK_B9X_RETENTION || (SOC_RISCV_TELINK_TL321X && ZEPHYR_VERSION_3_3)
default 16384 if SOC_RISCV_TELINK_TL721X || (SOC_RISCV_TELINK_TL321X && !ZEPHYR_VERSION_3_3)
default 13568 if SOC_RISCV_TELINK_W91
default 12288

config NET_IPV6_MLD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ using namespace chip::app::Clusters::Actions;
using namespace chip::app::Clusters::Actions::Attributes;
using namespace chip::Protocols::InteractionModel;

namespace {
std::unique_ptr<Clusters::Actions::ActionsDelegateImpl> sActionsDelegateImpl;
std::unique_ptr<Clusters::Actions::ActionsServer> sActionsServer;
} // namespace

CHIP_ERROR ActionsDelegateImpl::ReadActionAtIndex(uint16_t index, ActionStructStorage & action)
{
if (index >= kActionList.size())
Expand Down Expand Up @@ -129,3 +134,17 @@ Status ActionsDelegateImpl::HandleDisableActionWithDuration(uint16_t actionId, u
// Not implemented
return Status::NotFound;
}

void emberAfActionsClusterInitCallback(EndpointId endpoint)
{
VerifyOrReturn(endpoint == 1,
ChipLogError(Zcl, "Actions cluster delegate is not implemented for endpoint with id %d.", endpoint));
VerifyOrReturn(emberAfContainsServer(endpoint, Actions::Id) == true,
ChipLogError(Zcl, "Endpoint %d does not support Actions cluster.", endpoint));
VerifyOrReturn(!sActionsDelegateImpl && !sActionsServer);

sActionsDelegateImpl = std::make_unique<Actions::ActionsDelegateImpl>();
sActionsServer = std::make_unique<Actions::ActionsServer>(endpoint, *sActionsDelegateImpl.get());

sActionsServer->Init();
}
8 changes: 0 additions & 8 deletions examples/all-clusters-app/linux/main-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
#include <bridged-actions-stub.h>
#include <lib/support/CHIPMem.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/DiagnosticDataProvider.h>
Expand Down Expand Up @@ -87,7 +86,6 @@ Clusters::TemperatureControl::AppSupportedTemperatureLevelsDelegate sAppSupporte
Clusters::ModeSelect::StaticSupportedModesManager sStaticSupportedModesManager;
Clusters::ValveConfigurationAndControl::ValveControlDelegate sValveDelegate;
Clusters::TimeSynchronization::ExtendedTimeSyncDelegate sTimeSyncDelegate;
Clusters::Actions::ActionsDelegateImpl sActionsDelegateImpl;

// Please refer to https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces
constexpr const uint8_t kNamespaceCommon = 7;
Expand Down Expand Up @@ -342,12 +340,6 @@ void emberAfThermostatClusterInitCallback(EndpointId endpoint)
SetDefaultDelegate(endpoint, &delegate);
}

void emberAfActionsClusterInitCallback(EndpointId endpoint)
{
VerifyOrReturn(endpoint == 1);
Clusters::Actions::ActionsServer::Instance().SetDefaultDelegate(endpoint, &sActionsDelegateImpl);
}

Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer,
uint16_t maxReadLength)
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ CHIP_ERROR BaseApplication::Init()
* Wait for the WiFi to be initialized
*/
ChipLogProgress(AppServer, "APP: Wait WiFi Init");
while (!IsStationReady())
while (!WifiInterface::GetInstance().IsStationReady())
{
osDelay(pdMS_TO_TICKS(10));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName)
#ifdef SL_WIFI
CHIP_ERROR SilabsMatterConfig::InitWiFi(void)
{
return InitWiFiStack();
return WifiInterface::GetInstance().InitWiFiStack();
}
#endif // SL_WIFI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,21 @@ public void handle(CommissionerDeclaration cd) {
});
}

@Override
public void onStop() {
super.onStop();
// Only stop connection if we are still connecting to the device
if (targetCastingPlayer.getConnectionState() == CastingPlayer.ConnectionState.CONNECTING) {
// NOTE, once stopConnecting() is called, the targetCastingPlayer's native object is freed
MatterError err = targetCastingPlayer.stopConnecting();
if (err.hasError()) {
Log.e(
TAG,
"Going back before connection finishes but stopConnecting() failed due to: " + err);
}
}
}

private void displayPasscodeInputDialog(Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);

Expand Down Expand Up @@ -336,18 +351,9 @@ public void onClick(DialogInterface dialog, int which) {
connectionFragmentStatusTextView.setText(
"Casting Player CONTINUE CONNECTING failed due to: "
+ finalErr
+ "\n\n");
+ ". Route back to disconnect & try again. \n\n");
});
Log.e(
TAG,
"displayPasscodeInputDialog() continueConnecting() failed, calling stopConnecting() due to: "
+ err);
// Since continueConnecting() failed, Attempt to cancel the connection attempt with
// the CastingPlayer/Commissioner.
err = targetCastingPlayer.stopConnecting();
if (err.hasError()) {
Log.e(TAG, "displayPasscodeInputDialog() stopConnecting() failed due to: " + err);
}
Log.e(TAG, "displayPasscodeInputDialog() continueConnecting() failed due to: " + err);
}
}
});
Expand All @@ -359,20 +365,9 @@ public void onClick(DialogInterface dialog, int which) {
public void onClick(DialogInterface dialog, int which) {
Log.i(
TAG,
"displayPasscodeInputDialog() user cancelled the CastingPlayer/Commissioner-Generated Passcode input dialog. Calling stopConnecting()");
"displayPasscodeInputDialog() user cancelled the CastingPlayer/Commissioner-Generated Passcode input dialog");
connectionFragmentStatusTextView.setText(
"Connection attempt with Casting Player cancelled by the Casting Client/Commissionee user. \n\nRoute back to exit. \n\n");
MatterError err = targetCastingPlayer.stopConnecting();
if (err.hasError()) {
MatterError finalErr = err;
getActivity()
.runOnUiThread(
() -> {
connectionFragmentStatusTextView.setText(
"Casting Player CANCEL failed due to: " + finalErr + "\n\n");
});
Log.e(TAG, "displayPasscodeInputDialog() stopConnecting() failed due to: " + err);
}
"Connection attempt with Casting Player cancelled by the Casting Client/Commissionee user. \n\nRoute back to disconnect & exit. \n\n");
dialog.cancel();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
* about the service discovered/resolved.
*/
public interface CastingPlayer {

/** @brief CastingPlayer's Conenction State */
public enum ConnectionState {
/** State when CastingPlayer is not connected */
NOT_CONNECTED,

/** State when CastingPlayer is attempting to connect */
CONNECTING,

/** State when CastingPlayer is connnected */
CONNECTED,
}

boolean isConnected();

String getDeviceId();
Expand Down Expand Up @@ -152,4 +165,16 @@ MatterError verifyOrEstablishConnection(

/** @brief Sets the internal connection state of this CastingPlayer to "disconnected" */
void disconnect();

/**
* @brief Get CastingPlayer's current ConnectionState.
* @return Current ConnectionState.
*/
ConnectionState getConnectionState();

/**
* @brief Get the Current ConnectionState of a CastingPlayer from the native layer.
* @returns A String representation of the CastingPlayer's current connectation.
*/
String getConnectionStateNative();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/
public class MatterCastingPlayer implements CastingPlayer {
private static final String TAG = MatterCastingPlayer.class.getSimpleName();

/**
* Time (in sec) to keep the commissioning window open, if commissioning is required. Must be >= 3
* minutes.
Expand Down Expand Up @@ -267,4 +268,28 @@ public MatterError continueConnecting() {

@Override
public native void disconnect();

/**
* @brief Get CastingPlayer's current ConnectionState.
* @throws IllegalArgumentException or NullPointerException when native layer returns invalid
* state.
* @return Current ConnectionState.
*/
@Override
public ConnectionState getConnectionState() {
return ConnectionState.valueOf(getConnectionStateNative());
}

/*
* @brief Get the Current ConnectionState of a CastingPlayer from the native layer.
*
* @returns A String representation of the CastingPlayer's current connectation.
* Possible return values are
* - "NOT_CONNECTED"
* - "CONNECTING"
* - "CONNECTED"
* - Error message or NULL on error
*/
@Override
public native String getConnectionStateNative();
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,45 @@ JNI_METHOD(void, disconnect)
castingPlayer->Disconnect();
}

JNI_METHOD(jstring, getConnectionStateNative)
(JNIEnv * env, jobject thiz)
{
char error_str[50];
jobject jstr_obj = nullptr;

if (NULL == env)
{
LogErrorOnFailure(
chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("JNIEnv interface is NULL"), jstr_obj));
return static_cast<jstring>(jstr_obj);
}

chip::DeviceLayer::StackLock lock;
ChipLogProgress(AppServer, "MatterCastingPlayer-JNI::getConnectionState()");

CastingPlayer * castingPlayer = support::convertCastingPlayerFromJavaToCpp(thiz);
VerifyOrReturnValue(castingPlayer != nullptr, env->NewStringUTF("Cast Player is nullptr"));

matter::casting::core::ConnectionState state = castingPlayer->GetConnectionState();
switch (state)
{
case matter::casting::core::ConnectionState::CASTING_PLAYER_NOT_CONNECTED:
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("NOT_CONNECTED"), jstr_obj));
break;
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTING:
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("CONNECTING"), jstr_obj));
break;
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTED:
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("CONNECTED"), jstr_obj));
break;
default:
snprintf(error_str, sizeof(error_str), "Unsupported Connection State: %d", state);
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString(error_str), jstr_obj));
break;
}
return static_cast<jstring>(jstr_obj);
}

JNI_METHOD(jobject, getEndpoints)
(JNIEnv * env, jobject thiz)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@

@class MCEndpoint;

/**
* @brief Represents CastingPlayer ConnectionState.
* @note Should be kept up to date with matter::casting::core::ConnectionState.
*/
typedef enum {
MC_CASTING_PLAYER_NOT_CONNECTED,
MC_CASTING_PLAYER_CONNECTING,
MC_CASTING_PLAYER_CONNECTED,
} MCCastingPlayerConnectionState;

/**
* @brief MCCastingPlayer represents a Matter commissioner that is able to play media to a physical
* output or to a display screen which is part of the device.
Expand Down Expand Up @@ -148,6 +158,13 @@
*/
- (void)disconnect;

/**
* @brief Get the CastingPlayer's connection state
* @param state The current connection state that will be return.
* @return nil if request submitted successfully, otherwise a NSError object corresponding to the error.
*/
- (NSError * _Nullable)getConnectionState:(MCCastingPlayerConnectionState * _Nonnull)state;

- (NSString * _Nonnull)identifier;
- (NSString * _Nonnull)deviceName;
- (uint16_t)vendorId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,35 @@ - (void)disconnect
});
}

- (NSError * _Nullable)getConnectionState:(MCCastingPlayerConnectionState * _Nonnull)state;
{
ChipLogProgress(AppServer, "MCCastingPlayer.getConnectionState() called");
VerifyOrReturnValue([[MCCastingApp getSharedInstance] isRunning], [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE], ChipLogError(AppServer, "MCCastingPlayer.getConnectionState() MCCastingApp NOT running"));

__block matter::casting::core::ConnectionState native_state = matter::casting::core::ConnectionState::CASTING_PLAYER_NOT_CONNECTED;
dispatch_queue_t workQueue = [[MCCastingApp getSharedInstance] getWorkQueue];
dispatch_sync(workQueue, ^{
native_state = _cppCastingPlayer->GetConnectionState();
});

switch (native_state) {
case matter::casting::core::ConnectionState::CASTING_PLAYER_NOT_CONNECTED:
*state = MC_CASTING_PLAYER_NOT_CONNECTED;
break;
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTING:
*state = MC_CASTING_PLAYER_CONNECTING;
break;
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTED:
*state = MC_CASTING_PLAYER_CONNECTED;
break;
default:
[NSException raise:@"Unhandled matter::casting::core::ConnectionState" format:@"%d is not handled", native_state];
break;
}

return nil;
}

- (instancetype _Nonnull)initWithCppCastingPlayer:(matter::casting::memory::Strong<matter::casting::core::CastingPlayer>)cppCastingPlayer
{
if (self = [super init]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ struct MCConnectionExampleView: View {
viewModel.connect(selectedCastingPlayer: self.selectedCastingPlayer, useCommissionerGeneratedPasscode: self.useCommissionerGeneratedPasscode)
}
})
.onDisappear(perform: {
viewModel.cancelConnectionAttempt(selectedCastingPlayer: self.selectedCastingPlayer)
})
}
}

Expand Down
Loading
Loading