From 2197957b3b2322cb26f0128dea739fbae3a6b84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Wed, 1 Sep 2021 20:00:27 +0200 Subject: [PATCH] [android] Exit to the main screen after commissioning (#9371) * [android] Exit to the main screen after commissioning Currently, Android CHIPTool automatically switches to the Light On/Off screen after commissioning a device reglardless of its device type, which is not optimal for devices such as sensors. Exit to the main screen, instead, so a user may select a suitable screen. * Restyled by prettier-markdown * Print a message on commissioning completion Co-authored-by: Restyled.io --- docs/guides/nrfconnect_android_commissioning.md | 17 +++++++++-------- .../google/chip/chiptool/CHIPToolActivity.kt | 12 +++++++----- .../app/src/main/res/values/strings.xml | 1 + 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/guides/nrfconnect_android_commissioning.md b/docs/guides/nrfconnect_android_commissioning.md index c46824a0e7931a..a367a6c142114d 100644 --- a/docs/guides/nrfconnect_android_commissioning.md +++ b/docs/guides/nrfconnect_android_commissioning.md @@ -185,22 +185,23 @@ device successfully joins the Thread network. ## Sending CHIP commands -Once the device is commissioned, the following screen appears: +Once the device is commissioned, the main application screen appears. -![CHIPTool device control screen](./images/CHIPTool_device_commissioned.jpg) +Check the IPv6 connectivity with the device using the following steps: -The two textboxes at the top contain **Fabric ID** and **Node ID** of the last -commissioned device. +1. Tap **LIGHT ON/OFF & LEVEL CLUSTER**. The following screen appears: -Check the IPv6 connectivity with the device using the following steps: + ![CHIPTool device control screen](./images/CHIPTool_device_commissioned.jpg) -1. Tap **UPDATE ADDRESS** to learn or refresh the IPv6 address of the device. + The two textboxes at the top contain **Fabric ID** and **Node ID** of the + last commissioned device. + +2. Tap **UPDATE ADDRESS** to learn or refresh the IPv6 address of the device. CHIPTool will use a built-in DNS-SD client to resolve **Fabric ID** and **Node ID** of the device to its IPv6 address. The result of the operation, be it the address or an error message, will be displayed at the bottom of the screen. - -2. Tap the following buttons to change the lock state of the nRF Connect door +3. Tap the following buttons to change the lock state of the nRF Connect door lock example application referenced in this guide: - **ON** and **OFF** buttons lock and unlock the door, respectively. diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt index 8a4b4372e2f3c0..59954a61e582f4 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt @@ -82,12 +82,14 @@ class CHIPToolActivity : } override fun onCommissioningComplete(code: Int) { - ChipClient.getDeviceController(this).close() - if (code == 0) { - showFragment(OnOffClientFragment.newInstance(), false) - } else { - showFragment(SelectActionFragment.newInstance(), false) + runOnUiThread { + Toast.makeText( + this, + getString(R.string.commissioning_completed, code), + Toast.LENGTH_SHORT).show() } + ChipClient.getDeviceController(this).close() + showFragment(SelectActionFragment.newInstance(), false) } override fun handleScanQrCodeClicked() { diff --git a/src/android/CHIPTool/app/src/main/res/values/strings.xml b/src/android/CHIPTool/app/src/main/res/values/strings.xml index 94ad474ec5ce44..e7a94de894b478 100644 --- a/src/android/CHIPTool/app/src/main/res/values/strings.xml +++ b/src/android/CHIPTool/app/src/main/res/values/strings.xml @@ -59,6 +59,7 @@ Pairing failed Network commissioning completed Network commissioning failed + Commissioning completed with result: %1$d Attestation Test Fetching…