forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrote shell of the provider delegate in the example app
- Loading branch information
1 parent
2d43920
commit 5fab9d8
Showing
5 changed files
with
117 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
58 changes: 58 additions & 0 deletions
58
examples/log-source-app/log-source-common/DiagnosticLogsProvider.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,58 @@ | ||
/** | ||
* | ||
* Copyright (c) 2023 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 <app-common/zap-generated/attributes/Accessors.h> | ||
#include <app-common/zap-generated/callback.h> | ||
#include "DiagnosticLogsProvider.h" | ||
|
||
#include <app/util/config.h> | ||
|
||
using namespace chip; | ||
using namespace chip::app; | ||
using namespace chip::app::Clusters::DiagnosticLogs; | ||
|
||
LogSessionHandle DiagnosticLogsProvider::StartLogCollection(IntentEnum logType) | ||
{ | ||
if (mIsInLogSession) | ||
{ | ||
return kInvalidLogSessionHandle; | ||
} | ||
mIsInLogSession = true; | ||
|
||
// use the log type to maybe read a different file | ||
mLogType = logType; | ||
|
||
// open a log file for reading | ||
return ++(Instance().mLogSessionHandle); | ||
} | ||
|
||
void DiagnosticLogsProvider::GetNextChunk(LogSessionHandle logSessionHandle, chip::MutableByteSpan & outBuffer, bool & outIsEOF) | ||
{ | ||
// check if the file is valid and return chunks. maintain numberofbytesread and skip that much into the file | ||
} | ||
|
||
void DiagnosticLogsProvider::EndLogCollection(LogSessionHandle logSessionHandle) | ||
{ | ||
// close the file | ||
mTotalNumberOfBytesConsumed = 0; | ||
mIsInLogSession = false; | ||
} | ||
|
||
uint32_t DiagnosticLogsProvider::GetTotalNumberOfBytesConsumed() | ||
{ | ||
return mTotalNumberOfBytesConsumed; | ||
} |
52 changes: 52 additions & 0 deletions
52
examples/log-source-app/log-source-common/DiagnosticLogsProvider.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,52 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 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 <app/clusters/diagnostic-logs-server/diagnostic-logs-provider-delegate.h> | ||
|
||
class DiagnosticLogsProvider : public chip::app::Clusters::DiagnosticLogs::Delegate | ||
{ | ||
|
||
public: | ||
DiagnosticLogsProvider() { } | ||
|
||
chip::app::Clusters::DiagnosticLogs::LogSessionHandle StartLogCollection(chip::app::Clusters::DiagnosticLogs::IntentEnum logType); | ||
|
||
void GetNextChunk(chip::app::Clusters::DiagnosticLogs::LogSessionHandle logSessionHandle, chip::MutableByteSpan & outBuffer, bool & outIsEOF); | ||
|
||
void EndLogCollection(chip::app::Clusters::DiagnosticLogs::LogSessionHandle logSessionHandle); | ||
|
||
uint32_t GetTotalNumberOfBytesConsumed(); | ||
|
||
static DiagnosticLogsProvider & Instance() | ||
{ | ||
static DiagnosticLogsProvider instance; | ||
return instance; | ||
} | ||
|
||
~DiagnosticLogsProvider() = default; | ||
|
||
protected: | ||
|
||
chip::app::Clusters::DiagnosticLogs::IntentEnum mLogType; | ||
chip::app::Clusters::DiagnosticLogs::LogSessionHandle mLogSessionHandle; | ||
uint32_t mTotalNumberOfBytesConsumed; | ||
|
||
bool mIsInLogSession; | ||
}; |
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