Skip to content
Snippets Groups Projects
Commit a77282a6 authored by Anian Bühler's avatar Anian Bühler
Browse files

updates on examples

parent 27e08ae7
No related branches found
No related tags found
No related merge requests found
......@@ -41,9 +41,6 @@ SoftwareSerial sSerial(10, 11);
DidacticPSNetBroker psnBroker;
void setup() {
//Starte Serielle Schnittstelle (zum PC)
Serial.begin(SERIAL_BAUD);
//Starte SoftwareSerielle Schnittstelle (zu IR-Link-Modulen)
sSerial.begin(SERIAL_BAUD);
......
......@@ -20,13 +20,13 @@
*date: 06.07.2021
*/
#include <Arduino.h>
#include "SoftwareSerial.h"
#include "didacticNet.h"
SoftwareSerial sSerial(10, 11); //Erzeuge SoftwareSerial-Instanz mit Rx = Pin10 -> Empfänger | Tx = Pin11 -> Sender
DidacticPSNetClient psnClient; //Erzeuge PubSub-Client-Instanz
UnblockingTimer uTimer;
//Callback-Funktion - wird beim Empfang neuer Daten aufgerufen
void clientCallback(char* mTopic, int mToLength, char* mPayload, int mPayloadLength) {
......
/**
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
......@@ -97,7 +87,7 @@ void setup() {
psnClient.subscribe(topicSub);
while (!psnClient.handleNetwork());
psnClient.setInterval(10000L);
psnClient.setInterval(5000L);
}
void loop() {
......@@ -111,4 +101,4 @@ void loop() {
digitalWrite(LED_PIN, !ledState);
digitalWrite(LED2_PIN, ledState);
}
}
}
\ No newline at end of file
......@@ -48,14 +48,13 @@ void myCallback(char* mTopic, int mToLength, char* mData, int mDaLength) {
Serial.println(mTopic);
//reply pong
strcpy(topicPub, mTopic);
if (!strcmp(mData, "Ping")) {
if (!strcmp(mData, "Ping")) { //Empfangene Nachricht == Ping
Serial.print(" ");
Serial.println(mTopic);
Serial.print(mTopic);
psnClient.publish(topicPub, payloadSend);
}
}
void setup() {
//Starte Serielle Schnittstelle (zum PC)
Serial.begin(SERIAL_BAUD);
......@@ -73,15 +72,8 @@ void setup() {
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(" ");
}
//subscribe auf alle möglichen Topics
psnClient.subscribe("*");
Serial.println("\n\nReady for Clients...");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment