-
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.
ESP32: Add otcli command in matter console (#29004)
* ESP32: Add otcli command in matter console * add function cli_transmit_task_post * use char ptr in xQueueSend * add constant for otcli transmit task
- Loading branch information
Showing
6 changed files
with
181 additions
and
9 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
68 changes: 68 additions & 0 deletions
68
examples/platform/esp32/shell_extension/openthread_cli_register.cpp
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,68 @@ | ||
/* | ||
* | ||
* 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 "sdkconfig.h" | ||
#if CONFIG_OPENTHREAD_CLI | ||
#include "esp_check.h" | ||
#include "esp_err.h" | ||
#include "esp_log.h" | ||
#include "freertos/FreeRTOS.h" | ||
#include "openthread_cli_register.h" | ||
#include "platform/ESP32/OpenthreadLauncher.h" | ||
#include <lib/shell/Engine.h> | ||
#include <memory> | ||
|
||
#define CLI_INPUT_BUFF_LENGTH 256u | ||
namespace chip { | ||
|
||
static CHIP_ERROR OtcliHandler(int argc, char * argv[]) | ||
{ | ||
/* the beginning of command "matter otcli" has already been removed */ | ||
std::unique_ptr<char[]> cli_str(new char[CLI_INPUT_BUFF_LENGTH]); | ||
memset(cli_str.get(), 0, CLI_INPUT_BUFF_LENGTH); | ||
uint8_t len = 0; | ||
for (size_t i = 0; i < (size_t) argc; ++i) | ||
{ | ||
len = len + strlen(argv[i]) + 1; | ||
if (len > CLI_INPUT_BUFF_LENGTH - 1) | ||
{ | ||
return CHIP_ERROR_INTERNAL; | ||
} | ||
strcat(cli_str.get(), argv[i]); | ||
strcat(cli_str.get(), " "); | ||
} | ||
|
||
if (cli_transmit_task_post(std::move(cli_str)) != CHIP_NO_ERROR) | ||
{ | ||
return CHIP_ERROR_INTERNAL; | ||
} | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
void RegisterOpenThreadCliCommands() | ||
{ | ||
static const chip::Shell::shell_command_t cmds[] = { | ||
{ | ||
.cmd_func = OtcliHandler, | ||
.cmd_name = "otcli", | ||
.cmd_help = "OpenThread cli commands", | ||
}, | ||
}; | ||
int cmds_num = sizeof(cmds) / sizeof(chip::Shell::shell_command_t); | ||
chip::Shell::Engine::Root().RegisterCommands(cmds, cmds_num); | ||
} | ||
} // namespace chip | ||
#endif // CONFIG_OPENTHREAD_CLI |
24 changes: 24 additions & 0 deletions
24
examples/platform/esp32/shell_extension/openthread_cli_register.h
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,24 @@ | ||
/* | ||
* | ||
* 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 RegisterOpenThreadCliCommands(); | ||
|
||
} // 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