Skip to content

Commit

Permalink
Add initial yaml test for ArmFailSafe timeout test (#17367)
Browse files Browse the repository at this point in the history
* Add yaml test for ArmFailSafe

* Address review comments
  • Loading branch information
yufengwangca authored and pull[bot] committed Jul 12, 2023
1 parent 282f0c2 commit 2312384
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 7 deletions.
1 change: 1 addition & 0 deletions examples/chip-tool/templates/tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ function getTests()
'TestSystemCommands',
'TestBinding',
'TestUserLabelCluster',
'TestArmFailSafe',
];

const MultiAdmin = [
Expand Down
72 changes: 72 additions & 0 deletions src/app/tests/suites/TestArmFailSafe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright (c) 2022 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.

name: ArmFailSafe Tests

config:
nodeId: 0x12344321
endpoint: 0
discriminator:
type: INT16U
defaultValue: 3840
payload:
type: CHAR_STRING
defaultValue: "MT:-24J0AFN00KA0648G00" # This value needs to be generated automatically

tests:
- label: "Reboot target device"
cluster: "SystemCommands"
command: "Reboot"
arguments:
values:
- name: "discriminator"
value: discriminator

- label: "Wait for the alpha device to be retrieved "
cluster: "DelayCommands"
command: "WaitForCommissionee"
arguments:
values:
- name: "nodeId"
value: nodeId

- label: "Query fabrics list"
command: "readAttribute"
cluster: "Operational Credentials"
attribute: "Fabrics"
response:
value: [{ Label: "", nodeId: nodeId }]
constraints:
type: list

- label: "ArmFailSafe on target device with timeout 0"
cluster: "General Commissioning"
command: "ArmFailSafe"
arguments:
values:
- name: "expiryLengthSeconds"
value: 0
- name: "breadcrumb"
value: 0
response:
values:
- name: "errorCode"
value: 0

- label: "Reads NodeLabel mandatory attribute of target device"
command: "readAttribute"
cluster: "Basic"
attribute: "NodeLabel"
response:
value: ""
2 changes: 1 addition & 1 deletion src/platform/Ameba/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ CHIP_ERROR ConnectivityManagerImpl::_Init()

// Set callback functions from chip_porting
chip_connmgr_set_callback_func((chip_connmgr_callback)(conn_callback_dispatcher), this);

// Register WiFi event handlers
wifi_reg_event_handler(WIFI_EVENT_CONNECT, ConnectivityManagerImpl::RtkWiFiStationConnectedHandler, NULL);
wifi_reg_event_handler(WIFI_EVENT_DISCONNECT, ConnectivityManagerImpl::RtkWiFiStationDisconnectedHandler, NULL);
Expand Down
12 changes: 6 additions & 6 deletions src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ constexpr char kWiFiCredentialsKeyName[] = "wifi-pass";
CHIP_ERROR AmebaWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeCallback)
{
CHIP_ERROR err;
size_t ssidLen = 0;
size_t credentialsLen = 0;
mpScanCallback = nullptr;
mpConnectCallback = nullptr;
size_t ssidLen = 0;
size_t credentialsLen = 0;
mpScanCallback = nullptr;
mpConnectCallback = nullptr;
mpStatusChangeCallback = networkStatusChangeCallback;

err = PersistedStorage::KeyValueStoreMgr().Get(kWiFiCredentialsKeyName, mSavedNetwork.credentials,
Expand All @@ -59,7 +59,7 @@ CHIP_ERROR AmebaWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChan
mSavedNetwork.credentialsLen = credentialsLen;
mSavedNetwork.ssidLen = ssidLen;

mStagingNetwork = mSavedNetwork;
mStagingNetwork = mSavedNetwork;
return err;
}

Expand Down Expand Up @@ -268,7 +268,7 @@ void AmebaWiFiDriver::OnNetworkStatusChange()
Network configuredNetwork;
rtw_wifi_setting_t mWiFiSetting;
CHIP_GetWiFiConfig(&mWiFiSetting);
bool staEnable = (mWiFiSetting.mode == RTW_MODE_STA || mWiFiSetting.mode == RTW_MODE_STA_AP);
bool staEnable = (mWiFiSetting.mode == RTW_MODE_STA || mWiFiSetting.mode == RTW_MODE_STA_AP);
bool staConnected = (mWiFiSetting.ssid[0] != 0);

CHIP_ERROR err = GetConfiguredNetwork(configuredNetwork);
Expand Down
238 changes: 238 additions & 0 deletions zzz_generated/chip-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2312384

Please sign in to comment.