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
a3762819
Commit
a3762819
authored
3 years ago
by
Anian Bühler
Browse files
Options
Downloads
Patches
Plain Diff
added intervalTime to handleNetwork
parent
b8cb7989
No related branches found
No related tags found
1 merge request
!4
Dev to Master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/didacticNet.cpp
+22
-11
22 additions, 11 deletions
src/didacticNet.cpp
src/didacticNet.h
+6
-0
6 additions, 0 deletions
src/didacticNet.h
with
28 additions
and
11 deletions
src/didacticNet.cpp
+
22
−
11
View file @
a3762819
...
...
@@ -34,7 +34,7 @@ void didacticPSNet::setStream(Stream& stream){
}
bool
didacticPSNet
::
handleNetwork
(){
if
(
_waitingTime
<=
millis
()){
//
if(_waitingTime <= millis()){
if
(
checkData
()){
if
(
recieveData
()){
//Serial.print("Message filter: ");Serial.println(_readBufferMessage[1]);
...
...
@@ -45,21 +45,23 @@ bool didacticPSNet::handleNetwork(){
}
_waitingTime
=
millis
()
+
random
(
CSMA_MIN_DELAY_MS
,
CSMA_MAX_DELAY_MS
);
}
else
if
(
_dataToSend
){
//send data to network
//else if(_dataToSend){
if
(
_dataToSend
&&
_waitingTime
<=
millis
()){
//send data to network
//TODO: test added CSMA_CHECKDELAY + 2nd checkData()
delayMicroseconds
(
CSMA_CHECK_DELAY_US
);
if
(
!
checkData
()){
if
(
!
sendData
()){
return
false
;
}
if
(
!
sendData
()){
return
false
;
}
else
{
_dataToSend
=
false
;
_waitingTime
=
millis
()
+
random
(
CSMA_MID_DELAY_MS
,
CSMA_MAX_DELAY_MS
);
//_waitingTime = millis()+ random(CSMA_MID_DELAY_MS, CSMA_MAX_DELAY_MS);
_waitingTime
=
millis
()
+
_intervalTime
;
//random(CSMA_MID_DELAY_MS, CSMA_MAX_DELAY_MS);
}
}
}
}
}
//
}
return
true
;
}
...
...
@@ -139,10 +141,17 @@ bool didacticPSNet::recieveData() {
return
false
;
}
void
didacticPSNet
::
setInterval
(
long
intervalTime
){
_intervalTime
=
intervalTime
;
}
//**************************************************************************
// CLIENT
//**************************************************************************
didacticPSNetClient
::
didacticPSNetClient
(){}
didacticPSNetClient
::
didacticPSNetClient
(){
_intervalTime
=
INTERVAL_CLIENT
;
}
didacticPSNetClient
::~
didacticPSNetClient
(){}
...
...
@@ -414,7 +423,9 @@ int didacticPSNetClient::readSerialData(Stream& rsStream, char* rsDataArray, cha
//**************************************************************************
//Broker
//**************************************************************************
didacticPSNetBroker
::
didacticPSNetBroker
(){}
didacticPSNetBroker
::
didacticPSNetBroker
(){
_intervalTime
=
INTERVAL_BROKER
;
}
didacticPSNetBroker
::~
didacticPSNetBroker
(){}
...
...
This diff is collapsed.
Click to expand it.
src/didacticNet.h
+
6
−
0
View file @
a3762819
...
...
@@ -31,6 +31,9 @@
#define CSMA_MID_DELAY_MS 20
#define CSMA_MAX_DELAY_MS 30
#define INTERVAL_CLIENT 500L
#define INTERVAL_BROKER 0L
#define MAX_NR_TOPICS_CLIENT 5
#define MAX_NR_TOPICS_BROKER 20
#define MAX_LEN_TOPICS 10
...
...
@@ -58,6 +61,7 @@ class didacticPSNet
bool
_dataToSend
=
false
;
// int Data to send for queue?
unsigned
long
_waitingTime
=
0L
;
unsigned
long
_intervalTime
;
int
_currentTopicLength
=
0
;
int
_currentPayloadLength
=
0
;
...
...
@@ -84,6 +88,8 @@ class didacticPSNet
bool
handleNetwork
();
bool
isDataToSend
();
void
setInterval
(
long
);
};
class
didacticPSNetClient
:
public
didacticPSNet
...
...
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