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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
letsgoING
Libraries
DidacticNetwork
Commits
15f7f664
Commit
15f7f664
authored
Jul 9, 2021
by
Anian Bühler
Browse files
Options
Downloads
Patches
Plain Diff
changed Data to Payload
parent
7438fa3c
No related branches found
No related tags found
2 merge requests
!3
Dev to master
,
!2
Dev to Master
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/didacticNet.cpp
+24
-24
24 additions, 24 deletions
src/didacticNet.cpp
src/didacticNet.h
+12
-12
12 additions, 12 deletions
src/didacticNet.h
with
36 additions
and
36 deletions
src/didacticNet.cpp
+
24
−
24
View file @
15f7f664
...
...
@@ -100,7 +100,7 @@ int didacticPSNet::checkData(){
bool
didacticPSNet
::
recieveData
()
{
static
int
msgCounter
=
0
;
static
int
topicCounter
=
0
;
static
int
data
Counter
=
0
;
static
int
payload
Counter
=
0
;
//if(msgCounter == NULL){ msgCounter = 0; }
//if(topicCounter == NULL){ topicCounter = 0; }
//if(dataCounter == NULL){ dataCounter = 0; }
...
...
@@ -109,7 +109,7 @@ bool didacticPSNet::recieveData() {
if
(
localBuffer
==
MSG_PRELIMITER
)
{
msgCounter
=
0
;
topicCounter
=
0
;
data
Counter
=
0
;
payload
Counter
=
0
;
_readBufferMessage
[
msgCounter
]
=
localBuffer
;
}
else
if
(
localBuffer
==
MSG_DELIMITER
&&
_readBufferMessage
[
0
]
==
MSG_PRELIMITER
)
{
...
...
@@ -139,14 +139,14 @@ didacticPSNetClient::didacticPSNetClient(){}
didacticPSNetClient
::~
didacticPSNetClient
(){}
bool
didacticPSNetClient
::
publish
(
char
*
topic
,
char
*
data
){
bool
didacticPSNetClient
::
publish
(
char
*
topic
,
char
*
payload
){
int
topicLength
=
strlen
(
topic
);
int
data
Length
=
strlen
(
data
);
int
payload
Length
=
strlen
(
payload
);
_sendBufferMessage
[
0
]
=
MSG_PRELIMITER
;
_sendBufferMessage
[
1
]
=
MSG_PUBLISH
;
_sendBufferMessage
[
2
+
topicLength
]
=
MSG_SEPARATOR
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
data
Length
]
=
MSG_DELIMITER
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
data
Length
+
1
]
=
'\0'
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
payload
Length
]
=
MSG_DELIMITER
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
payload
Length
+
1
]
=
'\0'
;
if
(
topicLength
<=
MAX_LEN_TOPICS
){
for
(
int
i
=
0
;
i
<
topicLength
;
i
++
){
...
...
@@ -156,9 +156,9 @@ bool didacticPSNetClient::publish(char* topic, char* data){
_dataToSend
=
false
;
return
false
;
}
if
(
data
Length
<=
MAX_LEN_PAYLOAD
){
for
(
int
i
=
0
;
i
<
data
Length
;
i
++
){
_sendBufferMessage
[
2
+
topicLength
+
1
+
i
]
=
data
[
i
];
if
(
payload
Length
<=
MAX_LEN_PAYLOAD
){
for
(
int
i
=
0
;
i
<
payload
Length
;
i
++
){
_sendBufferMessage
[
2
+
topicLength
+
1
+
i
]
=
payload
[
i
];
}
}
else
{
_dataToSend
=
false
;
...
...
@@ -168,12 +168,12 @@ bool didacticPSNetClient::publish(char* topic, char* data){
return
true
;
}
bool
didacticPSNetClient
::
publish
(
char
*
topic
,
int
topicLength
,
char
*
data
,
int
data
Length
){
bool
didacticPSNetClient
::
publish
(
char
*
topic
,
int
topicLength
,
char
*
payload
,
int
payload
Length
){
_sendBufferMessage
[
0
]
=
MSG_PRELIMITER
;
_sendBufferMessage
[
1
]
=
MSG_PUBLISH
;
_sendBufferMessage
[
2
+
topicLength
]
=
MSG_SEPARATOR
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
data
Length
]
=
MSG_DELIMITER
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
data
Length
+
1
]
=
'\0'
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
payload
Length
]
=
MSG_DELIMITER
;
_sendBufferMessage
[
2
+
topicLength
+
1
+
payload
Length
+
1
]
=
'\0'
;
if
(
topicLength
<=
MAX_LEN_TOPICS
){
for
(
int
i
=
0
;
i
<
topicLength
;
i
++
){
...
...
@@ -183,9 +183,9 @@ bool didacticPSNetClient::publish(char* topic, int topicLength, char* data , int
_dataToSend
=
false
;
return
false
;
}
if
(
data
Length
<=
MAX_LEN_PAYLOAD
){
for
(
int
i
=
0
;
i
<
data
Length
;
i
++
){
_sendBufferMessage
[
2
+
topicLength
+
1
+
i
]
=
data
[
i
];
if
(
payload
Length
<=
MAX_LEN_PAYLOAD
){
for
(
int
i
=
0
;
i
<
payload
Length
;
i
++
){
_sendBufferMessage
[
2
+
topicLength
+
1
+
i
]
=
payload
[
i
];
}
}
else
{
_dataToSend
=
false
;
...
...
@@ -302,22 +302,22 @@ bool didacticPSNetClient::getMessageFilter(char messageType){
return
messageType
==
MSG_UPDATE
;
}
bool
didacticPSNetClient
::
save
Data
(
char
*
buffer
,
int
position
){
strcpy
(
_
data
[
position
],
buffer
);
bool
didacticPSNetClient
::
save
Payload
(
char
*
buffer
,
int
position
){
strcpy
(
_
payload
[
position
],
buffer
);
return
true
;
}
bool
didacticPSNetClient
::
handleData
(){
int
currentTopicNr
=
0
;
int
topicLength
=
0
;
int
data
Length
=
0
;
int
payload
Length
=
0
;
topicLength
=
extractData
(
2
,
MAX_LEN_TOPICS
,
_bufferTopic
,
MSG_SEPARATOR
);
if
(
topicLength
>
0
){
currentTopicNr
=
getTopicNr
(
_bufferTopic
);
data
Length
=
extractData
(
topicLength
+
3
,
MAX_LEN_PAYLOAD
,
_buffer
Data
,
MSG_DELIMITER
);
payload
Length
=
extractData
(
topicLength
+
3
,
MAX_LEN_PAYLOAD
,
_buffer
Payload
,
MSG_DELIMITER
);
if
(
currentTopicNr
>=
0
){
save
Data
(
_buffer
Data
,
currentTopicNr
);
callback
(
_topic
[
currentTopicNr
],
topicLength
,
_
data
[
currentTopicNr
],
data
Length
);
save
Payload
(
_buffer
Payload
,
currentTopicNr
);
callback
(
_topic
[
currentTopicNr
],
topicLength
,
_
payload
[
currentTopicNr
],
payload
Length
);
}
}
return
true
;
...
...
@@ -354,7 +354,7 @@ bool didacticPSNetBroker::getMessageFilter(char messageType){
return
(
messageType
==
MSG_PUBLISH
||
messageType
==
MSG_SUBSCRIBE
);
}
bool
didacticPSNetBroker
::
save
Data
(
char
*
buffer
,
int
position
){
bool
didacticPSNetBroker
::
save
Payload
(
char
*
buffer
,
int
position
){
strcpy
(
_data
[
position
],
buffer
);
return
true
;
}
...
...
@@ -374,9 +374,9 @@ bool didacticPSNetBroker::handleData(){
topicLength
=
extractData
(
2
,
MAX_LEN_TOPICS
,
_bufferTopic
,
MSG_SEPARATOR
);
if
(
topicLength
>
0
){
currentTopicNr
=
getTopicNr
(
_bufferTopic
);
dataLength
=
extractData
(
topicLength
+
3
,
MAX_LEN_PAYLOAD
,
_buffer
Data
,
MSG_DELIMITER
);
dataLength
=
extractData
(
topicLength
+
3
,
MAX_LEN_PAYLOAD
,
_buffer
Payload
,
MSG_DELIMITER
);
if
(
currentTopicNr
>=
0
){
writeDataToTopic
(
currentTopicNr
,
_bufferTopic
,
_buffer
Data
);
writeDataToTopic
(
currentTopicNr
,
_bufferTopic
,
_buffer
Payload
);
update
(
_topic
[
currentTopicNr
],
topicLength
,
_data
[
currentTopicNr
],
dataLength
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/didacticNet.h
+
12
−
12
View file @
15f7f664
...
...
@@ -42,14 +42,14 @@ class didacticPSNet
PSNET_CALLBACK_SIGNATURE
;
char
_bufferTopic
[
MAX_LEN_TOPICS
+
1
]
=
{
0
};
char
_buffer
Data
[
MAX_LEN_PAYLOAD
+
1
]
=
{
0
};
char
_buffer
Payload
[
MAX_LEN_PAYLOAD
+
1
]
=
{
0
};
char
_readBufferMessage
[
MAX_LEN_TOPICS
+
MAX_LEN_PAYLOAD
+
4
+
1
];
char
_sendBufferMessage
[
MAX_LEN_TOPICS
+
MAX_LEN_PAYLOAD
+
4
+
1
];
bool
_dataToSend
=
false
;
// int Data to send for queue?
unsigned
long
_waitingTime
=
0L
;
int
_currentTopicLength
=
0
;
int
_current
Data
Length
=
0
;
int
_current
Payload
Length
=
0
;
didacticPSNet
&
setCallback
(
PSNET_CALLBACK_SIGNATURE
);
void
setStream
(
Stream
&
_port
);
...
...
@@ -62,7 +62,7 @@ class didacticPSNet
virtual
int
getTopicNr
(
char
*
)
=
0
;
virtual
int
getFreeTopicNr
()
=
0
;
virtual
bool
getMessageFilter
(
char
)
=
0
;
virtual
bool
save
Data
(
char
*
,
int
)
=
0
;
virtual
bool
save
Payload
(
char
*
,
int
)
=
0
;
virtual
bool
handleData
()
=
0
;
public
:
...
...
@@ -81,9 +81,9 @@ class didacticPSNetClient : public didacticPSNet
private:
char
_topic
[
MAX_NR_TOPICS_CLIENT
][
MAX_LEN_TOPICS
+
1
]
=
{
{
0
}
};
char
_
data
[
MAX_NR_TOPICS_CLIENT
][
MAX_LEN_PAYLOAD
+
1
]
=
{
{
0
}
};
char
_
payload
[
MAX_NR_TOPICS_CLIENT
][
MAX_LEN_PAYLOAD
+
1
]
=
{
{
0
}
};
bool
save
Data
(
char
*
,
int
);
bool
save
Payload
(
char
*
,
int
);
bool
getMessageFilter
(
char
);
bool
handleData
();
int
getTopicNr
(
char
*
);
...
...
@@ -110,7 +110,7 @@ class didacticPSNetBroker: public didacticPSNet
char
_topic
[
MAX_NR_TOPICS_BROKER
][
MAX_LEN_TOPICS
+
1
]
=
{
{
0
}
};
char
_data
[
MAX_NR_TOPICS_BROKER
][
MAX_LEN_PAYLOAD
+
1
]
=
{
{
0
}
};
bool
save
Data
(
char
*
,
int
);
bool
save
Payload
(
char
*
,
int
);
bool
getMessageFilter
(
char
);
void
writeDataToTopic
(
int
,
char
*
,
char
*
);
bool
handleData
();
...
...
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
sign in
to comment