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

[QPG6100] Addition OpenThread support #4561

Merged
merged 2 commits into from
Feb 18, 2021
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
4 changes: 0 additions & 4 deletions .github/workflows/examples-qpg6100.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ jobs:
- name: Build example QPG6100 Lock App
run: scripts/examples/gn_build_example.sh
examples/lock-app/qpg6100 out/lock_app_debug
- name: Build QPG6100 shell App
run: scripts/examples/gn_build_example.sh
examples/shell/qpg6100 out/shell_app
- name: Binary artifact suffix
id: outsuffix
uses: haya14busa/[email protected]
Expand All @@ -64,7 +61,6 @@ jobs:
steps.outsuffix.outputs.value }}
path: |
out/lock_app_debug/chip-qpg6100-lock-example.out
out/shell_app/shell-qpg6100.out
- name: Remove third_party binaries for CodeQL Analysis
run: find out -type d -name "third_party" -exec rm -rf {} +
- name: Perform CodeQL Analysis
Expand Down
28 changes: 13 additions & 15 deletions examples/lock-app/qpg6100/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/openthread.gni")
import("//build_overrides/qpg6100_sdk.gni")

import("${build_root}/config/defaults.gni")
Expand All @@ -31,7 +32,10 @@ qpg6100_sdk("sdk") {
"${examples_plat_dir}/project_include",
]

sources = [ "${examples_plat_dir}/project_include/CHIPProjectConfig.h" ]
sources = [
"${examples_plat_dir}/app/include/Service.h",
"${examples_plat_dir}/project_include/CHIPProjectConfig.h",
]

defines = []
if (is_debug) {
Expand All @@ -48,37 +52,31 @@ qpg6100_executable("lock_app") {

public_deps = [
":sdk",
"${chip_root}/examples/lock-app/lock-common",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",

# OpenThread to be enabled
# https://github.com/project-chip/connectedhomeip/issues/293
# "${chip_root}/third_party/openthread/platforms:libopenthread-platform",
# "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
# "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
# "${chip_root}/third_party/openthread/repo:libopenthread-ftd",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
"${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]

include_dirs += [
"${qpg6100_project_dir}/include/",
"${chip_root}/src/app/util",
"${chip_root}/src/app/server",
"${examples_plat_dir}/",
"${examples_plat_dir}",
"${examples_plat_dir}/app/include",
]

sources = [
"${examples_plat_dir}/app/Service.cpp",
"src/AppTask.cpp",
"src/BoltLockManager.cpp",
"src/ZclCallbacks.cpp",
"src/main.cpp",
]

deps = [
"${chip_root}/examples/lock-app/lock-common",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]

output_dir = root_out_dir

ldscript = "${qpg6100_sdk_root}/qpg6100/ldscripts/chip-qpg6100-example.ld"
Expand Down
47 changes: 32 additions & 15 deletions examples/lock-app/qpg6100/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ An example application showing the use
- [Building](#building)
- [Flashing the application](#flashing-the-application)
- [Viewing Logging Output](#viewing-logging-output)
- [Button Control](#button-control)
- [LED output](#led-output)

---

Expand All @@ -21,21 +23,6 @@ The QPG6100 Lock shows an implementation of a Door Lock device, based on CHIP
and the Qorvo QPG6100 SDK. Intention of this example is to demonstrate a CHIP
device, with Thread connectivity, using BLE to perform CHIP provisioning.

The example will be implemented in a phased approach, enabling more features
with separate updates.

Current status of implementation:

- Button and LED control
- Initialization of the CHIP stack.
- CHIP Logging, PlatformManager and ConfigurationManager enabled.
- BLE: CHIPoBLE advertisement and connection available for provisioning
- CHIP ZCL cluster control for the Lock mechanism through CHIP tool.

Pending:

- Thread: Linking QPG6100 OpenThread implementation to CHIP build

For more information on Qorvo and the platforms, please visit
[the Qorvo website](http://www.qorvo.com) or contact us on
[email protected].
Expand Down Expand Up @@ -133,3 +120,33 @@ qvCHIP v0.0.0.0 (CL:155586) running
- Note! Logging is currently encapsulated by the Qorvo logging module. Output
will have additional header and footer bytes. This will be updated later
into a raw stream for any serial terminal to parse.

## Button control

This application uses following buttons of the DK board:

- SW2: Used to perform a HW reset button for the full board
- SW4: Used to toggle the Unlock/Lock the simulated lock
- SW5: Used to perform, depending on the time the button is kept pressed,
- Software update - not yet supported (released before 3s)
- Trigger Thread joining (release after 3s)
- Factory reset (released after 6s)

Unused:

- SW1
- SW3 - slider switch

## LED output

The following LEDs are used during the application:

- LD1 - RED led: Status LED simulating the lock state
- On - lock closed
- Off - lock open
- Blinking - lock moving to new state
- LD2 - GRN led:
- Short blink every 1s: BLE advertising
- Fast blinks: BLE connected and subscribed
- Short off: Thread connected
- On: Full service connectivity
10 changes: 4 additions & 6 deletions examples/lock-app/qpg6100/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "gen/attribute-type.h"
#include "gen/cluster-id.h"

#include "Service.h"

#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#include <setup_payload/SetupPayload.h>

Expand All @@ -47,7 +49,7 @@ using namespace chip::DeviceLayer;

#define FACTORY_RESET_TRIGGER_TIMEOUT 3000
#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000
#define APP_TASK_STACK_SIZE (4096)
#define APP_TASK_STACK_SIZE (2048)
#define APP_TASK_PRIORITY 2
#define APP_EVENT_QUEUE_SIZE 10

Expand Down Expand Up @@ -122,8 +124,7 @@ void AppTask::AppTaskMain(void * pvParameter)
}

ChipLogProgress(NotSpecified, "App Task started");
// TODO: PR # 2939 - OT support
// SetDeviceName("QPG6100LockDemo._chip._udp.local.");
SetDeviceName("QPG6100LockDemo._chip._udp.local.");

while (true)
{
Expand Down Expand Up @@ -187,10 +188,7 @@ void AppTask::AppTaskMain(void * pvParameter)

if (nowUS > nextChangeTimeUS)
{
// TODO: PR # 2939 - OT support
/*
PublishService();
*/
mLastChangeTimeUS = nowUS;
}
}
Expand Down
34 changes: 32 additions & 2 deletions examples/lock-app/qpg6100/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ int CHIP_Init(void)
{
int ret = CHIP_ERROR_MAX;

// Init Chip memory management before the stack
chip::Platform::MemoryInit();
ret = chip::Platform::MemoryInit();
if (ret != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Platform::MemoryInit() failed");
goto exit;
}

ChipLogProgress(NotSpecified, "Init CHIP Stack");
ret = PlatformMgr().InitChipStack();
Expand All @@ -94,6 +98,32 @@ int CHIP_Init(void)
goto exit;
}

#if CHIP_ENABLE_OPENTHREAD
ChipLogProgress(NotSpecified, "Initializing OpenThread stack");

ret = ThreadStackMgr().InitThreadStack();
if (ret != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "ThreadStackMgr().InitThreadStack() failed");
goto exit;
}

ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
if (ret != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "ConnectivityMgr().SetThreadDeviceType() failed");
goto exit;
}

ChipLogProgress(NotSpecified, "Starting OpenThread task");
ret = ThreadStackMgrImpl().StartThreadTask();
if (ret != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "ThreadStackMgr().StartThreadTask() failed");
goto exit;
}
#endif // CHIP_ENABLE_OPENTHREAD

ChipLogProgress(NotSpecified, "Starting Platform Manager Event Loop");
ret = PlatformMgr().StartEventLoopTask();
if (ret != CHIP_NO_ERROR)
Expand Down
13 changes: 7 additions & 6 deletions examples/platform/qpg6100/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/qpg6100_sdk.gni")

import("${qpg6100_sdk_build_root}/qpg6100_sdk.gni")

config("chip_examples_project_config") {
include_dirs = [ "project_include" ]
}

# TODO - create OpenThread portion of build flow
# https://github.com/project-chip/connectedhomeip/issues/2939

source_set("openthread_core_config_qpg6100_chip_examples") {
sources = [ "project_include/OpenThreadConfig.h" ]

# public_deps = [
# "${chip_root}/third_party/openthread/platforms/qpg6100:openthread_core_config_qpg6100"
# ]
public_deps = [
"${chip_root}/third_party/openthread/platforms/qpg6100:openthread_core_config_qpg6100",
"${qpg6100_sdk_build_root}:qpg6100_sdk",
]
public_configs = [ ":chip_examples_project_config" ]
}
Loading