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
eeb465a3
Commit
eeb465a3
authored
4 years ago
by
Anian Bühler
Browse files
Options
Downloads
Patches
Plain Diff
reformatted
parent
f92a97ab
No related branches found
Branches containing commit
No related tags found
2 merge requests
!3
Dev to master
,
!2
Dev to Master
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+25
-12
25 additions, 12 deletions
README.md
src/didacticNet.cpp
+4
-4
4 additions, 4 deletions
src/didacticNet.cpp
src/didacticNet.h
+1
-1
1 addition, 1 deletion
src/didacticNet.h
with
30 additions
and
17 deletions
README.md
+
25
−
12
View file @
eeb465a3
...
...
@@ -28,7 +28,8 @@ didacticPSNetClient psnClient;
#Starten der Client-Instanz
void
psnClient
.
begin
(
Stream
&
sSerial
,
fcn
callback
);
//Param1: Schnittstelle (Serial | SoftSerial); param2: Callback-Funktion
// param1: Schnittstelle (Serial | SoftSerial)
// param2: Callback-Funktion
#Netzwerkverwaltung Client (Daten senden und Empfangen, Zugriffsregelung)
bool
psnClient
.
handleNetwork
();
...
...
@@ -38,26 +39,35 @@ bool psnClient.handleNetwork();
int
psnClient
.
subscribe
(
char
*
topic
);
// param: Topic String/char-Array ("example" / char topic[n])
int
psnClient
.
subscribe
(
char
*
topic
,
int
length
);
// param1: Topic String/char-Array; param2: Anzahl Zeichen des Topics
// param1: Topic String/char-Array
// param2: Anzahl Zeichen des Topics
// return ERROR-Wert: DN_ERROR_NOERROR, DN_ERROR_TOPIC_LEN (Topic zu lang - wird abgeschnitten)
#Topic eines anderen Clients entfernen
bool
psnClient
.
unsubscribe
(
char
*
topic
);
// param: Topic String/char-Array
bool
psnClient
.
unsubscribe
(
char
*
topic
,
int
length
);
// param1: Topic String/char-Array; Param2: Param2: Anzahl Zeichen des Topics
// param1: Topic String/char-Array
// param2: Anzahl Zeichen des Topics
// return true wenn Daten versendet / false wenn nicht
#Daten unter Topic veroeffentlichen
int
psnClient
.
publish
(
char
*
topic
,
char
*
payload
);
int
psnClient
.
publish
(
char
*
topic
,
char
*
payload
);
// param1: Topic String/char-Array; param2: payload-char-Array
int
psnClient
.
publish
(
char
*
topic
,
int
topicLength
,
char
*
payload
,
int
payloadLength
);
// param1: Topic String/char-Array; param2: Anzahl Zeichen des Topics, param3: payload-char-Array; param4: Anzahl Zeichen der Payload
int
psnClient
.
publish
(
char
*
topic
,
int
topicLength
,
char
*
payload
,
int
payloadLength
);
// param1: Topic String/char-Array
// param2: Anzahl Zeichen des Topics
// param3: payload-char-Array
// param4: Anzahl Zeichen der Payload
// return: ERROR-Wert: DN_ERROR_NOERROR, DN_ERROR_TOPIC_LEN, DN_ERROR_PAYLOAD_LEN (Payload zu lange - wird abgeschnitten)
#Callback-Funktion (wird bei neuen Daten aufgerufen)
void
clientCallback
(
char
*
topic
,
int
topicLength
,
char
*
payload
,
int
payloadLength
){...}
//param1: Topic der Nachricht, param2: Lange des Topics; param3: Nutdaten der Nachricht; param4: Laenge der
// param1: Topic der Nachricht
// param2: Lange des Topics
// param3: Nutdaten der Nachricht
// param4: Laenge der
```
### Broker
...
...
@@ -88,7 +98,8 @@ int psnClient.edgeDetected(bool currentState);
#Auf Wertaenderung groeßer Schwellwert pruefen
bool
psnClient
.
valueChanged
(
int
currentvalue
,
int
threshold
);
// param: aktueller Wert; param2: Schwellwert
// param1: aktueller Wert
// param2: Schwellwert
// return: true -> Aenderung groeßer als Schwellwert; sonst false
#Nicht blockierendes Warten
...
...
@@ -98,7 +109,9 @@ bool psnClient.timeElapsed(long);
#Einlesen von Text ueber Serialle Schnittstelle bis Endezeichen empfangen wird
int
psnClient
.
readSerialData
(
Stream
&
,
char
*
,
char
);
// param1: Schnittstelle (Serial | SoftSerial); param2: Array in das die Zeichen eingelesen werden; param3: Endezeichen (char)
// param1: Schnittstelle (Serial | SoftSerial)
// param2: Array in das die Zeichen eingelesen werden
// param3: Endezeichen (char)
// return: Anzahl der eingelesenen Zeichen (0 wenn noch kein Endezeichen)
```
...
...
@@ -107,8 +120,8 @@ int psnClient.readSerialData(Stream&, char*, char);
Konstanten aus der Library die fuer die Programmierung genutzt werden und teilweise angepasst werden koennen.
```
cpp
#ASCII Endezeichen
DN_ASCII_CR
->
'
CR
'
->
(
int
)
13
DN_ASCII_NL
->
'
NL
'
->
(
int
)
10
DN_ASCII_CR
"carriage return CR"
(
int
)
13
DN_ASCII_NL
"new line NL"
(
int
)
10
#Laenge Topics und Payload (Client und Broker)
MAX_LEN_TOPICS
default
:
10
...
...
@@ -119,7 +132,7 @@ MAX_NR_TOPICS_CLIENT default: 5
MAX_NR_TOPICS_BROKER
default
:
20
#ERRORs
DN_ERROR_NOERROR
0
DN_ERROR_NO
_
ERROR
0
DN_ERROR_TOPIC_LEN
-
1
DN_ERROR_PAYLOAD_LEN
-
2
...
...
This diff is collapsed.
Click to expand it.
src/didacticNet.cpp
+
4
−
4
View file @
eeb465a3
...
...
@@ -147,7 +147,7 @@ didacticPSNetClient::didacticPSNetClient(){}
didacticPSNetClient
::~
didacticPSNetClient
(){}
int
didacticPSNetClient
::
publish
(
char
*
topic
,
char
*
payload
){
int
error
=
DN_ERROR_NOERROR
;
int
error
=
DN_ERROR_NO
_
ERROR
;
int
topicLength
=
strlen
(
topic
);
int
payloadLength
=
strlen
(
payload
);
...
...
@@ -179,7 +179,7 @@ int didacticPSNetClient::publish(char* topic, char* payload){
}
int
didacticPSNetClient
::
publish
(
char
*
topic
,
int
topicLength
,
char
*
payload
,
int
payloadLength
){
int
error
=
DN_ERROR_NOERROR
;
int
error
=
DN_ERROR_NO
_
ERROR
;
_sendBufferMessage
[
0
]
=
MSG_PRELIMITER
;
_sendBufferMessage
[
1
]
=
MSG_PUBLISH
;
...
...
@@ -209,7 +209,7 @@ int didacticPSNetClient::publish(char* topic, int topicLength, char* payload , i
}
int
didacticPSNetClient
::
subscribe
(
char
*
topic
){
int
error
=
DN_ERROR_NOERROR
;
int
error
=
DN_ERROR_NO
_
ERROR
;
int
topicLength
=
strlen
(
topic
);
...
...
@@ -251,7 +251,7 @@ int didacticPSNetClient::subscribe(char* topic){
}
int
didacticPSNetClient
::
subscribe
(
char
*
topic
,
int
topicLength
){
int
error
=
DN_ERROR_NOERROR
;
int
error
=
DN_ERROR_NO
_
ERROR
;
if
(
topicLength
>
MAX_LEN_TOPICS
){
topicLength
=
MAX_LEN_TOPICS
;
...
...
This diff is collapsed.
Click to expand it.
src/didacticNet.h
+
1
−
1
View file @
eeb465a3
...
...
@@ -36,7 +36,7 @@
#define MAX_LEN_TOPICS 10
#define MAX_LEN_PAYLOAD 20
#define DN_ERROR_NOERROR
0
#define DN_ERROR_NO
_
ERROR 0
#define DN_ERROR_TOPIC_LEN -1
#define DN_ERROR_PAYLOAD_LEN -2
...
...
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