Skip to content

Commit

Permalink
Lock example for efr32 (#17651)
Browse files Browse the repository at this point in the history
Restyled by whitespace

Restyled by clang-format

Restyled by gn

Remove duplicate user and credential structure. Utilize provided door lock server structure that uses Span.h

Restyled by whitespace

Restyled by clang-format

Update lock-app documentation

Restyled by prettier-markdown

Add endpoint id to setlockstate function, add a todo comment for schedule functions

fix comment, have unimplemented code return failure

code review comments

zap regen

fix misspell reviewdog

Restyled by whitespace

Restyled by clang-format

Restyled by gn

bump timeout because it timed out

Add includes to esp32 app, needed due to zap file updates

update CMakeLists.txt for esp32

disable TI automation logging for size constraint

remove some unused code

manual restyle
  • Loading branch information
mykrupp authored and pull[bot] committed Jul 25, 2023
1 parent b5780e8 commit abe728f
Show file tree
Hide file tree
Showing 26 changed files with 1,289 additions and 449 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/examples-nrfconnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ concurrency:
jobs:
nrfconnect:
name: nRF Connect SDK
timeout-minutes: 120
timeout-minutes: 125

env:
BUILD_TYPE: nrfconnect
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
examples/pump-controller-app/nrfconnect/build/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: Build example nRF Connect SDK All Clusters App on nRF52840 DK
timeout-minutes: 10
timeout-minutes: 15
run: |
scripts/examples/nrfconnect_example.sh all-clusters-app nrf52840dk_nrf52840 -DCONF_FILE=prj_dfu.conf
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/cc13x2x7_26x2x7/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ chip_enable_ota_requestor = true

# Disable CHIP Logging
#chip_progress_logging = false
#chip_detail_logging = false
#chip_automation_logging = false
chip_detail_logging = false
chip_automation_logging = false

# BLE options
chip_config_network_layer_ble = true
Expand Down
23 changes: 7 additions & 16 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/pigweed.gni")

import("${build_root}/config/defaults.gni")

import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${efr32_sdk_build_root}/efr32_sdk.gni")

Expand All @@ -40,6 +40,7 @@ declare_args() {

# PIN code for PASE session establishment.
setupPinCode = 20202021
setupDiscriminator = 3840

# Monitor & log memory usage at runtime.
enable_heap_monitoring = false
Expand Down Expand Up @@ -115,6 +116,7 @@ efr32_sdk("sdk") {
defines = [
"BOARD_ID=${efr32_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]

Expand All @@ -124,13 +126,6 @@ efr32_sdk("sdk") {
"PW_RPC_ENABLED",
]
}
if (use_rs911x) {
defines += rs911x_defs
include_dirs += rs911x_plat_incs
} else if (use_wf200) {
defines += wf200_defs
include_dirs += wf200_plat_incs
}

# WiFi Settings
if (chip_enable_wifi) {
Expand All @@ -149,7 +144,6 @@ efr32_sdk("sdk") {
# Using LWIP instead of the native TCP/IP stack
defines += efr32_lwip_defs
}

if (sl_wfx_config_softap) {
defines += [ "SL_WFX_CONFIG_SOFTAP" ]
}
Expand All @@ -162,15 +156,14 @@ efr32_sdk("sdk") {
efr32_executable("lock_app") {
output_name = "chip-efr32-lock-example.out"
include_dirs = [ "include" ]

defines = []

sources = [
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/heap_4_silabs.c",
"${examples_plat_dir}/init_efrPlatform.cpp",
"src/AppTask.cpp",
"src/BoltLockManager.cpp",
"src/LockManager.cpp",
"src/ZclCallbacks.cpp",
"src/main.cpp",
]
Expand Down Expand Up @@ -248,7 +241,6 @@ efr32_executable("lock_app") {
defines += [ "DISPLAY_ENABLED" ]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]

deps += [ "${chip_root}/examples/common/QRCode" ]
}
}
Expand Down Expand Up @@ -295,16 +287,16 @@ efr32_executable("lock_app") {
}

if (enable_heap_monitoring) {
defines += [ "HEAP_MONITORING" ]
sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ]
defines += [ "HEAP_MONITORING" ]
}

ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld"

ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]

inputs = [ ldscript ]

ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]

if (chip_print_memory_usage) {
ldflags += [
"-Wl,--print-memory-usage",
Expand All @@ -322,7 +314,6 @@ efr32_executable("lock_app") {

output_dir = root_out_dir
}

group("efr32") {
deps = [ ":lock_app" ]
}
Expand Down
43 changes: 39 additions & 4 deletions examples/lock-app/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ combination with JLinkRTTClient as follows:

**LED 1** Simulates the Lock The following states are possible:

- _Solid On_ ; Bolt is locked
- _Solid On_ ; Bolt is unlocked
- _Blinking_ ; Bolt is moving to the desired state
- _Off_ ; Bolt is unlocked
- _Off_ ; Bolt is locked

**Push Button 0**

Expand All @@ -284,12 +284,47 @@ combination with JLinkRTTClient as follows:

[CHIPTool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md)

Here is an example with the CHIPTool:
Here is some CHIPTool examples:

Pairing with chip-tool:
```
chip-tool pairing ble-thread 1 hex:<operationalDataset> 20202021 3840
```

chip-tool onoff toggle 1 1
Set a user:
```
./out/chip-tool doorlock set-user OperationType UserIndex UserName UserUniqueId UserStatus UserType CredentialRule node-id/group-id
./out/chip-tool doorlock set-user 0 1 "mike" 5 1 0 0 1 1 --timedInteractionTimeoutMs 1000
```

Set a credential:
```
./out/chip-tool doorlock set-credential OperationType Credential CredentialData UserIndex UserStatus UserType node-id/group-id
./out/chip-tool doorlock set-credential 0 '{ "credentialType": 1, "credentialIndex": 1 }' "123456" 1 null null 1 1 --timedInteractionTimeoutMs 1000
```

Changing a credential:
```
./out/chip-tool doorlock set-credential OperationType Credential CredentialData UserIndex UserStatus UserType node-id/group-id
./out/chip-tool doorlock set-credential 2 '{ "credentialType": 1, "credentialIndex": 1 }' "123457" 1 null null 1 1 --timedInteractionTimeoutMs 1000
```

Get a user:
```
./out/chip-tool doorlock get-user UserIndex node-id/group-id
./out/chip-tool doorlock get-user 1 1 1
```

Unlock door:
```
./out/chip-tool doorlock unlock-door node-id/group-id
./out/chip-tool doorlock unlock-door 1 1
```

Lock door:
```
./out/chip-tool doorlock lock-door node-id/group-id
./out/chip-tool doorlock lock-door 1 1
```

### Notes
Expand Down
6 changes: 3 additions & 3 deletions examples/lock-app/efr32/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

#pragma once

// ---- Lock Example App Config ----
// ---- Door lock Example App Config ----

#define APP_TASK_NAME "Lck"
#define APP_TASK_NAME "Lock"

// Time it takes in ms for the simulated actuator to move from one
// state to another.
#define ACTUATOR_MOVEMENT_PERIOS_MS 2000
#define ACTUATOR_MOVEMENT_PERIOS_MS 10

// EFR Logging
#ifdef __cplusplus
Expand Down
8 changes: 4 additions & 4 deletions examples/lock-app/efr32/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <stdint.h>

#include "AppEvent.h"
#include "BoltLockManager.h"
#include "LockManager.h"
#include "sl_simple_button_instances.h"

#include "FreeRTOS.h"
Expand All @@ -46,7 +46,7 @@ class AppTask
CHIP_ERROR StartAppTask();
static void AppTaskMain(void * pvParameter);

void PostLockActionRequest(int32_t aActor, BoltLockManager::Action_t aAction);
void ActionRequest(int32_t aActor, LockManager::Action_t aAction);
void PostEvent(const AppEvent * event);

void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction);
Expand All @@ -56,8 +56,8 @@ class AppTask

CHIP_ERROR Init();

static void ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor);
static void ActionCompleted(BoltLockManager::Action_t aAction);
static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor);
static void ActionCompleted(LockManager::Action_t aAction);

void CancelTimer(void);

Expand Down
85 changes: 0 additions & 85 deletions examples/lock-app/efr32/include/BoltLockManager.h

This file was deleted.

8 changes: 6 additions & 2 deletions examples/lock-app/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#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, Chip Security Test Mode can be enabled and the
// requirement for authentication in various protocols can be disabled.
Expand All @@ -41,18 +44,19 @@
// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS.
//
#define CHIP_CONFIG_SECURITY_TEST_MODE 0
#define CHIP_CONFIG_REQUIRE_AUTH 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
*
* 0xFFF1: Test vendor.
* 0xFFF1: Test vendor
*/
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
*
* 0x8006: example lock-app
* 0x8006: example lock app
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006

Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/efr32/include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY (255)
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 48 // 96
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 48
#define configENABLE_FPU 0
#define configENABLE_MPU 0
/* FreeRTOS Secure Side Only and TrustZone Security Extension */
Expand All @@ -189,7 +189,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configUSE_TRACE_FACILITY 1
#define configQUEUE_REGISTRY_SIZE (10)
#define configUSE_QUEUE_SETS (0)
#define configUSE_NEWLIB_REENTRANT (0)
#define configUSE_NEWLIB_REENTRANT (1)
#define configENABLE_BACKWARD_COMPATIBILITY (1)
#define configSUPPORT_STATIC_ALLOCATION (1)
#define configSUPPORT_DYNAMIC_ALLOCATION (1)
Expand Down
Loading

0 comments on commit abe728f

Please sign in to comment.