Skip to content
Snippets Groups Projects
Select Git revision
  • 445f3ac65ee13997c15039a2ed292736378ae337
  • master default protected
  • dev_simplemode
  • dev_AddAppl
  • dev2
  • dev_stdCallback
  • dev
7 results

sPSN_PingTest.ino

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    sPSN_PingTest.ino 2.50 KiB
    /**
     *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:  04.07.2022
     */
    
    #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 newData(char* topic, char* payload) {
      if (!strcmp(payload, "Ping")){
        Serial.print(payload);
        Serial.print(" -> ");
      } else{
        Serial.print(payload);
        Serial.println(" :-D");
      } 
      digitalWrite(LED_BUILTIN, HIGH);
    }
    
    
    void setup() {
      //Starte Serielle Schnittstelle (zum PC)
      Serial.begin(SERIAL_BAUD);
      delay(2000);
    
      //Verwende eigene Nummer als Sende- und Empfangstopic