From c5af17753b06a9b62b7402849e57bea64803a760 Mon Sep 17 00:00:00 2001
From: RobertPatzke <robert.patzke@mfp-portal.de>
Date: Tue, 13 Feb 2024 10:48:06 +0100
Subject: [PATCH]

---
 libraries/BlePoll/BlePoll.cpp | 54 ++++++++++++++++++++++++++++++++++-
 libraries/BlePoll/BlePoll.h   |  2 ++
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/libraries/BlePoll/BlePoll.cpp b/libraries/BlePoll/BlePoll.cpp
index a895246..6fe6c7c 100644
--- a/libraries/BlePoll/BlePoll.cpp
+++ b/libraries/BlePoll/BlePoll.cpp
@@ -104,7 +104,9 @@ void BlePoll::begin(ComType typeIn, int adrIn, AppType appType, dword watchDog)
   if(typeIn == ctMASTER)
     master  = true;
   else
-    master = false;  void  resetPollCounters();
+    master = false;
+
+  resetPollCounters();
 
 
   chn     = 0;          // 1. Bewerbungskanal
@@ -138,6 +140,7 @@ void BlePoll::begin(ComType typeIn, int adrIn, AppType appType, dword watchDog)
      || appType == atTestSend
      || appType == atDevSOAAP
      || appType == atSOAAP2
+     || appType == atSOAPP2
     )
   {
     pduOut.adr5 = 0x53;
@@ -161,7 +164,9 @@ void BlePoll::begin(ComType typeIn, int adrIn, AppType appType, dword watchDog)
   pduOut.data[1] = appType;   // Pdu-Typ (TYPE)
   pduIn.data[1] = appType;
 
+  // --------------------------------------------------------------------------
   if(appType == atSOAAP1)
+  // --------------------------------------------------------------------------
   {
     if(master)
     {
@@ -177,7 +182,9 @@ void BlePoll::begin(ComType typeIn, int adrIn, AppType appType, dword watchDog)
       plMode = plmSoaapS;
     }
   }
+  // --------------------------------------------------------------------------
   else if(appType == atSOAAP2)
+  // --------------------------------------------------------------------------
   {
     if(master)
     {
@@ -212,7 +219,46 @@ void BlePoll::begin(ComType typeIn, int adrIn, AppType appType, dword watchDog)
       plMode = plmSoaapS;
     }
   }
+  // --------------------------------------------------------------------------
+  else if(appType == atSOAPP2)
+  // --------------------------------------------------------------------------
+  {
+    if(master)
+    {
+      // Bei atSOAPP2 wird die Übermittlung von Daten beim Sendeaufruf implementiert.
+      // Das erfordert eine spezifische Behandlung für jeden Slave.
+      // Die globalen Anweisungen sind obsolet und sollen demnächst eliminiert werden.
+      // (Vorher Auswertung kontrollieren).
+      //
+      valuePdu.appId = plptIMU3F4Ctrl4;
+      ctrlPdu.appId = plptCtrl2;
+      plMode = plmSoaapM;
+      fullCycle = true;
+
+      for(int i = 1; i <= MAXSLAVE; i++)
+      {
+        ctrlPtr = (PlpCtrl25Ptr) &slaveList[i].control;
+        ctrlPtr->counter = 0;
+        ctrlPtr->type = appType;
+        ctrlPtr->appId = plptCtrl2;
+        ctrlPtr->ctrlPath = 0;
+        ctrlPtr->ctrlCnt = 0;
+        ctrlPtr->reqAppId = plptIMU3F4Ctrl4;
+        ctrlPtr->ctrl[0] = 0;
+        ctrlPtr->ctrl[1] = 0;
+      }
+
+    }
+    else
+    {
+      valuePdu.appId = plptIMU3F4Ctrl4;
+      ctrlPdu.appId = plptCtrl2;
+      plMode = plmSoaapS;
+    }
+  }
+  // --------------------------------------------------------------------------
   else if (appType == atDevSOAAP)
+  // --------------------------------------------------------------------------
   {
     if(master)
     {
@@ -241,6 +287,12 @@ void BlePoll::begin(ComType typeIn, int adrIn, AppType appType, dword watchDog)
 // Konfiguration
 // --------------------------------------------------------------------------
 //
+void BlePoll::setNet(int chnIn, int areaIn)
+{
+  chn   = chnIn;
+  area  = areaIn;
+}
+
 void BlePoll::setPollAddress(int chnIn, int adrIn, int areaIn, bool masterIn, bool eadrIn, bool nakIn)
 {
   chn     = chnIn;
diff --git a/libraries/BlePoll/BlePoll.h b/libraries/BlePoll/BlePoll.h
index 4abe53d..b93748f 100644
--- a/libraries/BlePoll/BlePoll.h
+++ b/libraries/BlePoll/BlePoll.h
@@ -305,6 +305,7 @@ public:
     atTestSend,       // einfacher Sendetest (Soaap)
     atSOAAP1,         // Steuerung optischer und akustischer Ausgaben für Performance-Künstler
     atSOAAP2,         // Version 2
+    atSOAPP2,         // Version 2 erneuert (Beachte SOAAP->SOAPP)
     atDevSOAAP,       // Entwicklerbetrieb für SOAAP
     atDHA             // Dezentrale Hausautomatisierung
   } AppType;
@@ -470,6 +471,7 @@ public:
   // Konfiguration
   // --------------------------------------------------------------------------
   //
+  void setNet(int chnIn, int areaIn);     // Netzwerk ist Kanal und Area
   void setPollAddress(int chnIn, int adrIn, int areaIn, bool masterIn, bool eadrIn, bool nakIn);
   void setEmptyPollParams(int cycleTotal, int cycleRun, dword timeOut);
   void setDataPollParams(int slAdr, int prio, int minPrio, dword timeOut);
-- 
GitLab