Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DidacticNetwork
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
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
letsgoING
Libraries
DidacticNetwork
Commits
605831db
Commit
605831db
authored
3 years ago
by
Anian Bühler
Browse files
Options
Downloads
Patches
Plain Diff
added message-legnth-limit (cut Topic or Payload)
parent
0b3ad2a5
No related branches found
Branches containing commit
No related tags found
2 merge requests
!3
Dev to master
,
!2
Dev to Master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
keywords.txt
+0
-1
0 additions, 1 deletion
keywords.txt
src/didacticNet.cpp
+3
-59
3 additions, 59 deletions
src/didacticNet.cpp
with
3 additions
and
60 deletions
keywords.txt
+
0
−
1
View file @
605831db
...
...
@@ -5,7 +5,6 @@
#######################################
# Datatypes (KEYWORD1)
#######################################
didacticPSNet KEYWORD1
didacticPSNetBroker KEYWORD1
didacticPSNetClient KEYWORD1
...
...
This diff is collapsed.
Click to expand it.
src/didacticNet.cpp
+
3
−
59
View file @
605831db
...
...
@@ -150,8 +150,7 @@ int didacticPSNet::extractData(int startCounter, int maxLength, char* buffer, ch
buffer
[
counter
-
startCounter
]
=
_readBufferMessage
[
counter
];
counter
++
;
if
((
counter
-
startCounter
)
>
maxLength
){
//return -1;
Serial
.
print
(
"
\n
extractData - Return on MAX length
\n
"
);
counter
--
;
break
;
//if > maxLenght -> leave while and return
}
}
...
...
@@ -232,24 +231,6 @@ int didacticPSNetClient::publish(char* topic, char* payload){
for
(
int
i
=
0
;
i
<
payloadLength
;
i
++
){
_sendBufferMessage
[
2
+
topicLength
+
1
+
i
]
=
payload
[
i
];
}
/*
if(topicLength <= MAX_LEN_TOPICS){
for(int i = 0; i < topicLength; i++){
_sendBufferMessage[2+i] = topic[i];
}
}else { //cut topic if longer than max
_dataToSend = false;
return false;
}
if(payloadLength <= MAX_LEN_PAYLOAD){
for(int i = 0; i < payloadLength; i++){
_sendBufferMessage[2+topicLength+1+i] = payload[i];
}
}else { //cut message if longer than max
_dataToSend = false;
return false;
}
*/
_dataToSend
=
true
;
return
error
;
...
...
@@ -264,7 +245,7 @@ int didacticPSNetClient::publish(char* topic, int topicLength, char* payload , i
_sendBufferMessage
[
2
+
topicLength
+
1
+
payloadLength
]
=
MSG_DELIMITER
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
payloadLength
+
1
]
=
'\0'
;
//TODO: check
//TODO: check
if
(
topicLength
>
MAX_LEN_TOPICS
){
topicLength
=
MAX_LEN_TOPICS
;
error
+=
DN_ERROR_TOPIC_LEN
;
...
...
@@ -280,24 +261,7 @@ int didacticPSNetClient::publish(char* topic, int topicLength, char* payload , i
for
(
int
i
=
0
;
i
<
payloadLength
;
i
++
){
_sendBufferMessage
[
2
+
topicLength
+
1
+
i
]
=
payload
[
i
];
}
/*
if(topicLength <= MAX_LEN_TOPICS){
for(int i = 0; i < topicLength; i++){
_sendBufferMessage[2+i] = topic[i];
}
}else { //cut topic if longer than max
_dataToSend = false;
return false;
}
if(payloadLength <= MAX_LEN_PAYLOAD){
for(int i = 0; i < payloadLength; i++){
_sendBufferMessage[2+topicLength+1+i] = payload[i];
}
}else { //cut message if longer than max
_dataToSend = false;
return false;
}
*/
_dataToSend
=
true
;
return
error
;
}
...
...
@@ -323,8 +287,6 @@ int didacticPSNetClient::subscribe(char* topic){
if
(
topicNumber
<
0
){
topicNumber
=
0
;
}
// if( topicLength <= MAX_LEN_TOPICS){
for
(
int
i
=
0
;
i
<
topicLength
;
i
++
){
_topic
[
topicNumber
][
i
]
=
topic
[
i
];
_sendBufferMessage
[
2
+
i
]
=
topic
[
i
];
...
...
@@ -332,21 +294,13 @@ int didacticPSNetClient::subscribe(char* topic){
_topic
[
topicNumber
][
topicLength
]
=
'\0'
;
_sendBufferMessage
[
2
+
topicLength
+
1
]
=
'\0'
;
_dataToSend
=
true
;
/* }
else {
_dataToSend = false;
return false;
}*/
}
else
{
//if( topicLength <= MAX_LEN_TOPICS){
for
(
int
i
=
0
;
i
<
topicLength
;
i
++
){
_sendBufferMessage
[
2
+
i
]
=
topic
[
i
];
}
_sendBufferMessage
[
2
+
topicLength
+
1
]
=
'\0'
;
_dataToSend
=
true
;
//}
}
while
(
_dataToSend
){
handleNetwork
();
...
...
@@ -373,8 +327,6 @@ int didacticPSNetClient::subscribe(char* topic, int topicLength){
if
(
topicNumber
<
0
){
topicNumber
=
0
;
}
// if( topicLength <= MAX_LEN_TOPICS){
for
(
int
i
=
0
;
i
<
topicLength
;
i
++
){
_topic
[
topicNumber
][
i
]
=
topic
[
i
];
_sendBufferMessage
[
2
+
i
]
=
topic
[
i
];
...
...
@@ -382,21 +334,13 @@ int didacticPSNetClient::subscribe(char* topic, int topicLength){
_topic
[
topicNumber
][
topicLength
]
=
'\0'
;
_sendBufferMessage
[
2
+
topicLength
+
1
]
=
'\0'
;
_dataToSend
=
true
;
/* }
else {
_dataToSend = false;
return false;
}*/
}
else
{
//if( topicLength <= MAX_LEN_TOPICS){
for
(
int
i
=
0
;
i
<
topicLength
;
i
++
){
_sendBufferMessage
[
2
+
i
]
=
topic
[
i
];
}
_sendBufferMessage
[
2
+
topicLength
+
1
]
=
'\0'
;
_dataToSend
=
true
;
//}
}
while
(
_dataToSend
){
handleNetwork
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment