-
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 Mbed OS shell example implementation Add shell to mbed_example script, launch.json, tasks.json and build workflow Add sleep function to arch.c ConfiguraitonManagerImple cleanup * Add shell example to Mbed build workflow Fix server command * Fix network socket client commands - partial * Fix close IOCTL socket for Mbe implementation * Improve Mbed network client and example commands * Improve message buffer service and error logs * Fix BLE advertising stop * Add CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY flag to shell config * Improve echo server logs Mbed commands cleanup * Restore log filter * Fix handle DNS resolve callback checking error * Update app logging * Changes for Mbed OS update * Improve examples startup logging * Fix after platform clock changes * Fix MBED_PATH value Fix mbed shell commands Changes restyle * Remove mbed-specific shell command from shell app * Fix Mbed shell example build
- Loading branch information
Showing
14 changed files
with
277 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config/ | ||
build-*/ |
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,58 @@ | ||
# Copyright (c) 2021 ARM Limited. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.19.0) | ||
|
||
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH) | ||
get_filename_component(APP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. REALPATH) | ||
get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH) | ||
|
||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/config.in | ||
${CMAKE_CURRENT_BINARY_DIR}/chip_build/config | ||
@ONLY | ||
) | ||
|
||
set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "") | ||
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "") | ||
set(APP_TARGET chip-mbed-shell-example) | ||
|
||
include(${MBED_PATH}/tools/cmake/app.cmake) | ||
|
||
project(${APP_TARGET}) | ||
|
||
add_subdirectory(${MBED_PATH} ./mbed_build) | ||
add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) | ||
|
||
add_executable(${APP_TARGET}) | ||
|
||
add_subdirectory(${CHIP_ROOT}/config/mbed ./chip_build) | ||
|
||
mbed_configure_app_target(${APP_TARGET}) | ||
|
||
target_include_directories(${APP_TARGET} PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/main/include | ||
${APP_ROOT}/shell_common/include | ||
${GEN_DIR}/app-common) | ||
|
||
target_sources(${APP_TARGET} PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/main/main.cpp | ||
${APP_ROOT}/shell_common/cmd_misc.cpp | ||
${APP_ROOT}/shell_common/cmd_otcli.cpp | ||
${APP_ROOT}/shell_common/cmd_ping.cpp | ||
${APP_ROOT}/shell_common/cmd_send.cpp | ||
${APP_ROOT}/shell_common/globals.cpp | ||
) | ||
|
||
target_link_libraries(${APP_TARGET} mbed-os-posix-socket mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip) | ||
|
||
if(MBED_TARGET STREQUAL "CY8CPROTO_062_4343W") | ||
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network) | ||
endif() | ||
|
||
mbed_set_post_build(${APP_TARGET}) | ||
|
||
option(VERBOSE_BUILD "Have a verbose build process") | ||
if(VERBOSE_BUILD) | ||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
endif() |
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,6 @@ | ||
CONFIG_CHIP_BUILD_TESTS=n | ||
CONFIG_CHIP_WITH_EXTERNAL_MBEDTLS=y | ||
CONFIG_CHIP_PROJECT_CONFIG=main/include/CHIPProjectConfig.h | ||
CONFIG_CHIP_BYPASS_RENDEZVOUS=n | ||
CONFIG_CHIP_LIB_SHELL=y | ||
CONFIG_MBED_BSD_SOCKET_TRACE=n |
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,45 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* This is a place to put application or project-specific overrides | ||
* to the default configuration values for general CHIP features. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1 | ||
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 | ||
|
||
#define CHIP_SHELL_MAX_MODULES 30 | ||
|
||
// Use a default pairing code if one hasn't been provisioned in flash. | ||
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 | ||
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 | ||
|
||
/** | ||
* CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY | ||
* | ||
* Enables the use of a hard-coded default Chip device id and credentials if no device id | ||
* is found in Chip NV storage. | ||
* | ||
* This option is for testing only and should be disabled in production releases. | ||
*/ | ||
#define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 34 |
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,106 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 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 "mbedtls/platform.h" | ||
#include <ChipShellCollection.h> | ||
#include <lib/core/CHIPCore.h> | ||
#include <lib/shell/Engine.h> | ||
#include <lib/support/CHIPMem.h> | ||
#include <lib/support/logging/CHIPLogging.h> | ||
#include <platform/CHIPDeviceLayer.h> | ||
#include <platform/mbed/Logging.h> | ||
|
||
using namespace ::chip; | ||
using namespace ::chip::Shell; | ||
using namespace ::chip::DeviceLayer; | ||
using namespace ::chip::Logging::Platform; | ||
|
||
int main() | ||
{ | ||
int ret = 0; | ||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
|
||
mbed_logging_init(); | ||
|
||
ChipLogProgress(NotSpecified, "Mbed shell example application start"); | ||
|
||
ret = mbedtls_platform_setup(NULL); | ||
if (ret) | ||
{ | ||
ChipLogError(Shell, "Mbed TLS platform initialization failed [%d]", ret); | ||
goto exit; | ||
} | ||
|
||
err = chip::Platform::MemoryInit(); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
ChipLogError(Shell, "Memory initalization failed: %s", err.AsString()); | ||
ret = EXIT_FAILURE; | ||
goto exit; | ||
} | ||
|
||
err = PlatformMgr().InitChipStack(); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
ChipLogError(Shell, "Chip stack initalization failed: %s", err.AsString()); | ||
ret = EXIT_FAILURE; | ||
goto exit; | ||
} | ||
|
||
#ifdef MBED_CONF_APP_BLE_DEVICE_NAME | ||
err = ConnectivityMgr().SetBLEDeviceName(MBED_CONF_APP_BLE_DEVICE_NAME); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
ChipLogError(Shell, "Set BLE device name failed: %s", err.AsString()); | ||
ret = EXIT_FAILURE; | ||
goto exit; | ||
} | ||
#endif | ||
|
||
#if CHIP_DEVICE_CONFIG_ENABLE_WPA | ||
ConnectivityManagerImpl().StartWiFiManagement(); | ||
#endif | ||
|
||
err = PlatformMgr().StartEventLoopTask(); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
ChipLogError(Shell, "Chip stack start failed: %s", err.AsString()); | ||
ret = EXIT_FAILURE; | ||
goto exit; | ||
} | ||
|
||
// Initialize the default streamer that was linked. | ||
ret = streamer_init(streamer_get()); | ||
if (ret) | ||
{ | ||
ChipLogError(Shell, "Streamer initialization failed [%d]", ret); | ||
goto exit; | ||
} | ||
|
||
cmd_misc_init(); | ||
cmd_otcli_init(); | ||
cmd_ping_init(); | ||
cmd_send_init(); | ||
|
||
ChipLogProgress(NotSpecified, "Mbed shell example application run"); | ||
|
||
Engine::Root().RunMainLoop(); | ||
|
||
exit: | ||
ChipLogProgress(NotSpecified, "Exited with code %d", ret); | ||
return ret; | ||
} |
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,31 @@ | ||
{ | ||
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"chip_mbedtls_config.h\""], | ||
"target_overrides": { | ||
"*": { | ||
"platform.stdio-baud-rate": 115200, | ||
"lwip.ipv6-enabled": true, | ||
"lwip.raw-socket-enabled": true, | ||
"nsapi.default-wifi-security": "WPA_WPA2", | ||
"nsapi.default-wifi-ssid": "\"YOUR_SSID\"", | ||
"nsapi.default-wifi-password": "\"YOUR_PASSWORD\"", | ||
"mbed-trace.max-level": "TRACE_LEVEL_DEBUG", | ||
"mbed-trace.enable": true, | ||
"target.printf_lib": "std" | ||
}, | ||
"CY8CPROTO_062_4343W": { | ||
"target.network-default-interface-type": "WIFI", | ||
"target.macros_add": [ | ||
"MXCRYPTO_DISABLED", | ||
"NL_ASSERT_LOG=NL_ASSERT_LOG_DEFAULT", | ||
"NL_ASSERT_EXPECT_FLAGS=NL_ASSERT_FLAG_LOG", | ||
"WHD_PRINT_DISABLE" | ||
] | ||
} | ||
}, | ||
"config": { | ||
"ble-device-name": { | ||
"help": "Name used for BLE advertising.", | ||
"value": "\"MBED-shell\"" | ||
} | ||
} | ||
} |
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