Skip to content

Commit

Permalink
[QPG] QPG SDK feature updates (#25715)
Browse files Browse the repository at this point in the history
* SED support for QPG

Run code formatting on main.cpp

Add SED/FTD flags as part of CHIPProjectConfig.h

* Improve DNS SD implementation to trigger OTA requestor init when DNS SD connectivity changes

* * Adding qvIO_Init() to initialisation flow
* Add fix for initial ResetCount storage + removal double init

* Dynamic use of BLE task; re-trigger BLE advertising possible
* Enable heap sourcefile in FreeRTOS

* Added mbedtls software-only build

* Rotating Device ID

* Update project configurations - use versions not in official CD

* Update qpg_sdk to required version

* Removing lwip from examples

* Add Qorvo specific ZAP files for light and lock applications

Align Time Format Localization cluster XML to spec changes. (#25289)

* Configure sleep mode in application

* Enable sleepy for lighting and lock app by default

* * Remove hardcoded length definitions from FactoryDataProvider.cpp
* Remove unused hardware version from OTAImageProcessorImpl.cpp
* Update args.gni example applications

* Remove hardcoded CHIP header definitions in CHIPProjectConfig.h for lighting and lock app

* Changing BLE max fast interval to 50ms to cope with random 0-10ms delay

* Add CHIP_ROOT variable for .zap relative folder use

* Add namespace to persistent-storage app

* Revert ZAP template search based on env var

* Restyled by whitespace

Restyled by clang-format

Restyled by gn

---------

Co-authored-by: Nikita Solianik <[email protected]>
Co-authored-by: lucicop <[email protected]>
Co-authored-by: Adam Bodurka <[email protected]>
Co-authored-by: Milan Radovanovic <[email protected]>
Co-authored-by: Dieter Van der Meulen <[email protected]>
Co-authored-by: Frank Ngai <[email protected]>
Co-authored-by: Brecht Van Cauwenberghe <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
9 people authored and pull[bot] committed Aug 25, 2023
1 parent b8025b9 commit b4b9a5d
Show file tree
Hide file tree
Showing 33 changed files with 24,451 additions and 338 deletions.
3 changes: 2 additions & 1 deletion examples/lighting-app/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ qpg_executable("lighting_app") {
deps = [
":factorydata_lib",
":sdk",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/lighting-app/lighting-common:color-format",
"${chip_root}/examples/lighting-app/qpg/zap/",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
Expand All @@ -87,6 +87,7 @@ qpg_executable("lighting_app") {
]

defines = [ "GP_APP_DIVERSITY_POWERCYCLECOUNTING" ]

if (chip_enable_pw_rpc) {
defines += [
"PW_RPC_ENABLED",
Expand Down
6 changes: 6 additions & 0 deletions examples/lighting-app/qpg/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ qpg_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_ota_requestor = true
chip_openthread_ftd = true
enable_sleepy_device = false

# Disable lock tracking, since our FreeRTOS configuration does not set
# INCLUDE_xSemaphoreGetMutexHolder
chip_stack_lock_tracking = "none"

matter_device_vid = "0xFFF1"
matter_device_pid = "0x8005"
matter_device_software_version = "0x0001"
matter_device_software_version_string = "1.0"

pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
1 change: 1 addition & 0 deletions examples/lighting-app/qpg/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class AppTask
kFunction_NoneSelected = 0,
kFunction_SoftwareUpdate = 1,
kFunction_FactoryReset = 2,
kFunction_StartBleAdv = 3,

kFunction_Invalid
} Function;
Expand Down
66 changes: 20 additions & 46 deletions examples/lighting-app/qpg/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@

#pragma once

// Use a default setup PIN code if one hasn't been provisioned in flash.
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021
#endif
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00
#endif

// For convenience, enable Chip Security Test Mode and disable the requirement for
// authentication in various protocols.
//
Expand All @@ -44,41 +36,13 @@
//
#define CHIP_CONFIG_SECURITY_TEST_MODE 0

/**
* CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
*
* 0xFFF1: Test Vendor.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x10D0
#endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
*
* 0x8005: example lighting app
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005
#endif // CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0002
#endif

/**
Expand All @@ -89,7 +53,7 @@
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand All @@ -98,14 +62,6 @@
*/
#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1

/**
* CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER
*
* Enables the use of a hard-coded default serial number if none
* is found in Chip NV storage.
*/
#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN"

/**
* CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE
*
Expand Down Expand Up @@ -155,4 +111,22 @@
*/
#define CHIP_IM_MAX_NUM_WRITE_CLIENT 2

/**
* @def CHIP_DEVICE_CONFIG_ENABLE_SED
*
* @brief Defines if a matter device is acting as a Sleepy End Device(SED)
*/
#ifndef CHIP_DEVICE_CONFIG_ENABLE_SED
#define CHIP_DEVICE_CONFIG_ENABLE_SED 0
#endif

/**
* @def CHIP_DEVICE_CONFIG_THREAD_FTD
*
* @brief Defines if a matter device is acting as Full Thread Device (FTD)
*/
#ifndef CHIP_DEVICE_CONFIG_THREAD_FTD
#define CHIP_DEVICE_CONFIG_THREAD_FTD 1
#endif

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
46 changes: 35 additions & 11 deletions examples/lighting-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ using namespace ::chip::DeviceLayer;

#define FACTORY_RESET_TRIGGER_TIMEOUT 3000
#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000
#define APP_TASK_STACK_SIZE (2 * 1024)
#define OTA_START_TRIGGER_TIMEOUT 1500

#define APP_TASK_STACK_SIZE (3 * 1024)
#define APP_TASK_PRIORITY 2
#define APP_EVENT_QUEUE_SIZE 10
#define QPG_LIGHT_ENDPOINT_ID (1)
Expand Down Expand Up @@ -268,8 +270,6 @@ CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;

gpAppFramework_Reset_Init();

PlatformMgr().AddEventHandler(MatterEventHandler, 0);

ChipLogProgress(NotSpecified, "Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
Expand Down Expand Up @@ -404,9 +404,16 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent)
return;
}

// If we reached here, the button was held past FACTORY_RESET_TRIGGER_TIMEOUT,
// initiate factory reset
if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_SoftwareUpdate)
if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv)
{
ChipLogProgress(NotSpecified, "[BTN] Release button now to start Software Updater");
ChipLogProgress(NotSpecified, "[BTN] Hold to trigger Factory Reset");
sAppTask.mFunction = kFunction_SoftwareUpdate;
sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT - OTA_START_TRIGGER_TIMEOUT);
}
// If we reached here, the button was held past OTA_START_TRIGGER_TIMEOUT,
// initiate OTA update
else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_SoftwareUpdate)
{
ChipLogProgress(NotSpecified, "[BTN] Factory Reset selected. Release within %us to cancel.",
FACTORY_RESET_CANCEL_WINDOW_TIMEOUT / 1000);
Expand Down Expand Up @@ -450,19 +457,36 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_NoneSelected)
{
ChipLogProgress(NotSpecified, "[BTN] Hold to select function:");
ChipLogProgress(NotSpecified, "[BTN] - Trigger OTA (0-3s)");
ChipLogProgress(NotSpecified, "[BTN] - Trigger BLE adv (0-1.5s)");
ChipLogProgress(NotSpecified, "[BTN] - Trigger OTA (1.5-3s)");
ChipLogProgress(NotSpecified, "[BTN] - Factory Reset (>6s)");

sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT);

sAppTask.mFunction = kFunction_SoftwareUpdate;
sAppTask.mFunction = kFunction_StartBleAdv;
}
}
else
{
// If the button was released before factory reset got initiated, trigger a
// software update.
if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_SoftwareUpdate)
if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv)
{
sAppTask.CancelTimer();
sAppTask.mFunction = kFunction_NoneSelected;

if (ConnectivityMgr().IsBLEAdvertisingEnabled())
{
ChipLogProgress(NotSpecified, "BLE advertising already in progress.");
}
else
{
// Enable BLE advertisements and pairing window
if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() == CHIP_NO_ERROR)
{
ChipLogProgress(NotSpecified, "BLE advertising started. Waiting for Pairing.");
}
}
}
else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_SoftwareUpdate)
{
sAppTask.CancelTimer();

Expand Down
25 changes: 25 additions & 0 deletions examples/lighting-app/qpg/zap/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2020 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.

import("//build_overrides/chip.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/app/chip_data_model.gni")

chip_data_model("zap") {
zap_file = "light.zap"

zap_pregenerated_dir =
"${chip_root}/zzz_generated/lighting-app/qpg/zap-generated"
is_server = true
}
Loading

0 comments on commit b4b9a5d

Please sign in to comment.