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
Merge requests
!6
added examples
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
added examples
dev
into
master
Overview
0
Commits
1
Pipelines
0
Changes
3
Merged
Anian Bühler
requested to merge
dev
into
master
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
3
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
e0ebf7a9
1 commit,
3 years ago
3 files
+
208
−
1
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
examples/sPSN_PingTest/sPSN_PingTest.ino
0 → 100644
+
114
−
0
Options
/**
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
);
}
}
Loading