-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[K32W0][THREADIP-3665] Improve shell application (#11194)
* [K32W0][THREADIP-3665] Improve shell application Shell application lacked a method for commissioning it to a Thread/Matter network: * add commissioning support; * run the shell functionality in a dedicated task. Signed-off-by: Doru Gucea <[email protected]> * Restyled by clang-format * Restyled by gn * [K32W] DIsable ot cli for the moment Otherwise, the app won't fit into RAM0. Signed-off-by: Doru Gucea <[email protected]> * Restyled by clang-format * [K32W0] Fix variable type Signed-off-by: Doru Gucea <[email protected]> * [K32W0] Disable low power build for the shell app Signed-off-by: Doru Gucea <[email protected]> Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
1 parent
cd4fa81
commit 794a5fb
Showing
11 changed files
with
654 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ struct AppEvent | |
kEventType_Install, | ||
}; | ||
|
||
uint16_t Type; | ||
AppEventTypes Type; | ||
|
||
union | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ struct AppEvent | |
#endif | ||
}; | ||
|
||
uint16_t Type; | ||
AppEventTypes Type; | ||
|
||
union | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Nest Labs, Inc. | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
struct AppEvent; | ||
typedef void (*EventHandler)(AppEvent *); | ||
|
||
struct AppEvent | ||
{ | ||
enum AppEventTypes | ||
{ | ||
kEventType_Button = 0, | ||
kEventType_Timer, | ||
kEventType_TurnOn, | ||
kEventType_Install, | ||
}; | ||
|
||
AppEventTypes Type; | ||
|
||
union | ||
{ | ||
struct | ||
{ | ||
uint8_t PinNo; | ||
uint8_t Action; | ||
} ButtonEvent; | ||
struct | ||
{ | ||
void * Context; | ||
} TimerEvent; | ||
struct | ||
{ | ||
uint8_t Action; | ||
int32_t Actor; | ||
} LightEvent; | ||
}; | ||
|
||
EventHandler Handler; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Google LLC. | ||
* All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
#include "AppEvent.h" | ||
|
||
#include <platform/CHIPDeviceLayer.h> | ||
|
||
#include "FreeRTOS.h" | ||
#include "timers.h" | ||
|
||
// Application-defined error codes in the CHIP_ERROR space. | ||
#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01) | ||
#define APP_ERROR_CREATE_TASK_FAILED CHIP_APPLICATION_ERROR(0x02) | ||
#define APP_ERROR_UNHANDLED_EVENT CHIP_APPLICATION_ERROR(0x03) | ||
#define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) | ||
#define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) | ||
#define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) | ||
|
||
class AppTask | ||
{ | ||
public: | ||
CHIP_ERROR StartAppTask(); | ||
static void AppTaskMain(void * pvParameter); | ||
void PostEvent(const AppEvent * event); | ||
|
||
private: | ||
friend AppTask & GetAppTask(void); | ||
|
||
CHIP_ERROR Init(); | ||
|
||
void CancelTimer(void); | ||
|
||
void DispatchEvent(AppEvent * event); | ||
|
||
static void FunctionTimerEventHandler(AppEvent * aEvent); | ||
static void KBD_Callback(uint8_t events); | ||
static void HandleKeyboard(void); | ||
static void BleHandler(AppEvent * aEvent); | ||
static void ResetActionEventHandler(AppEvent * aEvent); | ||
static void InstallEventHandler(AppEvent * aEvent); | ||
|
||
static void ButtonEventHandler(uint8_t pin_no, uint8_t button_action); | ||
static void TimerEventHandler(TimerHandle_t xTimer); | ||
|
||
static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); | ||
|
||
static void ThreadStart(); | ||
void StartTimer(uint32_t aTimeoutInMs); | ||
|
||
enum Function_t | ||
{ | ||
kFunction_NoneSelected = 0, | ||
kFunction_SoftwareUpdate = 0, | ||
kFunction_FactoryReset, | ||
|
||
kFunction_Invalid | ||
} Function; | ||
|
||
Function_t mFunction = kFunction_NoneSelected; | ||
bool mResetTimerActive = false; | ||
|
||
static AppTask sAppTask; | ||
}; | ||
|
||
inline AppTask & GetAppTask(void) | ||
{ | ||
return AppTask::sAppTask; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.