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
79f47875
Verified
Commit
79f47875
authored
2 years ago
by
Anian Bühler
Browse files
Options
Downloads
Patches
Plain Diff
added getSubscribedTopics + examples
parent
1c9ec30c
No related branches found
No related tags found
1 merge request
!9
update master from dev2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/sPSN_PlotTopics/sPSN_PlotTopics.ino
+61
-0
61 additions, 0 deletions
examples/sPSN_PlotTopics/sPSN_PlotTopics.ino
keywords.txt
+4
-1
4 additions, 1 deletion
keywords.txt
src/DidacticNet.cpp
+9
-1
9 additions, 1 deletion
src/DidacticNet.cpp
src/DidacticNet.h
+4
-0
4 additions, 0 deletions
src/DidacticNet.h
with
78 additions
and
2 deletions
examples/sPSN_PlotTopics/sPSN_PlotTopics.ino
0 → 100644
+
61
−
0
View file @
79f47875
/**
*file: sPSN_PlotTopics
*author: letsgoING -> info@letsgoing.de
*
*description:
* Dieses Programm abboniert Beispiel-Topics und gibt diese auf dem SerialMonitor aus.
*
* parameter:
* MAX_LEN_PAYLOAD = 20 Zeichen (didacticNet.h)
* MAX_LEN_TOPICS = 10 Zeichen (didacticNet.h)
*
*date: 15.07.2022
*/
#include
<Arduino.h>
#include
"SoftwareSerial.h"
#include
"DidacticNet.h"
#define SERIAL_BAUD 2400 //lege Geschwindigkeit für serielle Schnittstellen fest
SoftwareSerial
sSerial
(
10
,
11
);
//Erzeuge SoftwareSerial-Instanz mit Rx = Pin10 -> Empfänger | Tx = Pin11 -> Sender
DidacticPSNetClient
psnClient
;
//Erzeuge PubSub-Client-Instanz
//Callback-Funktion - in diesem Beispiel nicht verwendet
void
newData
(
char
*
topic
,
char
*
payload
)
{
}
void
setup
()
{
Serial
.
begin
(
SERIAL_BAUD
);
//Starte Serielle Schnittstelle (zum PC)
sSerial
.
begin
(
SERIAL_BAUD
);
//Starte SoftwareSerielle Schnittstelle (zu IR-Link-Modulen)
psnClient
.
begin
(
sSerial
,
newData
);
//Starte PubSub Client an SoftwareSerial Schnittstelle
//Beliebige Beispiel-Topics abbonieren -> zusätzliche Topics hinzufügen
psnClient
.
subscribe
(
"temp1"
);
psnClient
.
subscribe
(
"temp2"
);
psnClient
.
subscribe
(
"light1"
);
psnClient
.
subscribe
(
"poti"
);
//lese Anzahl der abbonierten Topics aus
int
countTopics
=
psnClient
.
getMaxNrTopics
();
Serial
.
print
(
"Anzahl Topics: "
);
Serial
.
println
(
countTopics
);
//Gebe alle Topics nacheinander aus
for
(
int
i
=
0
;
i
<
countTopics
;
i
++
){
char
topic
[
MAX_LEN_TOPICS
];
psnClient
.
getSubscribedTopic
(
topic
,
i
);
Serial
.
print
(
"Topic "
);
Serial
.
print
(
i
);
Serial
.
print
(
": "
);
Serial
.
println
(
topic
);
}
}
void
loop
()
{
}
This diff is collapsed.
Click to expand it.
keywords.txt
+
4
−
1
View file @
79f47875
...
@@ -27,6 +27,9 @@ publishOnChange KEYWORD2
...
@@ -27,6 +27,9 @@ publishOnChange KEYWORD2
subscribe KEYWORD2
subscribe KEYWORD2
unsubscribe KEYWORD2
unsubscribe KEYWORD2
getMaxNrTopic KEYWORD2
getSubscribedTopic KEYWORD2
timeElapsed KEYWORD2
timeElapsed KEYWORD2
readSerialData KEYWORD2
readSerialData KEYWORD2
...
@@ -53,4 +56,4 @@ DN_ASCII_NL LITERAL1
...
@@ -53,4 +56,4 @@ DN_ASCII_NL LITERAL1
DN_PUBLISH_SUCCESSULL LITERAL1
DN_PUBLISH_SUCCESSULL LITERAL1
DN_ERROR_NO_ERROR LITERAL1
DN_ERROR_NO_ERROR LITERAL1
DN_ERROR_TOPIC_LEN LITERAL1
DN_ERROR_TOPIC_LEN LITERAL1
DN_ERROR_PAYLOAD_LEN LITERAL1
DN_ERROR_PAYLOAD_LEN LITERAL1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/DidacticNet.cpp
+
9
−
1
View file @
79f47875
...
@@ -268,7 +268,6 @@ int DidacticPSNetClient::subscribe(char* topic, int topicLength){
...
@@ -268,7 +268,6 @@ int DidacticPSNetClient::subscribe(char* topic, int topicLength){
return
error
;
return
error
;
}
}
bool
DidacticPSNetClient
::
unsubscribe
(
char
*
topic
){
bool
DidacticPSNetClient
::
unsubscribe
(
char
*
topic
){
return
unsubscribe
(
topic
,
strlen
(
topic
));
return
unsubscribe
(
topic
,
strlen
(
topic
));
}
}
...
@@ -331,6 +330,15 @@ int DidacticPSNetClient::getFreeTopicNr() {
...
@@ -331,6 +330,15 @@ int DidacticPSNetClient::getFreeTopicNr() {
return
-
1
;
return
-
1
;
}
}
int
DidacticPSNetClient
::
getSubscribedTopic
(
char
*
topic
,
int
number
){
strcpy
(
topic
,
_topic
[
number
]);
return
1
;
}
int
DidacticPSNetClient
::
getMaxNrTopics
(){
return
getFreeTopicNr
();
}
//**************************************************************************
//**************************************************************************
//Broker
//Broker
...
...
This diff is collapsed.
Click to expand it.
src/DidacticNet.h
+
4
−
0
View file @
79f47875
...
@@ -173,6 +173,10 @@ class DidacticPSNetClient : public DidacticPSNet
...
@@ -173,6 +173,10 @@ class DidacticPSNetClient : public DidacticPSNet
DidacticPSNetClient
();
DidacticPSNetClient
();
~
DidacticPSNetClient
();
~
DidacticPSNetClient
();
int
getMaxNrTopics
();
int
getSubscribedTopic
(
char
*
,
int
);
int
publish
(
char
*
,
char
*
);
int
publish
(
char
*
,
char
*
);
int
publish
(
char
*
,
int
,
char
*
,
int
);
int
publish
(
char
*
,
int
,
char
*
,
int
);
int
publish
(
char
*
,
int
);
int
publish
(
char
*
,
int
);
...
...
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