Skip to content

Commit

Permalink
Merge 55793d8 into ed28753
Browse files Browse the repository at this point in the history
  • Loading branch information
pull[bot] authored Feb 10, 2021
2 parents ed28753 + 55793d8 commit 1384136
Show file tree
Hide file tree
Showing 64 changed files with 779 additions and 423 deletions.
1 change: 1 addition & 0 deletions examples/chip-tool/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"helpers": [
"../../../src/app/zap-templates/partials/helper.js",
"../../../src/app/zap-templates/common/StringHelper.js",
"../../../src/app/zap-templates/templates/app/helper.js",
"../../../src/app/zap-templates/templates/chip/helper.js",
"helper.js"
],
Expand Down
27 changes: 27 additions & 0 deletions examples/common/pigweed/nrfconnect/PigweedLoggerMutex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
*
* 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.
*/

#include "PigweedLoggerMutex.h"

namespace chip {
namespace rpc {

PigweedLoggerMutex logger_mutex;

} // namespace rpc
} // namespace chip
52 changes: 52 additions & 0 deletions examples/common/pigweed/nrfconnect/PigweedLoggerMutex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
*
* 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.
*/

#pragma once

#include "PigweedLogger.h"
#include "pigweed/RpcService.h"
#include <kernel.h>

namespace chip {
namespace rpc {
class PigweedLoggerMutex : public ::chip::rpc::Mutex
{
public:
PigweedLoggerMutex() {}
void Lock() override
{
k_sem * sem = PigweedLogger::GetSemaphore();
if (sem)
{
k_sem_take(sem, K_FOREVER);
}
}
void Unlock() override
{
k_sem * sem = PigweedLogger::GetSemaphore();
if (sem)
{
k_sem_give(sem);
}
}
};

extern PigweedLoggerMutex logger_mutex;

} // namespace rpc
} // namespace chip
4 changes: 1 addition & 3 deletions examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ static LEDWidget sLightLED;

static bool sIsThreadProvisioned = false;
static bool sIsThreadEnabled = false;
static bool sIsThreadAttached = false;
static bool sHaveBLEConnections = false;
static bool sHaveServiceConnectivity = false;

Expand Down Expand Up @@ -187,7 +186,6 @@ void AppTask::AppTaskMain(void * pvParameter)
{
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
sIsThreadAttached = ConnectivityMgr().IsThreadAttached();
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity();
PlatformMgr().UnlockChipStack();
Expand All @@ -213,7 +211,7 @@ void AppTask::AppTaskMain(void * pvParameter)
{
sStatusLED.Set(true);
}
else if (sIsThreadProvisioned && sIsThreadEnabled && (!sIsThreadAttached || !sHaveServiceConnectivity))
else if (sIsThreadProvisioned && sIsThreadEnabled)
{
sStatusLED.Blink(950, 50);
}
Expand Down
4 changes: 3 additions & 1 deletion examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pw_proto_library(pigweed_lighting_protolib
target_sources(app PRIVATE
main/Rpc.cpp
../../common/pigweed/RpcService.cpp
../../common/pigweed/nrfconnect/PigweedLoggerMutex.cpp
${NRFCONNECT_COMMON}/util/PigweedLogger.cpp
)

Expand All @@ -96,7 +97,8 @@ target_include_directories(app PRIVATE
${PIGWEED_ROOT}/pw_sys_io/public
${CHIP_ROOT}/src/lib/support
${CHIP_ROOT}/src/system
../../common)
../../common
../../common/pigweed/nrfconnect)

target_link_libraries(app PRIVATE
pigweed_lighting_protolib.nanopb_rpc
Expand Down
11 changes: 2 additions & 9 deletions examples/lighting-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ NFCWidget sNFC;

bool sIsThreadProvisioned = false;
bool sIsThreadEnabled = false;
bool sIsThreadAttached = false;
bool sIsPairedToAccount = false;
bool sHaveBLEConnections = false;
bool sHaveServiceConnectivity = false;

Expand Down Expand Up @@ -164,16 +162,11 @@ int AppTask::StartApp()
{
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
sIsThreadAttached = ConnectivityMgr().IsThreadAttached();
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity();
PlatformMgr().UnlockChipStack();
}

// Consider the system to be "fully connected" if it has service
// connectivity and it is able to interact with the service on a regular basis.
bool isFullyConnected = sHaveServiceConnectivity;

// Update the status LED if factory reset has not been initiated.
//
// If system has "full connectivity", keep the LED On constantly.
Expand All @@ -188,11 +181,11 @@ int AppTask::StartApp()
// Otherwise, blink the LED ON for a very short time.
if (sAppTask.mFunction != kFunction_FactoryReset)
{
if (isFullyConnected)
if (sHaveServiceConnectivity)
{
sStatusLED.Set(true);
}
else if (sIsThreadProvisioned && sIsThreadEnabled && sIsPairedToAccount && (!sIsThreadAttached || !isFullyConnected))
else if (sIsThreadProvisioned && sIsThreadEnabled)
{
sStatusLED.Blink(950, 50);
}
Expand Down
27 changes: 2 additions & 25 deletions examples/lighting-app/nrfconnect/main/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Rpc.h"
#include "AppTask.h"
#include "PigweedLogger.h"
#include "PigweedLoggerMutex.h"
#include "pigweed/RpcService.h"

#include "main/pigweed_lighting.rpc.pb.h"
Expand Down Expand Up @@ -52,30 +53,6 @@ namespace {

using std::byte;

class PigweedLoggerMutex : public ::chip::rpc::Mutex
{
public:
PigweedLoggerMutex() {}
void Lock() override
{
k_sem * sem = PigweedLogger::GetSemaphore();
if (sem)
{
k_sem_take(sem, K_FOREVER);
}
}
void Unlock() override
{
k_sem * sem = PigweedLogger::GetSemaphore();
if (sem)
{
k_sem_give(sem);
}
}
};

PigweedLoggerMutex uart_mutex;

constexpr size_t kRpcTaskSize = 4096;
constexpr int kRpcPriority = 5;

Expand All @@ -101,7 +78,7 @@ k_tid_t Init()

void RunRpcService(void *, void *, void *)
{
Start(RegisterServices, &uart_mutex);
Start(RegisterServices, &logger_mutex);
}

} // namespace rpc
Expand Down
6 changes: 1 addition & 5 deletions examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ static LEDWidget sLockLED;

static bool sIsThreadProvisioned = false;
static bool sIsThreadEnabled = false;
static bool sIsThreadAttached = false;
static bool sIsPairedToAccount = false;
static bool sHaveBLEConnections = false;
static bool sHaveServiceConnectivity = false;

Expand Down Expand Up @@ -187,9 +185,7 @@ void AppTask::AppTaskMain(void * pvParameter)
{
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
sIsThreadAttached = ConnectivityMgr().IsThreadAttached();
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
sIsPairedToAccount = ConfigurationMgr().IsPairedToAccount();
sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity();
PlatformMgr().UnlockChipStack();
}
Expand All @@ -214,7 +210,7 @@ void AppTask::AppTaskMain(void * pvParameter)
{
sStatusLED.Set(true);
}
else if (sIsThreadProvisioned && sIsThreadEnabled && (!sIsThreadAttached || !sHaveServiceConnectivity))
else if (sIsThreadProvisioned && sIsThreadEnabled)
{
sStatusLED.Blink(950, 50);
}
Expand Down
12 changes: 2 additions & 10 deletions examples/lock-app/k32w/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ static LEDWidget sLockLED;

static bool sIsThreadProvisioned = false;
static bool sIsThreadEnabled = false;
static bool sIsThreadAttached = false;
static bool sIsPairedToAccount = false;
static bool sHaveBLEConnections = false;
static bool sHaveServiceConnectivity = false;

Expand Down Expand Up @@ -176,17 +174,11 @@ void AppTask::AppTaskMain(void * pvParameter)
{
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
sIsThreadAttached = ConnectivityMgr().IsThreadAttached();
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
sIsPairedToAccount = ConfigurationMgr().IsPairedToAccount();
sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity();
PlatformMgr().UnlockChipStack();
}

// Consider the system to be "fully connected" if it has service
// connectivity and it is able to interact with the service on a regular basis.
bool isFullyConnected = sHaveServiceConnectivity;

// Update the status LED if factory reset has not been initiated.
//
// If system has "full connectivity", keep the LED On constantly.
Expand All @@ -201,11 +193,11 @@ void AppTask::AppTaskMain(void * pvParameter)
// Otherwise, blink the LED ON for a very short time.
if (sAppTask.mFunction != kFunction_FactoryReset)
{
if (isFullyConnected)
if (sHaveServiceConnectivity)
{
sStatusLED.Set(true);
}
else if (sIsThreadProvisioned && sIsThreadEnabled && sIsPairedToAccount && (!sIsThreadAttached || !isFullyConnected))
else if (sIsThreadProvisioned && sIsThreadEnabled)
{
sStatusLED.Blink(950, 50);
}
Expand Down
11 changes: 2 additions & 9 deletions examples/lock-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ static NFCWidget sNFC;

static bool sIsThreadProvisioned = false;
static bool sIsThreadEnabled = false;
static bool sIsThreadAttached = false;
static bool sIsPairedToAccount = false;
static bool sHaveBLEConnections = false;
static bool sHaveServiceConnectivity = false;

Expand Down Expand Up @@ -156,16 +154,11 @@ int AppTask::StartApp()
{
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
sIsThreadAttached = ConnectivityMgr().IsThreadAttached();
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity();
PlatformMgr().UnlockChipStack();
}

// Consider the system to be "fully connected" if it has service
// connectivity and it is able to interact with the service on a regular basis.
bool isFullyConnected = sHaveServiceConnectivity;

// Update the status LED if factory reset has not been initiated.
//
// If system has "full connectivity", keep the LED On constantly.
Expand All @@ -180,11 +173,11 @@ int AppTask::StartApp()
// Otherwise, blink the LED ON for a very short time.
if (sAppTask.mFunction != kFunction_FactoryReset)
{
if (isFullyConnected)
if (sHaveServiceConnectivity)
{
sStatusLED.Set(true);
}
else if (sIsThreadProvisioned && sIsThreadEnabled && sIsPairedToAccount && (!sIsThreadAttached || !isFullyConnected))
else if (sIsThreadProvisioned && sIsThreadEnabled)
{
sStatusLED.Blink(950, 50);
}
Expand Down
6 changes: 1 addition & 5 deletions examples/lock-app/qpg6100/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ static QueueHandle_t sAppEventQueue;

static bool sIsThreadProvisioned = false;
static bool sIsThreadEnabled = false;
static bool sIsThreadAttached = false;
static bool sIsPairedToAccount = false;
static bool sHaveBLEConnections = false;
static bool sHaveServiceConnectivity = false;

Expand Down Expand Up @@ -145,7 +143,6 @@ void AppTask::AppTaskMain(void * pvParameter)
{
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
sIsThreadAttached = ConnectivityMgr().IsThreadAttached();
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity();
PlatformMgr().UnlockChipStack();
Expand All @@ -171,8 +168,7 @@ void AppTask::AppTaskMain(void * pvParameter)
{
qvCHIP_LedSet(SYSTEM_STATE_LED, true);
}
else if (sIsThreadProvisioned && sIsThreadEnabled && sIsPairedToAccount &&
(!sIsThreadAttached || !sHaveServiceConnectivity))
else if (sIsThreadProvisioned && sIsThreadEnabled)
{
qvCHIP_LedBlink(SYSTEM_STATE_LED, 950, 50);
}
Expand Down
1 change: 1 addition & 0 deletions examples/pigweed-app/nrfconnect/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
Loading

0 comments on commit 1384136

Please sign in to comment.