From a5e03336f9131fba4d9e2269c0ff80d69b019922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anian=20B=C3=BChler?= <anian.buehler@reutlingen-university.de> Date: Thu, 29 Apr 2021 10:55:16 +0200 Subject: [PATCH] updated library names to didacticNetwork --- simplePSNet.cpp => didacticNet.cpp | 70 +++++++++++++------------- simplePSNet.h => didacticNet.h | 30 +++++------ didacticNet.h.gch | Bin 0 -> 12689 bytes example/brokerClient/brokerClient.ino | 60 +++++++++++----------- example/sPSN_Chat/sPSN_Chat.ino | 26 +++++----- example/sPSN_Client1/sPSN_Client1.ino | 28 +++++------ example/sPSN_Client2/sPSN_Client2.ino | 34 ++++++------- example/sPSN_Server/sPSN_Server.ino | 28 +++++------ 8 files changed, 138 insertions(+), 138 deletions(-) rename simplePSNet.cpp => didacticNet.cpp (84%) rename simplePSNet.h => didacticNet.h (84%) create mode 100644 didacticNet.h.gch diff --git a/simplePSNet.cpp b/didacticNet.cpp similarity index 84% rename from simplePSNet.cpp rename to didacticNet.cpp index 0b8dc59..c6eafd9 100644 --- a/simplePSNet.cpp +++ b/didacticNet.cpp @@ -1,31 +1,31 @@ /**************************************************************************/ /*! - @file simplePSNet.cpp + @file didacticNet.cpp @author anian buehler @ letsgoING.org */ /**************************************************************************/ #include "Arduino.h" -#include "simplePSNet.h" +#include "didacticNet.h" //************************************************************************** //BASIC //************************************************************************** -simplePSNet::simplePSNet(){} +didacticPSNet::didacticPSNet(){} -simplePSNet::~simplePSNet(){} +didacticPSNet::~didacticPSNet(){} -simplePSNet& simplePSNet::setCallback(void(*callback)(char*, int, char*, int)){ +didacticPSNet& didacticPSNet::setCallback(void(*callback)(char*, int, char*, int)){ this->callback = callback; return *this; } -void simplePSNet::setStream(Stream& stream){ +void didacticPSNet::setStream(Stream& stream){ _port = &stream; } -bool simplePSNet::handleNetwork(){ +bool didacticPSNet::handleNetwork(){ if(_waitingTime <= millis()){ if(checkData()){ if(recieveData()){ @@ -51,11 +51,11 @@ bool simplePSNet::handleNetwork(){ return true; } -bool simplePSNet::isDataToSend(){ +bool didacticPSNet::isDataToSend(){ return _dataToSend; } -bool simplePSNet::sendData(){ +bool didacticPSNet::sendData(){ int counter = 0; while(_sendBufferMessage[counter]!= '\0'){ _port->write(_sendBufferMessage[counter]); @@ -67,7 +67,7 @@ bool simplePSNet::sendData(){ return true; } -int simplePSNet::extractData(int startCounter, int maxLength, char* buffer, char limiter){ +int didacticPSNet::extractData(int startCounter, int maxLength, char* buffer, char limiter){ int counter = startCounter; while(_readBufferMessage[counter]!= limiter){ buffer[counter-startCounter] = _readBufferMessage[counter]; @@ -80,11 +80,11 @@ int simplePSNet::extractData(int startCounter, int maxLength, char* buffer, char return counter-startCounter; //length of Topic } -int simplePSNet::checkData(){ +int didacticPSNet::checkData(){ return (int)_port->available(); } -bool simplePSNet::recieveData() { +bool didacticPSNet::recieveData() { static int msgCounter = 0; static int topicCounter = 0; static int dataCounter = 0; @@ -122,13 +122,13 @@ bool simplePSNet::recieveData() { //************************************************************************** // CLIENT //************************************************************************** -simplePSNetClient::simplePSNetClient(){} +didacticPSNetClient::didacticPSNetClient(){} -simplePSNetClient::~simplePSNetClient(){} +didacticPSNetClient::~didacticPSNetClient(){} -bool simplePSNetClient::publish(char* topic, char* data){ +bool didacticPSNetClient::publish(char* topic, char* data){ int topicLength = strlen(topic); - int dataLength = strlen(data); + int dataLength = strlen(data); _sendBufferMessage[0] = MSG_PRELIMITER; _sendBufferMessage[1] = MSG_PUBLISH; _sendBufferMessage[2+topicLength] = MSG_SEPARATOR; @@ -155,7 +155,7 @@ bool simplePSNetClient::publish(char* topic, char* data){ return true; } -bool simplePSNetClient::publish(char* topic, int topicLength, char* data , int dataLength){ +bool didacticPSNetClient::publish(char* topic, int topicLength, char* data , int dataLength){ _sendBufferMessage[0] = MSG_PRELIMITER; _sendBufferMessage[1] = MSG_PUBLISH; _sendBufferMessage[2+topicLength] = MSG_SEPARATOR; @@ -182,7 +182,7 @@ bool simplePSNetClient::publish(char* topic, int topicLength, char* data , int d return true; } -bool simplePSNetClient::subscribe(char* topic){ +bool didacticPSNetClient::subscribe(char* topic){ int topicLength = strlen(topic); _sendBufferMessage[0] = MSG_PRELIMITER; _sendBufferMessage[1] = MSG_SUBSCRIBE; @@ -224,7 +224,7 @@ bool simplePSNetClient::subscribe(char* topic){ return true; } -bool simplePSNetClient::subscribe(char* topic, int topicLength){ +bool didacticPSNetClient::subscribe(char* topic, int topicLength){ _sendBufferMessage[0] = MSG_PRELIMITER; _sendBufferMessage[1] = MSG_SUBSCRIBE; _sendBufferMessage[2+topicLength] = MSG_DELIMITER; @@ -266,7 +266,7 @@ bool simplePSNetClient::subscribe(char* topic, int topicLength){ } -bool simplePSNetClient::unsubscribe(char* topic){ +bool didacticPSNetClient::unsubscribe(char* topic){ int topicNumber = getTopicNr(topic); int topicLength = strlen(topic); if(topicNumber >= 0){ @@ -276,7 +276,7 @@ bool simplePSNetClient::unsubscribe(char* topic){ return false; } -bool simplePSNetClient::unsubscribe(char* topic, int topicLength){ +bool didacticPSNetClient::unsubscribe(char* topic, int topicLength){ int topicNumber = getTopicNr(topic); if(topicNumber >= 0){ _topic[topicNumber][0]='\0'; @@ -285,16 +285,16 @@ bool simplePSNetClient::unsubscribe(char* topic, int topicLength){ return false; } -bool simplePSNetClient::getMessageFilter(char messageType){ +bool didacticPSNetClient::getMessageFilter(char messageType){ return messageType == MSG_UPDATE; } -bool simplePSNetClient::saveData(char* buffer, int position){ +bool didacticPSNetClient::saveData(char* buffer, int position){ strcpy(_data[position], buffer); return true; } -bool simplePSNetClient::handleData(){ +bool didacticPSNetClient::handleData(){ int currentTopicNr = 0; int topicLength = 0; int dataLength = 0; @@ -310,7 +310,7 @@ bool simplePSNetClient::handleData(){ return true; } -int simplePSNetClient::getTopicNr(char* topic){ +int didacticPSNetClient::getTopicNr(char* topic){ for (int i = 0; i < MAX_NR_TOPICS_CLIENT; i++) { if (strcmp(_topic[i], topic) == 0) { return i; @@ -319,7 +319,7 @@ int simplePSNetClient::getTopicNr(char* topic){ return -1; } -int simplePSNetClient::getFreeTopicNr() { +int didacticPSNetClient::getFreeTopicNr() { for (int i = 0; i < MAX_NR_TOPICS_CLIENT; i++) { if (strcmp(_topic[i], "") == 0) { return i; @@ -332,28 +332,28 @@ int simplePSNetClient::getFreeTopicNr() { //************************************************************************** //SERVER //************************************************************************** -simplePSNetServer::simplePSNetServer(){} +didacticPSNetServer::didacticPSNetServer(){} -simplePSNetServer::~simplePSNetServer(){} +didacticPSNetServer::~didacticPSNetServer(){} -bool simplePSNetServer::getMessageFilter(char messageType){ +bool didacticPSNetServer::getMessageFilter(char messageType){ return (messageType == MSG_PUBLISH || messageType == MSG_SUBSCRIBE); } -bool simplePSNetServer::saveData(char* buffer, int position){ +bool didacticPSNetServer::saveData(char* buffer, int position){ strcpy(_data[position], buffer); return true; } -void simplePSNetServer::writeDataToTopic(int topicNumber, char* usedTopic, char* newData) { +void didacticPSNetServer::writeDataToTopic(int topicNumber, char* usedTopic, char* newData) { if(strcmp(_topic[topicNumber], "") == 0){ strcpy(_topic[topicNumber], usedTopic); } strcpy(_data[topicNumber], newData); } -bool simplePSNetServer::handleData(){ +bool didacticPSNetServer::handleData(){ int currentTopicNr = 0; int topicLength = 0; int dataLength = 0; @@ -380,7 +380,7 @@ bool simplePSNetServer::handleData(){ return true; } -bool simplePSNetServer::update(char* topic, int topicLength, char* data , int dataLength){ +bool didacticPSNetServer::update(char* topic, int topicLength, char* data , int dataLength){ _sendBufferMessage[0] = MSG_PRELIMITER; _sendBufferMessage[1] = MSG_UPDATE; _sendBufferMessage[2+topicLength] = MSG_SEPARATOR; @@ -407,7 +407,7 @@ bool simplePSNetServer::update(char* topic, int topicLength, char* data , int da return true; } -int simplePSNetServer::getTopicNr(char* topic){ +int didacticPSNetServer::getTopicNr(char* topic){ for (int i = 0; i < MAX_NR_TOPICS_SERVER; i++) { if (strcmp(_topic[i], topic) == 0) { return i; @@ -416,7 +416,7 @@ int simplePSNetServer::getTopicNr(char* topic){ return getFreeTopicNr(); } -int simplePSNetServer::getFreeTopicNr() { +int didacticPSNetServer::getFreeTopicNr() { for (int i = 0; i < MAX_NR_TOPICS_SERVER; i++) { if (strcmp(_topic[i], "") == 0) { return i; diff --git a/simplePSNet.h b/didacticNet.h similarity index 84% rename from simplePSNet.h rename to didacticNet.h index 4202d18..5165eea 100644 --- a/simplePSNet.h +++ b/didacticNet.h @@ -1,17 +1,17 @@ /**************************************************************************/ /*! - @file simplePSNet.h + @file didacticNet.h @author anian buehler @ letsgoING */ /**************************************************************************/ -#ifndef _SIMPLEPSNET_ -#define _SIMPLEPSNET_ +#ifndef _DIDACTICNET_ +#define _DIDACTICNET_ #include "Arduino.h" //callback(topic, topicLength, data, dataLength) -#define SPSN_CALLBACK_SIGNATURE void (*callback)(char*, int, char*, int) +#define PSNET_CALLBACK_SIGNATURE void (*callback)(char*, int, char*, int) #define MSG_PRELIMITER '<' #define MSG_DELIMITER '>' @@ -36,12 +36,12 @@ #define MAX_LEN_TOPICS 10 #define MAX_LEN_DATA 20 -class simplePSNet +class didacticPSNet { protected: Stream* _port; - SPSN_CALLBACK_SIGNATURE; + PSNET_CALLBACK_SIGNATURE; char _bufferTopic[MAX_LEN_TOPICS+1] = {0}; char _bufferData[MAX_LEN_DATA+1] = {0}; @@ -65,17 +65,17 @@ class simplePSNet virtual bool handleData()=0; public: - simplePSNet(); - ~simplePSNet(); + didacticPSNet(); + ~didacticPSNet(); - simplePSNet& setCallback(SPSN_CALLBACK_SIGNATURE); + didacticPSNet& setCallback(PSNET_CALLBACK_SIGNATURE); void setStream(Stream& _port); bool handleNetwork(); bool isDataToSend(); }; -class simplePSNetClient : public simplePSNet +class didacticPSNetClient : public didacticPSNet { private: @@ -89,8 +89,8 @@ class simplePSNetClient : public simplePSNet int getFreeTopicNr(); public: - simplePSNetClient(); - ~simplePSNetClient(); + didacticPSNetClient(); + ~didacticPSNetClient(); bool publish(char*, char*); bool publish(char*, int, char*, int); @@ -102,7 +102,7 @@ class simplePSNetClient : public simplePSNet }; -class simplePSNetServer: public simplePSNet +class didacticPSNetServer: public didacticPSNet { private: @@ -117,8 +117,8 @@ class simplePSNetServer: public simplePSNet int getFreeTopicNr(); public: - simplePSNetServer(); - ~simplePSNetServer(); + didacticPSNetServer(); + ~didacticPSNetServer(); bool update(char*, int, char*, int); diff --git a/didacticNet.h.gch b/didacticNet.h.gch new file mode 100644 index 0000000000000000000000000000000000000000..e0fb4aee34193b2fb500a1a4f8074946e4e380f5 GIT binary patch literal 12689 zcmb7K+j1gHcI`gn``u%Y@Alwxd}&3DWQsxsJUI{)5-|uEE~j<;l0l=Aniv|%2+ipD z&9D9n|A2qM5%zcZbG+8xd8<NwJXVAnHCdUtFKe&8b7$Q@uHWxBhhp&XumASn|4{$W z@4fuvm;d$s|M|h2w{PU<-~Z$1@;SBt|Kbbz<E{Pg8~2<(9sYg$=B1sTW=;D|c;0;> zpWh1;@YgSw{&&3c+b{S4cgAn@A=A7-;Su@1JQzQ9yg`@{{wmFQ^Y&N52>&|LD<0OV zZ{OS(yJEjt$NTwJe-9IW2fxP5=TkFZ%qHVYV`}Li<GbIL@B0@cb3GiJ{AP-Qcc)3c zk(_XtQ;k_aKAP3xu-|-mJ`_*2M!nvycm5nhe<;Jt;do(2d3U}@GIQO%!4mbCJN$g# zuh3mgu7^F-?fqmqoaME~pJC(&GI=msB#pLAOX^mDW+!b>u-|k~h;XKsoFx=WCtmh? zW|;TP`FY3mCfCzZep74wg&!7~@9+1;{pwJd-P7%-4Fpfpdh<&>Qx&{z7T-*B2>!f# z+T8Do+uHi$YR`?R0}MC(r+hLngVChBXxH&vl5vUOkU^+Vt$Xj*C$)9$tFLM!TKl(T ztasI&nTz29Q`%hWx8++}Om$XM{XV``Pt0Y)`(b}^#VLP+0bS@ljT{@723~TUlMO^$ zq>Zu@8|Npq^B>4K?eTP29X4yTdU`7M2fDGD)M+sq)tJewpU=!_xLAyGlaKqu?wE=; z(&k@dT&18Lj-;R@{8^4Dj%x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?d00001 diff --git a/example/brokerClient/brokerClient.ino b/example/brokerClient/brokerClient.ino index 8d957c1..c02aa5c 100644 --- a/example/brokerClient/brokerClient.ino +++ b/example/brokerClient/brokerClient.ino @@ -1,50 +1,50 @@ #include "Arduino.h" #include "SoftwareSerial.h" - #include "simplePSNet.h" - - + #include "didacticNet.h" + + //#define SERVER #define CLIENT #define C5 // C1 C2 C3 C4 C5 - + #define SERIAL_BAUD 2400 - + SoftwareSerial sSerial(10, 11); - + #ifdef SERVER - simplePSNetServer psnS; - + didacticPSNetServer psnS; + void setup() { Serial.begin(SERIAL_BAUD); sSerial.begin(SERIAL_BAUD); psnS.setStream(sSerial); } - + void loop() { psnS.handleNetwork(); } #endif - + #ifdef CLIENT unsigned long lastTime = 0L; byte ledPin3 = 3; byte ledPin5 = 5; byte ledPin6 = 6; byte buttonPin1= 2; - + bool currentState = false; bool lastState = false; bool togglestate = true; int lastValue = 0; - + bool dataReadDone = false; char readData[MAX_LEN_DATA*5]={'\0'}; char arrayBuffer[MAX_LEN_DATA+1] = {'\0'}; int counter = 0; - + void myCallback(char* mTopic, int mToLength, char* mData, int mDaLength) { - - + + #if defined(C1) || defined(C2) || defined(C3) || defined(C4) Serial.println("Callback: "); Serial.print("Topic: "); @@ -56,7 +56,7 @@ Serial.print(":\t"); Serial.println(mData); #endif - + #if defined(C1) digitalWrite(ledPin3,(bool)atoi(mData)); #elif defined(C3) @@ -68,7 +68,7 @@ digitalWrite(ledPin6,atoi(mData)<400); #endif } - + #if defined(C1) char topicSub[MAX_LEN_TOPICS]={"button1"}; char topicPub[MAX_LEN_TOPICS]={"poti1"}; @@ -85,25 +85,25 @@ char topicSub[MAX_LEN_TOPICS]={""}; char topicPub[MAX_LEN_TOPICS]={""}; #endif - - simplePSNetClient psnC; + + didacticPSNetClient psnC; void setup() { Serial.begin(2400); sSerial.begin(2400); - + pinMode(ledPin3, OUTPUT); pinMode(ledPin5, OUTPUT); pinMode(ledPin6, OUTPUT); - + pinMode(buttonPin1, INPUT); - + psnC.setStream(sSerial); psnC.setCallback(myCallback); - + #if defined(C1) || defined(C3) || defined(C4) psnC.subscribe(topicSub, strlen(topicSub)); #endif - + #if defined(C5) Serial.print("Bitte den eigenen Namen mit einem # eingeben\nund mit Enter bestaetigen. -> "); Serial.println("#DeinName"); @@ -116,10 +116,10 @@ Serial.println("*********************************************************************\n"); #endif } - + void loop() { psnC.handleNetwork(); - + #if defined(C1) || defined(C2) int currentValue = analogRead(0); if(abs(currentValue-lastValue) > 20){ @@ -131,7 +131,7 @@ lastValue = currentValue; } #endif - + #if defined(C3) if(digitalRead(buttonPin1)){ togglestate = !togglestate; @@ -146,9 +146,9 @@ } delay(500); } - + #endif - + #if defined(C4) currentState = digitalRead(buttonPin1); if(lastState != currentState){ @@ -159,7 +159,7 @@ } lastState = currentState; #endif - + #if defined(C5) if(Serial.available()){ char buffer = Serial.read(); diff --git a/example/sPSN_Chat/sPSN_Chat.ino b/example/sPSN_Chat/sPSN_Chat.ino index dd81446..a30cb2a 100644 --- a/example/sPSN_Chat/sPSN_Chat.ino +++ b/example/sPSN_Chat/sPSN_Chat.ino @@ -1,28 +1,28 @@ /** *file: sPSN_Chat.ino *author: letsgoING -> info@letsgoing.de - * + * *description: * Dieses Programm ist ein Teil eines Beispiels für ein einfaches Pub-Sub-Chat-Netzwerk. * Für dieses Chat-Netzwerk werden mindestens 3 Arduinos benötigt: - * - * Arduino1: sPSN_Server.ino - * - IR-Sender an Pin 11 IR-Empfänger an Pin10 - * - * Arduino2-n: sPSN_Chat.ino (dieses Programm) - * - IR-Sender an Pin 11 IR-Empfänger an Pin10 - * Funktion: + * + * Arduino1: sPSN_Server.ino + * - IR-Sender an Pin 11 IR-Empfänger an Pin10 + * + * Arduino2-n: sPSN_Chat.ino (dieses Programm) + * - IR-Sender an Pin 11 IR-Empfänger an Pin10 + * Funktion: * Am Arduino2-n kann ein eigner Name (Sende-Topic) angeben werden. * Danach kann angeben werden wem zugehört werden soll (Empfangs-Topics). * Arduino1 (Server) übernimmt das Verteilen der Nachrichten. - * + * *date: 14.12.2020 *version: 1.0 */ #include "SoftwareSerial.h" -#include "simplePSNet.h" +#include "didacticNet.h" //lege Geschwindigkeit für serielle Schnittstellen fest #define SERIAL_BAUD 2400 @@ -56,7 +56,7 @@ void myCallback(char* mTopic, int mToLength, char* mData, int mDaLength) { SoftwareSerial sSerial(10, 11); //Erzeuge Client-Instanz -simplePSNetClient psnClient; +didacticPSNetClient psnClient; void setup() { @@ -74,7 +74,7 @@ void setup() { Serial.print("Bitte den eigenen Namen mit einem # eingeben\nund mit Enter bestaetigen. -> "); Serial.println("#DeinName"); - Serial.print("Gebe dann die Namen deiner Chatpartner mit einem ? ein. -> "); + Serial.print("Gebe dann die Namen deiner Chatpartner mit einem @ ein. -> "); Serial.println("@ChatPartner"); Serial.println("Anschließend kannst du mit ihnen schreiben"); Serial.println(); @@ -91,7 +91,7 @@ void loop() { if (Serial.available()) { char buffer = Serial.read(); readData[counter] = buffer; - //Wenn Zeilenumbruch "CR", dann merke, dass Einlesen fertig + //Wenn Zeilenumbruch "CR", dann merke, dass Einlesen fertig //und setze String Abschluss "\0" ans Ende if (buffer == 13) { readData[counter] = '\0'; diff --git a/example/sPSN_Client1/sPSN_Client1.ino b/example/sPSN_Client1/sPSN_Client1.ino index 08eea40..7df942e 100644 --- a/example/sPSN_Client1/sPSN_Client1.ino +++ b/example/sPSN_Client1/sPSN_Client1.ino @@ -1,35 +1,35 @@ /** *file: sPSN_Client1 *author: letsgoING -> info@letsgoing.de - * + * *description: * Dieses Programm ist ein einfaches Beispiel für ein einfaches Pub-Sub-Netzwerk. * Für das Netwerk werden 3 Arduinos mit IR-Link-Modulen benötigt: - * - * Arduino1: sPSN_Server.ino + * + * Arduino1: sPSN_Server.ino * - IR-Sender an Pin 11 IR-Empfänger an Pin10 - * + * * Arduino2: sPSN_Client1.ino (dieses Programm) * - IR-Sender an Pin 11 IR-Empfänger an Pin10 * - Taster an Pin2 * - LED an Pin9 - * + * * Arduino3: sPSN_Client2.ino * - IR-Sender an Pin 11 IR-Empfänger an Pin10 * - Poti an PinA0 * - LED an Pin9 - * - * Funktion: - * Mit dem Poti an Arduino3 kann die LED am Arduino2 gedimmt werden. + * + * Funktion: + * Mit dem Poti an Arduino3 kann die LED am Arduino2 gedimmt werden. * Mit dem Taster an Arduino2 kann die LED an Arduino2 ein-/ausgeschaltet werden. * Arduino1 übernimmt das Verteilen der Nachrichten. - * + * *date: 14.12.2020 *version: 1.0 */ #include "SoftwareSerial.h" -#include "simplePSNet.h" +#include "didacticNet.h" //lege Geschwindigkeit für serielle Schnittstellen fest #define SERIAL_BAUD 2400 @@ -56,7 +56,7 @@ void myCallback(char* mTopic, int mToLength, char* mData, int mDaLength) { Serial.print(mTopic); Serial.print("\tData: "); Serial.println(mData); - + //Setze Ausgang entsprechend dem gesendeten Wert digitalWrite(ledPin, (bool)atoi(mData)); } @@ -67,13 +67,13 @@ void myCallback(char* mTopic, int mToLength, char* mData, int mDaLength) { SoftwareSerial sSerial(10, 11); //Erzeuge Client-Instanz -simplePSNetClient psnClient; +didacticPSNetClient psnClient; void setup() { //Starte Serielle Schnittstelle (zum PC) Serial.begin(SERIAL_BAUD); - + Serial.print("\nStarting sPSNet: \nlistening to:\t"); Serial.println(topicSub); Serial.print("sending to:\t"); @@ -100,7 +100,7 @@ void loop() { //lese Poti ein und speichere Wert int currentValue = analogRead(potiPin); - + //Übertrage Werte nur, wenn sie sich geändert haben if (abs(currentValue - lastValue) > 20) { //warte kurz, um nicht zu oft zu senden diff --git a/example/sPSN_Client2/sPSN_Client2.ino b/example/sPSN_Client2/sPSN_Client2.ino index d185011..39c2396 100644 --- a/example/sPSN_Client2/sPSN_Client2.ino +++ b/example/sPSN_Client2/sPSN_Client2.ino @@ -1,35 +1,35 @@ /** *file: sPSN_Client2 *author: letsgoING -> info@letsgoing.de - * + * *description: * Dieses Programm ist ein einfaches Beispiel für ein einfaches Pub-Sub-Netzwerk. * Für das Netwerk werden 3 Arduinos mit IR-Link-Modulen benötigt: - * - * Arduino1: sPSN_Server.ino + * + * Arduino1: sPSN_Server.ino * - IR-Sender an Pin 11 IR-Empfänger an Pin10 - * - * Arduino2: sPSN_Client1.ino + * + * Arduino2: sPSN_Client1.ino * - IR-Sender an Pin 11 IR-Empfänger an Pin10 * - Taster an Pin2 * - LED an Pin9 - * + * * Arduino3: sPSN_Client2.ino (dieses Programm) * - IR-Sender an Pin 11 IR-Empfänger an Pin10 * - Poti an PinA0 * - LED an Pin9 - * - * Funktion: - * Mit dem Poti an Arduino3 kann die LED am Arduino2 gedimmt werden. + * + * Funktion: + * Mit dem Poti an Arduino3 kann die LED am Arduino2 gedimmt werden. * Mit dem Taster an Arduino2 kann die LED an Arduino2 ein-/ausgeschaltet werden. * Arduino1 übernimmt das Verteilen der Nachrichten. - * + * *date: 14.12.2020 *version: 1.0 */ #include "SoftwareSerial.h" -#include "simplePSNet.h" +#include "didacticNet.h" //lege Geschwindigkeit für serielle Schnittstellen fest #define SERIAL_BAUD 2400 @@ -65,18 +65,18 @@ void myCallback(char* mTopic, int mToLength, char* mData, int mDaLength) { SoftwareSerial sSerial(10, 11); //Erzeuge Client-Instanz -simplePSNetClient psnClient; +didacticPSNetClient psnClient; void setup() { //Starte Serielle Schnittstelle (zum PC) Serial.begin(SERIAL_BAUD); - + Serial.print("\nStarting sPSNet: \nlistening to:\t"); Serial.println(topicSub); Serial.print("sending to:\t"); Serial.println(topicPub); - + //Starte SoftwareSerielle Schnittstelle (zu IR-Link-Modulen) sSerial.begin(SERIAL_BAUD); @@ -85,7 +85,7 @@ void setup() { //Lege fest welche Serielle Schnittstelle für sPSN verwendet werden soll psnClient.setStream(sSerial); - + //Lege Callback-Funktion fest (wird ausgeführt wenn neue Daten ankommen) psnClient.setCallback(myCallback); @@ -99,7 +99,7 @@ void loop() { //lese aktuellen Zustand des Tasters ein bool currentState = digitalRead(buttonPin); - + //Wenn Flanke erkannt (fallend/steigend) dann übertrage den aktuellen Wert if (lastState != currentState) { //setze den Inhalt des Puffer-Arrays auf 0 @@ -111,7 +111,7 @@ void loop() { //warte kurz, um nicht zu oft zu senden delay(500); } - + //speichere aktuellen Wert, um zu erkennen, ob er sich ändert lastState = currentState; } diff --git a/example/sPSN_Server/sPSN_Server.ino b/example/sPSN_Server/sPSN_Server.ino index 876f89b..c943391 100644 --- a/example/sPSN_Server/sPSN_Server.ino +++ b/example/sPSN_Server/sPSN_Server.ino @@ -1,34 +1,34 @@ /** *file: sPSN_Server.ino *author: letsgoING -> info@letsgoing.de - * + * *description: * Dieses Programm ist ein Teil eines Beispiels für ein einfaches Pub-Sub-Netzwerk. - * + * * Für ein Sensor-Netwerk werden 3 Arduinos mit IR-Link-Modulen benötigt: - * Arduino1: sPSN_Server.ino (dieses Programm) - * - IR-Sender an Pin 11 IR-Empfänger an Pin10 - * Arduino2: sPSN_Client1.ino + * Arduino1: sPSN_Server.ino (dieses Programm) + * - IR-Sender an Pin 11 IR-Empfänger an Pin10 + * Arduino2: sPSN_Client1.ino * - IR-Sender an Pin 11 IR-Empfänger an Pin10 * - Taster an Pin2 - * - LED an Pin9 + * - LED an Pin9 * Arduino3: sPSN_Client2.ino * - IR-Sender an Pin 11 IR-Empfänger an Pin10 * - Poti an PinA0 * - LED an Pin9 - * + * * Für ein Chat-Netzwerk werden mindestens 3 Arduinos benötigt: - * Arduino1: sPSN_Server.ino (dieses Programm) - * - IR-Sender an Pin 11 IR-Empfänger an Pin10 - * Arduino2-n: sPSN_Chat.ino - * - IR-Sender an Pin 11 IR-Empfänger an Pin10 - * + * Arduino1: sPSN_Server.ino (dieses Programm) + * - IR-Sender an Pin 11 IR-Empfänger an Pin10 + * Arduino2-n: sPSN_Chat.ino + * - IR-Sender an Pin 11 IR-Empfänger an Pin10 + * *date: 14.12.2020 *version: 1.0 */ #include "SoftwareSerial.h" -#include "simplePSNet.h" +#include "didacticNet.h" //lege Geschwindigkeit für serielle Schnittstellen fest #define SERIAL_BAUD 2400 @@ -38,7 +38,7 @@ SoftwareSerial sSerial(10, 11); //Erzeuge Server-Instanz -simplePSNetServer psnServer; +didacticPSNetServer psnServer; void setup() { //Starte Serielle Schnittstelle (zum PC) -- GitLab