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
e0ebf7a9
Commit
e0ebf7a9
authored
3 years ago
by
Anian Bühler
Browse files
Options
Downloads
Patches
Plain Diff
added examples
parent
6862f786
No related branches found
No related tags found
1 merge request
!6
added examples
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/sPSN_PingTest/sPSN_PingTest.ino
+114
-0
114 additions, 0 deletions
examples/sPSN_PingTest/sPSN_PingTest.ino
examples/sPSN_PongTester/sPSN_PongTester.ino
+93
-0
93 additions, 0 deletions
examples/sPSN_PongTester/sPSN_PongTester.ino
src/didacticNet.h
+1
-1
1 addition, 1 deletion
src/didacticNet.h
with
208 additions
and
1 deletion
examples/sPSN_PingTest/sPSN_PingTest.ino
0 → 100644
+
114
−
0
View file @
e0ebf7a9
/**
file: sPSN_HWTest
author: letsgoING -> info@letsgoing.de
description:
Test-Software um Clients im Netzwerk "anzumelden"
date: 01.12.2021
*/
/**
*file: sPSN_PingTest
*author: letsgoING -> info@letsgoing.de
*
*description:
* Test-Software um Clients im Netzwerk "anzumelden"
* Für das Netwerk werden min. 3 Arduinos mit IR-Link-Modulen benötigt:
*
* Arduino1: sPSN_Broker.ino
*
* Arduino2: sPSN_PongTester.ino -> fragt Clients ab
*
* Arduino3: sPSN_PingTest.ino -> reagiert auf PongTester
*
*date: 01.12.2021
*/
#include
"Arduino.h"
#include
"SoftwareSerial.h"
#include
"didacticNet.h"
//lege Geschwindigkeit für serielle Schnittstellen fest
#define SERIAL_BAUD 2400
//HIER CLIENT-NUMMER ANPASSEN
//*******************************
#define MY_NUMBER 1
//*******************************
#define LED_PIN 5
#define LED2_PIN 6
#define BUTTON_PIN 2
//lege Pins für SoftwareSerielle Schnittstelle fest
// Rx = 10 -> Empfänger | Tx = 11 -> Sender
SoftwareSerial
sSerial
(
10
,
11
);
//Erzeuge Client-Instanz
DidacticPSNetClient
psnClient
;
EdgeDetector
eDetector
;
//Arrays für Empfangs- und Sende Topic
char
topicSub
[
MAX_LEN_TOPICS
]
=
""
;
char
topicPub
[
MAX_LEN_TOPICS
]
=
""
;
char
payloadSend
[]
=
"Ping"
;
bool
ledState
=
true
;
void
myCallback
(
char
*
mTopic
,
int
mToLength
,
char
*
mData
,
int
mDaLength
)
{
Serial
.
println
(
mData
);
digitalWrite
(
LED_BUILTIN
,
HIGH
);
}
void
setup
()
{
//Starte Serielle Schnittstelle (zum PC)
Serial
.
begin
(
SERIAL_BAUD
);
delay
(
2000
);
sprintf
(
topicPub
,
"%02d"
,
MY_NUMBER
);
sprintf
(
topicSub
,
"%02d"
,
MY_NUMBER
);
Serial
.
print
(
"
\n
Starting sPSNet as Client "
);
Serial
.
println
(
topicPub
);
//Starte SoftwareSerielle Schnittstelle (zu IR-Link-Modulen)
sSerial
.
begin
(
SERIAL_BAUD
);
pinMode
(
LED_BUILTIN
,
OUTPUT
);
pinMode
(
LED_PIN
,
OUTPUT
);
pinMode
(
LED2_PIN
,
OUTPUT
);
digitalWrite
(
LED_BUILTIN
,
LOW
);
digitalWrite
(
LED_PIN
,
ledState
);
digitalWrite
(
LED2_PIN
,
ledState
);
psnClient
.
begin
(
sSerial
,
myCallback
);
psnClient
.
publish
(
topicPub
,
payloadSend
);
while
(
!
psnClient
.
handleNetwork
());
psnClient
.
subscribe
(
topicSub
);
while
(
!
psnClient
.
handleNetwork
());
psnClient
.
setInterval
(
10000L
);
}
void
loop
()
{
//Verarbeiten der Daten, prüfen ob Netzwerk frei und versenden der Daten
psnClient
.
handleNetwork
();
psnClient
.
publish
(
topicPub
,
payloadSend
);
if
(
eDetector
.
edgeDetected
(
digitalRead
(
BUTTON_PIN
))
==
RISING
)
{
ledState
=
!
ledState
;
digitalWrite
(
LED_PIN
,
!
ledState
);
digitalWrite
(
LED2_PIN
,
ledState
);
}
}
This diff is collapsed.
Click to expand it.
examples/sPSN_PongTester/sPSN_PongTester.ino
0 → 100644
+
93
−
0
View file @
e0ebf7a9
/**
*file: sPSN_PongTester
*author: letsgoING -> info@letsgoing.de
*
*description:
* Test-Software um Clients im Netzwerk "anzumelden"
* Für das Netwerk werden min. 3 Arduinos mit IR-Link-Modulen benötigt:
*
* Arduino1: sPSN_Broker.ino
*
* Arduino2: sPSN_PongTester.ino -> fragt Clients ab
*
* Arduino3: sPSN_PingTest.ino -> reagiert auf PongTester
*
*date: 01.12.2021
*/
#include
"Arduino.h"
#include
"SoftwareSerial.h"
#include
"didacticNet.h"
//lege Geschwindigkeit für serielle Schnittstellen fest
#define SERIAL_BAUD 2400
//HIER CLIENT_ZAHL ANPASSEN
//*******************************
#define MAX_NR_CLIENTS 15
//*******************************
//lege Pins für SoftwareSerielle Schnittstelle fest
// Rx = 10 -> Empfänger | Tx = 11 -> Sender
SoftwareSerial
sSerial
(
10
,
11
);
//Erzeuge Client-Instanz
DidacticPSNetClient
psnClient
;
//Arrays für Empfangs- und Sende Topic
char
topicSub
[
MAX_LEN_TOPICS
]
=
""
;
char
topicPub
[
MAX_LEN_TOPICS
]
=
""
;
char
payloadSend
[]
=
"Pong"
;
bool
ledState
=
true
;
void
myCallback
(
char
*
mTopic
,
int
mToLength
,
char
*
mData
,
int
mDaLength
)
{
Serial
.
println
(
mTopic
);
//reply pong
strcpy
(
topicPub
,
mTopic
);
if
(
!
strcmp
(
mData
,
"Ping"
))
{
Serial
.
print
(
" "
);
Serial
.
println
(
mTopic
);
psnClient
.
publish
(
topicPub
,
payloadSend
);
}
}
void
setup
()
{
//Starte Serielle Schnittstelle (zum PC)
Serial
.
begin
(
SERIAL_BAUD
);
delay
(
2000
);
Serial
.
print
(
"
\n
Searching for "
);
Serial
.
print
(
MAX_NR_CLIENTS
);
Serial
.
println
(
" sPSNet-Clients"
);
//Starte SoftwareSerielle Schnittstelle (zu IR-Link-Modulen)
sSerial
.
begin
(
SERIAL_BAUD
);
pinMode
(
LED_BUILTIN
,
OUTPUT
);
digitalWrite
(
LED_BUILTIN
,
LOW
);
psnClient
.
begin
(
sSerial
,
myCallback
);
//psnClient.subscribe("*");
Serial
.
println
(
"Topics: "
);
for
(
int
clientNr
=
0
;
clientNr
<
MAX_NR_CLIENTS
;
++
clientNr
)
{
sprintf
(
topicSub
,
"%02d"
,
clientNr
);
psnClient
.
subscribe
(
topicSub
);
while
(
!
psnClient
.
handleNetwork
());
Serial
.
print
(
topicSub
);
Serial
.
print
(
" "
);
}
Serial
.
println
(
"
\n\n
Ready for Clients..."
);
}
void
loop
()
{
//Verarbeiten der Daten, prüfen ob Netzwerk frei und versenden der Daten
psnClient
.
handleNetwork
();
}
This diff is collapsed.
Click to expand it.
src/didacticNet.h
+
1
−
1
View file @
e0ebf7a9
...
...
@@ -34,7 +34,7 @@
#define INTERVAL_CLIENT 500L
#define INTERVAL_BROKER 0L
#define MAX_NR_TOPICS_CLIENT
5
#define MAX_NR_TOPICS_CLIENT
20
#define MAX_NR_TOPICS_BROKER 20
#define MAX_LEN_TOPICS 10
#define MAX_LEN_PAYLOAD 20
...
...
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