Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sensor System
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institut für Informatik
QE Research Group
FORTE
Sensor System
Merge requests
!22
Resend Data capabilities
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resend Data capabilities
29-resending-of-data-if-network-connection-was-lost
into
develop
Overview
0
Commits
7
Pipelines
0
Changes
9
Merged
Zoe Pfister
requested to merge
29-resending-of-data-if-network-connection-was-lost
into
develop
2 years ago
Overview
0
Commits
7
Pipelines
0
Changes
9
Expand
Closes
#29 (closed)
0
0
Merge request reports
Compare
develop
version 3
c8d1f24a
2 years ago
version 2
89aa4cff
2 years ago
version 1
0f2090ab
2 years ago
develop (base)
and
latest version
latest version
4e7bef29
7 commits,
2 years ago
version 3
c8d1f24a
6 commits,
2 years ago
version 2
89aa4cff
5 commits,
2 years ago
version 1
0f2090ab
4 commits,
2 years ago
9 files
+
739
−
468
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
9
Search (e.g. *.vue) (Ctrl+P)
host/host_central_mast/lib/ResendManager/ResendManager.cpp
0 → 100644
+
72
−
0
Options
//
// Created by cynthya on 1/5/23.
//
#include
"ResendManager.h"
#include
"Utilities.h"
void
ResendManager
::
init
()
{
createResendDirectory
();
// log
uint
lastResendFileId
=
getLastResendFileId
();
nextResendFileId
=
lastResendFileId
+
1
;
esp_log_write
(
ESP_LOG_INFO
,
"ResendManager"
,
"nextResendFileId: %d
\n
"
,
nextResendFileId
);
}
uint
ResendManager
::
getLastResendFileId
()
const
{
// get the next file id to be resend
auto
filesInDirectory
=
getFilesInDirectory
(
resendDirectoryPath
);
// convert the file names to uint
std
::
list
<
uint
>
fileUintIDs
;
try
{
for
(
const
auto
&
fileName
:
filesInDirectory
)
{
fileUintIDs
.
emplace_back
(
std
::
stoul
(
fileName
.
c_str
()));
}
}
catch
(
std
::
invalid_argument
&
e
)
{
esp_log_write
(
ESP_LOG_ERROR
,
"getLastResendFileId"
,
"Failed to convert file name to uint
\n
"
);
throw
;
}
// get the max
uint
max
=
0
;
for
(
const
auto
&
fileID
:
fileUintIDs
)
{
if
(
fileID
>
max
)
{
max
=
fileID
;
}
}
return
max
;
}
void
ResendManager
::
createResendDirectory
()
const
{
// create directory if it doesn't exist
createDirectory
(
"/resend"
);
}
void
ResendManager
::
storeForResend
(
const
String
&
messageToBeSend
)
{
// create file
String
filename
=
String
(
nextResendFileId
);
writeFile
(
messageToBeSend
,
resendDirectoryPath
+
"/"
+
filename
);
ResendManager
::
incrementCount
();
}
std
::
optional
<
ResendPointType
>
ResendManager
::
loadNextToBeResendMessage
()
{
// get first file in resend directory
auto
filename
=
getFirstFileNameInDirectory
(
resendDirectoryPath
.
c_str
());
if
(
filename
.
has_value
())
{
// read file
auto
message
=
readFile
(
resendDirectoryPath
+
"/"
+
filename
.
value
().
c_str
());
return
ResendPointType
{
message
,
filename
.
value
()};
}
return
std
::
nullopt
;
}
void
ResendManager
::
deleteResendMessage
(
const
String
&
filename
)
{
auto
filePath
=
resendDirectoryPath
+
"/"
+
filename
;
if
(
SD
.
remove
(
filePath
.
c_str
()))
{
esp_log_write
(
ESP_LOG_INFO
,
"ResendManager"
,
"Deleted file: %s
\n
"
,
filePath
.
c_str
());
}
else
{
esp_log_write
(
ESP_LOG_ERROR
,
"ResendManager"
,
"Failed to delete file: %s
\n
"
,
filePath
.
c_str
());
throw
;
}
}
Loading