-
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.
Add support for matter cli in EFR32 example apps (#12749)
* Support matter shell in all efr32 example apps * add source set and start task for other examples * add shell_common example cmds * restyle
- Loading branch information
1 parent
8d4a28a
commit 973320c
Showing
17 changed files
with
397 additions
and
42 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
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
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
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 Project CHIP Authors | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "matter_shell.h" | ||
#include <ChipShellCollection.h> | ||
#include <FreeRTOS.h> | ||
#include <lib/core/CHIPCore.h> | ||
#include <lib/shell/Engine.h> | ||
#include <task.h> | ||
|
||
using namespace ::chip; | ||
using chip::Shell::Engine; | ||
|
||
namespace { | ||
|
||
#define SHELL_TASK_STACK_SIZE 2048 | ||
#define SHELL_TASK_PRIORITY 5 | ||
TaskHandle_t shellTaskHandle; | ||
StackType_t shellStack[SHELL_TASK_STACK_SIZE / sizeof(StackType_t)]; | ||
StaticTask_t shellTaskStruct; | ||
|
||
void MatterShellTask(void * args) | ||
{ | ||
chip::Shell::Engine::Root().RunMainLoop(); | ||
} | ||
|
||
} // namespace | ||
|
||
extern "C" unsigned int sleep(unsigned int seconds) | ||
{ | ||
const TickType_t xDelay = 1000 * seconds / portTICK_PERIOD_MS; | ||
vTaskDelay(xDelay); | ||
return 0; | ||
} | ||
|
||
namespace chip { | ||
|
||
void NotifyShellProcess() | ||
{ | ||
xTaskNotifyGive(shellTaskHandle); | ||
} | ||
|
||
void NotifyShellProcessFromISR() | ||
{ | ||
BaseType_t yieldRequired = pdFALSE; | ||
if (shellTaskHandle != NULL) | ||
{ | ||
vTaskNotifyGiveFromISR(shellTaskHandle, &yieldRequired); | ||
} | ||
portYIELD_FROM_ISR(yieldRequired); | ||
} | ||
|
||
void WaitForShellActivity() | ||
{ | ||
ulTaskNotifyTake(pdTRUE, portMAX_DELAY); | ||
} | ||
|
||
void startShellTask() | ||
{ | ||
int status = chip::Shell::streamer_init(chip::Shell::streamer_get()); | ||
assert(status == 0); | ||
|
||
// For now also register commands from shell_common (shell app). | ||
// TODO move at least OTCLI to default commands in lib/shell/commands | ||
cmd_misc_init(); | ||
cmd_otcli_init(); | ||
cmd_ping_init(); | ||
cmd_send_init(); | ||
|
||
shellTaskHandle = xTaskCreateStatic(MatterShellTask, "matter_cli", ArraySize(shellStack), NULL, SHELL_TASK_PRIORITY, shellStack, | ||
&shellTaskStruct); | ||
} | ||
|
||
} // namespace chip |
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,27 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* | ||
* 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 | ||
|
||
namespace chip { | ||
|
||
void NotifyShellProcess(); | ||
void NotifyShellProcessFromISR(); | ||
void WaitForShellActivity(); | ||
void startShellTask(); | ||
|
||
} // namespace chip |
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
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
Oops, something went wrong.