From 8873a20dd3d3e1088cd9bd96de79d749fb794a72 Mon Sep 17 00:00:00 2001 From: adabreuti <76965454+adabreuti@users.noreply.github.com> Date: Wed, 31 Aug 2022 16:12:39 -0500 Subject: [PATCH] Add CC13xx Factory Reset to allclusters/lock app (#22141) * Add CC13xx Factory Reset to allclusters/lock app * Apply formatting * Revert args.gni * Restyled by prettier-markdown Co-authored-by: Restyled.io Co-authored-by: Andrei Litvin --- .../all-clusters-app/cc13x2x7_26x2x7/README.md | 6 +++--- .../cc13x2x7_26x2x7/main/AppTask.cpp | 15 ++++++++------- .../cc13x2x7_26x2x7/README.md | 6 +++--- .../cc13x2x7_26x2x7/main/AppTask.cpp | 15 ++++++++------- examples/lock-app/cc13x2x7_26x2x7/README.md | 6 +++--- .../lock-app/cc13x2x7_26x2x7/main/AppTask.cpp | 15 ++++++++------- 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/README.md b/examples/all-clusters-app/cc13x2x7_26x2x7/README.md index fd2d0ee9c07cbb..8513b32723fabc 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/README.md +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/README.md @@ -52,9 +52,9 @@ Short presses (less than 1000ms) of the user buttons are used currently unused in the all-clusters application, but stubs are provided. Long presses (greater than 1000ms) of the user buttons are used for controlling -BLE advertisements. The left button (`BTN-1`) is used to disable advertisements -if they are enabled. The Right button (`BTN-2`) is used to enable -advertisements. +BLE advertisements and resets. The left button (`BTN-1`) is used to perform a +factory reset of the device. The Right button (`BTN-2`) is used to disable BLE +advertisements (if enabled) or enable advertisements (if disabled). ## Building diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp index 09762791f4cf1a..14645f267a43db 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -347,12 +347,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) { - // Disable BLE advertisements - if (ConnectivityMgr().IsBLEAdvertisingEnabled()) - { - ConnectivityMgr().SetBLEAdvertisingEnabled(false); - PLAT_LOG("Disabled BLE Advertisements"); - } + chip::Server::GetInstance().ScheduleFactoryReset(); } break; @@ -367,13 +362,19 @@ void AppTask::DispatchEvent(AppEvent * aEvent) { if (Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() == CHIP_NO_ERROR) { - PLAT_LOG("Enabled BLE Advertisement"); + PLAT_LOG("Enabled BLE Advertisements"); } else { PLAT_LOG("OpenBasicCommissioningWindow() failed"); } } + else + { + // Disable BLE advertisements + ConnectivityMgr().SetBLEAdvertisingEnabled(false); + PLAT_LOG("Disabled BLE Advertisements"); + } } break; diff --git a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/README.md b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/README.md index c23cf324afe8af..102a48b67bdf46 100644 --- a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/README.md +++ b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/README.md @@ -52,9 +52,9 @@ Short presses (less than 1000ms) of the user buttons are used currently unused in the all-clusters application, but stubs are provided. Long presses (greater than 1000ms) of the user buttons are used for controlling -BLE advertisements. The left button (`BTN-1`) is used to disable advertisements -if they are enabled. The Right button (`BTN-2`) is used to enable -advertisements. +BLE advertisements and resets. The left button (`BTN-1`) is used to perform a +factory reset of the device. The Right button (`BTN-2`) is used to disable BLE +advertisements (if enabled) or enable advertisements (if disabled). ## Building diff --git a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp index 09762791f4cf1a..14645f267a43db 100644 --- a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -347,12 +347,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) { - // Disable BLE advertisements - if (ConnectivityMgr().IsBLEAdvertisingEnabled()) - { - ConnectivityMgr().SetBLEAdvertisingEnabled(false); - PLAT_LOG("Disabled BLE Advertisements"); - } + chip::Server::GetInstance().ScheduleFactoryReset(); } break; @@ -367,13 +362,19 @@ void AppTask::DispatchEvent(AppEvent * aEvent) { if (Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() == CHIP_NO_ERROR) { - PLAT_LOG("Enabled BLE Advertisement"); + PLAT_LOG("Enabled BLE Advertisements"); } else { PLAT_LOG("OpenBasicCommissioningWindow() failed"); } } + else + { + // Disable BLE advertisements + ConnectivityMgr().SetBLEAdvertisingEnabled(false); + PLAT_LOG("Disabled BLE Advertisements"); + } } break; diff --git a/examples/lock-app/cc13x2x7_26x2x7/README.md b/examples/lock-app/cc13x2x7_26x2x7/README.md index 6c457b0fabe281..b9160bf082c5fb 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/README.md +++ b/examples/lock-app/cc13x2x7_26x2x7/README.md @@ -50,9 +50,9 @@ lock and unlock of the door lock. The left button (`BTN-1`) is used to request locking. The right button (`BTN-2`) is used to request unlocking. Long presses (greater than 1000ms) of the user buttons are used for controlling -BLE advertisements. The left button (`BTN-1`) is used to disable advertisements -if they are enabled. The Right button (`BTN-2`) is used to enable -advertisements. +BLE advertisements and resets. The left button (`BTN-1`) is used to perform a +factory reset of the device. The Right button (`BTN-2`) is used to disable BLE +advertisements (if enabled) or enable advertisements (if disabled). ## Building diff --git a/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp index 4854eb4c5af0d8..55bf86deeedecc 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -345,12 +345,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } else if (AppEvent::kAppEventButtonType_LongClicked == aEvent->ButtonEvent.Type) { - // Disable BLE advertisements - if (ConnectivityMgr().IsBLEAdvertisingEnabled()) - { - ConnectivityMgr().SetBLEAdvertisingEnabled(false); - PLAT_LOG("Disabled BLE Advertisements"); - } + chip::Server::GetInstance().ScheduleFactoryReset(); } break; @@ -369,13 +364,19 @@ void AppTask::DispatchEvent(AppEvent * aEvent) { if (Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() == CHIP_NO_ERROR) { - PLAT_LOG("Enabled BLE Advertisement"); + PLAT_LOG("Enabled BLE Advertisements"); } else { PLAT_LOG("OpenBasicCommissioningWindow() failed"); } } + else + { + // Disable BLE advertisements + ConnectivityMgr().SetBLEAdvertisingEnabled(false); + PLAT_LOG("Disabled BLE Advertisements"); + } } break;