Skip to content

Commit

Permalink
[Telink] Create common apps files (#26087)
Browse files Browse the repository at this point in the history
* [Telink] Bridge-App demo draft added

* [Telink] Thermostat endpoint draft added

* [Telink] bridge included to Github CI

* [Telink] Bridged Temperature sensor added

* [Telink] cleanup & styling

* [Telink] Code cleanup

* [Telink] Set correct bridge app name

* [Telink] Fix typo after auto merge

* [Telink] removed needless atribute condition

* [Telink] PRODUCT_ID mod to fix Google Home pairing

* [Telink] Add common apps files

* [Telink] Update all-clusters-minimal-app example after add common apps files

* [Telink] Update light-switch-app example after add common apps files

* [Telink] Update lighting-app example after add common apps files

* [Telink] Update all-clusters-app example after add common apps files

* [Telink] Update contact-sensor-app example after add common apps files

* [Telink] Update lock-app example after add common apps files

* [Telink] Update ota-requestor-app example after add common apps files

* [Telink] Update pump-app example after add common apps files

* [Telink] Update pump-controller-app example after add common apps files

* [Telink] Update temperature-measurement-app example after add common apps files

* [Telink] Update thermostat example after add common apps files

* [Telink] Update window-app example after add common apps files

* [Telink] Update bridge-app example after add common apps files

* [Telink] Use correct "app" log module

* Restyled by whitespace

* Restyled by clang-format

---------

Co-authored-by: Dmytro Huz <[email protected]>
Co-authored-by: Alex Tsitsiura <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
4 people authored and pull[bot] committed Aug 23, 2023
1 parent 475be0c commit c223212
Show file tree
Hide file tree
Showing 91 changed files with 1,067 additions and 8,545 deletions.
4 changes: 3 additions & 1 deletion examples/all-clusters-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ target_include_directories(app PRIVATE
${ALL_CLUSTERS_COMMON_DIR}/include
${GEN_DIR}/app-common
${GEN_DIR}/all-clusters-app
${TELINK_COMMON}/common/include
${TELINK_COMMON}/util/include)

add_definitions(
Expand All @@ -69,11 +70,12 @@ add_definitions(

target_sources(app PRIVATE
src/AppTask.cpp
src/main.cpp
src/ZclDoorLockCallbacks.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
${TELINK_COMMON}/common/src/mainCommon.cpp
${TELINK_COMMON}/common/src/AppTaskCommon.cpp
${TELINK_COMMON}/util/src/LEDWidget.cpp
${TELINK_COMMON}/util/src/ButtonManager.cpp
${TELINK_COMMON}/util/src/ThreadUtil.cpp
Expand Down
18 changes: 6 additions & 12 deletions examples/all-clusters-app/telink/include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@
#pragma once

// ---- All Clusters Application example config ----
#define APP_USE_EXAMPLE_START_BUTTON 0
#define APP_USE_THREAD_START_BUTTON 1
#define APP_SET_DEVICE_INFO_PROVIDER 1
#define APP_SET_NETWORK_COMM_ENDPOINT_SEC 1
#define APP_USE_IDENTIFY_PWM 1 // APP_USE_IDENTIFY_PWM must be defined before including "AppConfigCommon.h"

// Buttons config
#define BUTTON_PORT DEVICE_DT_GET(DT_NODELABEL(gpioc))

#define BUTTON_PIN_1 2
#define BUTTON_PIN_3 3
#define BUTTON_PIN_4 1
#define BUTTON_PIN_2 0

// LEDs config
#define LEDS_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob))
#define SYSTEM_STATE_LED 7
#define LIGHTING_PWM_SPEC_IDENTIFY_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3))
#include "AppConfigCommon.h"
58 changes: 0 additions & 58 deletions examples/all-clusters-app/telink/include/AppEvent.h

This file was deleted.

62 changes: 4 additions & 58 deletions examples/all-clusters-app/telink/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,71 +18,17 @@

#pragma once

#include "AppEvent.h"
#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED
#include "LEDWidget.h"
#endif
#include "PWMDevice.h"
#include "AppTaskCommon.h"

#include <zephyr/drivers/gpio.h>

#include <platform/CHIPDeviceLayer.h>

#if CONFIG_CHIP_FACTORY_DATA
#include <platform/telink/FactoryDataProvider.h>
#endif

#include <cstdint>

struct k_timer;
struct Identify;

class AppTask
class AppTask : public AppTaskCommon
{
public:
CHIP_ERROR StartApp(void);

void PostEvent(AppEvent * event);
static void IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect);

private:
friend AppTask & GetAppTask(void);
friend class AppTaskCommon;

CHIP_ERROR Init(void);

static void ActionIdentifyStateUpdateHandler(k_timer * timer);

void DispatchEvent(AppEvent * event);

#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED
static void UpdateLedStateEventHandler(AppEvent * aEvent);
static void LEDStateUpdateHandler(LEDWidget * ledWidget);
static void UpdateStatusLED();
#endif
static void FactoryResetButtonEventHandler(void);
static void StartThreadButtonEventHandler(void);
static void StartBleAdvButtonEventHandler(void);

static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);

static void FactoryResetTimerTimeoutCallback(k_timer * timer);

static void FactoryResetTimerEventHandler(AppEvent * aEvent);
static void FactoryResetHandler(AppEvent * aEvent);
static void StartThreadHandler(AppEvent * aEvent);
static void StartBleAdvHandler(AppEvent * aEvent);
static void UpdateIdentifyStateEventHandler(AppEvent * aEvent);

static void InitButtons(void);

static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
CHIP_ERROR Init();

static AppTask sAppTask;
PWMDevice mPwmIdentifyLed;

#if CONFIG_CHIP_FACTORY_DATA
chip::DeviceLayer::FactoryDataProvider<chip::DeviceLayer::ExternalFlashFactoryData> mFactoryDataProvider;
#endif
};

inline AppTask & GetAppTask(void)
Expand Down
Loading

0 comments on commit c223212

Please sign in to comment.