Skip to content

Commit

Permalink
BTSDK-6720 Apply Restylers made fixes. (project-chip#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsusid committed Dec 8, 2021
1 parent 64285b9 commit eb19324
Show file tree
Hide file tree
Showing 44 changed files with 799 additions and 921 deletions.
3 changes: 2 additions & 1 deletion examples/build_overrides/cyw30739_sdk.gni
Expand Up @@ -14,5 +14,6 @@

declare_args() {
# Root directory for CYW30739 SDK.
cyw30739_sdk_build_root = "//third_party/connectedhomeip/third_party/cyw30739_sdk"
cyw30739_sdk_build_root =
"//third_party/connectedhomeip/third_party/cyw30739_sdk"
}
8 changes: 2 additions & 6 deletions examples/lighting-app/cyw30739/BUILD.gn
Expand Up @@ -27,13 +27,9 @@ declare_args() {
}

cyw30739_sdk("sdk") {
sources = [
"${cyw30739_project_dir}/include/CHIPProjectConfig.h",
]
sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ]

include_dirs = [
"${cyw30739_project_dir}/include",
]
include_dirs = [ "${cyw30739_project_dir}/include" ]

defines = [
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
Expand Down
116 changes: 58 additions & 58 deletions examples/lighting-app/cyw30739/README.md
Expand Up @@ -6,58 +6,58 @@ An example showing the use of Matter on the Infineon CYW30739 platform.

## Table of Contents

- [CHIP CYW30739 Lighting Example](#matter-cyw30739-lighting-example)
- [Introduction](#introduction)
- [Building](#building)
- [Flashing the Application](#flashing-the-application)
- [Running the Complete Example](#running-the-complete-example)
- [CHIP CYW30739 Lighting Example](#matter-cyw30739-lighting-example)
- [Introduction](#introduction)
- [Building](#building)
- [Flashing the Application](#flashing-the-application)
- [Running the Complete Example](#running-the-complete-example)

---

## Introduction

The CYW30739 lighting example provides a baseline demonstration of a Light control
device, built using Matter and the Infineon Modustoolbox SDK. It can be controlled
by a Matter controller over Openthread network.
The CYW30739 lighting example provides a baseline demonstration of a Light
control device, built using Matter and the Infineon Modustoolbox SDK. It can be
controlled by a Matter controller over Openthread network.

The CYW30739 device can be commissioned over Bluetooth Low Energy where the device
and the Matter controller will exchange security information with the Rendez-vous
procedure. Thread Network credentials are then provided to the CYW30739 device
which will then join the network.
The CYW30739 device can be commissioned over Bluetooth Low Energy where the
device and the Matter controller will exchange security information with the
Rendez-vous procedure. Thread Network credentials are then provided to the
CYW30739 device which will then join the network.

## Building

- Build the example application:
- Build the example application:

```bash
$ cd ~/connectedhomeip
$ git submodule update --init
$ ./scripts/examples/gn_build_example.sh examples/lighting-app/cyw30739 out/lighting-app
```
```bash
$ cd ~/connectedhomeip
$ git submodule update --init
$ ./scripts/examples/gn_build_example.sh examples/lighting-app/cyw30739 out/lighting-app
```

- To delete generated executable, libraries and object files use:
- To delete generated executable, libraries and object files use:

```bash
$ cd ~/connectedhomeip
$ rm -rf ./out/
```
```bash
$ cd ~/connectedhomeip
$ rm -rf ./out/
```

- OR use GN/Ninja directly
- OR use GN/Ninja directly

```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ git submodule update --init
$ source third_party/connectedhomeip/scripts/activate.sh
$ gn gen out/debug
$ ninja -C out/debug
```
```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ git submodule update --init
$ source third_party/connectedhomeip/scripts/activate.sh
$ gn gen out/debug
$ ninja -C out/debug
```

- To delete generated executable, libraries and object files use:
- To delete generated executable, libraries and object files use:

```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ rm -rf out/
```
```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ rm -rf out/
```

## Flashing the Application

Expand All @@ -72,33 +72,33 @@ Put the CYW30739 in to the recovery mode before running the flash script.

### Run Flash Script

- On the command line:
- On the command line:

```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ python3 out/debug/chip-cyw30739-lighting-example.flash.py
```
```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ python3 out/debug/chip-cyw30739-lighting-example.flash.py
```

## Running the Complete Example

- It is assumed here that you already have an OpenThread border router
configured and running. If not see the following guide
[Openthread_border_router](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/openthread_border_router_pi.md)
for more information on how to setup a border router on a raspberryPi.
- It is assumed here that you already have an OpenThread border router
configured and running. If not see the following guide
[Openthread_border_router](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/openthread_border_router_pi.md)
for more information on how to setup a border router on a raspberryPi.

- You can provision and control the Chip device using the python controller,
Chip tool standalone, Android or iOS app
- You can provision and control the Chip device using the python controller,
Chip tool standalone, Android or iOS app

[Python Controller](https://github.com/project-chip/connectedhomeip/blob/master/src/controller/python/README.md)
[Python Controller](https://github.com/project-chip/connectedhomeip/blob/master/src/controller/python/README.md)

Here is an example with the Python controller:
Here is an example with the Python controller:

```bash
$ chip-device-ctrl
chip-device-ctrl > connect -ble 3840 20202021 1234
chip-device-ctrl > zcl NetworkCommissioning AddThreadNetwork 1234 0 0 operationalDataset=hex:0e080000000000000000000300000b35060004001fffe00208dead00beef00cafe0708fddead00beef000005108e11d8ea8ffaa875713699f59e8807e0030a4f70656e5468726561640102c2980410edc641eb63b100b87e90a9980959befc0c0402a0fff8 breadcrumb=0 timeoutMs=1000
chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 1234 0 0 networkID=hex:dead00beef00cafe breadcrumb=0 timeoutMs=1000
chip-device-ctrl > close-ble
chip-device-ctrl > resolve 1234
chip-device-ctrl > zcl OnOff Toggle 1234 1 0
```
```bash
$ chip-device-ctrl
chip-device-ctrl > connect -ble 3840 20202021 1234
chip-device-ctrl > zcl NetworkCommissioning AddThreadNetwork 1234 0 0 operationalDataset=hex:0e080000000000000000000300000b35060004001fffe00208dead00beef00cafe0708fddead00beef000005108e11d8ea8ffaa875713699f59e8807e0030a4f70656e5468726561640102c2980410edc641eb63b100b87e90a9980959befc0c0402a0fff8 breadcrumb=0 timeoutMs=1000
chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 1234 0 0 networkID=hex:dead00beef00cafe breadcrumb=0 timeoutMs=1000
chip-device-ctrl > close-ble
chip-device-ctrl > resolve 1234
chip-device-ctrl > zcl OnOff Toggle 1234 1 0
```
2 changes: 1 addition & 1 deletion examples/lighting-app/cyw30739/include/ButtonHandler.h
Expand Up @@ -8,6 +8,6 @@ typedef enum
ON_OFF_BUTTON,
APP_MAX_BUTTON,
} application_button_t;
#define APP_MAX_BUTTON_DEF 1 // define for preprocessor
#define APP_MAX_BUTTON_DEF 1 // define for preprocessor

wiced_result_t app_button_init(void);
1 change: 0 additions & 1 deletion examples/lighting-app/cyw30739/include/CHIPProjectConfig.h
Expand Up @@ -28,7 +28,6 @@

#pragma once


// -------------------- Device Identification Configuration --------------------

/* The VendorName attribute of the Basic cluster. */
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/cyw30739/src/AppShellCommands.cpp
Expand Up @@ -2,9 +2,9 @@
* $ Copyright 2016-YEAR Cypress Semiconductor $
*/

#include "LightingManager.h"
#include <lib/shell/commands/Help.h>
#include <platform/CHIPDeviceLayer.h>
#include "LightingManager.h"

using namespace chip::Shell;

Expand Down
26 changes: 12 additions & 14 deletions examples/lighting-app/cyw30739/src/ButtonHandler.cpp
Expand Up @@ -15,18 +15,18 @@
/******************************************************
* Macros
******************************************************/
void app_button_event_handler( const button_manager_button_t* button, button_manager_event_t event, button_manager_button_state_t state );
void app_button_event_handler(const button_manager_button_t * button, button_manager_event_t event,
button_manager_button_state_t state);

static wiced_button_manager_configuration_t app_button_manager_configuration =
{
static wiced_button_manager_configuration_t app_button_manager_configuration = {
.short_hold_duration = 500, /*msec*/
.medium_hold_duration = 700,
.long_hold_duration = 1500,
.very_long_hold_duration = 2500,
.debounce_duration = 150, /* typically a click takes around ~150-200 ms */
.double_click_interval = 250,
.continuous_hold_detect = WICED_TRUE,
.event_handler = app_button_event_handler,
.event_handler = app_button_event_handler,
};

/* Static button configuration */
Expand All @@ -42,14 +42,11 @@ wiced_result_t app_button_init(void)
memset(app_button_configurations, 0, (sizeof(wiced_button_configuration_t) * APP_MAX_BUTTON_DEF));
memset(app_buttons, 0, (sizeof(button_manager_button_t) * APP_MAX_BUTTON_DEF));

app_button_configurations[ON_OFF_BUTTON].button = PLATFORM_BUTTON_1;
app_button_configurations[ON_OFF_BUTTON].button = PLATFORM_BUTTON_1;
app_button_configurations[ON_OFF_BUTTON].button_event_mask = BUTTON_CLICK_EVENT;
app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON];
app_buttons[ON_OFF_BUTTON].configuration = &app_button_configurations[ON_OFF_BUTTON];

result = wiced_button_manager_init(&app_button_manager,
&app_button_manager_configuration,
app_buttons,
1);
result = wiced_button_manager_init(&app_button_manager, &app_button_manager_configuration, app_buttons, 1);

if (result != WICED_SUCCESS)
{
Expand All @@ -58,12 +55,13 @@ wiced_result_t app_button_init(void)
return result;
}

void app_button_event_handler( const button_manager_button_t* button_mgr, button_manager_event_t event, button_manager_button_state_t state )
void app_button_event_handler(const button_manager_button_t * button_mgr, button_manager_event_t event,
button_manager_button_state_t state)
{
//printf("app_button_event_handler. button=%d, event=%d, state=%d\n", button_mgr[ON_OFF_BUTTON].configuration->button, event, state);
// printf("app_button_event_handler. button=%d, event=%d, state=%d\n", button_mgr[ON_OFF_BUTTON].configuration->button, event,
// state);

if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 &&
event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED)
if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 && event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED)
{
if (LightMgr().IsLightOn())
{
Expand Down
12 changes: 5 additions & 7 deletions examples/lighting-app/cyw30739/src/LightingManager.cpp
Expand Up @@ -10,10 +10,8 @@
#include <app/util/af.h>
#include <stdio.h>


LightingManager LightingManager::sLight;


CHIP_ERROR LightingManager::Init()
{
mState = kState_OffCompleted;
Expand All @@ -35,8 +33,8 @@ bool LightingManager::IsActionInProgress()
bool LightingManager::IsLightOn(void)
{
uint8_t value;
const EmberAfStatus status = emberAfReadServerAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID,
&value, sizeof(value));
const EmberAfStatus status =
emberAfReadServerAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, &value, sizeof(value));
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
printf("Error ReadServerAttribute 0x%02x\n", status);
Expand Down Expand Up @@ -84,8 +82,8 @@ bool LightingManager::InitiateAction(Actor_t aActor, Action_t aAction, uint8_t v

void LightingManager::WriteClusterState(uint8_t value)
{
const EmberAfStatus status = emberAfWriteServerAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID,
&value, ZCL_BOOLEAN_ATTRIBUTE_TYPE);
const EmberAfStatus status =
emberAfWriteServerAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, &value, ZCL_BOOLEAN_ATTRIBUTE_TYPE);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
printf("Error WriteServerAttribute 0x%02x\n", status);
Expand All @@ -95,7 +93,7 @@ void LightingManager::WriteClusterState(uint8_t value)
void LightingManager::WriteClusterLevel(uint8_t value)
{
const EmberAfStatus status = emberAfWriteServerAttribute(1, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID,
&value, ZCL_INT8U_ATTRIBUTE_TYPE);
&value, ZCL_INT8U_ATTRIBUTE_TYPE);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
printf("Error WriteServerAttribute 0x%02x\n", status);
Expand Down
8 changes: 4 additions & 4 deletions examples/lighting-app/cyw30739/src/ZclCallbacks.cpp
Expand Up @@ -2,9 +2,9 @@
* $ Copyright 2016-YEAR Cypress Semiconductor $
*/

#include "LightingManager.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <platform/CHIPDeviceLayer.h>
#include "LightingManager.h"

using namespace chip;
using namespace chip::app::Clusters;
Expand All @@ -24,8 +24,8 @@ void emberAfBasicClusterInitCallback(EndpointId endpoint)
Basic::Attributes::ManufacturingDate::Set(endpoint, CharSpan(cString));
}

void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type,
uint16_t size, uint8_t * value)
void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type, uint16_t size,
uint8_t * value)

{
switch (attributePath.mClusterId)
Expand All @@ -35,7 +35,7 @@ void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attrib
{
printf("ZCL OnOff -> %u\n", *value);
LightMgr().InitiateAction(LightingManager::ACTOR_ZCL_CMD,
(*value == 0) ? LightingManager::OFF_ACTION : LightingManager::ON_ACTION, *value);
(*value == 0) ? LightingManager::OFF_ACTION : LightingManager::ON_ACTION, *value);
return;
}
break;
Expand Down
16 changes: 7 additions & 9 deletions examples/lighting-app/cyw30739/src/main.cpp
Expand Up @@ -22,17 +22,15 @@ using namespace ::chip::Credentials;
using namespace ::chip::DeviceLayer;
using namespace ::chip::Shell;

static void EventHandler(const ChipDeviceEvent *event, intptr_t arg);
static void HandleThreadStateChangeEvent(const ChipDeviceEvent *event);
static void EventHandler(const ChipDeviceEvent * event, intptr_t arg);
static void HandleThreadStateChangeEvent(const ChipDeviceEvent * event);
static void LightManagerCallback(LightingManager::Actor_t actor, LightingManager::Action_t action, uint8_t value);

static wiced_led_config_t chip_lighting_led_config =
{
.led = PLATFORM_LED_1,
static wiced_led_config_t chip_lighting_led_config = {
.led = PLATFORM_LED_1,
.bright = 50,
};


APPLICATION_START()
{
CHIP_ERROR err;
Expand Down Expand Up @@ -77,7 +75,7 @@ APPLICATION_START()

#if CHIP_DEVICE_CONFIG_THREAD_FTD
err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
#else // !CHIP_DEVICE_CONFIG_THREAD_FTD
#else // !CHIP_DEVICE_CONFIG_THREAD_FTD
err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
#endif // CHIP_DEVICE_CONFIG_THREAD_FTD
if (err != CHIP_NO_ERROR)
Expand Down Expand Up @@ -125,7 +123,7 @@ APPLICATION_START()
assert(!wiced_rtos_check_for_stack_overflow());
}

void EventHandler(const ChipDeviceEvent *event, intptr_t arg)
void EventHandler(const ChipDeviceEvent * event, intptr_t arg)
{
switch (event->Type)
{
Expand All @@ -137,7 +135,7 @@ void EventHandler(const ChipDeviceEvent *event, intptr_t arg)
}
}

void HandleThreadStateChangeEvent(const ChipDeviceEvent *event)
void HandleThreadStateChangeEvent(const ChipDeviceEvent * event)
{
#if CHIP_BYPASS_RENDEZVOUS
if (event->ThreadStateChange.NetDataChanged && !ConnectivityMgr().IsThreadProvisioned())
Expand Down
4 changes: 1 addition & 3 deletions examples/platform/cyw30739/BUILD.gn
Expand Up @@ -21,9 +21,7 @@ config("chip_examples_project_config") {
source_set("openthread_core_config_ifx_chip_examples") {
sources = [ "project_include/OpenThreadConfig.h" ]

public_deps = [
"${chip_root}/third_party/openthread/platforms/ifx:openthread_core_config_ifx",
]
public_deps = [ "${chip_root}/third_party/openthread/platforms/ifx:openthread_core_config_ifx" ]

public_configs = [ ":chip_examples_project_config" ]
}

0 comments on commit eb19324

Please sign in to comment.