Skip to content

Commit

Permalink
Merge branch 'master' into esp32/update_managed_mdns_component
Browse files Browse the repository at this point in the history
  • Loading branch information
wqx6 authored May 30, 2023
2 parents 39a3688 + 22de5a0 commit 5304709
Show file tree
Hide file tree
Showing 118 changed files with 2,813 additions and 733 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/java-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ jobs:

env:
TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt"
JAVA_PATH: /usr/lib/jvm/java-8-openjdk-amd64

if: github.actor != 'restyled-io[bot]'
runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build-java:0.7.3
image: connectedhomeip/chip-build-java:0.7.15
options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0
net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0"

Expand Down Expand Up @@ -79,7 +78,30 @@ jobs:
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log
- name: Generate unit tests
timeout-minutes: 1
run: |
scripts/run_in_build_env.sh \
'./scripts/build/build_examples.py \
--target linux-x64-tests \
gen \
'
- name: Build unit tests
timeout-minutes: 25
run: scripts/run_in_build_env.sh 'ninja -C out/linux-x64-tests src:java_controller_tests'

- name: Run unit tests
timeout-minutes: 10
# TODO: this direct path loading is not maintainable. Our build system should define and
# support test classes.
run: |
$JAVA_PATH/bin/java \
-cp 'third_party/java_deps/artifacts/*:out/linux-x64-tests/lib/src/controller/java/*' \
org.junit.runner.JUnitCore \
chip.tlv.TlvWriterTest \
chip.tlv.TlvReadWriteTest \
chip.tlv.TlvReaderTest \
chip.jsontlv.JsonToTlvToJsonTest
- name: Build Java Matter Controller and all clusters app
timeout-minutes: 50
run: |
Expand Down
4 changes: 2 additions & 2 deletions build/chip/java/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
java_path = getenv("JAVA_PATH")
declare_args() {
java_matter_controller_dependent_paths = []
build_java_matter_controller = false
matter_enable_java_compilation = false
if (java_path != "" && current_os != "android") {
java_matter_controller_dependent_paths += [ "${java_path}/include/" ]

Expand All @@ -27,6 +27,6 @@ declare_args() {
[ "${java_path}/include/linux/" ]
}

build_java_matter_controller = true
matter_enable_java_compilation = true
}
}
4 changes: 2 additions & 2 deletions build/chip/java/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ kotlinc_runner = "${chip_root}/build/chip/java/kotlinc_runner.py"
jar_runner = "${chip_root}/build/chip/java/jar_runner.py"
write_build_config = "${chip_root}/build/chip/java/write_build_config.py"

assert(android_sdk_root != "" || build_java_matter_controller,
"android_sdk_root or java_path must be specified")
assert(android_sdk_root != "" || matter_enable_java_compilation,
"android_sdk_root must be specified or JAVA_PATH must be set.")

# Declare a java library target
#
Expand Down
2 changes: 1 addition & 1 deletion build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ config("strict_warnings") {
cflags += [ "-Wconversion" ]
}

if (build_java_matter_controller) {
if (matter_enable_java_compilation) {
cflags -= [ "-Wshadow" ]
}

Expand Down
2 changes: 1 addition & 1 deletion config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ idf_component_get_property(lwip_lib lwip COMPONENT_LIB)
list(APPEND chip_libraries $<TARGET_FILE:${lwip_lib}>)


if (CONFIG_ESP_WIFI_ENABLED)
if (CONFIG_ESP32_WIFI_ENABLED)
idf_component_get_property(esp_wifi_lib esp_wifi COMPONENT_LIB)
idf_component_get_property(esp_wifi_dir esp_wifi COMPONENT_DIR)
list(APPEND chip_libraries $<TARGET_FILE:${esp_wifi_lib}>)
Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/commands/common/CHIPCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class CHIPCommand : public Command
using PeerId = ::chip::PeerId;
using PeerAddress = ::chip::Transport::PeerAddress;

static constexpr uint16_t kMaxGroupsPerFabric = 5;
static constexpr uint16_t kMaxGroupKeysPerFabric = 8;
static constexpr uint16_t kMaxGroupsPerFabric = 50;
static constexpr uint16_t kMaxGroupKeysPerFabric = 25;

CHIPCommand(const char * commandName, CredentialIssuerCommands * credIssuerCmds, const char * helpText = nullptr) :
Command(commandName, helpText), mCredIssuerCmds(credIssuerCmds)
Expand Down
4 changes: 0 additions & 4 deletions examples/java-matter-controller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ kotlin_binary("java-matter-controller") {
output_name = "java-matter-controller"
deps = [
":java",
"${chip_root}/src/controller/java:json_to_tlv_to_json_test",
"${chip_root}/src/controller/java:onboarding_payload",
"${chip_root}/src/controller/java:tlv_read_write_test",
"${chip_root}/src/controller/java:tlv_reader_test",
"${chip_root}/src/controller/java:tlv_writer_test",
"${chip_root}/third_party/java_deps:kotlin-stdlib",
]

Expand Down
13 changes: 6 additions & 7 deletions examples/platform/silabs/efr32/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ static uint8_t sRxFifoBuffer[MAX_BUFFER_SIZE];
static Fifo_t sReceiveFifo;

static void UART_rx_callback(UARTDRV_Handle_t handle, Ecode_t transferStatus, uint8_t * data, UARTDRV_Count_t transferCount);
static void UART_tx_callback(struct UARTDRV_HandleData * handle, Ecode_t transferStatus, uint8_t * data,
UARTDRV_Count_t transferCount);
static void uartSendBytes(uint8_t * buffer, uint16_t nbOfBytes);

static bool InitFifo(Fifo_t * fifo, uint8_t * pDataBuffer, uint16_t bufferSize)
Expand Down Expand Up @@ -474,14 +472,15 @@ void uartSendBytes(uint8_t * buffer, uint16_t nbOfBytes)
#endif

#if (defined(EFR32MG24) && defined(WF200_WIFI))
// Blocking transmit for the MG24 + WF200 since UART TX is multiplexed with
// WF200 SPI IRQ
pre_uart_transfer();
#endif /* EFR32MG24 && WF200_WIFI */

UARTDRV_ForceTransmit(vcom_handle, (uint8_t *) buffer, nbOfBytes);
post_uart_transfer();
#else
// Non Blocking Transmit
UARTDRV_Transmit(vcom_handle, (uint8_t *) buffer, nbOfBytes, UART_tx_callback);
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);

#if (defined(EFR32MG24) && defined(WF200_WIFI))
post_uart_transfer();
#endif /* EFR32MG24 && WF200_WIFI */

#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
Expand Down
17 changes: 11 additions & 6 deletions examples/platform/telink/common/include/AppConfigCommon.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@
#pragma once

// 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
#if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE
#define BUTTON_FACTORY_RESET GPIO_DT_SPEC_GET(DT_NODELABEL(key_1), gpios)
#define BUTTON_BLE_START GPIO_DT_SPEC_GET(DT_NODELABEL(key_2), gpios)
#define BUTTON_THREAD_START GPIO_DT_SPEC_GET(DT_NODELABEL(key_3), gpios)
#define BUTTON_EXAMPLE_ACTION GPIO_DT_SPEC_GET(DT_NODELABEL(key_4), gpios)
#else
#define BUTTON_COL_1 GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_col1), gpios)
#define BUTTON_COL_2 GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_col2), gpios)
#define BUTTON_ROW_1 GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_row1), gpios)
#define BUTTON_ROW_2 GPIO_DT_SPEC_GET(DT_NODELABEL(key_matrix_row2), gpios)
#endif

// LEDs config
#define LEDS_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob))
Expand Down
88 changes: 79 additions & 9 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
#include <app/InteractionModelEngine.h>
#endif

#ifdef CONFIG_CHIP_FACTORY_RESET_ERASE_NVS
#include <zephyr/fs/nvs.h>
#include <zephyr/settings/settings.h>
#endif

using namespace chip::app;

LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);
Expand All @@ -47,6 +52,22 @@ constexpr int kFactoryResetCalcTimeout = 3000;
constexpr int kFactoryResetTriggerCntr = 3;
constexpr int kAppEventQueueSize = 10;

#if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE
const struct gpio_dt_spec sFactoryResetButtonDt = BUTTON_FACTORY_RESET;
const struct gpio_dt_spec sBleStartButtonDt = BUTTON_BLE_START;
#if APP_USE_THREAD_START_BUTTON
const struct gpio_dt_spec sThreadStartButtonDt = BUTTON_THREAD_START;
#endif
#if APP_USE_EXAMPLE_START_BUTTON
const struct gpio_dt_spec sExampleActionButtonDt = BUTTON_EXAMPLE_ACTION;
#endif
#else
const struct gpio_dt_spec sButtonCol1Dt = BUTTON_COL_1;
const struct gpio_dt_spec sButtonCol2Dt = BUTTON_COL_2;
const struct gpio_dt_spec sButtonRow1Dt = BUTTON_ROW_1;
const struct gpio_dt_spec sButtonRow2Dt = BUTTON_ROW_2;
#endif

#if APP_USE_IDENTIFY_PWM
constexpr uint32_t kIdentifyBlinkRateMs = 200;
constexpr uint32_t kIdentifyOkayOnRateMs = 50;
Expand Down Expand Up @@ -118,7 +139,47 @@ class AppFabricTableDelegate : public FabricTable::Delegate
{
if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0)
{
chip::Server::GetInstance().ScheduleFactoryReset();
ChipLogProgress(DeviceLayer, "Performing erasing of settings partition");

#ifdef CONFIG_CHIP_FACTORY_RESET_ERASE_NVS
void * storage = nullptr;
int status = settings_storage_get(&storage);

if (status == 0)
{
status = nvs_clear(static_cast<nvs_fs *>(storage));
}

if (!status)
{
status = nvs_mount(static_cast<nvs_fs *>(storage));
}

if (status)
{
ChipLogError(DeviceLayer, "Storage clearance failed: %d", status);
}
#else
const CHIP_ERROR err = PersistedStorage::KeyValueStoreMgrImpl().DoFactoryReset();

if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Factory reset failed: %" CHIP_ERROR_FORMAT, err.Format());
}

ConnectivityMgr().ErasePersistentInfo();
#endif
}
}
};

class PlatformMgrDelegate : public DeviceLayer::PlatformManagerDelegate
{
void OnShutDown() override
{
if (ThreadStackManagerImpl().IsThreadEnabled())
{
ThreadStackManagerImpl().Finalize();
}
}
};
Expand Down Expand Up @@ -240,6 +301,15 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void)
chip::app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&GetICDUtil());
#endif

// We need to disable OpenThread to prevent writing to the NVS storage when factory reset occurs
// The OpenThread thread is running during factory reset. The nvs_clear function is called during
// factory reset, which makes the NVS storage innaccessible, but the OpenThread knows nothing
// about this and tries to store the parameters to NVS. Because of this the OpenThread need to be
// shut down before NVS. This delegate fixes the issue "Failed to store setting , ret -13",
// which means that the NVS is already disabled.
// For this the OnShutdown function is used
PlatformMgr().SetDelegate(new PlatformMgrDelegate);

// Add CHIP event handler and start CHIP thread.
// Note that all the initialization code should happen prior to this point to avoid data races
// between the main and the CHIP threads.
Expand All @@ -258,28 +328,28 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void)
void AppTaskCommon::InitButtons(void)
{
#if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE
sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_1, FactoryResetButtonEventHandler);
sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, StartBleAdvButtonEventHandler);
sFactoryResetButton.Configure(&sFactoryResetButtonDt, FactoryResetButtonEventHandler);
sBleAdvStartButton.Configure(&sBleStartButtonDt, StartBleAdvButtonEventHandler);
#if APP_USE_EXAMPLE_START_BUTTON
if (ExampleActionEventHandler)
{
sExampleActionButton.Configure(BUTTON_PORT, BUTTON_PIN_2, ExampleActionButtonEventHandler);
sExampleActionButton.Configure(&sExampleActionButtonDt, ExampleActionButtonEventHandler);
}
#endif
#if APP_USE_THREAD_START_BUTTON
sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, StartThreadButtonEventHandler);
sThreadStartButton.Configure(&sThreadStartButtonDt, StartThreadButtonEventHandler);
#endif
#else
sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler);
sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler);
sFactoryResetButton.Configure(&sButtonRow1Dt, &sButtonCol1Dt, FactoryResetButtonEventHandler);
sBleAdvStartButton.Configure(&sButtonRow2Dt, &sButtonCol2Dt, StartBleAdvButtonEventHandler);
#if APP_USE_EXAMPLE_START_BUTTON
if (ExampleActionEventHandler)
{
sExampleActionButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, ExampleActionButtonEventHandler);
sExampleActionButton.Configure(&sButtonRow1Dt, &sButtonCol2Dt, ExampleActionButtonEventHandler);
}
#endif
#if APP_USE_THREAD_START_BUTTON
sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, StartThreadButtonEventHandler);
sThreadStartButton.Configure(&sButtonRow2Dt, &sButtonCol1Dt, StartThreadButtonEventHandler);
#endif
#endif

Expand Down
16 changes: 8 additions & 8 deletions examples/platform/telink/util/include/ButtonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
class Button
{
public:
void Configure(const struct device * port, gpio_pin_t outPin, gpio_pin_t inPin, void (*callback)(void));
void Configure(const struct device * port, gpio_pin_t inPin, void (*callback)(void));
void Configure(const gpio_dt_spec * input_button_dt, const gpio_dt_spec * output_button_dt, void (*callback)(void));
void Configure(const gpio_dt_spec * input_button_dt, void (*callback)(void));
void Poll(Button * previous);
void PollIRQ(void);
void PollIRQ(const struct device * dev, uint32_t pins);
void SetCallback(void (*callback)(void));

private:
int Init(void);
int Deinit(void);

const struct device * mPort;
gpio_pin_t mOutPin;
gpio_pin_t mInPin;
int mPreviousState = STATE_LOW;
const struct gpio_dt_spec * mInput_button;
const struct gpio_dt_spec * mOutput_matrix_pin;
int mPreviousState = STATE_LOW;
struct gpio_callback mButton_cb_data;
void (*mCallback)(void) = NULL;
};

Expand All @@ -48,7 +48,7 @@ class ButtonManager
public:
void Init(void);
void Poll(void);
void PollIRQ(void);
void PollIRQ(const struct device * dev, uint32_t pins);
void AddButton(Button & button);
void SetCallback(unsigned int index, void (*callback)(void));

Expand Down
Loading

0 comments on commit 5304709

Please sign in to comment.