diff --git a/components/spit/include/I_SAD_Client.hpp b/components/spit/include/I_SAD_Client.hpp index 1a95070..1384906 100644 --- a/components/spit/include/I_SAD_Client.hpp +++ b/components/spit/include/I_SAD_Client.hpp @@ -3,35 +3,37 @@ #include using namespace std; +class SAD_DetectedServer; class I_SAD_Client { -public: - /** - * If a new server was found by the ServerAutoDetect mechanism, this function is called.
- * To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.
- * If a server can be reached via several IP addresses, the IP address is selected according to the following preference:
- * 1.) If a loopback address is available, it is used.
- * 2.) If an IP4 address is available, it is used.
- * 3.) In the other cases the IP6 address is used.
- * @param p_ID the id of the server (every started server should generate an id) - * @param p_Name the name of the SPIT server - * @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running - * @param p_IP the selected ip address of the SPIT server - * @param p_Port the port of the SPIT server - * @param p_Addition sometimes server may have additional informations - * @param p_IsIP4 the server ip is a ip4 address - */ - virtual void eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) = 0; - /** - * If a SPITServer is not more found, this function is called. - * To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.
- * @param p_ID the id of the server (every started server should generate an id) - * @param p_Name the name of the SPIT server - * @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running - * @param p_IP the selected ip address of the SPIT server - * @param p_Port the port of the SPIT server - * @param p_Addition sometimes server may have additional informations - * @param p_IsIP4 the server ip is a ip4 address - */ - virtual void eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) = 0; - virtual void eventServerChanged(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) = 0; + public: + /** + * If a new server was found by the ServerAutoDetect mechanism, this function is called.
+ * To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.
+ * If a server can be reached via several IP addresses, the IP address is selected according to the following preference:
+ * 1.) If a loopback address is available, it is used.
+ * 2.) If an IP4 address is available, it is used.
+ * 3.) In the other cases the IP6 address is used.
+ * @param p_ID the id of the server (every started server should generate an id) + * @param p_Name the name of the SPIT server + * @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running + * @param p_IP the selected ip address of the SPIT server + * @param p_Port the port of the SPIT server + * @param p_Addition sometimes server may have additional informations + * @param p_IsIP4 the server ip is a ip4 address + */ + virtual void eventServerDetected(SAD_DetectedServer &server) = 0; + /** + * If a SPITServer is not more found, this function is called. + * To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.
+ * @param p_ID the id of the server (every started server should generate an id) + * @param p_Name the name of the SPIT server + * @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running + * @param p_IP the selected ip address of the SPIT server + * @param p_Port the port of the SPIT server + * @param p_Addition sometimes server may have additional informations + * @param p_IsIP4 the server ip is a ip4 address + */ + virtual void eventServerChanged(SAD_DetectedServer &server) = 0; + + virtual void eventServerLost(SAD_DetectedServer &server) = 0; }; diff --git a/components/spit/include/MyApp.h b/components/spit/include/MyApp.h deleted file mode 100644 index 0cd168d..0000000 --- a/components/spit/include/MyApp.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -/* - * File: MySPITApp.h - * Author: Hagi - * - * Created on 17. April 2019, 18:24 - */ - -#ifndef MYSPITAPP_H -#define MYSPITAPP_H - -#include "SPIT_Client.h" -#include -#include -#include "SPITType.h" -#include "SPITObject.h" -#include "SPITPlayer.h" -#include "SAD_DetectedServer.hpp" - -using namespace std; - -class MyApp { - public: - MyApp(); - // Client's infos is set by the client - static string s_ClientName; - static string s_ProjectName; - void init(); - - private: - SPIT_Client _SpitClient; // pointer to an instance of the SPIT_Client, which do the main work for you - - // Server's project infos filled by eventProjectReport - static string m_ServerProjectID; - static string m_ServerProjectName; - static int m_ServerFramesPerSecond; // set when the server reports his project, see eventProjectReport - // liveSHOWsoftware will use 44100 frames per second as time resolution - // All times are given in frames, - - public: - static void onServerEvent(SPIT_Client::ServerEvent event, const SAD_DetectedServer &p_DetectedServer); - static void onConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus); - - //----- Project ----- - static void onStartProjectTransfer(); - static void onEndProjectTransfer(); - static void onProjectReport(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond); - static void onProjectClosed(string p_ProjectID); - - //----- SPITType ----- - static bool onCheckSpitTypeVeto(SPIT_Message::ReportSPITType* p_ReportSPITType); - static void onSpitType(bool p_New, const SPITType &p_SPITType); - static void onSpitTypeRemote(bool p_New, const SPITType &p_SPITType); - static void onSpitTypeRemoved(const SPITType &p_SPITType); - static void onSpitTypeRemoteRemoved(const SPITType &p_SPITType); - - //----- SPITObject ----- - static bool onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject* p_ReportSPITObject); - static void onSpitObject(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject); - static void onSpitObjectRemote(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject); - static void onSpitObjectRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject); - static void onSpitObjectRemoteRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject); - - //----- Play SPITObjects ----- - static void onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames); - static void onPlaySpitType(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value); - - //----- Server changes status of one of his REMOTE SPITObjects ----- - // REMOTE only Server->Client RemoteObject's play status - static void onPlayRemoteObjectStatus(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value); - - void sendRemoteObject(string p_SPITObjectID, int p_Valueppm = 0, char p_ValueFlag = 0x00); - //----- - void testLiveShowRemote(); - - //------ User's options normally should not be used, the server is master of things ------ - public: -}; - -#endif /* MYSPITAPP_H */ diff --git a/components/spit/include/SAD_DetectedServer.hpp b/components/spit/include/SAD_DetectedServer.hpp index 84f80e5..e0cb50a 100644 --- a/components/spit/include/SAD_DetectedServer.hpp +++ b/components/spit/include/SAD_DetectedServer.hpp @@ -1,138 +1,119 @@ #pragma once #include "I_SAD_Client.hpp" +#include #include #include -#include using namespace std; class SAD_DetectedServer { -public: - SAD_DetectedServer(); - SAD_DetectedServer(const SAD_DetectedServer& orig) { - m_ID = orig.getID(); - m_Name = orig.getName(); - m_ComputerName = orig.getComputerName(); - m_IP = orig.getIP(); - m_IPIsIP4 = orig.getIpIsIP4(); - m_ClientIP = orig.getClientIP(); - m_Port = orig.getPort(); - m_Additions = orig.getAdditions(); - } - ~SAD_DetectedServer(); - - private: - string m_ID; - string m_Name; - string m_ComputerName; - string m_IP; - bool m_IPIsIP4; - string m_ClientIP; - string m_Port; - string m_Additions; - string m_ServerProjectName; - bool m_New; - bool m_Changed; - bool m_FoundAgain; - - public: - string getID() const { return m_ID; } - string getName() const { return m_Name; } - string getComputerName() const { return m_ComputerName; } - string getIP() const { return m_IP; } - bool getIpIsIP4() const { return m_IPIsIP4; } - string getPort() const { return m_Port; } - string getClientIP() const { return m_ClientIP; } - string getAdditions() const { return m_Additions; } - string getProjectName() const {return m_ServerProjectName;} -private: - void setID(string p_ID) { m_ID = p_ID; } - void setName(string p_Name) { m_Name = p_Name; } - void setComputerName(string p_ComputerName) { m_ComputerName = p_ComputerName; } - void setIP(string p_IP) { m_IP = p_IP; } - void setClientIP(string p_IP) { m_ClientIP = p_IP; } - void setPort(string p_Port) { m_Port = p_Port; } - void setAdditions(string p_Additions) { m_Additions = p_Additions;} - void setProjectName(string p_ServerProjectName); + public: + SAD_DetectedServer(); + SAD_DetectedServer(const SAD_DetectedServer &orig) { + m_ID = orig.getID(); + m_Name = orig.getName(); + m_ComputerName = orig.getComputerName(); + m_IP = orig.getIP(); + m_ClientIP = orig.getClientIP(); + m_Port = orig.getPort(); + m_Additions = orig.getAdditions(); + } + ~SAD_DetectedServer(); - void setIPIsIP4(bool p_IsIP4) { m_IPIsIP4 = p_IsIP4; } - bool getNew() const { return m_New; } - bool getChanged() const { return m_Changed; } - bool getFoundAgain() const { return m_FoundAgain; } - void setChanged() { m_Changed = true; } - void setNew(bool p_New) { m_New = p_New; } - void setFoundAgain() { m_FoundAgain = true; } + private: + string m_ID; + string m_Name; + string m_ComputerName; + string m_IP; + string m_ClientIP; + string m_Port; + string m_Additions; + string m_ServerProjectName; + bool m_New; + bool m_Changed; + bool m_FoundAgain; - //SAD_Client m_ThreadSend will send to Multicast addresses - void startCycleSAD() { - m_IPIsIP4 = false; - m_Changed = false; - m_FoundAgain = false; - m_New = false; - } - //SAD_Client m_Thread_Send has paused in the meantime m_ThreadReceive may received messages from servers - void endCycleSAD() { } -private: - static unordered_map s_DetectedServers; -public: - static const int PARAMINDEX_PRECODE = 0; - static const int PARAMINDEX_SPITTASKID = 1; - static const int PARAMINDEX_NAME = 2; - static const int PARAMINDEX_ID = 3; - static const int PARAMINDEX_COMPUTERNAME = 4; - static const int PARAMINDEX_PORT = 5; - static const int PARAMINDEX_CLIENTIP = 6; - static const int PARAMINDEX_ADDITIONS = 7; - static const int PARAMINDEX_SERVERPROJECTNAME = 8; - static const int PARAMINDEX_IP = 9; - /** - * Used by SAD_Client to add a found SPITServer - don't use this manually - * @param p_IsIP4 true = the server is reached via a IP4 address
false = the server is reahed via a IP6 address - * @param p_ServerID the id of the server, every instance of a SPITServer has an own id - * @param p_ServerParams the server's parameter - */ - static void addDetectedServer(bool p_IsIP4, string p_ServerID, string p_ServerParams[]); - /** - * Used by SAD_Client to remove a SPITServer - don't use this manually - * @param p_DetectedServer - */ - static void removeDetectedServer(SAD_DetectedServer* p_DetectedServer); - /** - * Used by SAD_Client to clear all found SPITServers - don't use this manually - */ - static void clearDetectedServers(); - /** - * Used by SAD_Client internally - don't use this manually - */ - static void cycleStart(); - /** - * Used by SAD_Client internally -don't use this manually - * @param p_SADClientInterface - */ - static void cycleEnd(I_SAD_Client& p_SADClientInterface); + public: + string getID() const { return m_ID; } + string getName() const { return m_Name; } + string getComputerName() const { return m_ComputerName; } + string getIP() const { return m_IP; } + string getPort() const { return m_Port; } + string getClientIP() const { return m_ClientIP; } + string getAdditions() const { return m_Additions; } + string getProjectName() const { return m_ServerProjectName; } - /** - * Returns a reference of the DetectedServer with the id p_ServerID.
- * If no DetectedServer is found an eyception is thrown. - * @param p_ServerID the id of the SPITServer - * @return the reference of the SAD_DetectedServer instance with getID() == p_ServerID - */ - static const SAD_DetectedServer& getRefDetectedServer(string p_ServerID) { - SAD_DetectedServer* ptrDetectedServer = NULL; - { - auto i = s_DetectedServers.find(p_ServerID); - if (i != s_DetectedServers.end()) { - ptrDetectedServer = i->second; - } - if (ptrDetectedServer != NULL) { - return *ptrDetectedServer; - } + private: + void setID(string p_ID) { m_ID = p_ID; } + void setName(string p_Name) { m_Name = p_Name; } + void setComputerName(string p_ComputerName) { m_ComputerName = p_ComputerName; } + void setIP(string p_IP) { m_IP = p_IP; } + void setClientIP(string p_IP) { m_ClientIP = p_IP; } + void setPort(string p_Port) { m_Port = p_Port; } + void setAdditions(string p_Additions) { m_Additions = p_Additions; } + void setProjectName(string p_ServerProjectName); - throw new exception(); - } - } + bool getNew() const { return m_New; } + bool getChanged() const { return m_Changed; } + bool getFoundAgain() const { return m_FoundAgain; } + void setChanged() { m_Changed = true; } + void setNew(bool p_New) { m_New = p_New; } + void setFoundAgain() { m_FoundAgain = true; } + // SAD_Client m_ThreadSend will send to Multicast addresses + void startCycleSAD() { + m_Changed = false; + m_FoundAgain = false; + m_New = false; + } + + private: + static unordered_map s_DetectedServers; + + public: + static const int PARAMINDEX_PRECODE = 0; + static const int PARAMINDEX_SPITTASKID = 1; + static const int PARAMINDEX_NAME = 2; + static const int PARAMINDEX_ID = 3; + static const int PARAMINDEX_COMPUTERNAME = 4; + static const int PARAMINDEX_PORT = 5; + static const int PARAMINDEX_CLIENTIP = 6; + static const int PARAMINDEX_ADDITIONS = 7; + static const int PARAMINDEX_SERVERPROJECTNAME = 8; + static const int PARAMINDEX_IP = 9; + /** + * Used by SAD_Client to add a found SPITServer - don't use this manually + * @param p_IsIP4 true = the server is reached via a IP4 address
false = the server is reahed via a IP6 address + * @param p_ServerID the id of the server, every instance of a SPITServer has an own id + * @param p_ServerParams the server's parameter + */ + static void addDetectedServer(string p_ServerID, string p_ServerParams[]); + /** + * Used by SAD_Client to remove a SPITServer - don't use this manually + * @param p_DetectedServer + */ + static void removeDetectedServer(SAD_DetectedServer &server); + /** + * Used by SAD_Client to clear all found SPITServers - don't use this manually + */ + static void clearDetectedServers(); + /** + * Used by SAD_Client internally - don't use this manually + */ + static void cycleStart(); + /** + * Used by SAD_Client internally -don't use this manually + * @param p_SADClientInterface + */ + static void cycleEnd(I_SAD_Client &p_SADClientInterface); + + /** + * Returns a reference of the DetectedServer with the id p_ServerID.
+ * If no DetectedServer is found an eyception is thrown. + * @param p_ServerID the id of the SPITServer + * @return the reference of the SAD_DetectedServer instance with getID() == p_ServerID + */ + static const SAD_DetectedServer &getRefDetectedServer(string p_ServerID); }; - diff --git a/components/spit/include/SPITObject.h b/components/spit/include/SPITObject.h index 588a64b..8ae8232 100644 --- a/components/spit/include/SPITObject.h +++ b/components/spit/include/SPITObject.h @@ -4,7 +4,7 @@ * and open the template in the editor. */ -/* +/* * File: SPITObject.h * Author: Hagi * @@ -14,8 +14,8 @@ #ifndef SPITOBJECT_H #define SPITOBJECT_H -#include "SPIT_Message.h" #include "SPITType.h" +#include "SPIT_Message.h" #include #include @@ -24,153 +24,153 @@ using namespace std; class SPITObjectListener; class SPITObject { -private: - - static unordered_map s_SPITObjects; - static unordered_map s_SPITObjectsRemote; -public: - static SPITObject* getSPITObject(string p_ID); - static const SPITObject& getSPITObjectRef(string p_ID); - static bool addSPITObject(SPITObject* p_ptrSpitObject); - static bool removeSPITObject(SPITObject* p_ptrSpitObject); - static bool removeSPITObject(string p_SpitObjectID); - static int getSPITObjectCount(); - static SPITObject* getSPITObject(int p_Index); - static const SPITObject& getSPITObjectRef(int p_Index); - static void clearSPITObjects(); - static void clearUnconfirmedSPITObjects(); - static void setConfirmedFalse(); - - static SPITObject* getSPITObjectRemote(string p_ID); - static const SPITObject& getSPITObjectRemoteRef(string p_ID); - static bool addSPITObjectRemote(SPITObject* p_ptrSpitObject); - static bool removeSPITObjectRemote(SPITObject* p_ptrSpitObject); - static bool removeSPITObjectRemote(string p_SpitObjectID); - static int getSPITObjectRemoteCount(); - static SPITObject* getSPITObjectRemote(int p_Index); - static const SPITObject& getSPITObjectRemoteRef(int p_Index); - static void clearSPITObjectsRemote(); + private: + static unordered_map s_SPITObjects; + static unordered_map s_SPITObjectsRemote; - static void eventProjectClosed(); - - SPITObject(); -// SPITObject(const SPITObject& orig); - ~SPITObject(); -private: - string m_ID; - string m_Name; - string m_SPITTypeID; - string m_ServerParams; - string m_Remark; - bool m_Confirmed; - bool m_Fixed; - bool m_CreatedByClient; - bool m_ServerRemote; - bool m_ActionAssigned; - bool m_ActionAssignedType; //Virtual construct - long long m_FrameStart; - long long m_FrameLength; - long long m_FrameFadeInLength; - long long m_FrameFadeOutLength; - char m_ValueUse; - int m_ValueFactor; - int m_Track; - long long m_Delay; - long long m_Duration; - - bool m_PlayPrePosition; - long long m_PlayTimeInsideFrames; - int m_PlayValue; - char m_PlayValueFlag; - - - void initMembers(); -public: - string getID() const { return m_ID; } - string getName() const { return m_Name; } - string getRemark() const { return m_Remark; } - string getSPITTypeID() const { return m_SPITTypeID; } - string getServerParams() const { return m_ServerParams; } - - /** - * Returns if the SPITType triggers an action on the Server or on the client. - * @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType
- * true = the action is triggered on the server. The server waits for the client to play objects of this SPITType. - */ - bool getServerRemote() const { return m_ServerRemote; } - - /** - * This is used by the server and client to tell if the other side has registered the changes. - * @return true = other side has registered the changes. - */ - bool getConfirmed() const { return m_Confirmed; } - bool getFixed() const { return m_Fixed; } - bool getCreatedByClient() { return m_CreatedByClient; } - /** - * This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.
- * This is used when an action is associated with a SPITType.
- * Then this action is done for every SPITObject with the SPITType. - * @return true = an action is assigned for the SPITType. - */ - bool getActionAssignedType() const { return m_ActionAssignedType; } - /** Returns if this SPITObject has an associated action or not.
- * @return true = the user has asscociated an action with this SPITObject or
- * the user has asscociated an action with the SPITType of this SPITObject - */ - bool getActionAssigned() const { return m_ActionAssigned || m_ActionAssignedType; } - - long long getFrameStart() const { return m_FrameStart; } - // contains the length of the SPITObject - long long getFrameLength() const { return m_FrameLength; } - long long getFrameFadeInLength() const { return m_FrameFadeInLength; } - long long getFrameFadeOutLength() const { return m_FrameFadeOutLength; } - char getValueUse() const { return m_ValueUse; } - int getValueFactor() const { return m_ValueFactor; } - int getTrack() const { return m_Track; } + public: + static SPITObject *getSPITObject(string p_ID); + static const SPITObject &getSPITObjectRef(string p_ID); + static bool addSPITObject(SPITObject *p_ptrSpitObject); + static bool removeSPITObject(SPITObject *p_ptrSpitObject); + static bool removeSPITObject(string p_SpitObjectID); + static int getSPITObjectCount(); + static SPITObject *getSPITObject(int p_Index); + static const SPITObject &getSPITObjectRef(int p_Index); + static void clearSPITObjects(); + static void clearUnconfirmedSPITObjects(); + static void setConfirmedFalse(); - long long getDelay() const { return m_Delay; } - long long getDuration() const { return m_Duration; } - - bool getProjectIndepended() const { - SPITType* ptrSPITType; - if (m_ServerRemote == false) { - ptrSPITType = SPITType::getSPITType(m_SPITTypeID); - if (ptrSPITType == NULL) return true; - return ptrSPITType->getProjectIndepended(); - } - else { - ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID); - if (ptrSPITType == NULL) return true; - return ptrSPITType->getProjectIndepended(); - } - }; + static SPITObject *getSPITObjectRemote(string p_ID); + static const SPITObject &getSPITObjectRemoteRef(string p_ID); + static bool addSPITObjectRemote(SPITObject *p_ptrSpitObject); + static bool removeSPITObjectRemote(SPITObject *p_ptrSpitObject); + static bool removeSPITObjectRemote(string p_SpitObjectID); + static int getSPITObjectRemoteCount(); + static SPITObject *getSPITObjectRemote(int p_Index); + static const SPITObject &getSPITObjectRemoteRef(int p_Index); + static void clearSPITObjectsRemote(); - void setID(string p_ID); - bool setConfirmed(bool p_Confirmed); - void setCreatedByClient(bool p_CreatedByClient); - bool setName(string p_Name); - bool setRemark(string p_Remark); - bool setServerParams(string p_ServerParams); - bool setSPITTypeID(string p_GroupName); - bool setServerRemote(bool p_BelongstoServer); - bool setActionAssignedType(bool p_ActionAssigned); - bool setActionAssigned(bool p_ActionAssigned); - bool setFixed(bool p_Fixed); - bool setFrameStart(long long p_FrameStart); - bool setFrameLength(long long p_FrameLength); - bool setFrameFadeInLength(long long p_FrameFadeInLength); - bool setFrameFadeOutLength(long long p_FrameFadeOutLength); - bool setValueUse(char p_ValueUse); - bool setValueFactor(int p_ValueFactor); - bool setTrack(int p_Track); - bool setDelay(long long p_Delay); - bool setDuration(long long p_Duration); + static void eventProjectClosed(); - bool setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject); - void fillMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject); - void fillMessageOP(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject); + SPITObject(); + // SPITObject(const SPITObject& orig); + ~SPITObject(); + + private: + string m_ID; + string m_Name; + string m_SPITTypeID; + string m_ServerParams; + string m_Remark; + bool m_Confirmed; + bool m_Fixed; + bool m_CreatedByClient; + bool m_ServerRemote; + bool m_ActionAssigned; + bool m_ActionAssignedType; // Virtual construct + long long m_FrameStart; + long long m_FrameLength; + long long m_FrameFadeInLength; + long long m_FrameFadeOutLength; + char m_ValueUse; + int m_ValueFactor; + int m_Track; + long long m_Delay; + long long m_Duration; + + bool m_PlayPrePosition; + long long m_PlayTimeInsideFrames; + int m_PlayValue; + char m_PlayValueFlag; + + void initMembers(); + + public: + string getID() const { return m_ID; } + string getName() const { return m_Name; } + string getRemark() const { return m_Remark; } + string getSPITTypeID() const { return m_SPITTypeID; } + string getServerParams() const { return m_ServerParams; } + + /** + * Returns if the SPITType triggers an action on the Server or on the client. + * @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType
+ * true = the action is triggered on the server. The server waits for the client to play objects of this SPITType. + */ + bool getServerRemote() const { return m_ServerRemote; } + + /** + * This is used by the server and client to tell if the other side has registered the changes. + * @return true = other side has registered the changes. + */ + bool getConfirmed() const { return m_Confirmed; } + bool getFixed() const { return m_Fixed; } + bool getCreatedByClient() { return m_CreatedByClient; } + /** + * This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.
+ * This is used when an action is associated with a SPITType.
+ * Then this action is done for every SPITObject with the SPITType. + * @return true = an action is assigned for the SPITType. + */ + bool getActionAssignedType() const { return m_ActionAssignedType; } + /** Returns if this SPITObject has an associated action or not.
+ * @return true = the user has asscociated an action with this SPITObject or
+ * the user has asscociated an action with the SPITType of this SPITObject + */ + bool getActionAssigned() const { return m_ActionAssigned || m_ActionAssignedType; } + + long long getFrameStart() const { return m_FrameStart; } + // contains the length of the SPITObject + long long getFrameLength() const { return m_FrameLength; } + long long getFrameFadeInLength() const { return m_FrameFadeInLength; } + long long getFrameFadeOutLength() const { return m_FrameFadeOutLength; } + char getValueUse() const { return m_ValueUse; } + int getValueFactor() const { return m_ValueFactor; } + int getTrack() const { return m_Track; } + + long long getDelay() const { return m_Delay; } + long long getDuration() const { return m_Duration; } + + bool getProjectIndepended() const { + SPITType *ptrSPITType; + if (m_ServerRemote == false) { + ptrSPITType = SPITType::getSPITType(m_SPITTypeID); + if (ptrSPITType == NULL) + return true; + return ptrSPITType->getProjectIndepended(); + } else { + ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID); + if (ptrSPITType == NULL) + return true; + return ptrSPITType->getProjectIndepended(); + } + }; + + void setID(string p_ID); + bool setConfirmed(bool p_Confirmed); + void setCreatedByClient(bool p_CreatedByClient); + bool setName(string p_Name); + bool setRemark(string p_Remark); + bool setServerParams(string p_ServerParams); + bool setSPITTypeID(string p_GroupName); + bool setServerRemote(bool p_BelongstoServer); + bool setActionAssignedType(bool p_ActionAssigned); + bool setActionAssigned(bool p_ActionAssigned); + bool setFixed(bool p_Fixed); + bool setFrameStart(long long p_FrameStart); + bool setFrameLength(long long p_FrameLength); + bool setFrameFadeInLength(long long p_FrameFadeInLength); + bool setFrameFadeOutLength(long long p_FrameFadeOutLength); + bool setValueUse(char p_ValueUse); + bool setValueFactor(int p_ValueFactor); + bool setTrack(int p_Track); + bool setDelay(long long p_Delay); + bool setDuration(long long p_Duration); + + bool setMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject); + void fillMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject); + void fillMessageOP(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject); }; - #endif /* SPITOBJECT_H */ - diff --git a/components/spit/include/SPITPlayer.h b/components/spit/include/SPITPlayer.h index 94f4e53..1b74a00 100644 --- a/components/spit/include/SPITPlayer.h +++ b/components/spit/include/SPITPlayer.h @@ -4,7 +4,7 @@ * and open the template in the editor. */ -/* +/* * File: SPITPLayer.h * Author: Hagi * @@ -18,79 +18,77 @@ #include class SPITPlayer { - -//----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------ -public: - class PlaySPITType { - public: - PlaySPITType(); - PlaySPITType(SPITPlayer* p_SPITPlayer, string p_SPITObjectID); - PlaySPITType(const PlaySPITType& orig); - - string getSPITTypeID() const { - return m_SPITTypeID; - } - - void startPlaySequence(); - bool getIsNew() const { return m_IsNew; } - void setIsNew(bool p_IsNew) { m_IsNew = p_IsNew; } - bool getIsPlayed() const { return m_IsPlayed; } - void setIsPlayed(bool p_IsFound) { m_IsPlayed = p_IsFound; } - string getPlayerID() const { return m_PlayerID; } - string getPlayerName() const { return m_PlayerName; } - bool getPlayerIsRunning() const { return m_PlayerRuns; } - void setPlayerIsRunning(bool p_PlayerRuns) { m_PlayerRuns = p_PlayerRuns; } - void setValue(double p_Value) { m_Value = p_Value; } - void addValue(double p_Value, double p_ValueFactor) { m_Value += (p_Value * p_ValueFactor); } - double getValue() const { return m_Value; } - - private: - string m_PlayerID; - string m_PlayerName; - bool m_PlayerRuns; - string m_SPITTypeID; - bool m_IsPlayed; - bool m_IsNew; - double m_Value; - }; - -//----- SPITPlayer ------ -public: - //list the SPITPlayers - static unordered_map s_SPITPlayers; //all actual played objects - static SPITPlayer* getSPITPlayer(string p_PlayerID); //if a player does not exist creates a new one - static void clearPlayers(); - - SPITPlayer(string p_PlayerID); - virtual ~SPITPlayer(); - - - void startPlaySequence(); //called by SPIT_Client::parsePlaySPITStart - PlaySPITType* addSPITType_Playing (string p_SPITTypeID); //called by SPIT_Client::parsePlaySPITStart - void endPlaySequence(); //called by SPIT_Client::parsePlaySPITEnd - string getID() { - return m_ID; - } - - unordered_map* getPlaySPITTypes(); - void setIsRunning(bool p_IsRunning); - bool getIsRunning() { return m_IsRunning; } - void setName(string p_Name); - string getName() { return m_Name; } - void setType(char p_Type); - char getType() { return m_Type; } - void setTime(long long p_Frames); - long long getTime() { return m_TimeFrames; } - -private: - string m_ID; - string m_Name; - char m_Type; - unordered_map m_PlaySPITTypes; - bool m_IsRunning; - long long m_TimeFrames; + //----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------ + public: + class PlaySPITType { + public: + PlaySPITType(); + PlaySPITType(SPITPlayer *p_SPITPlayer, string p_SPITObjectID); + PlaySPITType(const PlaySPITType &orig); + + string getSPITTypeID() const { + return m_SPITTypeID; + } + + void startPlaySequence(); + bool getIsNew() const { return m_IsNew; } + void setIsNew(bool p_IsNew) { m_IsNew = p_IsNew; } + bool getIsPlayed() const { return m_IsPlayed; } + void setIsPlayed(bool p_IsFound) { m_IsPlayed = p_IsFound; } + string getPlayerID() const { return m_PlayerID; } + string getPlayerName() const { return m_PlayerName; } + bool getPlayerIsRunning() const { return m_PlayerRuns; } + void setPlayerIsRunning(bool p_PlayerRuns) { m_PlayerRuns = p_PlayerRuns; } + void setValue(double p_Value) { m_Value = p_Value; } + void addValue(double p_Value, double p_ValueFactor) { m_Value += (p_Value * p_ValueFactor); } + double getValue() const { return m_Value; } + + private: + string m_PlayerID; + string m_PlayerName; + bool m_PlayerRuns; + string m_SPITTypeID; + bool m_IsPlayed; + bool m_IsNew; + double m_Value; + }; + + //----- SPITPlayer ------ + public: + // list the SPITPlayers + static unordered_map s_SPITPlayers; // all actual played objects + static SPITPlayer *getSPITPlayer(string p_PlayerID); // if a player does not exist creates a new one + static void clearPlayers(); + + SPITPlayer(string p_PlayerID); + virtual ~SPITPlayer(); + + void startPlaySequence(); // called by SPIT_Client::parsePlaySPITStart + PlaySPITType *addSPITType_Playing(string p_SPITTypeID); // called by SPIT_Client::parsePlaySPITStart + void endPlaySequence(); // called by SPIT_Client::parsePlaySPITEnd + + string getID() { + return m_ID; + } + + unordered_map *getPlaySPITTypes(); + void setIsRunning(bool p_IsRunning) { m_IsRunning = p_IsRunning; } + void setName(string p_Name) { m_Name = p_Name; } + void setType(char p_Type) { m_Type = p_Type; } + void setTime(long long p_Frames) { m_TimeFrames = p_Frames; } + bool getIsRunning() { return m_IsRunning; } + string getName() { return m_Name; } + char getType() { return m_Type; } + long long getTime() { return m_TimeFrames; } + + private: + string m_ID; + string m_Name; + char m_Type; + unordered_map m_PlaySPITTypes; + bool m_IsRunning; + long long m_TimeFrames; }; #endif /* SPITPLAYER_H */ - diff --git a/components/spit/include/SPITSocket.h b/components/spit/include/SPITSocket.h index 4bbfcf2..189ddda 100644 --- a/components/spit/include/SPITSocket.h +++ b/components/spit/include/SPITSocket.h @@ -4,7 +4,7 @@ * and open the template in the editor. */ -/* +/* * SPITSocket is the base class for WindowsSocket, UnixSocket,. * Used by SPIT_Client and SAD_Client. * File: SPITSocket.h @@ -16,17 +16,17 @@ #ifndef SPITSOCKET_H #define SPITSOCKET_H -#include -#include "esp_netif.h" -#include -#include -#include -#include -#include -#include -#include #include "Task.hpp" #include "esp_log.h" +#include "esp_netif.h" +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; @@ -35,133 +35,132 @@ string createGUID(); /** Returns the name of the client's host computer*/ string getClientHostName(); -class SPITSocket{ - public: - static const int FAMILY_IP4 = AF_INET; +class SPITSocket { + public: + static const int FAMILY_IP4 = AF_INET; - /** - * IPAddress class is used to fetch all available IP addresses of the computer - * This is for internal usage - */ - struct IPAddress { - public: - IPAddress(const string& p_IPAddress, const string& p_SubnetMask) - : m_IPAddress(p_IPAddress), m_SubnetMask(p_SubnetMask) { } - const string m_IPAddress; - const string m_SubnetMask; + /** + * IPAddress class is used to fetch all available IP addresses of the computer + * This is for internal usage + */ + struct IPAddress { + public: + IPAddress(const string &p_IPAddress, const string &p_SubnetMask) + : m_IPAddress(p_IPAddress), m_SubnetMask(p_SubnetMask) {} + const string m_IPAddress; + const string m_SubnetMask; - /** - * Calculates the broadcast address from a ip4 address - * @param p_IPAddress the ip4 address - * @return returns the broadcast address - */ - string getBroadcastIP4() const { - struct in_addr broadcast; - unsigned long ulIPAddress; - unsigned long ulSubnetMask; + /** + * Calculates the broadcast address from a ip4 address + * @param p_IPAddress the ip4 address + * @return returns the broadcast address + */ + string getBroadcastIP4() const { + struct in_addr broadcast; + unsigned long ulIPAddress; + unsigned long ulSubnetMask; - ulIPAddress = inet_addr(m_IPAddress.data()); - ulSubnetMask = inet_addr(m_SubnetMask.data()); - broadcast.s_addr = ulIPAddress | ~ulSubnetMask; + ulIPAddress = inet_addr(m_IPAddress.data()); + ulSubnetMask = inet_addr(m_SubnetMask.data()); + broadcast.s_addr = ulIPAddress | ~ulSubnetMask; - return inet_ntoa(broadcast); - } - }; - const IPAddress mOwnIp; - static IPAddress getAdaptersInfo(); - bool createSocket_UDP(); - static const int INVALID_SOCKET = -1; + return inet_ntoa(broadcast); + } + }; + const IPAddress mOwnIp; + static IPAddress getAdaptersInfo(); + bool createSocket_UDP(); + static const int INVALID_SOCKET = -1; -private: - int m_UDPSocketIP4; + private: + int m_UDPSocketIP4; -public: - //-------- class -------------- - SPITSocket(IPAddress ip) : mOwnIp(ip) { - m_UDPSocketIP4 = INVALID_SOCKET; - - m_ServerIP = ""; - m_ServerPort = ""; - m_ClientIP = ""; - m_ClientPort = ""; - m_BoundClientPort = ""; - m_BoundClientFamily = 0; - m_IsBound = false; - createSocket_UDP(); + public: + //-------- class -------------- + SPITSocket(IPAddress ip) : mOwnIp(ip) { + m_UDPSocketIP4 = INVALID_SOCKET; - } - virtual ~SPITSocket() { - ESP_LOGD("UDP", "Shutting down ..."); - - if (m_UDPSocketIP4 != INVALID_SOCKET) { - shutdown(m_UDPSocketIP4, 2); - close(m_UDPSocketIP4); - m_UDPSocketIP4 = INVALID_SOCKET; - } - fos::Task::delayMs(100); + m_ServerIP = ""; + m_ServerPort = ""; + m_ClientIP = ""; + m_ClientPort = ""; + m_BoundClientPort = ""; + m_BoundClientFamily = 0; m_IsBound = false; - } -private: - string m_ServerIP; - string m_ServerPort; - string m_ClientIP; - string m_ClientPort; //port given by the user maybe "0" - string m_BoundClientPort; //port set after bind - int m_BoundClientFamily; - bool m_IsBound; + createSocket_UDP(); + } + virtual ~SPITSocket() { + ESP_LOGD("UDP", "Shutting down ..."); -public: - /** - * Sets the ip address and port for server and client. - * @param p_ServerIP - * @param p_ServerPort - * @param p_ClientIP - * @param p_ClientPort - */ - void setConnectionParams(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort) { - m_ServerIP = p_ServerIP; - m_ServerPort = p_ServerPort; - m_ClientIP = p_ClientIP; - m_ClientPort = p_ClientPort; - } - - /** - * Send a message to the server as set by setConnectionParams - * @param p_MessageBytes byte buffer containing the message - * @param p_MessageLength length of the messaeg - * @return - */ - int sendMessage(const char* p_MessageBytes, int p_MessageLength) { - if (m_ServerPort.length() <= 0) - return -1; - int intResult; - { - if (m_IsBound == false) - return -1; - intResult = sendMessageTo(m_BoundClientFamily, m_ServerIP, m_ServerPort, p_MessageBytes, p_MessageLength); - } - return intResult; - } + if (m_UDPSocketIP4 != INVALID_SOCKET) { + shutdown(m_UDPSocketIP4, 2); + close(m_UDPSocketIP4); + m_UDPSocketIP4 = INVALID_SOCKET; + } + fos::Task::delayMs(100); + m_IsBound = false; + } - int receiveMessage(int p_InetFamily, char* p_Buffer, int p_BufferLength, string* p_ServerIP); - int setBroadcast(bool p_Broadcast); - int bindSocket(string p_ServerIP, string p_ClientIP, string p_ClientPort); - - // * Internal usage - don't use this manually - // * Use sendMessage instead - int sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Port, const char* p_MessageBytes, int p_MessageLength); - - string getServerIP() { return m_ServerIP; } - string getServerPort(){ return m_ServerPort; } - string getClientIP() { return m_ClientIP; } - string getClientPort() { return m_ClientPort; } - string getBoundClientPort() { return m_BoundClientPort; } - void setBoundClientPort(string p_Port) { m_BoundClientPort = p_Port; } - void setBoundClientFamily(int p_Family) { m_BoundClientFamily = p_Family; } - int getBoundClientFamily() { return m_BoundClientFamily; } - void setIsBound(bool p_IsBound) { m_IsBound = p_IsBound; } - bool getIsBound() { return m_IsBound; } + private: + string m_ServerIP; + string m_ServerPort; + string m_ClientIP; + string m_ClientPort; // port given by the user maybe "0" + string m_BoundClientPort; // port set after bind + int m_BoundClientFamily; + bool m_IsBound; + + public: + /** + * Sets the ip address and port for server and client. + * @param p_ServerIP + * @param p_ServerPort + * @param p_ClientIP + * @param p_ClientPort + */ + void setConnectionParams(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort) { + m_ServerIP = p_ServerIP; + m_ServerPort = p_ServerPort; + m_ClientIP = p_ClientIP; + m_ClientPort = p_ClientPort; + } + + /** + * Send a message to the server as set by setConnectionParams + * @param p_MessageBytes byte buffer containing the message + * @param p_MessageLength length of the messaeg + * @return + */ + int sendMessage(const char *p_MessageBytes, int p_MessageLength) { + if (m_ServerPort.length() <= 0) + return -1; + int intResult; + { + if (m_IsBound == false) + return -1; + intResult = sendMessageTo(m_BoundClientFamily, m_ServerIP, m_ServerPort, p_MessageBytes, p_MessageLength); + } + return intResult; + } + + int receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLength, string *p_ServerIP); + int setBroadcast(bool p_Broadcast); + int bindSocket(string p_ServerIP, string p_ClientIP, string p_ClientPort); + + // * Internal usage - don't use this manually + // * Use sendMessage instead + int sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Port, const char *p_MessageBytes, int p_MessageLength); + + string getServerIP() { return m_ServerIP; } + string getServerPort() { return m_ServerPort; } + string getClientIP() { return m_ClientIP; } + string getClientPort() { return m_ClientPort; } + string getBoundClientPort() { return m_BoundClientPort; } + void setBoundClientPort(string p_Port) { m_BoundClientPort = p_Port; } + void setBoundClientFamily(int p_Family) { m_BoundClientFamily = p_Family; } + int getBoundClientFamily() { return m_BoundClientFamily; } + void setIsBound(bool p_IsBound) { m_IsBound = p_IsBound; } + bool getIsBound() { return m_IsBound; } }; #endif /* SPITSOCKET_H */ - diff --git a/components/spit/include/SPITType.h b/components/spit/include/SPITType.h index 4d436fe..6d27d91 100644 --- a/components/spit/include/SPITType.h +++ b/components/spit/include/SPITType.h @@ -4,7 +4,7 @@ * and open the template in the editor. */ -/* +/* * File: SPITType.h * Author: Hagi * @@ -24,119 +24,117 @@ using namespace std; class SPITTypeListener; class SPITType { -private: - static unordered_map s_SPITTypes; - static unordered_map s_SPITTypesRemote; - -public: - static SPITType* getSPITType(string p_ID); - static const SPITType& getSPITTypeRef(string p_ID); - static bool addSPITType(SPITType* p_ptrSpitType); - static bool removeSPITType(SPITType* p_ptrSpitType); - static int getSPITTypeCount(); - static SPITType* getSPITType(int p_Index); - static const SPITType& getSPITTypeRef(int p_Index); - static void clearSPITTypes(); - static void setConfirmedFalse(); + private: + static unordered_map s_SPITTypes; + static unordered_map s_SPITTypesRemote; - static SPITType* getSPITTypeRemote(string p_ID); - static const SPITType& getSPITTypeRemoteRef(string p_ID); - static bool addSPITTypeRemote(SPITType* p_ptrSpitType); - static bool removeSPITTypeRemote(SPITType* p_ptrSpitType); - static int getSPITTypeRemoteCount(); - static SPITType* getSPITTypeRemote(int p_Index); - static const SPITType& getSPITTypeRemoteRef(int p_Index); - static void clearSPITTypesRemote(); - - static void eventProjectClosed(); - - SPITType(); - SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended,long long p_DefaultDelay, long long p_DefaultDuration); -// SPITType(const SPITType& orig); - ~SPITType(); -private: - - bool m_Confirmed; - string m_ID; - bool m_Fixed; - bool m_ServerRemote; - bool m_ServerProjectIndepended; - string m_GroupName; - string m_Name; - long long m_DefaultDelay; - long long m_DefaultDuration; - - bool m_CreatedByClient; //flag true = the SPITTyype is created by the client - //false = the SPITType is received from the server - - bool m_ActionAssigned; //This is a virtual flag if user associates an action with a SPITType. - //Can be used to setActionAssigned for all SPITObjects with this SPITType - - void initMembers(); - -public: - string getID() const{ return m_ID; } - string getGroupName() const { return m_GroupName; } - string getName() const { return m_Name; } - /** - * Returns if the SPITType triggers an action on the Server or on the client. - * @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType
- * true = the action is triggered on the server. The server waits for the client to play objects of this SPITType. - */ - bool getServerRemote() const { - return m_ServerRemote; - } - - bool getProjectIndepended() const { - return m_ServerProjectIndepended; - } - /** - * This is used by the server and client to tell if the other side has registered the changes. - * @return true = other side has registered the changes. - */ - bool getConfirmed() const { return m_Confirmed; } - bool getFixed() const { return m_Fixed; } - long long getDefaultDelay() const { return m_DefaultDelay; } - long long getDefaultDuration() const { return m_DefaultDuration; } - bool getCreatedByClient() const { return m_CreatedByClient; } - - /** - * Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
- * This can used to setActionAssigned to all SPITObjects with this SPITType.
- * This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.
- * @return true = the user has associated an action with this SPITType. - */ - bool getActionAssigned() const { - return m_ActionAssigned; - } - - -public: - void setID(string p_ID); - bool setGroupName(string p_GroupName); - bool setName(string p_Name); - bool setServerRemote(bool p_BelongstoServer); - bool setProjectIndepended(bool p_ProjectIndepeneded); - bool setConfirmed(bool p_Confirmed); - bool setFixed(bool p_Fixed); - bool setDefaultDelay(long long p_Delay); - bool setDefaultDuration(long long p_Duration); - - void setCreatedByClient(bool p_CreatedByClient); - - /** - * Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
- * This can used to setActionAssigned to all SPITObjects with this SPITType.
- * This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.
- * @return true = the m_ActionAssigned has changed. - */ - bool setActionAssigned(bool p_ActionAssigned); - - bool setMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType); - void fillMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType); - void fillMessageOP(SPIT_Message::RemoveSPITType* p_RemoveSPITType); -// static char* stringCopy(const char* p_String); + public: + static SPITType *getSPITType(string p_ID); + static const SPITType &getSPITTypeRef(string p_ID); + static bool addSPITType(SPITType *p_ptrSpitType); + static bool removeSPITType(SPITType *p_ptrSpitType); + static int getSPITTypeCount(); + static SPITType *getSPITType(int p_Index); + static const SPITType &getSPITTypeRef(int p_Index); + static void clearSPITTypes(); + static void setConfirmedFalse(); + + static SPITType *getSPITTypeRemote(string p_ID); + static const SPITType &getSPITTypeRemoteRef(string p_ID); + static bool addSPITTypeRemote(SPITType *p_ptrSpitType); + static bool removeSPITTypeRemote(SPITType *p_ptrSpitType); + static int getSPITTypeRemoteCount(); + static SPITType *getSPITTypeRemote(int p_Index); + static const SPITType &getSPITTypeRemoteRef(int p_Index); + static void clearSPITTypesRemote(); + + static void eventProjectClosed(); + + SPITType(); + SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended, long long p_DefaultDelay, long long p_DefaultDuration); + // SPITType(const SPITType& orig); + ~SPITType(); + + private: + bool m_Confirmed; + string m_ID; + bool m_Fixed; + bool m_ServerRemote; + bool m_ServerProjectIndepended; + string m_GroupName; + string m_Name; + long long m_DefaultDelay; + long long m_DefaultDuration; + + bool m_CreatedByClient; // flag true = the SPITTyype is created by the client + // false = the SPITType is received from the server + + bool m_ActionAssigned; // This is a virtual flag if user associates an action with a SPITType. + // Can be used to setActionAssigned for all SPITObjects with this SPITType + + void initMembers(); + + public: + string getID() const { return m_ID; } + string getGroupName() const { return m_GroupName; } + string getName() const { return m_Name; } + /** + * Returns if the SPITType triggers an action on the Server or on the client. + * @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType
+ * true = the action is triggered on the server. The server waits for the client to play objects of this SPITType. + */ + bool getServerRemote() const { + return m_ServerRemote; + } + + bool getProjectIndepended() const { + return m_ServerProjectIndepended; + } + /** + * This is used by the server and client to tell if the other side has registered the changes. + * @return true = other side has registered the changes. + */ + bool getConfirmed() const { return m_Confirmed; } + bool getFixed() const { return m_Fixed; } + long long getDefaultDelay() const { return m_DefaultDelay; } + long long getDefaultDuration() const { return m_DefaultDuration; } + bool getCreatedByClient() const { return m_CreatedByClient; } + + /** + * Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
+ * This can used to setActionAssigned to all SPITObjects with this SPITType.
+ * This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.
+ * @return true = the user has associated an action with this SPITType. + */ + bool getActionAssigned() const { + return m_ActionAssigned; + } + + public: + void setID(string p_ID); + bool setGroupName(string p_GroupName); + bool setName(string p_Name); + bool setServerRemote(bool p_BelongstoServer); + bool setProjectIndepended(bool p_ProjectIndepeneded); + bool setConfirmed(bool p_Confirmed); + bool setFixed(bool p_Fixed); + bool setDefaultDelay(long long p_Delay); + bool setDefaultDuration(long long p_Duration); + + void setCreatedByClient(bool p_CreatedByClient); + + /** + * Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
+ * This can used to setActionAssigned to all SPITObjects with this SPITType.
+ * This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.
+ * @return true = the m_ActionAssigned has changed. + */ + bool setActionAssigned(bool p_ActionAssigned); + + bool setMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType); + void fillMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType); + void fillMessageOP(SPIT_Message::RemoveSPITType *p_RemoveSPITType); + // static char* stringCopy(const char* p_String); }; - #endif /* SPITTYPE_H */ \ No newline at end of file diff --git a/components/spit/include/SPIT_Client.h b/components/spit/include/SPIT_Client.h index bf065b7..fd72916 100644 --- a/components/spit/include/SPIT_Client.h +++ b/components/spit/include/SPIT_Client.h @@ -4,7 +4,7 @@ * and open the template in the editor. */ -/* +/* * File: SPIT_Client.h * Author: Hagi * @@ -14,12 +14,12 @@ #ifndef SPIT_CLIENT_H #define SPIT_CLIENT_H -#include "SPITSocket.h" #include "SAD_DetectedServer.hpp" -#include "SPIT_Message.h" -#include "SPITType.h" #include "SPITObject.h" #include "SPITPlayer.h" +#include "SPITSocket.h" +#include "SPITType.h" +#include "SPIT_Message.h" #include #include @@ -27,316 +27,327 @@ using namespace std; class SPIT_Client : I_SAD_Client { -public: - /** Maximal length of a SPITMessage*/ - static const int MAXSPITMESSAGEBYTECOUNT = 512; - - enum ServerEvent { - Detect, - Lost, - Changed, - }; + public: + /** Maximal length of a SPITMessage*/ + static const int MAXSPITMESSAGEBYTECOUNT = 512; - struct Callbacks { - void(*onServerEvent)(ServerEvent event, const SAD_DetectedServer &p_DetectedServer); - void(*onConnectionStatus)(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus); - void(*onStartProjectTransfer)(); - void(*onEndProjectTransfer)(); - void(*onProjectClosed)(string); - void(*onProjectReport)(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond); - void(*onSpitType)(bool p_New, const SPITType &p_SPITType); - void(*onSpitTypeRemote)(bool p_New, const SPITType &p_SPITType); - void(*onSpitObject)(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject); - void(*onSpitObjectRemote)(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject); - void(*onSpitTypeRemoved)(const SPITType &p_SPITType); - void(*onSpitTypeRemoteRemoved)(const SPITType &p_SPITType); - void(*onSpitObjectRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject); - void(*onSpitObjectRemoteRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject); - void(*onPlay)(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames); - void(*onPlaySpitType)(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value); - void(*onPlayRemoteObjectStatus)(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value); - bool(*onCheckSpitTypeVeto)(SPIT_Message::ReportSPITType* p_ReportSPITType); - bool(*onCheckSpitObjectVeto)(SPIT_Message::ReportSPITObject* p_ReportSPITObject); - }; + enum class ProjUpdate { + ServerLoaded, + StartTransfer, + EndTransfer, + ServerClosed, + }; + enum class ServerEvent { + Detect, + Lost, + Changed, + }; + enum class ObjectEvent { + Created, + Changed, + Deleted + }; -//----- Connection Status ----- -public: - /** No Connection established.
Either no connect tried or disconnected*/ - static const int CONNECTION_NONE = 0; - /** Server has disconnected*/ - static const int CONNECTION_NONESERVER = 1; - /** The connection is lost
Either because of a network crash or because the server no longer responds.*/ - static const int CONNECTION_LOST = 2; - /** Connection to the serv er is established.*/ - static const int CONNECTION_OK = 3; - /** A connection to the server is tried.*/ - static const int CONNECTION_TRYCONNECTION = 4; - -//------ PlayerType ------ -public: - /** continous main player, time value can be used like a timecode.
The time value is the position in server's project.
A server should use only one main player.*/ - static const char PLAYERTYPE_MAIN = 0x02; - /** continous player. This player plays SPIT objects sometime during the project.*/ - static const char PLAYERTYPE_CONTINOUS = 0x01; - /** diescrete player. This player is used to transmit single discrete values.*/ - static const char PLAYERTYPE_DISCRETE = 0x00; + struct Callbacks { + void (*onServerEvent)(ServerEvent event, const SAD_DetectedServer &p_DetectedServer){}; + void (*onConnectionStatus)(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus){}; + void (*onProjectUpdate)(ProjUpdate state, string projectId){}; -//------ Value Flag ------ -//------ used by sendRemoteObject -public: - /**Set the given value directly*/ - static const char VALUEFLAG_DIRECT = 0x00; - /**Increase the existing value by the given value.
This is usefull e.g. when instead of a fader a endless wheel is used*/ - static const char VALUEFLAG_INCREASE = 0x01; - /**Decrease the existing value by the given value.
This is usefull e.g. when instead of a fader a endless wheel is used*/ - static const char VALUEFLAG_DECREASE = 0x02; + void (*onSpitType)(ObjectEvent event, const SPITType &p_SPITType){}; + void (*onSpitTypeRemote)(ObjectEvent event, const SPITType &p_SPITType){}; + void (*onSpitObject)(ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject){}; + void (*onSpitObjectRemote)(ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject){}; -//----- SPIT_Client ----- -public: - SPIT_Client(string name, string projName, Callbacks calls); - virtual ~SPIT_Client(); - static int s_MAX_OVERTAKING_SPIT_MESSAGES; -private: - Callbacks mCallbacks; + void (*onPlay)(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames){}; + void (*onPlaySpitType)(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value){}; + void (*onPlayRemoteObjectStatus)(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value){}; + bool (*onCheckSpitTypeVeto)(SPIT_Message::ReportSPITType *p_ReportSPITType){}; + bool (*onCheckSpitObjectVeto)(SPIT_Message::ReportSPITObject *p_ReportSPITObject){}; + }; - fos::TaskT * m_ThreadReceive{}; - bool m_StopReceiveSPITMessages; + //----- Connection Status ----- + public: + /** No Connection established.
Either no connect tried or disconnected*/ + static const int CONNECTION_NONE = 0; + /** Server has disconnected*/ + static const int CONNECTION_NONESERVER = 1; + /** The connection is lost
Either because of a network crash or because the server no longer responds.*/ + static const int CONNECTION_LOST = 2; + /** Connection to the serv er is established.*/ + static const int CONNECTION_OK = 3; + /** A connection to the server is tried.*/ + static const int CONNECTION_TRYCONNECTION = 4; - int m_ConnectionStatus; - bool m_DisconnectedByServer{}; //flag true = when server disconnects - string m_ID; - string m_Name; - string m_ProjName; - string m_ComputerName; + //------ PlayerType ------ + public: + /** continous main player, time value can be used like a timecode.
The time value is the position in server's project.
A server should use only one main player.*/ + static const char PLAYERTYPE_MAIN = 0x02; + /** continous player. This player plays SPIT objects sometime during the project.*/ + static const char PLAYERTYPE_CONTINOUS = 0x01; + /** diescrete player. This player is used to transmit single discrete values.*/ + static const char PLAYERTYPE_DISCRETE = 0x00; - string m_ClientProjectName; - - unsigned char m_MessageNumber_Send; - int m_MessageNumber_Received; - vector m_OvertakingSPIT_Messages; + //------ Value Flag ------ + //------ used by sendRemoteObject + public: + /**Set the given value directly*/ + static const char VALUEFLAG_DIRECT = 0x00; + /**Increase the existing value by the given value.
This is usefull e.g. when instead of a fader a endless wheel is used*/ + static const char VALUEFLAG_INCREASE = 0x01; + /**Decrease the existing value by the given value.
This is usefull e.g. when instead of a fader a endless wheel is used*/ + static const char VALUEFLAG_DECREASE = 0x02; - //Server's info filled by parseConnectAnswer - string m_ServerID{}; - string m_ServerName{}; - string m_ServerComputerName{}; - int m_ServerStepTime{-1}; - - //--- Server Project --- - string m_ServerProjectID; - string m_ServerProjectName; - int m_ServerFramesPerSecond; - -public: - /** The ID of the client.
Every client instance should set an unique id*/ - string getID() { return m_ID; } - /** The name of the client, should be set by the user app*/ - string getName() { return m_Name; } - //----- Computer Params ----- - /** The name of the client's host computer*/ - string getComputerName() { return m_ComputerName; } - void setClientProjectName(string p_ClientProjectName) { m_ClientProjectName = p_ClientProjectName; } - string getClientProjectName() { return m_ClientProjectName; } + //----- SPIT_Client ----- + public: + SPIT_Client(string name, string projName, Callbacks calls); + virtual ~SPIT_Client(); + static int s_MAX_OVERTAKING_SPIT_MESSAGES; - //connected Server Infos - /** The ID of the connected SPITServer*/ - string getServerID() { return m_ServerID; } - /** The host computername of the connected SPITServer*/ - string getServerComputerName() { return m_ServerComputerName; } - /** The name of the connected SPITServer*/ - string getServerName() { return m_ServerName; } + private: + Callbacks mCallbacks; - /** Expected Refreah Rate of the connectd SPITServer.
- * When the server plays objects, it will do so at discrete time steps.
- * Play events will take place in these time steps.. - */ - int getServerStepTime() { return m_ServerStepTime; } - - /** Should be called when the client wants to close his project*/ - void clientProjectClose(); - /** - * Should be called whenever the client has a project loaded - */ - void clientProjectLoaded(); - - /** - * - * @param p_SPITTypeID - * @param p_ActionAssigned - */ - void setActionSPITType(string p_SPITTypeID, bool p_ActionAssigned); - void setActionSPITObject(string p_SPITObjectID, bool p_ActionAssigned); - -//--------------- SPITMessage --------------- -private: - bool startReceiveSPITMessages(); - void stopReceiveSPITMessages(); - static void receiveSPITMessage(SPIT_Client& rM); - // Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected + fos::TaskT *m_ThreadReceive{}; + bool m_StopReceiveSPITMessages; + + int m_ConnectionStatus; + bool m_DisconnectedByServer{}; // flag true = when server disconnects + string m_ID; + string m_Name; + string m_ProjName; + string m_ComputerName; + + string m_ClientProjectName; + + unsigned char m_MessageNumber_Send; + int m_MessageNumber_Received; + vector m_OvertakingSPIT_Messages; + + // Server's info filled by parseConnectAnswer + string m_ServerID{}; + string m_ServerName{}; + string m_ServerComputerName{}; + int m_ServerStepTime{-1}; + + //--- Server Project --- + string m_ServerProjectID; + string m_ServerProjectName; + int m_ServerFramesPerSecond; + + public: + /** The ID of the client.
Every client instance should set an unique id*/ + string getID() { return m_ID; } + /** The name of the client, should be set by the user app*/ + string getName() { return m_Name; } + //----- Computer Params ----- + /** The name of the client's host computer*/ + string getComputerName() { return m_ComputerName; } + void setClientProjectName(string p_ClientProjectName) { m_ClientProjectName = p_ClientProjectName; } + string getClientProjectName() { return m_ClientProjectName; } + + // connected Server Infos + /** The ID of the connected SPITServer*/ + string getServerID() { return m_ServerID; } + /** The host computername of the connected SPITServer*/ + string getServerComputerName() { return m_ServerComputerName; } + /** The name of the connected SPITServer*/ + string getServerName() { return m_ServerName; } + + /** Expected Refreah Rate of the connectd SPITServer.
+ * When the server plays objects, it will do so at discrete time steps.
+ * Play events will take place in these time steps.. + */ + int getServerStepTime() { return m_ServerStepTime; } + + /** Should be called when the client wants to close his project*/ + void clientProjectClose(); + /** + * Should be called whenever the client has a project loaded + */ + void clientProjectLoaded(); + + /** + * + * @param p_SPITTypeID + * @param p_ActionAssigned + */ + void setActionSPITType(string p_SPITTypeID, bool p_ActionAssigned); + void setActionSPITObject(string p_SPITObjectID, bool p_ActionAssigned); + + //--------------- SPITMessage --------------- + private: + bool startReceiveSPITMessages(); + void stopReceiveSPITMessages(); + static void receiveSPITMessage(SPIT_Client &rM); + // Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by m_ServerID -public: - void fillHeader(SPIT_Message::Header* p_Header); - int sendSPITMessage(SPIT_Message::OPPart& p_SPITMessageOPPart); + public: + void fillHeader(SPIT_Message::Header *p_Header); + int sendSPITMessage(SPIT_Message::OPPart &p_SPITMessageOPPart); -//--------------- ServerAutoDetection SAD --------------- -public: - /** Starts the autodetection of SPITServers in the local network. If a connection is tried, the autodetection should be stopped before.*/ - void startServerAutoDetect(); - /** Stops the autodetection of SPITServers in the local network*/ - void stopServerAutoDetect(); - /** Called every time a new SPITServer is detetced in the local network */ - void eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4); - /** Called every time a prior detected SPITServer is is no longer found.*/ - void eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4); - void eventServerChanged(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4); - -//--------------- Connection --------------- -public: - /** - * Tries a connection to the SPITServer - * @param p_ServerIP ip address of the SPITServer - * @param p_ServerPort port of the SPITServer - * @param p_ClientIP IP of the client - * @param p_ClientPort if "0" any free port will be used - * @param p_LoginName maybe some SPITServer need a login - liveSHOWsoftware will not. - * @param p_LoginPassword maybe some SPITServer need a login - liveSHOWsoftware will not - * @return true = the connection try is ok, SPITServer will answer with COnnectAnswer and an eventConnectionStatus will occur.
- * false = something is going wrong. (client could not bind) - */ - bool connect(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort, string p_LoginName = "", string p_LoginPassword = ""); - /** - * Terminates the connection to the SPITServer. - */ - void disconnect(); - -private: - void disconnectInternal(int p_Cause); - void resetMessageNumberReceived(); - void parseSPIT_Message(unique_ptr p_SPITMessage); - void checkParseSPIT_Message(unique_ptr p_SPITMessage); - void addOvertakingSPIT_Message(SPIT_Message* p_SPIT_Message); - void parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswer); - void parseDisconnect(SPIT_Message::Disconnect* p_Disconnect); - void parseWatchdog(SPIT_Message::Watchdog* p_Watchdog); - void parseWatchdogAnswer(SPIT_Message::WatchdogAnswer* p_WatchdogAnswer); -public: - /** Used internally*/ - void sendWatchdog(); - /** Used internally. When the connection to the SPITServer is lost an eventConnectionStatus will occur*/ - void eventWatchdogLost(); -//--------------- SPIT Project --------------- -private: - void parseReportSPITProject(SPIT_Message::ReportSPITProject* p_ReportSPITProject); - void parseCloseSPITProject(SPIT_Message::CloseSPITProject* p_CloseSPITProject); -public: - /** Returns the SPITServer's project ID - may be the same as the project's name*/ - string getServerProjectID(); - /** Returns the SPITServer's project name*/ - string getServerProjectName(); - /** Returns frame rate per second. This is the time resolution in which the server transmits time data. The unit of time data is always frames.*/ - int getServerFramesPerSecond(); - -private: - void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer); - void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer); - void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer); -public: - static void sendProject(SPIT_Client* p_PtrSPIT_Client); - -// --------------- SPIT Types --------------- -public: - /** - * Creates a fixed SPITType for application actions that are always present and project independent.
- * Fixed SPIT types cannot be changed or deleted by the server.
- * These SPITTypes will be automatically added to the SPITType-List and sended to the server. - * @param p_ID an unique of the SPITType, these are always the same per client approach. Different client approaches should use different ids. - * @param p_GroupName a name which groups the actions/SPITTypes - * @param p_Name the name of the Action/SPITType - * @param p_DefaultDelay maybe there is an default delay until the action starts, this is only used for graphical representations, 0 is allowd - * @param p_DefaultDuration maybe the action has a default duration, this is only used for graphical representations, 0 is allowd - * @return the pointer to the new SPITType. - */ - SPITType* createSPITTypeFixed(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration); + //--------------- ServerAutoDetection SAD --------------- + public: + /** Starts the autodetection of SPITServers in the local network. If a connection is tried, the autodetection should be stopped before.*/ + void startServerAutoDetect(); + /** Stops the autodetection of SPITServers in the local network*/ + void stopServerAutoDetect(); + /** Called every time a new SPITServer is detetced in the local network */ + void eventServerDetected(SAD_DetectedServer &server); + /** Called every time a prior detected SPITServer is is no longer found.*/ + void eventServerLost(SAD_DetectedServer &server); + void eventServerChanged(SAD_DetectedServer &server); - /** - * Creates a SPITType for application actions.
- * These SPITTypes will be automatically added to the SPITType-List and sended to the server. - * @param p_ID an unique of the SPITType, these are always the same per client approach. Different client approaches should use different ids. - * @param p_GroupName a name which groups the actions/SPITTypes - * @param p_Name the name of the Action/SPITType - * @param p_DefaultDelay maybe there is an default delay until the action starts, this is only used for graphical representations, 0 is allowd - * @param p_DefaultDuration maybe the action has a default duration, this is only used for graphical representations, 0 is allowd - * @param p_Fixed true = the server is not allowed to change this SPITType, false = the server may change or delete this SPITType - * @param p_ProjectIndepended true = the SPITType belongs to a specific project, false = the SpitType always exists for every project - * @return the pointer to the new SPITType. - */ - SPITType* createSPITType(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration, bool p_Fixed, bool p_ProjectIndepended); -private: - //receive SPITTypes - void parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPITType); - void parseRemoveSPITType(SPIT_Message::RemoveSPITType* p_RemoveSPITType); - int sendSPITTypeInternal(SPITType* p_SPITType); -public: - /** - * If a client wants to change a SPITType, he should send it to the server.
- * If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the change.
- * @param p_SPITTypeID the id of the SPITType to remove. - * @return 0 = is sended, -1 = is not sended - */ - bool changeSPITType(SPITType* p_SPITType); - /** - * If a client wants to remove a SPITType, he should send it to the server.
- * If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the deletion.
- * @param p_SPITTypeID the id of the SPITType to remove. - * @return 0 = is sended, -1 = is not sended - */ - int removeSPITType(string p_SPITTypeID); -public: - -//--------------- SPIT Objects --------------- -private: - void parseReportSPITObject(SPIT_Message::ReportSPITObject* p_ReportSPITObject); - void parseRemoveSPITObject(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject); - int sendSPITObjectInternal(SPITObject* ptrSPITObject); -public: - /** - * When the client changes a SPITObject (normally the client should not do this), then it should send the changes to the SPITServer.
- * The SPITServer may discard the changes and an eventSPITObject occurs.
- * @param p_SPITObject the pointer to the changed SPITObject. - * @return 0 = sended, -1 = not sended - */ - bool changeSPITObject(SPITObject* p_SPITObject); - /** - * When the client removes a SPITObject (normally the client should not do this), then he should send it to the SPITServer.
- * The SPITServer may discard the deletion and an eventSPITObject occurs.
- * @param p_SPITObjectID the id of the SPITObject to remove. - * @return 0 = sended, -1 = not sended - */ - int removeSPITObject(string p_SPITObjectID); -public: - -//--------------- Play SPIT Objects --------------- -private: - void parsePlaySPITStart(SPIT_Message::PlaySPITStart* p_PlaySPITStart); - void parsePlaySPITObject(SPIT_Message::PlaySPITObject* p_PlaySPITObject); - void parsePlaySPITEnd(SPIT_Message::PlaySPITEnd* p_PlaySPITEnd); - void parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_ReportPlayStatus); - - public: - //--------- Remote ---------- - void sendRemoteObject(string p_SPITObjectID, int p_Valueppm = 0, char p_ValueFlag = 0x00); + //--------------- Connection --------------- + public: + /** + * Tries a connection to the SPITServer + * @param p_ServerIP ip address of the SPITServer + * @param p_ServerPort port of the SPITServer + * @param p_ClientIP IP of the client + * @param p_ClientPort if "0" any free port will be used + * @param p_LoginName maybe some SPITServer need a login - liveSHOWsoftware will not. + * @param p_LoginPassword maybe some SPITServer need a login - liveSHOWsoftware will not + * @return true = the connection try is ok, SPITServer will answer with COnnectAnswer and an eventConnectionStatus will occur.
+ * false = something is going wrong. (client could not bind) + */ + bool connect(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort, string p_LoginName = "", string p_LoginPassword = ""); + /** + * Terminates the connection to the SPITServer. + */ + void disconnect(); - private: - static void processSocketTask(SPIT_Client & instance); - fos::TaskT* sThread{}; - bool abortSearch{}; - bool sAnswered{}; - static fos::Semaphore sStartSad; - SPITSocket * mSPITSocket; - void answerWatchdog() { - sAnswered = true; - } + private: + void disconnectInternal(int p_Cause); + void resetMessageNumberReceived(); + void parseSPIT_Message(unique_ptr p_SPITMessage); + void checkParseSPIT_Message(unique_ptr p_SPITMessage); + void addOvertakingSPIT_Message(SPIT_Message *p_SPIT_Message); + void parseConnectAnswer(SPIT_Message::ConnectAnswer *p_ConnectAnswer); + void parseDisconnect(SPIT_Message::Disconnect *p_Disconnect); + void parseWatchdog(SPIT_Message::Watchdog *p_Watchdog); + void parseWatchdogAnswer(SPIT_Message::WatchdogAnswer *p_WatchdogAnswer); + public: + /** Used internally*/ + void sendWatchdog(); + /** Used internally. When the connection to the SPITServer is lost an eventConnectionStatus will occur*/ + void eventWatchdogLost(); + //--------------- SPIT Project --------------- + private: + void parseReportSPITProject(SPIT_Message::ReportSPITProject *p_ReportSPITProject); + void parseCloseSPITProject(SPIT_Message::CloseSPITProject *p_CloseSPITProject); + + public: + /** Returns the SPITServer's project ID - may be the same as the project's name*/ + string getServerProjectID(); + /** Returns the SPITServer's project name*/ + string getServerProjectName(); + /** Returns frame rate per second. This is the time resolution in which the server transmits time data. The unit of time data is always frames.*/ + int getServerFramesPerSecond(); + + private: + void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer *p_RequestProjectTransfer); + void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer *p_StartProjectTransfer); + void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer *p_EndProjectTransfer); + + public: + static void sendProject(SPIT_Client *p_PtrSPIT_Client); + + // --------------- SPIT Types --------------- + public: + /** + * Creates a fixed SPITType for application actions that are always present and project independent.
+ * Fixed SPIT types cannot be changed or deleted by the server.
+ * These SPITTypes will be automatically added to the SPITType-List and sended to the server. + * @param p_ID an unique of the SPITType, these are always the same per client approach. Different client approaches should use different ids. + * @param p_GroupName a name which groups the actions/SPITTypes + * @param p_Name the name of the Action/SPITType + * @param p_DefaultDelay maybe there is an default delay until the action starts, this is only used for graphical representations, 0 is allowd + * @param p_DefaultDuration maybe the action has a default duration, this is only used for graphical representations, 0 is allowd + * @return the pointer to the new SPITType. + */ + SPITType *createSPITTypeFixed(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration); + + /** + * Creates a SPITType for application actions.
+ * These SPITTypes will be automatically added to the SPITType-List and sended to the server. + * @param p_ID an unique of the SPITType, these are always the same per client approach. Different client approaches should use different ids. + * @param p_GroupName a name which groups the actions/SPITTypes + * @param p_Name the name of the Action/SPITType + * @param p_DefaultDelay maybe there is an default delay until the action starts, this is only used for graphical representations, 0 is allowd + * @param p_DefaultDuration maybe the action has a default duration, this is only used for graphical representations, 0 is allowd + * @param p_Fixed true = the server is not allowed to change this SPITType, false = the server may change or delete this SPITType + * @param p_ProjectIndepended true = the SPITType belongs to a specific project, false = the SpitType always exists for every project + * @return the pointer to the new SPITType. + */ + SPITType *createSPITType(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration, bool p_Fixed, bool p_ProjectIndepended); + + private: + // receive SPITTypes + void parseReportSPITType(SPIT_Message::ReportSPITType *p_ReportSPITType); + void parseRemoveSPITType(SPIT_Message::RemoveSPITType *p_RemoveSPITType); + int sendSPITTypeInternal(SPITType *p_SPITType); + + public: + /** + * If a client wants to change a SPITType, he should send it to the server.
+ * If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the change.
+ * @param p_SPITTypeID the id of the SPITType to remove. + * @return 0 = is sended, -1 = is not sended + */ + bool changeSPITType(SPITType *p_SPITType); + /** + * If a client wants to remove a SPITType, he should send it to the server.
+ * If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the deletion.
+ * @param p_SPITTypeID the id of the SPITType to remove. + * @return 0 = is sended, -1 = is not sended + */ + int removeSPITType(string p_SPITTypeID); + + public: + //--------------- SPIT Objects --------------- + private: + void parseReportSPITObject(SPIT_Message::ReportSPITObject *p_ReportSPITObject); + void parseRemoveSPITObject(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject); + int sendSPITObjectInternal(SPITObject *ptrSPITObject); + + public: + /** + * When the client changes a SPITObject (normally the client should not do this), then it should send the changes to the SPITServer.
+ * The SPITServer may discard the changes and an eventSPITObject occurs.
+ * @param p_SPITObject the pointer to the changed SPITObject. + * @return 0 = sended, -1 = not sended + */ + bool changeSPITObject(SPITObject *p_SPITObject); + /** + * When the client removes a SPITObject (normally the client should not do this), then he should send it to the SPITServer.
+ * The SPITServer may discard the deletion and an eventSPITObject occurs.
+ * @param p_SPITObjectID the id of the SPITObject to remove. + * @return 0 = sended, -1 = not sended + */ + int removeSPITObject(string p_SPITObjectID); + + public: + //--------------- Play SPIT Objects --------------- + private: + void parsePlaySPITStart(SPIT_Message::PlaySPITStart *p_PlaySPITStart); + void parsePlaySPITObject(SPIT_Message::PlaySPITObject *p_PlaySPITObject); + void parsePlaySPITEnd(SPIT_Message::PlaySPITEnd *p_PlaySPITEnd); + void parseReportPlayStatus(SPIT_Message::ReportPlayStatus *p_ReportPlayStatus); + + public: + //--------- Remote ---------- + void sendRemoteObject(string p_SPITObjectID, int p_Valueppm = 0, char p_ValueFlag = 0x00); + + private: + static void processSocketTask(SPIT_Client &instance); + fos::TaskT *sThread{}; + bool abortSearch{}; + bool sAnswered{}; + static fos::Semaphore sStartSad; + SPITSocket *mSPITSocket; + void answerWatchdog() { + sAnswered = true; + } }; #endif /* SPIT_CLIENT_H */ - diff --git a/components/spit/include/SPIT_Message.h b/components/spit/include/SPIT_Message.h index 9f6c9fd..9c3a0fb 100644 --- a/components/spit/include/SPIT_Message.h +++ b/components/spit/include/SPIT_Message.h @@ -4,7 +4,7 @@ * and open the template in the editor. */ -/* +/* * File: SPIT_Message.h * Author: Hagi * @@ -19,932 +19,843 @@ using namespace std; static const string SPITID = "#spit#"; -//static char stringEmpty[] = ""; +// static char stringEmpty[] = ""; static char nullChar[] = "\0"; -class SPIT_Message { -//----------- Header ----------- -public: - - class Header { - public: - static const int BYTESLENGTH = 99; - virtual ~Header(); - Header(const Header& orig); - Header(); - //Members - private: - string m_SPITID; - int m_SPITVersion; - unsigned char m_MessageNumber; - int m_BytesCount; - string m_ServerID; - string m_ClientID; - int m_OPFlag; - int m_ParseOffset = 0; +class SPIT_Message { + //----------- Header ----------- + public: + class Header { + public: + static const int BYTESLENGTH = 99; + virtual ~Header(); + Header(const Header &orig); + Header(); + // Members + private: + string m_SPITID; + int m_SPITVersion; + unsigned char m_MessageNumber; + int m_BytesCount; + string m_ServerID; + string m_ClientID; + int m_OPFlag; + int m_ParseOffset = 0; - void initMembers(); - - public: - const string getSPITID() const { - return m_SPITID; - } - int getSPITVersion() const { - return m_SPITVersion; - } - unsigned char getMessageNumber() const { - return m_MessageNumber; - } - int getBytesCount() const { - return m_BytesCount; - } - const string getServerID() const { - return m_ServerID; - } - const string getClientID() const { - return m_ClientID; - } - int getOPFlag() const { - return m_OPFlag; - } - - //Receive - public: - bool parse(char* p_Bytes, int p_ByteCount); - - //Send - public: - Header(int p_SPITVersion, int p_OPFlag); - void setMessageNumber(unsigned char p_MessageNumber); - void setServerID(string p_ServerID); - void setClientID(string p_ID); - void setOPFlag(int p_OPFlag); - bool fillBytes(char* p_Bytes, int p_ByteCount); - }; + void initMembers(); -//----------- OPPart ----------- -public: - class OPPart { - - //Members - protected: - Header* m_Header; - int m_ParseOffset; - int m_BytesCount; - private: - void initMembers(); - public: - virtual ~OPPart(); -// OPPart(const OPPart& orig); - Header* getHeader() const { - return m_Header; - } - - int getBytesCount() const { - return m_BytesCount; - } - const string getServerID() const { - if (m_Header == NULL) return ""; - return m_Header->getServerID(); - } - const string getClientID() const { - if (m_Header == NULL) return ""; - return m_Header->getClientID(); - } - - int getOPFlag() const { - if (m_Header == NULL) return -1; - return m_Header->getOPFlag(); - } - - //Receive - public: - OPPart(Header* p_Header, int p_OPFlag); - void setHeader(Header* p_Header); - virtual bool parse(char* p_Bytes, int p_ByteCounth)=0; - - //Send - public: - OPPart(); - virtual bool fillBytes(char* p_Bytes, int p_ByteCount)=0; - }; + public: + const string getSPITID() const { return m_SPITID; } + int getSPITVersion() const { return m_SPITVersion; } + unsigned char getMessageNumber() const { return m_MessageNumber; } + int getBytesCount() const { return m_BytesCount; } + const string getServerID() const { return m_ServerID; } + const string getClientID() const { return m_ClientID; } + int getOPFlag() const { return m_OPFlag; } - -//----------- SPIT_Message ----------- - -public: - static const int SPITVERSION = 1; + // Receive + public: + bool parse(char *p_Bytes, int p_ByteCount); - //SPIT_Object value usage - static const char VALUEUSE_DISCARD = 0x00; //value of SPITObejct is not used - static const char VALUEUSE_INRANGE = 0x01; //value of SPITOBject in range 0 - 1000000ppm - static const char VALUEUSE_OVERRIDE = 0x02; //value can be overridden - - //SPIT Player type - static const char PLAYERTYPE_MAIN = 0x02; - static const char PLAYERTYPE_CONTINIOUS = 0x01; - static const char PLAYERTYPE_DISCRETE = 0x00; + // Send + public: + Header(int p_SPITVersion, int p_OPFlag); + void setMessageNumber(unsigned char p_MessageNumber); + void setServerID(string p_ServerID); + void setClientID(string p_ID); + void setOPFlag(int p_OPFlag); + bool fillBytes(char *p_Bytes, int p_ByteCount); + }; - //PlayObject value usage - static const char VALUEFLAG_DIRECT = 0x00; //use the vlue direct - static const char VALUEFLAG_INCREASE = 0x01; //increase the value - static const char VALUEFLAG_DECREASE = 0x02; //decrease the value - - - SPIT_Message(); - virtual ~SPIT_Message(); -// SPIT_Message(const SPIT_Message& orig); - -//Members -private: - char* m_MessageBytes; - int m_MessageByteCount; - Header* m_Header; - OPPart* m_OPPart; - bool m_MessageBytesCreated; - - void initMembers(); - -//Receive -public: - SPIT_Message(char* p_MessageBytes, int p_MessageBytesLength); - -// SPIT_Message(const SPIT_Message& orig); - const Header* getHeader() const { - return m_Header; - } - int getOPFlag() const { - if (m_Header == NULL) return -1; - return m_Header->getOPFlag(); - } - const OPPart* getOPPart() const { - return m_OPPart; - } - int getMesageByteCount() const { - return m_MessageByteCount; - } - - OPPart* parse(); - -//Send -public: - SPIT_Message(OPPart* p_OPPart); - bool fillBytes(); - const char* getMessageBytes(); - - - - -//------------------------------ Connection ---------------------------------- - -//----------- Connect ----------- -public: - class Connect : public OPPart { - public: - static const int OPFLAG = 1; - static const int BYTESLENGTH = 304; + //----------- OPPart ----------- + public: + class OPPart { - private: - string m_ClientComputerName; - string m_ClientName; - string m_LoginName; - string m_LoginPassword; - string m_ServerIP; - int m_ServerPort; - void initMembers(); - public: - ~Connect(); -// Connect(const Connect& orig); - //Receive - public: - Connect(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - const string getClientComputerName() const { - return m_ClientComputerName; - } - const string getClientName() const { - return m_ClientName; - } - const string getLoginName() const { - return m_LoginName; - } - const string getLoginPassword() const { - return m_LoginPassword; - } - const string getServerIP() const { - return m_ServerIP; - } - int getServerPort() const { - return m_ServerPort; - } - - //Send - public: - Connect(); - void setClientComputerName(string p_ComputerName); - void setClientName(string p_ClientName); - void setLoginName(string p_LoginName); - void setLoginPassword(string p_LoginPassword); - void setServerIP(string p_ServerIP); - void setServerPort(int p_ServerPort); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - -//----------- ConnectAnswer ----------- + // Members + protected: + Header *m_Header; + int m_ParseOffset; + int m_BytesCount; - class ConnectAnswer : public OPPart { - public: - static const int OPFLAG = 2; - static const int BYTESLENGTH = 137; - private: - string m_ServerComputerName; - string m_ServerName; - bool m_Connected; - int m_StepTime; //ms step size the Server will send play sequences - - void initMembers(); - public: - ~ConnectAnswer(); - ConnectAnswer(const ConnectAnswer& orig); - //Receive - ConnectAnswer(Header* p_Header); - - bool parse(char* p_Bytes, int p_ByteCount); - - const string getServerComputerName() const { - return m_ServerComputerName; - } - const string getServerName() const { - return m_ServerName; - } - bool getConnected() const { - return m_Connected; - } - int getStepTime() const { - return m_StepTime; - } - - //Send - public: - ConnectAnswer(); - void setServerComputerName(string p_ServerComputerName); - void setServerName(string p_ContollerName); - void setConnected(bool p_Connected); - void setStepTime(int p_StepTime_ms); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; + private: + void initMembers(); -//----------- Disconnect ----------- + public: + virtual ~OPPart(); + // OPPart(const OPPart& orig); + Header *getHeader() const { return m_Header; } + int getBytesCount() const { return m_BytesCount; } - class Disconnect : public OPPart { - public: - static const int OPFLAG = 3; - static const int BYTESLENGTH = 4; - - private: - void initMembers(); - public: - ~Disconnect(); - Disconnect(const Disconnect& orig); - //Receive - Disconnect(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - // Send - public: - Disconnect(); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; + const string getServerID() const { + if (m_Header == NULL) + return ""; + return m_Header->getServerID(); + } + const string getClientID() const { + if (m_Header == NULL) + return ""; + return m_Header->getClientID(); + } -//----------- Watchdog ----------- - - class Watchdog : public OPPart { - public: - static const int OPFLAG = 8; - static const int BYTESLENGTH = 4; - private: - void initMembers(); - public: - ~Watchdog(); - Watchdog(const Watchdog& orig); - //Receive - Watchdog(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - // Send - public: - Watchdog(); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; + int getOPFlag() const { + if (m_Header == NULL) + return -1; + return m_Header->getOPFlag(); + } -//----------- WatchdogAnswer ----------- - - class WatchdogAnswer : public OPPart { - public: - static const int OPFLAG = 9; - static const int BYTESLENGTH = 4; - private: - void initMembers(); - //Receive - public: - ~WatchdogAnswer(); - WatchdogAnswer(const WatchdogAnswer& orig); - WatchdogAnswer(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - // Send - public: - WatchdogAnswer(); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - - -//------------------------------ SPITProject ---------------------------------- + // Receive + public: + OPPart(Header *p_Header, int p_OPFlag); + void setHeader(Header *p_Header); + virtual bool parse(char *p_Bytes, int p_ByteCounth) = 0; -//----------- ReportSPITProject ----------- - - class ReportSPITProject : public OPPart { - public: - static const int OPFLAG = 11; - static const int BYTESLENGTH = 113; - private: - string m_ProjectID; - string m_ProjectName; - int m_FramesPerSecond; //Frames per second - - void initMembers(); - //Receive - public: - ~ReportSPITProject(); - ReportSPITProject(const ReportSPITProject& orig); - ReportSPITProject(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - const string getProjectID() const { - return m_ProjectID; - } - const string getProjectName() const { - return m_ProjectName; - } - int getFramesPerSecond() const { - return m_FramesPerSecond; - } - // Send - ReportSPITProject(); - - void setProjectID(string p_ClientID); - void setProjectName(string p_ClientName); - void setFramesPerSecond(const int p_FramesPerSecond); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; + // Send + public: + OPPart(); + virtual bool fillBytes(char *p_Bytes, int p_ByteCount) = 0; + }; -//----------- CloseSPITProject ----------- - - class CloseSPITProject : public OPPart { - public: - static const int OPFLAG = 13; - static const int BYTESLENGTH = 45; - private: - string m_ProjectID; - - void initMembers(); - public: - ~CloseSPITProject(); - CloseSPITProject(const CloseSPITProject& orig); - //Receive - CloseSPITProject(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - const string getProjectID() const { - return m_ProjectID; - } - // Send - public: - CloseSPITProject(); - - void setProjectID(string p_ClientID); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - -//----------- StartProjectTransfer ----------- - class RequestProjectTransfer : public OPPart { - public: - static const int OPFLAG = 15; - static const int BYTESLENGTH = 4; - private: - void initMembers(); - public: - ~RequestProjectTransfer(); - RequestProjectTransfer(const RequestProjectTransfer& orig); - //Receive - RequestProjectTransfer(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - // Send - public: - RequestProjectTransfer(); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - -//----------- StartProjectTransfer ----------- - - class StartProjectTransfer : public OPPart { - public: - static const int OPFLAG = 16; - static const int BYTESLENGTH = 4; - - private: - void initMembers(); - public: - ~StartProjectTransfer(); - StartProjectTransfer(const StartProjectTransfer& orig); - //Receive - StartProjectTransfer(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - // Send - public: - StartProjectTransfer(); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; + //----------- SPIT_Message ----------- -//----------- EndProjectTransfer ----------- - class EndProjectTransfer : public OPPart { - public: - static const int OPFLAG = 17; - static const int BYTESLENGTH = 4; - private: - void initMembers(); - public: - ~EndProjectTransfer(); - EndProjectTransfer(const EndProjectTransfer& orig); - //Receive - EndProjectTransfer(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - // Send - EndProjectTransfer(); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - -//---------------------------- SPIT_Types ---------------------------------- - -//----------- ReportSPITType ----------- - class ReportSPITType : public OPPart { - public: - static const int OPFLAG = 21; - static const int BYTESLENGTH = 168; - private: - bool m_Confirmed; - string m_SPITTypeID; - bool m_Fixed; - bool m_ServerRemote; - bool m_ServerProjectIndepended; - string m_SPITTypeGroupName; - string m_SPITTypeName; - long long m_Delay; - long long m_Duration; - - void initMembers(); - public: - ~ReportSPITType(); - ReportSPITType(const ReportSPITType& orig); - //Receive - ReportSPITType(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - bool getConfirmed() const { - return m_Confirmed; - } - const string getID() const { - return m_SPITTypeID; - } - bool getFixed() const { - return m_Fixed; - } - bool getServerRemote() const { - return m_ServerRemote; - } - bool getServerProjectIndepended() const { - return m_ServerProjectIndepended; - } - const string getGroupName() const { - return m_SPITTypeGroupName; - } - const string getName() const { - return m_SPITTypeName; - } - long long getDelay() const { - return m_Delay; - } - long long getDuration() const { - return m_Duration; - } - // Send - public: - ReportSPITType(); - - void setConfirmed(bool p_Confirmed); - void setID(string p_ID); - void setFixed(bool p_Fixed); - void setServerRemote(bool p_IsServerRemote); - void setServerProjectIndepended(bool p_ProjectIndpended); - void setGroupName(string p_GroupName); - void setName(string p_Name); - void setDelay(long long p_Delay); - void setDuration(long long p_Duration); - - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - -//----------- RemoveSPITType ----------- - - class RemoveSPITType : public OPPart { - public: - static const int OPFLAG = 23; - static const int BYTESLENGTH = 45; - private: - string m_SPITTypeID; - - void initMembers(); - public: - ~RemoveSPITType(); - RemoveSPITType(const RemoveSPITType& orig); - //Receive - RemoveSPITType(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - const string getID() const { - return m_SPITTypeID; - } - // Send - RemoveSPITType(); - - void setID(string p_ID); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; + public: + static const int SPITVERSION = 1; + // SPIT_Object value usage + static const char VALUEUSE_DISCARD = 0x00; // value of SPITObejct is not used + static const char VALUEUSE_INRANGE = 0x01; // value of SPITOBject in range 0 - 1000000ppm + static const char VALUEUSE_OVERRIDE = 0x02; // value can be overridden + // SPIT Player type + static const char PLAYERTYPE_MAIN = 0x02; + static const char PLAYERTYPE_CONTINIOUS = 0x01; + static const char PLAYERTYPE_DISCRETE = 0x00; -//---------------------------- SPITObjects ---------------------------------- - -//----------- ReportSPITObject ----------- - - class ReportSPITObject : public OPPart { - public: - static const int OPFLAG = 31; - static const int BYTESLENGTH = 339; - private: - bool m_Confirmed; - string m_SPITObjectID; - bool m_Fixed; - bool m_ServerRemote; - string m_SPITObjectName; - string m_SPITTypeID; - string m_ServerParams; - long long m_FrameStart; - long long m_FrameLength; - long long m_FrameFadeInLength; - long long m_FrameFadeOutLength; - int m_ValueFactor; - char m_ValueUse; - int m_Track; - string m_Remark; - long long m_Delay; - long long m_Duration; - bool m_ActionAssigned; - - void initMembers(); - public: - ~ReportSPITObject(); - ReportSPITObject(const ReportSPITObject& orig); - //Receive - ReportSPITObject(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - bool getConfirmed() const { - return m_Confirmed; - } - const string getID() const { - return m_SPITObjectID; - } - bool getFixed() const { - return m_Fixed; - } - bool getServerRemote() const { - return m_ServerRemote; - } - const string getName() const { - return m_SPITObjectName; - } - const string getSPITTypeID() const { - return m_SPITTypeID; - } - const string getServerParams() const { - return m_ServerParams; - } - long long getFrameStart() const { - return m_FrameStart; - } - long long getFrameLength() const { - return m_FrameLength; - } - long long getFrameFadeInLength() const { - return m_FrameFadeInLength; - } - long long getFrameFadeOutLength() const { - return m_FrameFadeOutLength; - } - int getValueFactor() const { - return m_ValueFactor; - } - char getValueUse() const { - return m_ValueUse; - } - int getTrack() const { - return m_Track; - } - const string getRemark() const { - return m_Remark; - } - long long getDelay() const { - return m_Delay; - } - long long getDuration() const { - return m_Duration; - } - bool getActionAssigned() const { - return m_ActionAssigned; - } - // Send - public: - ReportSPITObject(); - - void setConfirmed(bool p_Confirmed); - void setID(string p_ID); - void setFixed(bool p_Fixed); - void setServerRemote(bool p_IsRemote); - void setName(string p_Name); - void setSPITTypeID(string p_ID); - void setServerParams(string p_Parameters); - void setFrameStart(long long p_StartTime); - void setFrameLength(long long p_Length); - void setFrameFadeInLength(long long p_FadeInTime); - void setFrameFadeOutLength(long long p_FadeOutTime); - void setValueFactor(int p_Volume); - void setValueUse(char p_ValueUse); - void setTrack(int p_Track); - void setRemark(string p_Description); - void setDelay(long long p_Delay); - void setDuration(long long p_Duration); - void setActionAssigned(bool p_ActionAssigned); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; + // PlayObject value usage + static const char VALUEFLAG_DIRECT = 0x00; // use the vlue direct + static const char VALUEFLAG_INCREASE = 0x01; // increase the value + static const char VALUEFLAG_DECREASE = 0x02; // decrease the value -//----------- RemoveSPITObject ----------- - - class RemoveSPITObject : public OPPart { - public: - static const int OPFLAG = 33; - static const int BYTESLENGTH = 45; - private: - string m_SPITObjectID; - - void initMembers(); - public: - ~RemoveSPITObject(); - RemoveSPITObject(const RemoveSPITObject& orig); - //Receive - RemoveSPITObject(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - const string getID() const { - return m_SPITObjectID; - } - // Send - public: - RemoveSPITObject(); - void setID(string p_ID); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - -//---------------------------- SPITPlayer ---------------------------------- + SPIT_Message(); + virtual ~SPIT_Message(); + // SPIT_Message(const SPIT_Message& orig); -//----------- PlaySPITStart ----------- - - class PlaySPITStart : public OPPart { - public: - static const int OPFLAG = 37; - static const int BYTESLENGTH = 119; - private: - string m_PlayerID; - string m_PlayerName; - char m_PlayerType; - bool m_PlayerIsRunning; - long long m_Time; //Frames - - void initMembers(); - public: - ~PlaySPITStart(); - PlaySPITStart(const PlaySPITStart& orig); - //Receive - PlaySPITStart(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - const string getPlayerID() const { - return m_PlayerID; - } - const string getPlayerName() const { - return m_PlayerName; - } - char getPlayerType() const { - return m_PlayerType; - } - bool getPlayerIsRunning() const { - return m_PlayerIsRunning; - } - long long getTime() const { - return m_Time; - } - - // Send - public: - PlaySPITStart(); - - void setPlayerID(string p_PlayerID); - void setPlayerName(string p_PlayerName); - void setPlayerType(char p_PlayerType); - void setPlayerIsRunning(bool p_IsPlaying); - void setTime(long long p_Time); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - -//----------- PlaySPITObject ----------- - - class PlaySPITObject : public OPPart { - public: - static const int OPFLAG = 38; - static const int BYTESLENGTH = 100; - private: - string m_PlayerID; - string m_SPITObjectID; - long long m_FrameInsideObject; //Frames - bool m_PlayPrePosition; - int m_Value; - char m_ValueFlag; - - void initMembers(); - public: - ~PlaySPITObject(); - PlaySPITObject(const PlaySPITObject& orig); - //Receive - PlaySPITObject(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - const string getPlayerID() const { - return m_PlayerID; - } - const string getSPITObjectID() const { - return m_SPITObjectID; - } - long long getFrameInsideObject() const { - return m_FrameInsideObject; - } - bool getPlayPrePosition() const { - return m_PlayPrePosition; - } - int getValue() const { - return m_Value; - } - char getValueFlag() const { - return m_ValueFlag; - } - // Send - PlaySPITObject(); - - void setPlayerID(string p_PlayerID); - void setID(string p_ID); - void setFrameInsideObject(long long p_TimeInside); - void setPlayPrePosition(bool p_PlayOldPosition); - void setValue(int p_Value); - void setValueFlag(char p_ValueFlag); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - -//----------- PlaySPITEnd ----------- - class PlaySPITEnd : public OPPart { - public: - static const int OPFLAG = 39; - static const int BYTESLENGTH = 45; - private: - string m_PlayerID; - - void initMembers(); - public: - ~PlaySPITEnd(); - PlaySPITEnd(const PlaySPITEnd& orig); - //Receive - PlaySPITEnd(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - const string getPlayerID() const { - return m_PlayerID; - } - // Send - public: - PlaySPITEnd(); - void setPlayerID(string p_PlayerID); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - - -//----------- ReportPlayStatus ----------- - - class ReportPlayStatus : public OPPart { - public: - static const int OPFLAG = 40; - static const int BYTESLENGTH = 57; - private: - string m_SPITObjectID; - long long m_FrameInsideObject; //Frames - int m_Value; - - void initMembers(); - public: - ~ReportPlayStatus(); - ReportPlayStatus(const ReportPlayStatus& orig); - //Receive - ReportPlayStatus(Header* p_Header); - bool parse(char* p_Bytes, int p_ByteCount); - - const string getID() const { - return m_SPITObjectID; - } - long long getFrameInsideObject() const { - return m_FrameInsideObject; - } - int getValue() const { - return m_Value; - } - // Send - ReportPlayStatus(); - - void setID(string p_ID); - void setFrameInsideObject(long long p_TimeInside); - void setValue(int p_Value); - bool fillBytes(char* p_MessageBytes, int p_ByteCount); - }; - - - - -//----------------------- static helper functions ---------------------------- -public: - static bool isSystemLittleEndian(); - static int getInt(char* p_Bytes, int p_ByteCount, int p_Offset); - static int setInt(int p_Value, char* p_Bytes, int p_ByteCount, int p_Offset); - static long long getLong(char* p_Bytes, int p_ByteCount, int p_Offset); - static int setLong(long long p_Value, char* p_Bytes, int p_ByteCount, int p_Offset); - static bool getBoolean(char* p_Bytes, int p_ByteCount, int p_Offset); - static int setBoolean(bool p_Value, char* p_Bytes, int p_ByteCount, int p_Offset); - static char getByte(char* p_Bytes, int p_ByteCount, int p_Offset); - static int setByte(int p_Value, char* p_Bytes, int p_ByteCount, int p_Offset); - /** - * Returns the string char* of the part of the byte sequence (0x00 null terminated). - * @param p_Bytes the byte array - * @param p_Offset the startposition of strings bytes - * @param p_Length the length of the string included the null terminate byte (0x00).
- * The length of the string will be p_Length -1. - * @return the String char* - * @throws Exception if p_Bytes == null
- * p_Offset less than 0
- * p_Bytes.length less than p_Offset + p_Length
- * No 0x00 null terminate byte is found - */ - static string getString(char* p_Bytes, int p_ByteCount, int p_Offset, int p_Length); - - /** - * Fill the p_String in the byte array.
- * If p_String length is greater than p_Length -1, the p_String will be truncated. - * CAUTION the return value should be freed after use. - * @param p_String the string - * @param p_Bytes the byte array where the string is filled - * @param p_Offset the offset inside the byte array - * @param p_Length the maximal length of the string included the null character.
- * @throws Exception if p_String == NULL, p_Bytes == NULL
- * p_Offset less than 0
- * p_ByteCount less than p_Offset + p_Length - * @return p_Length - */ - static int setString(string p_String, char* p_Bytes, int p_ByteCount, int p_Offset, int p_Length); - /** - * Compares two strings for equality. - * @param p_String1 string terminated by null character - * @param p_String2 string terminated by null character - * @return true if both strings are equal
- * false if the strings are NULL or not equal or not terminated by "\0" - */ -// static bool stringEqual(const char* p_String1, const char* p_String2); -// static char* stringCopy(const char* p_String); - static char* createByteArray(const OPPart* p_OPPart, int* p_BytesCount); + // Members + private: + char *m_MessageBytes; + int m_MessageByteCount; + Header *m_Header; + OPPart *m_OPPart; + bool m_MessageBytesCreated; + + void initMembers(); + + // Receive + public: + SPIT_Message(char *p_MessageBytes, int p_MessageBytesLength); + + // SPIT_Message(const SPIT_Message& orig); + const Header *getHeader() const { return m_Header; } + int getOPFlag() const { + if (m_Header == NULL) + return -1; + return m_Header->getOPFlag(); + } + const OPPart *getOPPart() const { return m_OPPart; } + int getMesageByteCount() const { return m_MessageByteCount; } + + OPPart *parse(); + + // Send + public: + SPIT_Message(OPPart *p_OPPart); + bool fillBytes(); + const char *getMessageBytes(); + + //------------------------------ Connection ---------------------------------- + + //----------- Connect ----------- + public: + class Connect : public OPPart { + public: + static const int OPFLAG = 1; + static const int BYTESLENGTH = 304; + + private: + string m_ClientComputerName; + string m_ClientName; + string m_LoginName; + string m_LoginPassword; + string m_ServerIP; + int m_ServerPort; + void initMembers(); + + public: + ~Connect(); + // Connect(const Connect& orig); + // Receive + public: + Connect(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + const string getClientComputerName() const { return m_ClientComputerName; } + const string getClientName() const { return m_ClientName; } + const string getLoginName() const { return m_LoginName; } + const string getLoginPassword() const { return m_LoginPassword; } + const string getServerIP() const { return m_ServerIP; } + int getServerPort() const { return m_ServerPort; } + + // Send + public: + Connect(); + void setClientComputerName(string p_ComputerName); + void setClientName(string p_ClientName); + void setLoginName(string p_LoginName); + void setLoginPassword(string p_LoginPassword); + void setServerIP(string p_ServerIP); + void setServerPort(int p_ServerPort); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- ConnectAnswer ----------- + + class ConnectAnswer : public OPPart { + public: + static const int OPFLAG = 2; + static const int BYTESLENGTH = 137; + + private: + string m_ServerComputerName; + string m_ServerName; + bool m_Connected; + int m_StepTime; // ms step size the Server will send play sequences + + void initMembers(); + + public: + ~ConnectAnswer(); + ConnectAnswer(const ConnectAnswer &orig); + // Receive + ConnectAnswer(Header *p_Header); + + bool parse(char *p_Bytes, int p_ByteCount); + + const string getServerComputerName() const { return m_ServerComputerName; } + const string getServerName() const { return m_ServerName; } + bool getConnected() const { return m_Connected; } + int getStepTime() const { return m_StepTime; } + + // Send + public: + ConnectAnswer(); + void setServerComputerName(string p_ServerComputerName); + void setServerName(string p_ContollerName); + void setConnected(bool p_Connected); + void setStepTime(int p_StepTime_ms); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- Disconnect ----------- + + class Disconnect : public OPPart { + public: + static const int OPFLAG = 3; + static const int BYTESLENGTH = 4; + + private: + void initMembers(); + + public: + ~Disconnect(); + Disconnect(const Disconnect &orig); + // Receive + Disconnect(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + // Send + public: + Disconnect(); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- Watchdog ----------- + + class Watchdog : public OPPart { + public: + static const int OPFLAG = 8; + static const int BYTESLENGTH = 4; + + private: + void initMembers(); + + public: + ~Watchdog(); + Watchdog(const Watchdog &orig); + // Receive + Watchdog(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + // Send + public: + Watchdog(); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- WatchdogAnswer ----------- + + class WatchdogAnswer : public OPPart { + public: + static const int OPFLAG = 9; + static const int BYTESLENGTH = 4; + + private: + void initMembers(); + // Receive + public: + ~WatchdogAnswer(); + WatchdogAnswer(const WatchdogAnswer &orig); + WatchdogAnswer(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + // Send + public: + WatchdogAnswer(); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //------------------------------ SPITProject ---------------------------------- + + //----------- ReportSPITProject ----------- + + class ReportSPITProject : public OPPart { + public: + static const int OPFLAG = 11; + static const int BYTESLENGTH = 113; + + private: + string m_ProjectID; + string m_ProjectName; + int m_FramesPerSecond; // Frames per second + + void initMembers(); + // Receive + public: + ~ReportSPITProject(); + ReportSPITProject(const ReportSPITProject &orig); + ReportSPITProject(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + const string getProjectID() const { + return m_ProjectID; + } + const string getProjectName() const { + return m_ProjectName; + } + int getFramesPerSecond() const { + return m_FramesPerSecond; + } + // Send + ReportSPITProject(); + + void setProjectID(string p_ClientID); + void setProjectName(string p_ClientName); + void setFramesPerSecond(const int p_FramesPerSecond); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- CloseSPITProject ----------- + + class CloseSPITProject : public OPPart { + public: + static const int OPFLAG = 13; + static const int BYTESLENGTH = 45; + + private: + string m_ProjectID; + + void initMembers(); + + public: + ~CloseSPITProject(); + CloseSPITProject(const CloseSPITProject &orig); + // Receive + CloseSPITProject(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + const string getProjectID() const { + return m_ProjectID; + } + // Send + public: + CloseSPITProject(); + + void setProjectID(string p_ClientID); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- StartProjectTransfer ----------- + class RequestProjectTransfer : public OPPart { + public: + static const int OPFLAG = 15; + static const int BYTESLENGTH = 4; + + private: + void initMembers(); + + public: + ~RequestProjectTransfer(); + RequestProjectTransfer(const RequestProjectTransfer &orig); + // Receive + RequestProjectTransfer(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + // Send + public: + RequestProjectTransfer(); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- StartProjectTransfer ----------- + + class StartProjectTransfer : public OPPart { + public: + static const int OPFLAG = 16; + static const int BYTESLENGTH = 4; + + private: + void initMembers(); + + public: + ~StartProjectTransfer(); + StartProjectTransfer(const StartProjectTransfer &orig); + // Receive + StartProjectTransfer(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + // Send + public: + StartProjectTransfer(); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- EndProjectTransfer ----------- + class EndProjectTransfer : public OPPart { + public: + static const int OPFLAG = 17; + static const int BYTESLENGTH = 4; + + private: + void initMembers(); + + public: + ~EndProjectTransfer(); + EndProjectTransfer(const EndProjectTransfer &orig); + // Receive + EndProjectTransfer(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + // Send + EndProjectTransfer(); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //---------------------------- SPIT_Types ---------------------------------- + + //----------- ReportSPITType ----------- + class ReportSPITType : public OPPart { + public: + static const int OPFLAG = 21; + static const int BYTESLENGTH = 168; + + private: + bool m_Confirmed; + string m_SPITTypeID; + bool m_Fixed; + bool m_ServerRemote; + bool m_ServerProjectIndepended; + string m_SPITTypeGroupName; + string m_SPITTypeName; + long long m_Delay; + long long m_Duration; + + void initMembers(); + + public: + ~ReportSPITType(); + ReportSPITType(const ReportSPITType &orig); + // Receive + ReportSPITType(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + bool getConfirmed() const { + return m_Confirmed; + } + const string getID() const { + return m_SPITTypeID; + } + bool getFixed() const { + return m_Fixed; + } + bool getServerRemote() const { + return m_ServerRemote; + } + bool getServerProjectIndepended() const { + return m_ServerProjectIndepended; + } + const string getGroupName() const { + return m_SPITTypeGroupName; + } + const string getName() const { + return m_SPITTypeName; + } + long long getDelay() const { + return m_Delay; + } + long long getDuration() const { + return m_Duration; + } + // Send + public: + ReportSPITType(); + + void setConfirmed(bool p_Confirmed); + void setID(string p_ID); + void setFixed(bool p_Fixed); + void setServerRemote(bool p_IsServerRemote); + void setServerProjectIndepended(bool p_ProjectIndpended); + void setGroupName(string p_GroupName); + void setName(string p_Name); + void setDelay(long long p_Delay); + void setDuration(long long p_Duration); + + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- RemoveSPITType ----------- + + class RemoveSPITType : public OPPart { + public: + static const int OPFLAG = 23; + static const int BYTESLENGTH = 45; + + private: + string m_SPITTypeID; + + void initMembers(); + + public: + ~RemoveSPITType(); + RemoveSPITType(const RemoveSPITType &orig); + // Receive + RemoveSPITType(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + const string getID() const { + return m_SPITTypeID; + } + // Send + RemoveSPITType(); + + void setID(string p_ID); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //---------------------------- SPITObjects ---------------------------------- + + //----------- ReportSPITObject ----------- + + class ReportSPITObject : public OPPart { + public: + static const int OPFLAG = 31; + static const int BYTESLENGTH = 339; + + private: + bool m_Confirmed; + string m_SPITObjectID; + bool m_Fixed; + bool m_ServerRemote; + string m_SPITObjectName; + string m_SPITTypeID; + string m_ServerParams; + long long m_FrameStart; + long long m_FrameLength; + long long m_FrameFadeInLength; + long long m_FrameFadeOutLength; + int m_ValueFactor; + char m_ValueUse; + int m_Track; + string m_Remark; + long long m_Delay; + long long m_Duration; + bool m_ActionAssigned; + + void initMembers(); + + public: + ~ReportSPITObject(); + ReportSPITObject(const ReportSPITObject &orig); + // Receive + ReportSPITObject(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + bool getConfirmed() const { return m_Confirmed; } + const string getID() const { return m_SPITObjectID; } + bool getFixed() const { return m_Fixed; } + bool getServerRemote() const { return m_ServerRemote; } + const string getName() const { return m_SPITObjectName; } + const string getSPITTypeID() const { return m_SPITTypeID; } + const string getServerParams() const { return m_ServerParams; } + long long getFrameStart() const { return m_FrameStart; } + long long getFrameLength() const { return m_FrameLength; } + long long getFrameFadeInLength() const { return m_FrameFadeInLength; } + long long getFrameFadeOutLength() const { return m_FrameFadeOutLength; } + int getValueFactor() const { return m_ValueFactor; } + char getValueUse() const { return m_ValueUse; } + int getTrack() const { return m_Track; } + const string getRemark() const { return m_Remark; } + long long getDelay() const { return m_Delay; } + long long getDuration() const { return m_Duration; } + bool getActionAssigned() const { return m_ActionAssigned; } + // Send + public: + ReportSPITObject(); + + void setConfirmed(bool p_Confirmed); + void setID(string p_ID); + void setFixed(bool p_Fixed); + void setServerRemote(bool p_IsRemote); + void setName(string p_Name); + void setSPITTypeID(string p_ID); + void setServerParams(string p_Parameters); + void setFrameStart(long long p_StartTime); + void setFrameLength(long long p_Length); + void setFrameFadeInLength(long long p_FadeInTime); + void setFrameFadeOutLength(long long p_FadeOutTime); + void setValueFactor(int p_Volume); + void setValueUse(char p_ValueUse); + void setTrack(int p_Track); + void setRemark(string p_Description); + void setDelay(long long p_Delay); + void setDuration(long long p_Duration); + void setActionAssigned(bool p_ActionAssigned); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- RemoveSPITObject ----------- + + class RemoveSPITObject : public OPPart { + public: + static const int OPFLAG = 33; + static const int BYTESLENGTH = 45; + + private: + string m_SPITObjectID; + + void initMembers(); + + public: + ~RemoveSPITObject(); + RemoveSPITObject(const RemoveSPITObject &orig); + // Receive + RemoveSPITObject(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + const string getID() const { + return m_SPITObjectID; + } + // Send + public: + RemoveSPITObject(); + void setID(string p_ID); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //---------------------------- SPITPlayer ---------------------------------- + + //----------- PlaySPITStart ----------- + + class PlaySPITStart : public OPPart { + public: + static const int OPFLAG = 37; + static const int BYTESLENGTH = 119; + + private: + string m_PlayerID; + string m_PlayerName; + char m_PlayerType; + bool m_PlayerIsRunning; + long long m_Time; // Frames + + void initMembers(); + + public: + ~PlaySPITStart(); + PlaySPITStart(const PlaySPITStart &orig); + // Receive + PlaySPITStart(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + const string getPlayerID() const { return m_PlayerID; } + const string getPlayerName() const { return m_PlayerName; } + char getPlayerType() const { return m_PlayerType; } + bool getPlayerIsRunning() const { return m_PlayerIsRunning; } + long long getTime() const { return m_Time; } + + // Send + public: + PlaySPITStart(); + + void setPlayerID(string p_PlayerID); + void setPlayerName(string p_PlayerName); + void setPlayerType(char p_PlayerType); + void setPlayerIsRunning(bool p_IsPlaying); + void setTime(long long p_Time); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- PlaySPITObject ----------- + + class PlaySPITObject : public OPPart { + public: + static const int OPFLAG = 38; + static const int BYTESLENGTH = 100; + + private: + string m_PlayerID; + string m_SPITObjectID; + long long m_FrameInsideObject; // Frames + bool m_PlayPrePosition; + int m_Value; + char m_ValueFlag; + + void initMembers(); + + public: + ~PlaySPITObject(); + PlaySPITObject(const PlaySPITObject &orig); + // Receive + PlaySPITObject(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + const string getPlayerID() const { return m_PlayerID; } + const string getSPITObjectID() const { return m_SPITObjectID; } + long long getFrameInsideObject() const { return m_FrameInsideObject; } + bool getPlayPrePosition() const { return m_PlayPrePosition; } + int getValue() const { return m_Value; } + char getValueFlag() const { return m_ValueFlag; } + // Send + PlaySPITObject(); + + void setPlayerID(string p_PlayerID); + void setID(string p_ID); + void setFrameInsideObject(long long p_TimeInside); + void setPlayPrePosition(bool p_PlayOldPosition); + void setValue(int p_Value); + void setValueFlag(char p_ValueFlag); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- PlaySPITEnd ----------- + class PlaySPITEnd : public OPPart { + public: + static const int OPFLAG = 39; + static const int BYTESLENGTH = 45; + + private: + string m_PlayerID; + + void initMembers(); + + public: + ~PlaySPITEnd(); + PlaySPITEnd(const PlaySPITEnd &orig); + // Receive + PlaySPITEnd(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + const string getPlayerID() const { return m_PlayerID; } + // Send + public: + PlaySPITEnd(); + void setPlayerID(string p_PlayerID); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------- ReportPlayStatus ----------- + + class ReportPlayStatus : public OPPart { + public: + static const int OPFLAG = 40; + static const int BYTESLENGTH = 57; + + private: + string m_SPITObjectID; + long long m_FrameInsideObject; // Frames + int m_Value; + + void initMembers(); + + public: + ~ReportPlayStatus(); + ReportPlayStatus(const ReportPlayStatus &orig); + // Receive + ReportPlayStatus(Header *p_Header); + bool parse(char *p_Bytes, int p_ByteCount); + + const string getID() const { return m_SPITObjectID; } + long long getFrameInsideObject() const { return m_FrameInsideObject; } + int getValue() const { return m_Value; } + // Send + ReportPlayStatus(); + + void setID(string p_ID); + void setFrameInsideObject(long long p_TimeInside); + void setValue(int p_Value); + bool fillBytes(char *p_MessageBytes, int p_ByteCount); + }; + + //----------------------- static helper functions ---------------------------- + public: + static bool isSystemLittleEndian(); + static int getInt(char *p_Bytes, int p_ByteCount, int p_Offset); + static int setInt(int p_Value, char *p_Bytes, int p_ByteCount, int p_Offset); + static long long getLong(char *p_Bytes, int p_ByteCount, int p_Offset); + static int setLong(long long p_Value, char *p_Bytes, int p_ByteCount, int p_Offset); + static bool getBoolean(char *p_Bytes, int p_ByteCount, int p_Offset); + static int setBoolean(bool p_Value, char *p_Bytes, int p_ByteCount, int p_Offset); + static char getByte(char *p_Bytes, int p_ByteCount, int p_Offset); + static int setByte(int p_Value, char *p_Bytes, int p_ByteCount, int p_Offset); + /** + * Returns the string char* of the part of the byte sequence (0x00 null terminated). + * @param p_Bytes the byte array + * @param p_Offset the startposition of strings bytes + * @param p_Length the length of the string included the null terminate byte (0x00).
+ * The length of the string will be p_Length -1. + * @return the String char* + * @throws Exception if p_Bytes == null
+ * p_Offset less than 0
+ * p_Bytes.length less than p_Offset + p_Length
+ * No 0x00 null terminate byte is found + */ + static string getString(char *p_Bytes, int p_ByteCount, int p_Offset, int p_Length); + + /** + * Fill the p_String in the byte array.
+ * If p_String length is greater than p_Length -1, the p_String will be truncated. + * CAUTION the return value should be freed after use. + * @param p_String the string + * @param p_Bytes the byte array where the string is filled + * @param p_Offset the offset inside the byte array + * @param p_Length the maximal length of the string included the null character.
+ * @throws Exception if p_String == NULL, p_Bytes == NULL
+ * p_Offset less than 0
+ * p_ByteCount less than p_Offset + p_Length + * @return p_Length + */ + static int setString(string p_String, char *p_Bytes, int p_ByteCount, int p_Offset, int p_Length); + /** + * Compares two strings for equality. + * @param p_String1 string terminated by null character + * @param p_String2 string terminated by null character + * @return true if both strings are equal
+ * false if the strings are NULL or not equal or not terminated by "\0" + */ + // static bool stringEqual(const char* p_String1, const char* p_String2); + // static char* stringCopy(const char* p_String); + static char *createByteArray(const OPPart *p_OPPart, int *p_BytesCount); }; #endif /* SPIT_MESSAGE_H */ - - - \ No newline at end of file diff --git a/components/spit/src/MyApp.cpp b/components/spit/src/MyApp.cpp deleted file mode 100644 index 6f25d82..0000000 --- a/components/spit/src/MyApp.cpp +++ /dev/null @@ -1,452 +0,0 @@ - -#include "MyApp.h" -#include "Task.hpp" -#include "esp_log.h" -#include "Semaphore.hpp" -#include "Queue.hpp" -#include - -const char *TAG = "SPIT"; - -MyApp::MyApp() : - _SpitClient ( - s_ClientName, s_ProjectName, - { - .onServerEvent = onServerEvent, - .onConnectionStatus = onConnectionStatus, - .onStartProjectTransfer = onStartProjectTransfer, - .onEndProjectTransfer = onEndProjectTransfer, - .onProjectClosed = onProjectClosed, - .onProjectReport = onProjectReport, - .onSpitType = onSpitType, - .onSpitTypeRemote = onSpitTypeRemote, - .onSpitObject = onSpitObject, - .onSpitObjectRemote = onSpitObjectRemote, - .onSpitTypeRemoved = onSpitTypeRemoved, - .onSpitTypeRemoteRemoved = onSpitTypeRemoteRemoved, - .onSpitObjectRemoved = onSpitObjectRemoved, - .onSpitObjectRemoteRemoved = onSpitObjectRemoteRemoved, - .onPlay = onPlay, - .onPlaySpitType = onPlaySpitType, - .onPlayRemoteObjectStatus = onPlayRemoteObjectStatus, - .onCheckSpitTypeVeto = onCheckSpitTypeVeto, - .onCheckSpitObjectVeto = onCheckSpitObjectVeto, - }) { - } - -string MyApp::m_ServerProjectID{}; -string MyApp::m_ServerProjectName{}; -int MyApp::m_ServerFramesPerSecond{44100}; // set when the server reports his project, see eventProjectReport - -void MyApp::init() { - SPITType *ptrSPITType1Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action1ID", "ActionGroupName", "Action1Name", 0, 0); - SPITType *ptrSPITType2Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action2ID", "ActionGroupName", "Action2Name", 0, 0); - - // When an action exist which should be done whenever a SPITObject with this SPITType is played, - // then you should 'setAssignedActionType' to true - _SpitClient.setActionSPITType(ptrSPITType1Fix->getID(), true); - _SpitClient.setActionSPITType(ptrSPITType2Fix->getID(), true); - _SpitClient.clientProjectLoaded(); - _SpitClient.startServerAutoDetect(); -} - -void MyApp::onServerEvent(SPIT_Client::ServerEvent event, const SAD_DetectedServer &p_DetectedServer) { - switch (event) - { - case SPIT_Client::ServerEvent::Detect: - ESP_LOGI(TAG, "SERVER DETECTED"); - ESP_LOGI(TAG, " Name: %s", p_DetectedServer.getName().data()); - ESP_LOGI(TAG, " ID: %s", p_DetectedServer.getID().data()); - ESP_LOGI(TAG, " Computer: %s", p_DetectedServer.getComputerName().data()); - ESP_LOGI(TAG, " IP: %s", p_DetectedServer.getIP().data()); - ESP_LOGI(TAG, " Port: %s", p_DetectedServer.getPort().data()); - ESP_LOGI(TAG, " Addition: %s", p_DetectedServer.getAdditions().data()); - ESP_LOGI(TAG, " ClientIP: %s", p_DetectedServer.getClientIP().data()); - break; - case SPIT_Client::ServerEvent::Lost: - ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data()); - - break; - case SPIT_Client::ServerEvent::Changed: - ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data()); - break; - - default: - break; - } -} - -//--------------------------------------- -//---------- Connecting event ---------- - -void MyApp::onConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus) { - ESP_LOGI(TAG, "MySPITApp: eventConnectionStatus %d ", p_ConnectionStatus); -} - -//----------------------------------------------------------- -//---------- Server's Project events ------------------------ -/** - * The Server reports his loaded project - * Called when - * a) the connection to the server is established. - * b) server load a new project - * c) server saves the project under a new name - * @param p_ProjectID the server project's id (maybe the filename of the project or a part o it or the same as p_ProjectName) - * @param p_ProjectName the server project's name - * @param p_FramesPerSeoond All times in SPIT are given in frames. FramesPerSecond can be used to convert frames to seconds.... - */ -void MyApp::onProjectReport(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond) { - ESP_LOGI(TAG, "eventProjectReport ID: %s Name: %s FramesPerSecond: %d", p_ProjectID.data(), p_ProjectName.data(), p_FramesPerSeoond); - m_ServerProjectID = p_ProjectID; - m_ServerProjectName = p_ProjectName; - m_ServerFramesPerSecond = p_FramesPerSeoond; - // set the frames per second as the server - perhaps the client's time values have to be recalculated. -} - -/** - * Called when the server closes his project. - * @param p_ProjectID the id of the project - * The server loads only one project at time-> the ID is not actually necessary - */ -void MyApp::onProjectClosed(string p_ProjectID) { - ESP_LOGI(TAG, "eventProjectClosed ID: %s", p_ProjectID.data()); - // If we don't save SPITServer's project specific information - // perhaps close all SPITObjects and RemoteSPITObjects to avoid conflicts, when the SPITServer loads a new project - // SPITObject::clearSPITObjects(); - // SPITObject::clearSPITObjectsRemote(); -} - -// The server starts the transfer of its project, that means -// All SPITTypes and SPITObjects available on the server are transferred in the following. -void MyApp::onStartProjectTransfer() { - ESP_LOGI(TAG, "eventStartProjectTransfer"); -} -// The transfer of the server's SPITTypes and SPITObjects is finished. -void MyApp::onEndProjectTransfer() { - ESP_LOGI(TAG, "eventEndProjectTransfer"); -} - -//---------------------------------------------------- -//--------- SPITType events ---------- - - -/** - * The SPITCLientInterface (implemented by this) will be asked to veto the SPITType while SPIT_Client.parseReportSPITType.
- * @param p_ReportSPITType - * @return false = the SPITType is denied, true = the SPITType is accepted - */ -bool MyApp::onCheckSpitTypeVeto(SPIT_Message::ReportSPITType* p_ReportSPITType) { - if (p_ReportSPITType == NULL) return true; - SPITType* ptrSPITType; - ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID()); - - //Don't allow foreign SPITTypes - if (ptrSPITType == NULL) return false; - if (ptrSPITType->getCreatedByClient() == false) return false; - return true; -} - -bool MyApp::onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject* p_ReportSPITObject) { - if (p_ReportSPITObject == NULL) return true; - SPITType* ptrSPITType; - ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID()); - if (ptrSPITType == NULL) return false; - - //Don't allow SPITObjects which refers to a SPITType which is not created by this client - other SPITTypes cannot be handled here - //if (ptrSPITType->getCreatedByClient() == false) return false; - - // SPITObject* ptrSPITObject; -// ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITOnject->getID()); - //Don't allow foreign SPITTypes -// if (ptrSPITObject == NULL) return false; - - return true; - -} - -/** - * Called when the server has created, loaded or changed a SPITType. - * May also occur when the server confirms a SPITType created or changed by the client. - * @param p_New true = server created a new SPITType - * false = server changed a existing SPITType - * @param p_SPITType a reference to a copy of the SPITType instance. - */ -void MyApp::onSpitType(bool p_New, const SPITType &p_SPITType) { - // fetch information of the SPITType - if (p_New) { - ESP_LOGD(TAG, "eventSPITType NEW"); - } else { - ESP_LOGD(TAG, "eventSPITType CHANGED"); - } - ESP_LOGI(TAG, " ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed()); - - // Check your actions - // Whenever you provide an action for this SPITType take this over in your code. - // call _SpitClient.setActionSPITType(p_SPITType.getID(), true); - - // for our little excample as described in loadClientProject we do following - // This may be redundand, because we defined the SPITTypes as fixed, so the server can't change them - // But foe all SPITTypes which are not fixed we need to setActionSPITType - - // if ("MySPITAPP_Action1ID" == p_SPITType.getID()) { - // _SpitClient.setActionSPITType(p_SPITType.getID(), true); - // } - // if ("MySPITAPP_Action2ID" == p_SPITType.getID()) { - // _SpitClient.setActionSPITType(p_SPITType.getID(), true); - // } -} -/** - * Called when the server has created or changed a Remote SPITType. - * Remote SPITType are used in Remote SPITObjects. A Remote SPITObject is used to remote control the SPITServer. - * @param p_New true = server created a new SPITType / false = server changed a existing SPITType - */ -void MyApp::onSpitTypeRemote(bool p_New, const SPITType &p_SPITType) { - if (p_New) { - ESP_LOGD(TAG, "eventSPITTypeRemote NEW"); - } else { - // we had to inform all Remote SPITObjects using the p_SPITType - // perhaps the SPITObject uses information from the SPITType - SPITObject *ptrSPITObject; - int intSPITObjectCount; - intSPITObjectCount = SPITObject::getSPITObjectRemoteCount(); - for (int intObject = 0; intObject < intSPITObjectCount; intObject++) { - ptrSPITObject = SPITObject::getSPITObjectRemote(intObject); - if (ptrSPITObject == NULL) - continue; - if (ptrSPITObject->getSPITTypeID() == p_SPITType.getID()) { - // call ecentSPITObjectRemote - onSpitObjectRemote(false, p_SPITType, *ptrSPITObject); - } - } - ESP_LOGD(TAG, "eventSPITTypeRemote CHANGED"); - } - ESP_LOGD(TAG, "ID: %s GroupName: %s Name: %s confirmed: %d", - p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed()); - // this is a remote SPITType, if you want you can list this for later remote use. -} - -/** - * Called when the server has removed a SPITType. - * After this function has been exited the SPITType is emeoved from the SPITType-List and the pointer is deleted. - * So use the pointer immediately or use the copyconstructor to make a copy for extended use. - * You have to release the copy yourself later (delete ptr...) - */ -void MyApp::onSpitTypeRemoved(const SPITType &p_SPITType) { - ESP_LOGD(TAG, "eventSPITType Removed"); - ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data()); - - // Check your actions - // take the removal of the SPITType over in your code - - // CAUTION: Deleted SPIT types can be added later again (perhaps per UNDO on the SPITServer) - //-> don't remove your assigned action immediately - keep it to reassign it later -} -/** - * Called when the server has removed a Remote SPITType. - * Remote SPITType are used in Remote SPITObjects. A Remote SPITObject is used to remote control the SPITServer. - * After this function has been exited the SPITType is emeoved from the Remote SPITType-List and the pointer is deleted. - * So use the pointer immediately or use the copyconstructor to make a copy for extended use. - * You have to release the copy yourself later (delete ptr...) - * @param p_SPITType a reference to a copy of the SPITType instance. - */ -void MyApp::onSpitTypeRemoteRemoved(const SPITType &p_SPITType) { - ESP_LOGD(TAG, "eventSPITTypeRemote Removed"); - ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data()); - - // This is a remote SPITType - // If you have listet this prior you should remove it from the list -} - -/** - * Called when the server has created, loaded or changed a SPITObject. - * May also occur when the server confirms a SPITObject created by the client, what the client should never do!!. - * @param p_New true = server created a new SPITObject - * false = server changed a existing SPITObject - * @param p_SPITType a reference to a copy of the associated SPITType instance. - * @param p_SPITObject a reference to a copy of the SPITObject instance. - */ -void MyApp::onSpitObject(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject) { - if (p_New) { - ESP_LOGI(TAG, "eventSPITObject NEW"); - } else { - ESP_LOGD(TAG, "eventSPITObject CHANGED"); - } - ESP_LOGI(TAG, " ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data()); - - // check your actions - // Whenever you provide an action for this SPITObject take this over in your code. - // call _SpitClient.setActionSPITObject(p_SPITObject.getID(), true); - - // for our little excample as described in loadClientProject: - // We have only actions for SPITTypes - means every SPITObject with the associated "Actionx"-SPITTypes will trigger the action when it is played - //-> no need to do something here, because setActionSPITType has been set prior and the SPITObject will automatically inherits this - // SPITObjects with other SPITTypes asscciated will trigger no actions -} -/** - * Called when the server has created or changed a Remote SPITObject. - * A Remote SPITObject is used to remote control the SPITServer. - * @param p_New true = server created a new remote SPITObject - * false = server changed a existing remote SPITObject - * @param p_SPITType a reference to a copy of the associated SPITType instance. - * @param p_SPITObject a reference to a copy of the SPITObject instance. - */ -void MyApp::onSpitObjectRemote(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject) { - if (p_New) { - ESP_LOGI(TAG, "eventSPITObjectRemote NEW"); - } else { - ESP_LOGD(TAG, "eventSPITObjectRemote CHANGED"); - } - ESP_LOGI(TAG, " ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data()); - - // This is a remote SPITObject which can be used to remote control the server. - // If you want you can list this for later use -} - -/** - * Called when the server has removed a SPITObject. - * After this function has been exited the SPITObject is emeoved from the SPITObject-List and the pointer is deleted. - * So use the pointer immediately or use the copyconstructor to make a copy for extended use. - * You have to release the copy yourself later (delete ptr...) - * @param p_SPITType a reference to a copy of the associated SPITType instance. - * @param p_SPITObject a reference to a copy of the SPITObject instance. - */ -void MyApp::onSpitObjectRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject) { - ESP_LOGD(TAG, "eventSPITObject Removed"); - ESP_LOGD(TAG, " ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data()); - - // Check your actions - // take the removal of the SPITObject over in your code - - // CAUTION: Deleted SPITObjects can be added later again (perhaps per UNDO on the SPITServer) - //-> don't remove your assigned action immediately - keep it to reassign it later -} -/** - * Called when the server has removed a Remote SPITObject. - * A Remote SPITObject is used to remote control the SPITServer. - * After this function has been exited the SPITObject is emeoved from the SPITObject-List and the pointer is deleted. - * So use the pointer immediately or use the copyconstructor to make a copy for extended use. - * You have to release the copy yourself later (delete ptr...) - * @param p_SPITType a reference to a copy of the associated SPITType instance. - * @param p_SPITObject a reference to a copy of the SPITObject instance. - */ -void MyApp::onSpitObjectRemoteRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject) { - ESP_LOGD(TAG, "eventSPITObjectRemote Removed"); - ESP_LOGD(TAG, " ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data()); - - // This is a remote SPITObject - // If you have listet this prior you should remove it from the list -} - -//-------------------------------------------------------------- -//---------------- Playing SPITObjects ---------------- -// Following is called when the SPITServer play SPITObjects. -// For every step the server does following sequence occurs: -// a) eventPlay -// b) several eventPlayObject for each actual played SPITObjectin this step -// NEXT STAP of the server -// a) eventPlay -// b) several eventPlayObject for each actual played SPITObject in this step -// ... - -// SPITServer may use several methods for playing SPITObjects. -// e.g. liveSHOWsoftware has the timeline and jingles which plays objects, where the timeline the main player is. -// SPIT distinguishes between the different players. All eventPlay... functions contain the information which player plays the SPIT object. - -void MyApp::onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames) { - ESP_LOGD(TAG, "eventPlay Player: %s Runs: %d Time: %lld", p_PlayerName.data(), p_PlayerIsRunning, p_TimeFrames); - - switch (p_PlayerType) { - case SPIT_Client::PLAYERTYPE_MAIN: - // p_FrameTimes contains the position inside the server's project, we can use it like a timecode - int intMilliseconds; - intMilliseconds = (int)(((double)p_TimeFrames / (double)m_ServerFramesPerSecond) * 1000); - break; - case SPIT_Client::PLAYERTYPE_CONTINOUS: - // The olayer is playing only single Object sequences sometime during the project - break; - case SPIT_Client::PLAYERTYPE_DISCRETE: - // Only discrete values where submitted, e.g the fader position of remote faders. - break; - } -} - -/** - * Called when the SPITServer plays a SPITObject. For every played SPITObject one eventPlayObject is called. - * You can decide here which action should be done or not. - * - * @param p_Started true = The SPITObject is newly played (e.g. in liveSHOWsoftware the cursor enters the SPITObject) - * @param p_Ended Das true = Playback of SPITObject finished (e.g. in liveSHOWsoftware the cursor has exited the SPIT object) - * @param p_SPITType the associated SPITType of p_SPITObject - * @param p_SPITObject the actual played or stopped SPITObject - * @param p_PlayObject contains information about the play status: - * frame where the cursor is inside the SPITObject - * whether the player is running or not - * the actual value of the SPITObject (in liveSHOWsoftware objects ma faded in or out or the main value is decreased, .. - */ -void MyApp::onPlaySpitType(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value) { - // double doubleValue = ((double)p_PlayObject.getValue() / 1000000) * ((double)p_PlayObject.getValueFactor() / 1000000); - - ESP_LOGD(TAG, "eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d", p_PlayerID.data(), p_PlayerIsRunning, p_Started, p_Ended); - // ESP_LOGD(TAG, " SPITType: %s SPITObject: %s Position: %lld Value: %f\n", p_SPITTypeID.data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue); - ESP_LOGD(TAG, " SPITType: %s Value: %f\n", p_SPITTypeID.data(), p_Value); - - if (p_SPITTypeID == "MySPITAPP_Action1ID") { // do Action 1 - // we can get some information about the play status - if (p_Started == true) { - ESP_LOGI(TAG, "MyApp AKTION 1 started Value: %f and running: %d", p_Value, p_PlayerIsRunning); - } else if (p_Ended == true) { - ESP_LOGI(TAG, "MyApp AKTION 1 ended"); // p_PlayObject.getFrameInside() is -1 - } else { - ESP_LOGD(TAG, "MyApp AKTION 1 is played Value: %f and running: %d", p_Value, p_PlayerIsRunning); - } - } else if (p_SPITTypeID == "MySPITAPP_Action2ID") { // do Action 2 - if (p_Started == true) { - ESP_LOGI(TAG, "AKTION 2 started Value: %f and running: %d", p_Value, p_PlayerIsRunning); - } else if (p_Ended == true) { - ESP_LOGI(TAG, "AKTION 2 ended"); // p_PlayObject.getFrameInside() is -1 - } else { - ESP_LOGD(TAG, "AKTION 2 is played Value: %f and running: %d", p_Value, p_PlayerIsRunning); - } - } -} - -//-------------------------------------------------------------- -//---------------- Remote Control SPITServer ---------------- -// The SPITServer has sent all possibilities to control it remotely - remote SPITObjects - see eventSPITObjectRemote -// Some of them may control functionality with values (fader psotions for loudness of sound, ...). -// When the server changes one of these value objects, it sends an eventPlayRemoteObjectStatus. - -/** - * Called when a remote SpitObject which value function is changed by the server. - * This allows the Client to adjust its display for the remote command. - * @param p_SPITType the assigned remote SPITType of p_SPITObject - * @param p_SPITObject the remote SPITObject which is changed - * @param p_FrameInsideObject can be discarded - * @param p_Value the new value - */ -void MyApp::onPlayRemoteObjectStatus(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value) { - ESP_LOGD(TAG, "eventPlayRemoteObjectStatus RemoteSPITType: %s RemoteSPITObject: %s Position: %lld Value: %d", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_FrameInsideObject, p_Value); -} - -/** - * Send a remote control command to the SPITServer. - * There may be different command types: - * a) Some don't use value e.g. go to next scene, olay a jingle, .. - * b) Some use values e.g. the main sound fader - * @param p_SPITObjectID the id of the remote SPITObject (this represents the remote control command) - * @param p_Valueppm the value in ppm - * in case a) the value is ignored - * in case b) the value is used - * @param p_ValueFlag indicates how the server should use p_Valueppm: - * VALUEFLAG_DIRECT (0x00) The server will overwrite his existing value with p_Value - * VALUEFLAG_INCREASE (0x01) The server increases his existing value by p_Valueppm - * VALUEFLAG_DECREASE (0x01) The server decreases his existing value by p_Valueppm - */ -void MyApp::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p_ValueFlag) { - _SpitClient.sendRemoteObject(p_SPITObjectID, p_Valueppm, p_ValueFlag); -} - -void MyApp::testLiveShowRemote() { - // We jump to the next Scenebridge - no Value is needed - _SpitClient.sendRemoteObject("playControlStart"); -} diff --git a/components/spit/src/SAD_DetectedServer.cpp b/components/spit/src/SAD_DetectedServer.cpp index db85926..e50825f 100644 --- a/components/spit/src/SAD_DetectedServer.cpp +++ b/components/spit/src/SAD_DetectedServer.cpp @@ -4,174 +4,130 @@ * and open the template in the editor. */ -/* +/* * SAD_DetectedServer holds information about SPIT Server detected by ServerAutoDetection (SAD). * File: SAD_DetectedServer.cpp * Author: Hagi - * + * * Created on 4. Mai 2019, 13:51 */ #include "SAD_DetectedServer.hpp" #include "esp_log.h" -static const char * TAG = "SpitSrv"; +static const char *TAG = "SpitSrv"; -unordered_map SAD_DetectedServer::s_DetectedServers; +unordered_map SAD_DetectedServer::s_DetectedServers; SAD_DetectedServer::~SAD_DetectedServer() { } //----- Detected Server ----- SAD_DetectedServer::SAD_DetectedServer() { - m_ID = ""; - m_Name = ""; - m_ComputerName = ""; - m_ClientIP = ""; - m_Port = ""; - m_Additions = ""; - m_IPIsIP4 = false; + m_ID = ""; + m_Name = ""; + m_ComputerName = ""; + m_ClientIP = ""; + m_Port = ""; + m_Additions = ""; } void SAD_DetectedServer::setProjectName(string p_ServerProjectName) { - if (m_ServerProjectName.compare(p_ServerProjectName) != 0) { - if (m_New == false) { - m_Changed = true; - } - } - m_ServerProjectName = p_ServerProjectName; + if (m_ServerProjectName.compare(p_ServerProjectName) != 0) { + if (m_New == false) { + m_Changed = true; + } + } + m_ServerProjectName = p_ServerProjectName; } void SAD_DetectedServer::cycleStart() { - for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) { - i->second->startCycleSAD(); - } + for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) { + i->second->startCycleSAD(); + } } -void SAD_DetectedServer::cycleEnd(I_SAD_Client& sadClient) { - list o_LostServers; - list o_NewServers; - list o_ChangedServers; - SAD_DetectedServer* ptrDetectedServer; - { - for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) { - ptrDetectedServer = i->second; - if (ptrDetectedServer->getFoundAgain() == false) { - o_LostServers.push_back(ptrDetectedServer); - ptrDetectedServer->endCycleSAD(); - } - else if (ptrDetectedServer->getNew()) { - o_NewServers.push_back(ptrDetectedServer); - ptrDetectedServer->setNew(false); - ptrDetectedServer->endCycleSAD(); - } - else if (ptrDetectedServer->getChanged()) { - o_ChangedServers.push_back(ptrDetectedServer); - ptrDetectedServer->endCycleSAD(); - } - else { - ptrDetectedServer->endCycleSAD(); - } - } - } - //Notify client interface about lost servers - for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) { - ptrDetectedServer = *i; - sadClient.eventServerLost(ptrDetectedServer->getID(), ptrDetectedServer->getName(), - ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(), - ptrDetectedServer->getClientIP(), - ptrDetectedServer->getIpIsIP4()); - } - //Remove lost servers - for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) { - ptrDetectedServer = *i; - removeDetectedServer(ptrDetectedServer); - } - o_LostServers.clear(); - - for (auto i = o_NewServers.begin(); i != o_NewServers.end(); i++) { - ptrDetectedServer = *i; - sadClient.eventServerDetected(ptrDetectedServer->getID(), ptrDetectedServer->getName(), - ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(), - ptrDetectedServer->getClientIP(), - ptrDetectedServer->getIpIsIP4()); - } - o_NewServers.clear(); - for (auto i = o_ChangedServers.begin(); i != o_ChangedServers.end(); i++) { - ptrDetectedServer = *i; - sadClient.eventServerChanged(ptrDetectedServer->getID(), ptrDetectedServer->getName(), - ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(), - ptrDetectedServer->getClientIP(), - ptrDetectedServer->getIpIsIP4()); - } - o_ChangedServers.clear(); +void SAD_DetectedServer::cycleEnd(I_SAD_Client &sadClient) { + for (auto &srv : s_DetectedServers) { + SAD_DetectedServer *ptrDetectedServer = srv.second; + if (ptrDetectedServer->getFoundAgain() == false) { + sadClient.eventServerLost(*ptrDetectedServer); + removeDetectedServer(*ptrDetectedServer); + } else if (ptrDetectedServer->getNew()) { + ptrDetectedServer->setNew(false); + sadClient.eventServerDetected(*ptrDetectedServer); + } else if (ptrDetectedServer->getChanged()) { + sadClient.eventServerChanged(*ptrDetectedServer); + } + } } - /** - * Used by SAD_Client to add a found SPITServer - don't use this manually - * @param p_IsIP4 true = the server is reached via a IP4 address
false = the server is reahed via a IP6 address - * @param p_ServerID the id of the server, every instance of a SPITServer has an own id - * @param p_ServerParams the server's parameter - */ -void SAD_DetectedServer::addDetectedServer(bool p_IsIP4, string p_ServerID, string p_ServerParams[]) { - SAD_DetectedServer* ptrDetectedServer; - { - auto i = s_DetectedServers.find(p_ServerID); - if (i != s_DetectedServers.end()) { - ptrDetectedServer = i->second; - } - else { - ptrDetectedServer = new SAD_DetectedServer(); - ptrDetectedServer->setID(p_ServerParams[PARAMINDEX_ID]); - ptrDetectedServer->setNew(true); - } - ptrDetectedServer->setFoundAgain(); - //second prefer IP4 - if (p_IsIP4 == true) { - ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]); - ptrDetectedServer->setIPIsIP4(true); - ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]); - } - else if (ptrDetectedServer->getIpIsIP4() == false){ - ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]); - ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]); - } - ptrDetectedServer->setName(p_ServerParams[PARAMINDEX_NAME]); - ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]); - ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]); - ptrDetectedServer->setAdditions(p_ServerParams[PARAMINDEX_ADDITIONS]); - ptrDetectedServer->setProjectName(p_ServerParams[PARAMINDEX_SERVERPROJECTNAME]); +/** + * Used by SAD_Client to add a found SPITServer - don't use this manually + * @param p_IsIP4 true = the server is reached via a IP4 address
false = the server is reahed via a IP6 address + * @param p_ServerID the id of the server, every instance of a SPITServer has an own id + * @param p_ServerParams the server's parameter + */ +void SAD_DetectedServer::addDetectedServer(string p_ServerID, string p_ServerParams[]) { + SAD_DetectedServer *ptrDetectedServer; + { + auto i = s_DetectedServers.find(p_ServerID); + if (i != s_DetectedServers.end()) { + ptrDetectedServer = i->second; + } else { + ptrDetectedServer = new SAD_DetectedServer(); + ptrDetectedServer->setID(p_ServerParams[PARAMINDEX_ID]); + ptrDetectedServer->setNew(true); + } + ptrDetectedServer->setFoundAgain(); - s_DetectedServers[ptrDetectedServer->getID()] = ptrDetectedServer; - } - } - /** - * Used by SAD_Client to remove a SPITServer - don't use this manually - * @param p_DetectedServer - */ -void SAD_DetectedServer::removeDetectedServer(SAD_DetectedServer* p_DetectedServer) { - SAD_DetectedServer* o_DetectedServer; - { - auto i = s_DetectedServers.find(p_DetectedServer->getID()); - if (i != s_DetectedServers.end()) { - o_DetectedServer = i->second; - i = s_DetectedServers.erase(i); - delete o_DetectedServer; - } - } - } - - /** - * Used by SAD_Client to clear all found SPITServers - don't use this manually - */ + // second prefer IP4 + ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]); + ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]); + ptrDetectedServer->setName(p_ServerParams[PARAMINDEX_NAME]); + ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]); + ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]); + ptrDetectedServer->setAdditions(p_ServerParams[PARAMINDEX_ADDITIONS]); + ptrDetectedServer->setProjectName(p_ServerParams[PARAMINDEX_SERVERPROJECTNAME]); + + s_DetectedServers[ptrDetectedServer->getID()] = ptrDetectedServer; + } +} +/** + * Used by SAD_Client to remove a SPITServer - don't use this manually + * @param p_DetectedServer + */ +void SAD_DetectedServer::removeDetectedServer(SAD_DetectedServer &server) { + auto i = s_DetectedServers.find(server.getID()); + if (i != s_DetectedServers.end()) { + SAD_DetectedServer *o_DetectedServer = i->second; + i = s_DetectedServers.erase(i); + delete o_DetectedServer; + } +} + +/** + * Used by SAD_Client to clear all found SPITServers - don't use this manually + */ void SAD_DetectedServer::clearDetectedServers() { - SAD_DetectedServer* ptrDetectedServer; - { - for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) { - ptrDetectedServer = i->second; - i = s_DetectedServers.erase(i); - delete ptrDetectedServer; - if (i == s_DetectedServers.end()) { - break; - } - } - } - } + for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) { + SAD_DetectedServer *ptrDetectedServer = i->second; + i = s_DetectedServers.erase(i); + delete ptrDetectedServer; + if (i == s_DetectedServers.end()) { + break; + } + } +} + +const SAD_DetectedServer &SAD_DetectedServer::getRefDetectedServer(string p_ServerID) { + SAD_DetectedServer *ptrDetectedServer = nullptr; + + auto i = s_DetectedServers.find(p_ServerID); + if (i != s_DetectedServers.end()) { + ptrDetectedServer = i->second; + } + if (ptrDetectedServer != NULL) { + return *ptrDetectedServer; + } + + throw new exception(); +} \ No newline at end of file diff --git a/components/spit/src/SPITObject.cpp b/components/spit/src/SPITObject.cpp index 03c3132..377945b 100644 --- a/components/spit/src/SPITObject.cpp +++ b/components/spit/src/SPITObject.cpp @@ -4,427 +4,438 @@ * and open the template in the editor. */ -/* - * SPITObject describes a SPIT Object +/* + * SPITObject describes a SPIT Object * File: SPITObject.cpp * Author: Hagi - * + * * Created on 9. April 2019, 12:11 */ #include "SPITObject.h" #include "SPITSocket.h" - unordered_map SPITObject::s_SPITObjects; - unordered_map SPITObject::s_SPITObjectsRemote; - - SPITObject* SPITObject::getSPITObject(string p_ID) { - { - auto i = s_SPITObjects.find(p_ID); - if (i == s_SPITObjects.end()) { - return NULL; - } - return i->second; - } - } - /** - * Returns the reference of the SPITObject with ID == p_ID.
- * Throws an exception if no SPITObject is not found.
- * @param p_ID the ID - * @return reference of the SPITType with ID == p_ID - */ - const SPITObject& SPITObject::getSPITObjectRef(string p_ID) { - { - auto i = s_SPITObjects.find(p_ID); - if (i == s_SPITObjects.end()) { - throw "SPITObject no SPITObject with given id"; - } - return *(i->second); - } - } - - SPITObject* SPITObject::getSPITObjectRemote(string p_ID) { - { - auto i = s_SPITObjectsRemote.find(p_ID); - if (i == s_SPITObjectsRemote.end()) { - return NULL; - } - return i->second; - } - } - /** - * Returns the reference of the remote SPITObject with ID == p_ID.
- * Throws an exception if no SPITObject is not found.
- * @param p_ID the ID - * @return reference of the SPITType with ID == p_ID - */ - const SPITObject& SPITObject::getSPITObjectRemoteRef(string p_ID) { - { - auto i = s_SPITObjectsRemote.find(p_ID); - if (i == s_SPITObjectsRemote.end()) { - throw "Remote SPITObject no SPITObject with given id"; - } - return *(i->second); - } - } +unordered_map SPITObject::s_SPITObjects; +unordered_map SPITObject::s_SPITObjectsRemote; - bool SPITObject::addSPITObject(SPITObject* p_ptrSPITObject) { - if (p_ptrSPITObject == NULL) return false; - { - s_SPITObjects[p_ptrSPITObject->getID()] = p_ptrSPITObject; - return true; - } - } - bool SPITObject::addSPITObjectRemote(SPITObject* p_ptrSPITObject) { - if (p_ptrSPITObject == NULL) return false; - { - s_SPITObjectsRemote[p_ptrSPITObject->getID()] = p_ptrSPITObject; - return true; - } - } - bool SPITObject::removeSPITObject(SPITObject* p_ptrSPITObject) { - if (p_ptrSPITObject == NULL) return false; - return removeSPITObject(p_ptrSPITObject->getID()); - } - bool SPITObject::removeSPITObject(string p_SPITObjectID) { - { - auto i = s_SPITObjects.find(p_SPITObjectID); - if (i == s_SPITObjects.end()) { - return false; - } - i = s_SPITObjects.erase(i); - return true; - } - } - bool SPITObject::removeSPITObjectRemote(SPITObject* p_ptrSPITObject) { - if (p_ptrSPITObject == NULL) return false; - return removeSPITObjectRemote(p_ptrSPITObject->getID()); - } - bool SPITObject::removeSPITObjectRemote(string p_ptrSPITObject) { - { - auto i = s_SPITObjectsRemote.find(p_ptrSPITObject); - if (i == s_SPITObjectsRemote.end()) { - return false; - } - i = s_SPITObjectsRemote.erase(i); - return true; - } - } +SPITObject *SPITObject::getSPITObject(string p_ID) { + { + auto i = s_SPITObjects.find(p_ID); + if (i == s_SPITObjects.end()) { + return NULL; + } + return i->second; + } +} +/** + * Returns the reference of the SPITObject with ID == p_ID.
+ * Throws an exception if no SPITObject is not found.
+ * @param p_ID the ID + * @return reference of the SPITType with ID == p_ID + */ +const SPITObject &SPITObject::getSPITObjectRef(string p_ID) { + { + auto i = s_SPITObjects.find(p_ID); + if (i == s_SPITObjects.end()) { + throw "SPITObject no SPITObject with given id"; + } + return *(i->second); + } +} - int SPITObject::getSPITObjectCount() { - return s_SPITObjects.size(); - } - int SPITObject::getSPITObjectRemoteCount() { - return s_SPITObjectsRemote.size(); - } - SPITObject* SPITObject::getSPITObject(int p_Index) { - SPITObject* ptrSPITObject = NULL; - { - if (p_Index >= 0 && p_Index < s_SPITObjects.size()) { - unordered_map::iterator i = next(s_SPITObjects.begin(), p_Index); - ptrSPITObject = i->second; - return ptrSPITObject; - } - else { - return NULL; - } - } - } - /** - * Returns a reference to the SPITObject at position p_Index.
- * Throws an exception if p_Index is out of range.
- * @param p_Index position - * @return the reference of the SPITObject at position. - */ - const SPITObject& SPITObject::getSPITObjectRef(int p_Index) { - SPITObject* ptrSPITObject = NULL; - { - if (p_Index >= 0 && p_Index < s_SPITObjects.size()) { - unordered_map::iterator i = next(s_SPITObjects.begin(), p_Index); - ptrSPITObject = i->second; - return *ptrSPITObject; - } - else { - throw "SPITObject index out of range"; - } - } - } - SPITObject* SPITObject::getSPITObjectRemote(int p_Index) { - SPITObject* ptrSPITObject = NULL; - { - if (p_Index >= 0 && p_Index < s_SPITObjectsRemote.size()) { - unordered_map::iterator i = next(s_SPITObjectsRemote.begin(), p_Index); - ptrSPITObject = i->second; - return ptrSPITObject; - } - else { - return NULL; - } - } - } - /** - * Returns a reference to the remote SPITObject at position p_Index.
- * Throws an exception if p_Index is out of range.
- * @param p_Index position - * @return the reference of the SPITObject at position. - */ - const SPITObject& SPITObject::getSPITObjectRemoteRef(int p_Index) { - SPITObject* ptrSPITObject = NULL; - { - if (p_Index >= 0 && p_Index < s_SPITObjectsRemote.size()) { - unordered_map::iterator i = next(s_SPITObjectsRemote.begin(), p_Index); - ptrSPITObject = i->second; - return *ptrSPITObject; - } - else { - throw "Remote SPITObject index out of range"; - } - } - } - - void SPITObject::clearSPITObjects() { - SPITObject* ptrSPITObject; - { - for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) { - ptrSPITObject = i->second; - i = s_SPITObjects.erase(i); - delete ptrSPITObject; - if (i == s_SPITObjects.end()) { - break; - } - } - } - } - void SPITObject::clearSPITObjectsRemote() { - SPITObject* ptrSPITObject; - { - for (auto i = s_SPITObjectsRemote.begin(); i != s_SPITObjectsRemote.end(); i++) { - ptrSPITObject = i->second; - i = s_SPITObjectsRemote.erase(i); - delete ptrSPITObject; - if (i == s_SPITObjectsRemote.end()) { - break; - } - } - } - } +SPITObject *SPITObject::getSPITObjectRemote(string p_ID) { + { + auto i = s_SPITObjectsRemote.find(p_ID); + if (i == s_SPITObjectsRemote.end()) { + return NULL; + } + return i->second; + } +} +/** + * Returns the reference of the remote SPITObject with ID == p_ID.
+ * Throws an exception if no SPITObject is not found.
+ * @param p_ID the ID + * @return reference of the SPITType with ID == p_ID + */ +const SPITObject &SPITObject::getSPITObjectRemoteRef(string p_ID) { + { + auto i = s_SPITObjectsRemote.find(p_ID); + if (i == s_SPITObjectsRemote.end()) { + throw "Remote SPITObject no SPITObject with given id"; + } + return *(i->second); + } +} - /** - * clears all unconfirmed SPITObjects not created by this SPIT_Client. - */ - void SPITObject::clearUnconfirmedSPITObjects() { - for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) { - SPITObject* ptrSPITObject = i->second; - if (ptrSPITObject->getCreatedByClient() == false && ptrSPITObject->getConfirmed() == false) { - i = s_SPITObjects.erase(i); - delete ptrSPITObject; - } - if (i == s_SPITObjects.end()) { - break; - } - } - } +bool SPITObject::addSPITObject(SPITObject *p_ptrSPITObject) { + if (p_ptrSPITObject == NULL) + return false; + { + s_SPITObjects[p_ptrSPITObject->getID()] = p_ptrSPITObject; + return true; + } +} +bool SPITObject::addSPITObjectRemote(SPITObject *p_ptrSPITObject) { + if (p_ptrSPITObject == NULL) + return false; + { + s_SPITObjectsRemote[p_ptrSPITObject->getID()] = p_ptrSPITObject; + return true; + } +} +bool SPITObject::removeSPITObject(SPITObject *p_ptrSPITObject) { + if (p_ptrSPITObject == NULL) + return false; + return removeSPITObject(p_ptrSPITObject->getID()); +} +bool SPITObject::removeSPITObject(string p_SPITObjectID) { + { + auto i = s_SPITObjects.find(p_SPITObjectID); + if (i == s_SPITObjects.end()) { + return false; + } + i = s_SPITObjects.erase(i); + return true; + } +} +bool SPITObject::removeSPITObjectRemote(SPITObject *p_ptrSPITObject) { + if (p_ptrSPITObject == NULL) + return false; + return removeSPITObjectRemote(p_ptrSPITObject->getID()); +} +bool SPITObject::removeSPITObjectRemote(string p_ptrSPITObject) { + { + auto i = s_SPITObjectsRemote.find(p_ptrSPITObject); + if (i == s_SPITObjectsRemote.end()) { + return false; + } + i = s_SPITObjectsRemote.erase(i); + return true; + } +} - void SPITObject::eventProjectClosed() { - for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) { - SPITObject* ptrSPITObject = i->second; - if (ptrSPITObject->getCreatedByClient() == true) { - continue; - } - i = s_SPITObjects.erase(i); - delete ptrSPITObject; - if (i == s_SPITObjects.end()) { - break; - } - } - //Remote - for (auto i = s_SPITObjectsRemote.begin(); i != s_SPITObjectsRemote.end(); i++) { - SPITObject* ptrSPITObject = i->second; - i = s_SPITObjectsRemote.erase(i); - delete ptrSPITObject; - if (i == s_SPITObjectsRemote.end()) { - break; - } - } - } - /** - * sets confirmed = false for all SPITObjects.
- * This should be called when the client has loaded a project.
- */ - void SPITObject::setConfirmedFalse() { - SPITObject* ptrSPITObject; - { - for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) { - ptrSPITObject = i->second; - ptrSPITObject->setConfirmed(false); - } - } - } +int SPITObject::getSPITObjectCount() { + return s_SPITObjects.size(); +} +int SPITObject::getSPITObjectRemoteCount() { + return s_SPITObjectsRemote.size(); +} +SPITObject *SPITObject::getSPITObject(int p_Index) { + SPITObject *ptrSPITObject = NULL; + { + if (p_Index >= 0 && p_Index < s_SPITObjects.size()) { + unordered_map::iterator i = next(s_SPITObjects.begin(), p_Index); + ptrSPITObject = i->second; + return ptrSPITObject; + } else { + return NULL; + } + } +} +/** + * Returns a reference to the SPITObject at position p_Index.
+ * Throws an exception if p_Index is out of range.
+ * @param p_Index position + * @return the reference of the SPITObject at position. + */ +const SPITObject &SPITObject::getSPITObjectRef(int p_Index) { + SPITObject *ptrSPITObject = NULL; + { + if (p_Index >= 0 && p_Index < s_SPITObjects.size()) { + unordered_map::iterator i = next(s_SPITObjects.begin(), p_Index); + ptrSPITObject = i->second; + return *ptrSPITObject; + } else { + throw "SPITObject index out of range"; + } + } +} +SPITObject *SPITObject::getSPITObjectRemote(int p_Index) { + SPITObject *ptrSPITObject = NULL; + { + if (p_Index >= 0 && p_Index < s_SPITObjectsRemote.size()) { + unordered_map::iterator i = next(s_SPITObjectsRemote.begin(), p_Index); + ptrSPITObject = i->second; + return ptrSPITObject; + } else { + return NULL; + } + } +} +/** + * Returns a reference to the remote SPITObject at position p_Index.
+ * Throws an exception if p_Index is out of range.
+ * @param p_Index position + * @return the reference of the SPITObject at position. + */ +const SPITObject &SPITObject::getSPITObjectRemoteRef(int p_Index) { + SPITObject *ptrSPITObject = NULL; + { + if (p_Index >= 0 && p_Index < s_SPITObjectsRemote.size()) { + unordered_map::iterator i = next(s_SPITObjectsRemote.begin(), p_Index); + ptrSPITObject = i->second; + return *ptrSPITObject; + } else { + throw "Remote SPITObject index out of range"; + } + } +} +void SPITObject::clearSPITObjects() { + SPITObject *ptrSPITObject; + { + for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) { + ptrSPITObject = i->second; + i = s_SPITObjects.erase(i); + delete ptrSPITObject; + if (i == s_SPITObjects.end()) { + break; + } + } + } +} +void SPITObject::clearSPITObjectsRemote() { + SPITObject *ptrSPITObject; + { + for (auto i = s_SPITObjectsRemote.begin(); i != s_SPITObjectsRemote.end(); i++) { + ptrSPITObject = i->second; + i = s_SPITObjectsRemote.erase(i); + delete ptrSPITObject; + if (i == s_SPITObjectsRemote.end()) { + break; + } + } + } +} + +/** + * clears all unconfirmed SPITObjects not created by this SPIT_Client. + */ +void SPITObject::clearUnconfirmedSPITObjects() { + for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) { + SPITObject *ptrSPITObject = i->second; + if (ptrSPITObject->getCreatedByClient() == false && ptrSPITObject->getConfirmed() == false) { + i = s_SPITObjects.erase(i); + delete ptrSPITObject; + } + if (i == s_SPITObjects.end()) { + break; + } + } +} + +void SPITObject::eventProjectClosed() { + for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) { + SPITObject *ptrSPITObject = i->second; + if (ptrSPITObject->getCreatedByClient() == true) { + continue; + } + i = s_SPITObjects.erase(i); + delete ptrSPITObject; + if (i == s_SPITObjects.end()) { + break; + } + } + // Remote + for (auto i = s_SPITObjectsRemote.begin(); i != s_SPITObjectsRemote.end(); i++) { + SPITObject *ptrSPITObject = i->second; + i = s_SPITObjectsRemote.erase(i); + delete ptrSPITObject; + if (i == s_SPITObjectsRemote.end()) { + break; + } + } +} +/** + * sets confirmed = false for all SPITObjects.
+ * This should be called when the client has loaded a project.
+ */ +void SPITObject::setConfirmedFalse() { + SPITObject *ptrSPITObject; + { + for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) { + ptrSPITObject = i->second; + ptrSPITObject->setConfirmed(false); + } + } +} - SPITObject::SPITObject() { - initMembers(); + initMembers(); } void SPITObject::initMembers() { - m_ActionAssigned = false; - m_ActionAssignedType = false; - m_Confirmed = false; - m_Delay = 0; - m_Duration = 0; - m_Fixed = false; - m_CreatedByClient = false; - m_FrameFadeInLength = 0; - m_FrameFadeOutLength = 0; - m_FrameLength = 0; - m_FrameStart = 0; - m_Remark = ""; - m_ID = createGUID(); - m_Name = ""; - m_SPITTypeID = ""; - m_ServerParams = ""; - m_ServerRemote = false; - m_Track = 0; - m_ValueFactor = 1000000; //Values are given in ppm -> 1000000 = 1/1; - m_ValueUse = 0x01; + m_ActionAssigned = false; + m_ActionAssignedType = false; + m_Confirmed = false; + m_Delay = 0; + m_Duration = 0; + m_Fixed = false; + m_CreatedByClient = false; + m_FrameFadeInLength = 0; + m_FrameFadeOutLength = 0; + m_FrameLength = 0; + m_FrameStart = 0; + m_Remark = ""; + m_ID = createGUID(); + m_Name = ""; + m_SPITTypeID = ""; + m_ServerParams = ""; + m_ServerRemote = false; + m_Track = 0; + m_ValueFactor = 1000000; // Values are given in ppm -> 1000000 = 1/1; + m_ValueUse = 0x01; } -SPITObject::~SPITObject() { } +SPITObject::~SPITObject() {} +bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject) { + bool boolChangeAllowed; + bool boolChanged = false; -bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject) { - bool boolChangeAllowed; - bool boolChanged = false; - - if (m_CreatedByClient == true && m_Fixed == true) { - boolChangeAllowed = false; - } - else { - boolChangeAllowed = true; - } - - //Confirmation should be changable - if (m_CreatedByClient) { - //Server reports a client created SPITType -> the type is confirmed - m_Confirmed = true; - } - else { - //type is NOT client created -> the client has to confirm the SPITtype - m_Confirmed = p_ReportSPITObject->getConfirmed(); - } - - if (m_Delay != p_ReportSPITObject->getDelay()) { - if (boolChangeAllowed == false) throw new exception(); - m_Delay = p_ReportSPITObject->getDelay(); - boolChanged = true; - } - if (m_Duration != p_ReportSPITObject->getDuration()) { - if (boolChangeAllowed == false) throw new exception(); - m_Duration = p_ReportSPITObject->getDuration(); - boolChanged = true; - } - if (m_Fixed != p_ReportSPITObject->getFixed()) { - if (boolChangeAllowed == false) throw new exception(); - m_Fixed = p_ReportSPITObject->getFixed(); - boolChanged = true; - } - if (m_FrameFadeInLength != p_ReportSPITObject->getFrameFadeInLength()) { - if (boolChangeAllowed == false) throw new exception(); - m_FrameFadeInLength = p_ReportSPITObject->getFrameFadeInLength(); - boolChanged= true; - } - if (m_FrameFadeOutLength != p_ReportSPITObject->getFrameFadeOutLength()) { - if (boolChangeAllowed == false) throw new exception(); - m_FrameFadeOutLength = p_ReportSPITObject->getFrameFadeOutLength(); - boolChanged = true; - } - if (m_FrameLength != p_ReportSPITObject->getFrameLength()) { - if (boolChangeAllowed == false) throw new exception(); - m_FrameLength = p_ReportSPITObject->getFrameLength(); - boolChanged = true; - } - if (m_FrameStart != p_ReportSPITObject->getFrameStart()) { - if (boolChangeAllowed == false) throw new exception(); - m_FrameStart = p_ReportSPITObject->getFrameStart(); - boolChanged = true; - } - if (m_Remark != p_ReportSPITObject->getRemark()) { - if (boolChangeAllowed == false) throw new exception(); - m_Remark = p_ReportSPITObject->getRemark(); - boolChanged = true; - } - if (m_ID != p_ReportSPITObject->getID()) { - if (boolChangeAllowed == false) throw new exception(); - m_ID = p_ReportSPITObject->getID(); - boolChanged = true; - } - if (m_Name != p_ReportSPITObject->getName()) { - if (boolChangeAllowed == false) throw new exception(); - m_Name = p_ReportSPITObject->getName(); - boolChanged = true; - } - if (m_SPITTypeID != p_ReportSPITObject->getSPITTypeID()) { - if (boolChangeAllowed == false) throw new exception(); - m_SPITTypeID = p_ReportSPITObject->getSPITTypeID(); - boolChanged = true; - } - if (m_ServerParams != p_ReportSPITObject->getServerParams()) { - if (boolChangeAllowed == false) throw new exception(); - m_ServerParams = p_ReportSPITObject->getServerParams(); - boolChanged = true; - } - if (m_ServerRemote != p_ReportSPITObject->getServerRemote()) { - if (boolChangeAllowed == false) throw new exception(); - m_ServerRemote = p_ReportSPITObject->getServerRemote(); - boolChanged = true; - } - if (m_Track != p_ReportSPITObject->getTrack()) { - if (boolChangeAllowed == false) throw new exception(); - m_Track = p_ReportSPITObject->getTrack(); - boolChanged = true; - } - if (m_ValueFactor != p_ReportSPITObject->getValueFactor()) { - if (boolChangeAllowed == false) throw new exception(); - m_ValueFactor = p_ReportSPITObject->getValueFactor(); - boolChanged = true; - } - if (m_ValueUse != p_ReportSPITObject->getValueUse()) { - if (boolChangeAllowed == false) throw new exception(); - m_ValueUse = p_ReportSPITObject->getValueUse(); - boolChanged = true; - } - return boolChanged; + if (m_CreatedByClient == true && m_Fixed == true) { + boolChangeAllowed = false; + } else { + boolChangeAllowed = true; + } + + // Confirmation should be changable + if (m_CreatedByClient) { + // Server reports a client created SPITType -> the type is confirmed + m_Confirmed = true; + } else { + // type is NOT client created -> the client has to confirm the SPITtype + m_Confirmed = p_ReportSPITObject->getConfirmed(); + } + + if (m_Delay != p_ReportSPITObject->getDelay()) { + if (boolChangeAllowed == false) + throw new exception(); + m_Delay = p_ReportSPITObject->getDelay(); + boolChanged = true; + } + if (m_Duration != p_ReportSPITObject->getDuration()) { + if (boolChangeAllowed == false) + throw new exception(); + m_Duration = p_ReportSPITObject->getDuration(); + boolChanged = true; + } + if (m_Fixed != p_ReportSPITObject->getFixed()) { + if (boolChangeAllowed == false) + throw new exception(); + m_Fixed = p_ReportSPITObject->getFixed(); + boolChanged = true; + } + if (m_FrameFadeInLength != p_ReportSPITObject->getFrameFadeInLength()) { + if (boolChangeAllowed == false) + throw new exception(); + m_FrameFadeInLength = p_ReportSPITObject->getFrameFadeInLength(); + boolChanged = true; + } + if (m_FrameFadeOutLength != p_ReportSPITObject->getFrameFadeOutLength()) { + if (boolChangeAllowed == false) + throw new exception(); + m_FrameFadeOutLength = p_ReportSPITObject->getFrameFadeOutLength(); + boolChanged = true; + } + if (m_FrameLength != p_ReportSPITObject->getFrameLength()) { + if (boolChangeAllowed == false) + throw new exception(); + m_FrameLength = p_ReportSPITObject->getFrameLength(); + boolChanged = true; + } + if (m_FrameStart != p_ReportSPITObject->getFrameStart()) { + if (boolChangeAllowed == false) + throw new exception(); + m_FrameStart = p_ReportSPITObject->getFrameStart(); + boolChanged = true; + } + if (m_Remark != p_ReportSPITObject->getRemark()) { + if (boolChangeAllowed == false) + throw new exception(); + m_Remark = p_ReportSPITObject->getRemark(); + boolChanged = true; + } + if (m_ID != p_ReportSPITObject->getID()) { + if (boolChangeAllowed == false) + throw new exception(); + m_ID = p_ReportSPITObject->getID(); + boolChanged = true; + } + if (m_Name != p_ReportSPITObject->getName()) { + if (boolChangeAllowed == false) + throw new exception(); + m_Name = p_ReportSPITObject->getName(); + boolChanged = true; + } + if (m_SPITTypeID != p_ReportSPITObject->getSPITTypeID()) { + if (boolChangeAllowed == false) + throw new exception(); + m_SPITTypeID = p_ReportSPITObject->getSPITTypeID(); + boolChanged = true; + } + if (m_ServerParams != p_ReportSPITObject->getServerParams()) { + if (boolChangeAllowed == false) + throw new exception(); + m_ServerParams = p_ReportSPITObject->getServerParams(); + boolChanged = true; + } + if (m_ServerRemote != p_ReportSPITObject->getServerRemote()) { + if (boolChangeAllowed == false) + throw new exception(); + m_ServerRemote = p_ReportSPITObject->getServerRemote(); + boolChanged = true; + } + if (m_Track != p_ReportSPITObject->getTrack()) { + if (boolChangeAllowed == false) + throw new exception(); + m_Track = p_ReportSPITObject->getTrack(); + boolChanged = true; + } + if (m_ValueFactor != p_ReportSPITObject->getValueFactor()) { + if (boolChangeAllowed == false) + throw new exception(); + m_ValueFactor = p_ReportSPITObject->getValueFactor(); + boolChanged = true; + } + if (m_ValueUse != p_ReportSPITObject->getValueUse()) { + if (boolChangeAllowed == false) + throw new exception(); + m_ValueUse = p_ReportSPITObject->getValueUse(); + boolChanged = true; + } + return boolChanged; } -void SPITObject::fillMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject) { - p_ReportSPITObject->setActionAssigned(getActionAssigned()); //Action can be assigned to type or to this object - p_ReportSPITObject->setConfirmed(m_Confirmed); - p_ReportSPITObject->setDelay(m_Delay); - p_ReportSPITObject->setDuration(m_Duration); - p_ReportSPITObject->setFixed(m_Fixed); - p_ReportSPITObject->setFrameFadeInLength(m_FrameFadeInLength); - p_ReportSPITObject->setFrameFadeOutLength(m_FrameFadeOutLength); - p_ReportSPITObject->setFrameLength(m_FrameLength); - p_ReportSPITObject->setFrameStart(m_FrameStart); - p_ReportSPITObject->setID(m_ID); - p_ReportSPITObject->setName(m_Name); - p_ReportSPITObject->setRemark(m_Remark); - p_ReportSPITObject->setSPITTypeID(m_SPITTypeID); - p_ReportSPITObject->setServerParams(m_ServerParams); - p_ReportSPITObject->setServerRemote(m_ServerRemote); - p_ReportSPITObject->setTrack(m_Track); - p_ReportSPITObject->setValueFactor(m_ValueFactor); - p_ReportSPITObject->setValueUse(m_ValueUse); +void SPITObject::fillMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject) { + p_ReportSPITObject->setActionAssigned(getActionAssigned()); // Action can be assigned to type or to this object + p_ReportSPITObject->setConfirmed(m_Confirmed); + p_ReportSPITObject->setDelay(m_Delay); + p_ReportSPITObject->setDuration(m_Duration); + p_ReportSPITObject->setFixed(m_Fixed); + p_ReportSPITObject->setFrameFadeInLength(m_FrameFadeInLength); + p_ReportSPITObject->setFrameFadeOutLength(m_FrameFadeOutLength); + p_ReportSPITObject->setFrameLength(m_FrameLength); + p_ReportSPITObject->setFrameStart(m_FrameStart); + p_ReportSPITObject->setID(m_ID); + p_ReportSPITObject->setName(m_Name); + p_ReportSPITObject->setRemark(m_Remark); + p_ReportSPITObject->setSPITTypeID(m_SPITTypeID); + p_ReportSPITObject->setServerParams(m_ServerParams); + p_ReportSPITObject->setServerRemote(m_ServerRemote); + p_ReportSPITObject->setTrack(m_Track); + p_ReportSPITObject->setValueFactor(m_ValueFactor); + p_ReportSPITObject->setValueUse(m_ValueUse); } -void SPITObject::fillMessageOP(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject) { - p_RemoveSPITObject->setID(m_ID); +void SPITObject::fillMessageOP(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject) { + p_RemoveSPITObject->setID(m_ID); } void SPITObject::setID(string p_ID) { - m_ID = p_ID; + m_ID = p_ID; } void SPITObject::setCreatedByClient(bool p_CreatedByClient) { - m_CreatedByClient = p_CreatedByClient; + m_CreatedByClient = p_CreatedByClient; } /** @@ -433,122 +444,142 @@ void SPITObject::setCreatedByClient(bool p_CreatedByClient) { * @return if m_Confirmed has changed */ bool SPITObject::setConfirmed(bool p_Confirmed) { - if (m_Confirmed == p_Confirmed) return false; - m_Confirmed = p_Confirmed; - return true; + if (m_Confirmed == p_Confirmed) + return false; + m_Confirmed = p_Confirmed; + return true; } bool SPITObject::setName(string p_Name) { - if (m_Name == p_Name) return false; - m_Name = p_Name; - m_Confirmed = false; - return true; + if (m_Name == p_Name) + return false; + m_Name = p_Name; + m_Confirmed = false; + return true; } bool SPITObject::setRemark(string p_Remark) { - if (m_Remark == p_Remark) return false; - m_Remark = p_Remark; - m_Confirmed = false; - return true; + if (m_Remark == p_Remark) + return false; + m_Remark = p_Remark; + m_Confirmed = false; + return true; } bool SPITObject::setServerParams(string p_ServerParams) { - if (m_ServerParams == p_ServerParams) return false; - m_ServerParams = p_ServerParams; - m_Confirmed = false; - return true; + if (m_ServerParams == p_ServerParams) + return false; + m_ServerParams = p_ServerParams; + m_Confirmed = false; + return true; } bool SPITObject::setSPITTypeID(string p_SPITTypeID) { - if (m_SPITTypeID == p_SPITTypeID) return false; - m_SPITTypeID = p_SPITTypeID; - m_Confirmed = false; - return true; + if (m_SPITTypeID == p_SPITTypeID) + return false; + m_SPITTypeID = p_SPITTypeID; + m_Confirmed = false; + return true; } bool SPITObject::setServerRemote(bool p_BelongstoServer) { - if (m_ServerRemote == p_BelongstoServer) return false; - m_ServerRemote = p_BelongstoServer; - m_Confirmed = false; - return true; + if (m_ServerRemote == p_BelongstoServer) + return false; + m_ServerRemote = p_BelongstoServer; + m_Confirmed = false; + return true; } - /** - * This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.
- * This is used when an action is associated with a SPITType.
- * Then this action is done for every SPITObject with the SPITType. - * @return true = an action is assigned for the SPITType. - */ +/** + * This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.
+ * This is used when an action is associated with a SPITType.
+ * Then this action is done for every SPITObject with the SPITType. + * @return true = an action is assigned for the SPITType. + */ bool SPITObject::setActionAssignedType(bool p_ActionAssigned) { - if (m_ActionAssignedType == p_ActionAssigned) return false; - bool boolOldActionAssigend; - boolOldActionAssigend = getActionAssigned(); - m_ActionAssignedType = p_ActionAssigned; - if (getActionAssigned() == boolOldActionAssigend) return false; - m_Confirmed = false; - return true; + if (m_ActionAssignedType == p_ActionAssigned) + return false; + bool boolOldActionAssigend; + boolOldActionAssigend = getActionAssigned(); + m_ActionAssignedType = p_ActionAssigned; + if (getActionAssigned() == boolOldActionAssigend) + return false; + m_Confirmed = false; + return true; } bool SPITObject::setActionAssigned(bool p_ActionAssigned) { - if (m_ActionAssigned == p_ActionAssigned) return false; - bool boolOldActionAssigend; - boolOldActionAssigend = getActionAssigned(); - m_ActionAssigned = p_ActionAssigned; - if (getActionAssigned() == boolOldActionAssigend) return false; - m_Confirmed = false; - return true; + if (m_ActionAssigned == p_ActionAssigned) + return false; + bool boolOldActionAssigend; + boolOldActionAssigend = getActionAssigned(); + m_ActionAssigned = p_ActionAssigned; + if (getActionAssigned() == boolOldActionAssigend) + return false; + m_Confirmed = false; + return true; } bool SPITObject::setFixed(bool p_Fixed) { - if (m_Fixed == p_Fixed) return false; - m_Fixed = p_Fixed; - m_Confirmed = false; - return true; + if (m_Fixed == p_Fixed) + return false; + m_Fixed = p_Fixed; + m_Confirmed = false; + return true; } bool SPITObject::setFrameStart(long long p_FrameStart) { - if (m_FrameStart == p_FrameStart) return false; - m_FrameStart = p_FrameStart; - m_Confirmed = false; - return true; + if (m_FrameStart == p_FrameStart) + return false; + m_FrameStart = p_FrameStart; + m_Confirmed = false; + return true; } bool SPITObject::setFrameLength(long long p_FrameLength) { - if (m_FrameLength == p_FrameLength) return false; - m_FrameLength = p_FrameLength; - m_Confirmed = false; - return true; + if (m_FrameLength == p_FrameLength) + return false; + m_FrameLength = p_FrameLength; + m_Confirmed = false; + return true; } -bool SPITObject::setFrameFadeInLength(long long p_FrameFadeInLength) { - if (m_FrameFadeInLength == p_FrameFadeInLength) return false; - m_FrameFadeInLength = p_FrameFadeInLength; - m_Confirmed = false; - return true; +bool SPITObject::setFrameFadeInLength(long long p_FrameFadeInLength) { + if (m_FrameFadeInLength == p_FrameFadeInLength) + return false; + m_FrameFadeInLength = p_FrameFadeInLength; + m_Confirmed = false; + return true; } bool SPITObject::setFrameFadeOutLength(long long p_FrameFadeOutLength) { - if (m_FrameFadeOutLength == p_FrameFadeOutLength) return false; - m_FrameFadeOutLength = p_FrameFadeOutLength; - m_Confirmed = false; - return true; + if (m_FrameFadeOutLength == p_FrameFadeOutLength) + return false; + m_FrameFadeOutLength = p_FrameFadeOutLength; + m_Confirmed = false; + return true; } bool SPITObject::setValueUse(char p_ValueUse) { - if (m_ValueUse == p_ValueUse) return false; - m_ValueUse = p_ValueUse; - m_Confirmed = false; - return true; + if (m_ValueUse == p_ValueUse) + return false; + m_ValueUse = p_ValueUse; + m_Confirmed = false; + return true; } bool SPITObject::setValueFactor(int p_ValueFactor) { - if (m_ValueFactor == p_ValueFactor) return false; - m_ValueFactor = p_ValueFactor; - m_Confirmed = false; - return true; + if (m_ValueFactor == p_ValueFactor) + return false; + m_ValueFactor = p_ValueFactor; + m_Confirmed = false; + return true; } bool SPITObject::setTrack(int p_Track) { - if (m_Track == p_Track) return false; - m_Track = p_Track; - m_Confirmed = false; - return true; + if (m_Track == p_Track) + return false; + m_Track = p_Track; + m_Confirmed = false; + return true; } bool SPITObject::setDelay(long long p_Delay) { - if (m_Delay == p_Delay) return false; - m_Delay = p_Delay; - m_Confirmed = false; - return true; + if (m_Delay == p_Delay) + return false; + m_Delay = p_Delay; + m_Confirmed = false; + return true; } bool SPITObject::setDuration(long long p_Duration) { - if (m_Duration == p_Duration) return false; - m_Duration = p_Duration; - m_Confirmed = false; - return true; + if (m_Duration == p_Duration) + return false; + m_Duration = p_Duration; + m_Confirmed = false; + return true; } diff --git a/components/spit/src/SPITPlayer.cpp b/components/spit/src/SPITPlayer.cpp index d8d3119..4f7a513 100644 --- a/components/spit/src/SPITPlayer.cpp +++ b/components/spit/src/SPITPlayer.cpp @@ -4,150 +4,134 @@ * and open the template in the editor. */ -/* +/* * SPITPlayer describes a virtual SPIT Player. * File: SPITPLayer.cpp * Author: Hagi - * + * * Created on 30. April 2019, 11:44 */ #include "SPITPlayer.h" #include -unordered_map SPITPlayer::s_SPITPlayers; +unordered_map SPITPlayer::s_SPITPlayers; -SPITPlayer* SPITPlayer::getSPITPlayer(string p_PlayerID) { - { - auto i = s_SPITPlayers.find(p_PlayerID); - if (i == s_SPITPlayers.end()) { - s_SPITPlayers[p_PlayerID] = new SPITPlayer(p_PlayerID); - } - i = s_SPITPlayers.find(p_PlayerID); - if (i == s_SPITPlayers.end()) return NULL; - return i->second; - } +SPITPlayer *SPITPlayer::getSPITPlayer(string p_PlayerID) { + { + auto i = s_SPITPlayers.find(p_PlayerID); + if (i == s_SPITPlayers.end()) { + s_SPITPlayers[p_PlayerID] = new SPITPlayer(p_PlayerID); + } + i = s_SPITPlayers.find(p_PlayerID); + if (i == s_SPITPlayers.end()) + return NULL; + return i->second; + } } void SPITPlayer::clearPlayers() { - ; - vector o_SPITPlayers; - for (auto i = s_SPITPlayers.begin(); i != s_SPITPlayers.end(); i++) { - SPITPlayer* ptrSPITPlayer = i->second; - o_SPITPlayers.push_back(ptrSPITPlayer); - } - for (auto i = o_SPITPlayers.begin(); i != o_SPITPlayers.end(); i++) { - SPITPlayer* ptrSPITPlayer = *i; - delete ptrSPITPlayer; - } - o_SPITPlayers.clear(); + ; + vector o_SPITPlayers; + for (auto i = s_SPITPlayers.begin(); i != s_SPITPlayers.end(); i++) { + SPITPlayer *ptrSPITPlayer = i->second; + o_SPITPlayers.push_back(ptrSPITPlayer); + } + for (auto i = o_SPITPlayers.begin(); i != o_SPITPlayers.end(); i++) { + SPITPlayer *ptrSPITPlayer = *i; + delete ptrSPITPlayer; + } + o_SPITPlayers.clear(); } SPITPlayer::SPITPlayer(string p_PlayerID) { - m_ID = p_PlayerID; - s_SPITPlayers[p_PlayerID] = this; + m_ID = p_PlayerID; + s_SPITPlayers[p_PlayerID] = this; } SPITPlayer::~SPITPlayer() { - PlaySPITType* ptrPlaySPITType; - for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) { - ptrPlaySPITType = i->second; - i = m_PlaySPITTypes.erase(i); - delete ptrPlaySPITType; - if (i == m_PlaySPITTypes.end()) { - break; - } - } - + PlaySPITType *ptrPlaySPITType; + for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) { + ptrPlaySPITType = i->second; + i = m_PlaySPITTypes.erase(i); + delete ptrPlaySPITType; + if (i == m_PlaySPITTypes.end()) { + break; + } + } } -void SPITPlayer::setIsRunning(bool p_IsRunning) { - m_IsRunning = p_IsRunning; -} -void SPITPlayer::setName(string p_Name) { - m_Name = p_Name; -} -void SPITPlayer::setType(char p_Type) { - m_Type = p_Type; -} -void SPITPlayer::setTime(long long p_Frames) { - m_TimeFrames = p_Frames; -} - -unordered_map* SPITPlayer::getPlaySPITTypes() { - return &m_PlaySPITTypes; +unordered_map *SPITPlayer::getPlaySPITTypes() { + return &m_PlaySPITTypes; } /** - * + * * @param p_SPITObjectID * @return true = new PlayObject added
- * false = PlayObject exists + * false = PlayObject exists */ -SPITPlayer::PlaySPITType* SPITPlayer::addSPITType_Playing (string p_SPITTypeID) { - PlaySPITType* ptrPlaySPITType; - - auto i = m_PlaySPITTypes.find(p_SPITTypeID); - if (i == m_PlaySPITTypes.end()) { - ptrPlaySPITType = new PlaySPITType(this, p_SPITTypeID); - ptrPlaySPITType->setIsPlayed(true); - ptrPlaySPITType->setIsNew(true); - m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType; - } - else { - ptrPlaySPITType = i->second; - ptrPlaySPITType->setIsPlayed(true); - } - return ptrPlaySPITType; - +SPITPlayer::PlaySPITType *SPITPlayer::addSPITType_Playing(string p_SPITTypeID) { + PlaySPITType *ptrPlaySPITType; + + auto i = m_PlaySPITTypes.find(p_SPITTypeID); + if (i == m_PlaySPITTypes.end()) { + ptrPlaySPITType = new PlaySPITType(this, p_SPITTypeID); + ptrPlaySPITType->setIsPlayed(true); + ptrPlaySPITType->setIsNew(true); + m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType; + } else { + ptrPlaySPITType = i->second; + ptrPlaySPITType->setIsPlayed(true); + } + return ptrPlaySPITType; } void SPITPlayer::startPlaySequence() { - PlaySPITType* ptrPlaySPITType; - for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) { - ptrPlaySPITType = i->second; - ptrPlaySPITType->startPlaySequence(); - } + PlaySPITType *ptrPlaySPITType; + for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) { + ptrPlaySPITType = i->second; + ptrPlaySPITType->startPlaySequence(); + } } void SPITPlayer::endPlaySequence() { - PlaySPITType* ptrPlaySPITType; - - for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) { - ptrPlaySPITType = i->second; - if (ptrPlaySPITType->getIsPlayed() == false) { - i = m_PlaySPITTypes.erase(i); - delete ptrPlaySPITType; - if (i == m_PlaySPITTypes.end()) { - break; - } - } - } - + PlaySPITType *ptrPlaySPITType; + + for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) { + ptrPlaySPITType = i->second; + if (ptrPlaySPITType->getIsPlayed() == false) { + i = m_PlaySPITTypes.erase(i); + delete ptrPlaySPITType; + if (i == m_PlaySPITTypes.end()) { + break; + } + } + } } SPITPlayer::PlaySPITType::PlaySPITType() { } -SPITPlayer::PlaySPITType::PlaySPITType(SPITPlayer* p_SPITPlayer, string p_SPITTypeID) { - m_SPITTypeID = p_SPITTypeID; - m_PlayerID = p_SPITPlayer->getID(); - m_PlayerName = p_SPITPlayer->getName(); - startPlaySequence(); - m_IsNew = true; +SPITPlayer::PlaySPITType::PlaySPITType(SPITPlayer *p_SPITPlayer, string p_SPITTypeID) { + m_SPITTypeID = p_SPITTypeID; + m_PlayerID = p_SPITPlayer->getID(); + m_PlayerName = p_SPITPlayer->getName(); + startPlaySequence(); + m_IsNew = true; } -SPITPlayer::PlaySPITType::PlaySPITType(const PlaySPITType& orig) { - m_SPITTypeID = orig.getSPITTypeID(); - m_IsPlayed = orig.getIsPlayed(); - m_IsNew = orig.getIsNew(); +SPITPlayer::PlaySPITType::PlaySPITType(const PlaySPITType &orig) { + m_SPITTypeID = orig.getSPITTypeID(); + m_IsPlayed = orig.getIsPlayed(); + m_IsNew = orig.getIsNew(); - m_PlayerID = orig.getPlayerID(); - m_PlayerName = orig.getPlayerName(); - m_PlayerRuns = orig.getPlayerIsRunning(); + m_PlayerID = orig.getPlayerID(); + m_PlayerName = orig.getPlayerName(); + m_PlayerRuns = orig.getPlayerIsRunning(); - m_Value = orig.getValue(); + m_Value = orig.getValue(); } void SPITPlayer::PlaySPITType::startPlaySequence() { - m_IsPlayed = false; - m_IsNew = false; - - m_Value = 0; + m_IsPlayed = false; + m_IsNew = false; + + m_Value = 0; } \ No newline at end of file diff --git a/components/spit/src/SPITSocket.cpp b/components/spit/src/SPITSocket.cpp index 0d05480..b93b695 100644 --- a/components/spit/src/SPITSocket.cpp +++ b/components/spit/src/SPITSocket.cpp @@ -15,11 +15,11 @@ #include "SPITSocket.h" #include "Task.hpp" +#include "esp/uuid.h" #include "esp_log.h" #include "esp_netif.h" -#include "esp/uuid.h" -#include #include +#include using namespace std; /** @@ -43,14 +43,14 @@ bool SPITSocket::createSocket_UDP() { } else { intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_REUSEADDR, (void *)&intOptionValue4, sizeof(intOptionValue4)); } - if (intResult < 0) { - boolSuccess = false; - } + if (intResult < 0) { + boolSuccess = false; + } if (boolSuccess == true) { struct timeval tv; - tv.tv_sec = 1; // seconds - tv.tv_usec = 0; // microseconds (0.0 sec) + tv.tv_sec = 1; // seconds + tv.tv_usec = 0; // microseconds (0.0 sec) // This sets the receive timeout setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); @@ -61,8 +61,8 @@ bool SPITSocket::createSocket_UDP() { // fcntl(m_UDPSocketIP4, F_SETFL, intFlags | O_NONBLOCK); // int intBufferSize = 2046 * 512; - // intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVBUF, (void*)&intBufferSize, sizeof(intBufferSize)); - // intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_SNDBUF, (void*)&intBufferSize, sizeof(intBufferSize)); + // intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVBUF, (void*)&intBufferSize, sizeof(intBufferSize)); + // intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_SNDBUF, (void*)&intBufferSize, sizeof(intBufferSize)); } return boolSuccess; } @@ -186,8 +186,8 @@ int SPITSocket::sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Serv intResult = sendto(m_UDPSocketIP4, p_MessageBytes, p_MessageLength, 0, (const sockaddr *)&o_IP4SocketAddress, (socklen_t)intSocklen); if (intResult < 0) { printf("UnixSocket::sendMessageTo IP4 sendto %s FAILED %s\n", p_ServerIP.data(), strerror(errno)); - printf("UnixSocket::sendMessageTo ret=%d %s / %s / %d\n", intResult, - p_ServerPort.data(), p_MessageBytes, p_MessageLength); + printf("UnixSocket::sendMessageTo ret=%d %s / %s / %d\n", intResult, + p_ServerPort.data(), p_MessageBytes, p_MessageLength); } freeaddrinfo(ptrAddressInfo); } @@ -196,23 +196,23 @@ int SPITSocket::sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Serv intResult = -1; } - if (intResult < 0) { - return -1; - } + if (intResult < 0) { + return -1; + } return 0; } - /** - * Call this for receiving a message - * This will block until a message is received or the underlying socket is closed - * @param p_InetFamily either AF_INET or AF_INET6
- * The SPITSocket creates two udp sockets, one for IP4 and one for IP6 - * This parameter decides from which socket should a message recieved - * @param p_Buffer the buffer containing the received message later. - * @param p_BufferLength the size of the buffer - * @param p_ServerIP a pointer to a string, when a messages is received the string will contain the ip address of the sender/server - * if p_ServerIP is NULL - no detection of the server will be done. - * @return - */ +/** + * Call this for receiving a message + * This will block until a message is received or the underlying socket is closed + * @param p_InetFamily either AF_INET or AF_INET6
+ * The SPITSocket creates two udp sockets, one for IP4 and one for IP6 + * This parameter decides from which socket should a message recieved + * @param p_Buffer the buffer containing the received message later. + * @param p_BufferLength the size of the buffer + * @param p_ServerIP a pointer to a string, when a messages is received the string will contain the ip address of the sender/server + * if p_ServerIP is NULL - no detection of the server will be done. + * @return + */ int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLength, string *p_ServerIP) { int intResult = -1; // ADDRINFO *AI; @@ -226,7 +226,7 @@ int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLen } intSocklen = sizeof(o_IP4SocketAddress); memset(&o_IP4SocketAddress, 0, intSocklen); - intResult = recvfrom(m_UDPSocketIP4, (void *)p_Buffer, p_BufferLength, 0 , (sockaddr *)&o_IP4SocketAddress, (socklen_t *)&intSocklen); + intResult = recvfrom(m_UDPSocketIP4, (void *)p_Buffer, p_BufferLength, 0, (sockaddr *)&o_IP4SocketAddress, (socklen_t *)&intSocklen); if (intResult >= 0) { if (p_ServerIP != NULL) { char bufferIP4[INET_ADDRSTRLEN]; @@ -239,7 +239,6 @@ int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLen return intResult; } - SPITSocket::IPAddress SPITSocket::getAdaptersInfo() { // iterate over active interfaces, and print out IPs esp_netif_t *netif = NULL; @@ -261,12 +260,12 @@ SPITSocket::IPAddress SPITSocket::getAdaptersInfo() { } string createGUID() { - // uuid_t id; - // uuid_generate(id); - // char *guid_string = new char[100]; - // uuid_unparse(id, guid_string); - // string stringGUID = guid_string; - // return stringGUID; + // uuid_t id; + // uuid_generate(id); + // char *guid_string = new char[100]; + // uuid_unparse(id, guid_string); + // string stringGUID = guid_string; + // return stringGUID; uuid_t uu; char uu_str[UUID_STR_LEN]; @@ -274,15 +273,16 @@ string createGUID() { uuid_generate(uu); uuid_unparse(uu, uu_str); string stringGUID = uu_str; - return stringGUID; + return stringGUID; } /** The name of the client's host computer*/ string getClientHostName() { - string stringHostName = ""; - const char * hostname; - esp_netif_get_hostname(esp_netif_get_default_netif(), &hostname); - if (hostname != nullptr) { - stringHostName = hostname; - } - return stringHostName;; + string stringHostName = ""; + const char *hostname; + esp_netif_get_hostname(esp_netif_get_default_netif(), &hostname); + if (hostname != nullptr) { + stringHostName = hostname; + } + return stringHostName; + ; } diff --git a/components/spit/src/SPITType.cpp b/components/spit/src/SPITType.cpp index 5e71ea2..6883456 100644 --- a/components/spit/src/SPITType.cpp +++ b/components/spit/src/SPITType.cpp @@ -4,447 +4,455 @@ * and open the template in the editor. */ -/* +/* * SPITType describes a SPIT Type * File: SPITType.cpp * Author: Hagi - * + * * Created on 8. April 2019, 08:40 */ - #include "SPITType.h" #include "esp_log.h" -static const char * TAG = "SPIT"; +static const char *TAG = "SPIT"; - unordered_map SPITType::s_SPITTypes; - unordered_map SPITType::s_SPITTypesRemote; - - SPITType* SPITType::getSPITType(string p_ID) { - { - auto i = s_SPITTypes.find(p_ID); - if (i == s_SPITTypes.end()) { - return NULL; - } - return i->second; - } - } - /** - * Returns the reference of the SPITType with ID == p_ID.
- * Throws an exception if no SPITType is not found.
- * @param p_ID the ID - * @return reference of the SPITType with ID == p_ID - */ - const SPITType& SPITType::getSPITTypeRef(string p_ID) { - { - auto i = s_SPITTypes.find(p_ID); - if (i == s_SPITTypes.end()) { - throw "SPITType no SPITType with given ID"; - } - return *(i->second); - } - } +unordered_map SPITType::s_SPITTypes; +unordered_map SPITType::s_SPITTypesRemote; - SPITType* SPITType::getSPITTypeRemote(string p_ID) { - { - auto i = s_SPITTypesRemote.find(p_ID); - if (i == s_SPITTypesRemote.end()) { - return NULL; - } - return i->second; - } - } - /** - * Returns the reference of the remote SPITType with ID == p_ID.
- * Throws an exception if no SPITType is not found.
- * @param p_ID the ID - * @return reference of the SPITType with ID == p_ID - */ - const SPITType& SPITType::getSPITTypeRemoteRef(string p_ID) { - { - auto i = s_SPITTypesRemote.find(p_ID); - if (i == s_SPITTypesRemote.end()) { - throw "Remote SPITType no SPITType with given ID"; - } - return *(i->second); - } - } +SPITType *SPITType::getSPITType(string p_ID) { + { + auto i = s_SPITTypes.find(p_ID); + if (i == s_SPITTypes.end()) { + return NULL; + } + return i->second; + } +} +/** + * Returns the reference of the SPITType with ID == p_ID.
+ * Throws an exception if no SPITType is not found.
+ * @param p_ID the ID + * @return reference of the SPITType with ID == p_ID + */ +const SPITType &SPITType::getSPITTypeRef(string p_ID) { + { + auto i = s_SPITTypes.find(p_ID); + if (i == s_SPITTypes.end()) { + throw "SPITType no SPITType with given ID"; + } + return *(i->second); + } +} - bool SPITType::addSPITType(SPITType* p_ptrSpitType) { - if (p_ptrSpitType == NULL) return false; - { - s_SPITTypes[p_ptrSpitType->getID()] = p_ptrSpitType; - return true; - } - } - bool SPITType::addSPITTypeRemote(SPITType* p_ptrSpitType) { - if (p_ptrSpitType == NULL) return false; - { - s_SPITTypesRemote[p_ptrSpitType->getID()] = p_ptrSpitType; - return true; - } - } - bool SPITType::removeSPITType(SPITType* p_ptrSpitType) { - if (p_ptrSpitType == NULL) return false; - { - auto i = s_SPITTypes.find(p_ptrSpitType->getID()); - if (i == s_SPITTypes.end()) { - return false; - } - i = s_SPITTypes.erase(i); - return true; - } - } - bool SPITType::removeSPITTypeRemote(SPITType* p_ptrSpitType) { - if (p_ptrSpitType == NULL) return false; - { - auto i = s_SPITTypesRemote.find(p_ptrSpitType->getID()); - if (i == s_SPITTypesRemote.end()) { - return false; - } - i = s_SPITTypesRemote.erase(i); - return true; - } - } +SPITType *SPITType::getSPITTypeRemote(string p_ID) { + { + auto i = s_SPITTypesRemote.find(p_ID); + if (i == s_SPITTypesRemote.end()) { + return NULL; + } + return i->second; + } +} +/** + * Returns the reference of the remote SPITType with ID == p_ID.
+ * Throws an exception if no SPITType is not found.
+ * @param p_ID the ID + * @return reference of the SPITType with ID == p_ID + */ +const SPITType &SPITType::getSPITTypeRemoteRef(string p_ID) { + { + auto i = s_SPITTypesRemote.find(p_ID); + if (i == s_SPITTypesRemote.end()) { + throw "Remote SPITType no SPITType with given ID"; + } + return *(i->second); + } +} - int SPITType::getSPITTypeCount() { - return s_SPITTypes.size(); - } - int SPITType::getSPITTypeRemoteCount() { - return s_SPITTypesRemote.size(); - } - SPITType* SPITType::getSPITType(int p_Index) { - SPITType* ptrSPITType = NULL; - { - if (p_Index < s_SPITTypes.size()) { - unordered_map::iterator i = next(s_SPITTypes.begin(), p_Index); - ptrSPITType = i->second; - } - return ptrSPITType; - } - } - /** - * Returns a reference to the SPITType at position p_Index.
- * Throws an exception if p_Index is out of range.
- * @param p_Index position - * @return the reference of the SPITType at position. - */ - const SPITType& SPITType::getSPITTypeRef(int p_Index) { - SPITType* ptrSPITType = NULL; - { - if (p_Index >= 0 && p_Index < s_SPITTypes.size()) { - unordered_map::iterator i = next(s_SPITTypes.begin(), p_Index); - ptrSPITType = i->second; - return *ptrSPITType; - } - else { - throw "SPITType index out of range"; - } - } - } - SPITType* SPITType::getSPITTypeRemote(int p_Index) { - SPITType* ptrSPITType = NULL; - { - if (p_Index < s_SPITTypesRemote.size()) { - unordered_map::iterator i = next(s_SPITTypesRemote.begin(), p_Index); - ptrSPITType = i->second; - } - return ptrSPITType; - } - } - /** - * Returns a reference to the remote SPITType at position p_Index.
- * Throws an exception if p_Index is out of range.
- * @param p_Index position - * @return the reference of the SPITType at position. - */ - const SPITType& SPITType::getSPITTypeRemoteRef(int p_Index) { - SPITType* ptrSPITType = NULL; - { - if (p_Index >= 0 && p_Index < s_SPITTypesRemote.size()) { - unordered_map::iterator i = next(s_SPITTypesRemote.begin(), p_Index); - ptrSPITType = i->second; - return *ptrSPITType; - } - else { - throw "Remote SPITType index out of range"; - } - } - } - - void SPITType::clearSPITTypes() { - SPITType* ptrSPITType; - { - for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) { - ptrSPITType = i->second; - i = s_SPITTypes.erase(i); - delete ptrSPITType; - if (i == s_SPITTypes.end()) { - break; - } - } - } - } - void SPITType::clearSPITTypesRemote() { - SPITType* ptrSPITType; - { - for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) { - ptrSPITType = i->second; - i = s_SPITTypesRemote.erase(i); - delete ptrSPITType; - if (i == s_SPITTypesRemote.end()) { - break; - } - } - } - } - - void SPITType::eventProjectClosed() { - SPITType* ptrSPITType; - for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) { - ptrSPITType = i->second; - if (ptrSPITType->getCreatedByClient() == true) { - continue; - } - i = s_SPITTypes.erase(i); - delete ptrSPITType; - if (i == s_SPITTypes.end()) { - break; - } - } - //Remote - for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) { - ptrSPITType = i->second; - i = s_SPITTypesRemote.erase(i); - delete ptrSPITType; - if (i == s_SPITTypesRemote.end()) { - break; - } - } - } +bool SPITType::addSPITType(SPITType *p_ptrSpitType) { + if (p_ptrSpitType == NULL) + return false; + { + s_SPITTypes[p_ptrSpitType->getID()] = p_ptrSpitType; + return true; + } +} +bool SPITType::addSPITTypeRemote(SPITType *p_ptrSpitType) { + if (p_ptrSpitType == NULL) + return false; + { + s_SPITTypesRemote[p_ptrSpitType->getID()] = p_ptrSpitType; + return true; + } +} +bool SPITType::removeSPITType(SPITType *p_ptrSpitType) { + if (p_ptrSpitType == NULL) + return false; + { + auto i = s_SPITTypes.find(p_ptrSpitType->getID()); + if (i == s_SPITTypes.end()) { + return false; + } + i = s_SPITTypes.erase(i); + return true; + } +} +bool SPITType::removeSPITTypeRemote(SPITType *p_ptrSpitType) { + if (p_ptrSpitType == NULL) + return false; + { + auto i = s_SPITTypesRemote.find(p_ptrSpitType->getID()); + if (i == s_SPITTypesRemote.end()) { + return false; + } + i = s_SPITTypesRemote.erase(i); + return true; + } +} + +int SPITType::getSPITTypeCount() { + return s_SPITTypes.size(); +} +int SPITType::getSPITTypeRemoteCount() { + return s_SPITTypesRemote.size(); +} +SPITType *SPITType::getSPITType(int p_Index) { + SPITType *ptrSPITType = NULL; + { + if (p_Index < s_SPITTypes.size()) { + unordered_map::iterator i = next(s_SPITTypes.begin(), p_Index); + ptrSPITType = i->second; + } + return ptrSPITType; + } +} +/** + * Returns a reference to the SPITType at position p_Index.
+ * Throws an exception if p_Index is out of range.
+ * @param p_Index position + * @return the reference of the SPITType at position. + */ +const SPITType &SPITType::getSPITTypeRef(int p_Index) { + SPITType *ptrSPITType = NULL; + { + if (p_Index >= 0 && p_Index < s_SPITTypes.size()) { + unordered_map::iterator i = next(s_SPITTypes.begin(), p_Index); + ptrSPITType = i->second; + return *ptrSPITType; + } else { + throw "SPITType index out of range"; + } + } +} +SPITType *SPITType::getSPITTypeRemote(int p_Index) { + SPITType *ptrSPITType = NULL; + { + if (p_Index < s_SPITTypesRemote.size()) { + unordered_map::iterator i = next(s_SPITTypesRemote.begin(), p_Index); + ptrSPITType = i->second; + } + return ptrSPITType; + } +} +/** + * Returns a reference to the remote SPITType at position p_Index.
+ * Throws an exception if p_Index is out of range.
+ * @param p_Index position + * @return the reference of the SPITType at position. + */ +const SPITType &SPITType::getSPITTypeRemoteRef(int p_Index) { + SPITType *ptrSPITType = NULL; + { + if (p_Index >= 0 && p_Index < s_SPITTypesRemote.size()) { + unordered_map::iterator i = next(s_SPITTypesRemote.begin(), p_Index); + ptrSPITType = i->second; + return *ptrSPITType; + } else { + throw "Remote SPITType index out of range"; + } + } +} + +void SPITType::clearSPITTypes() { + SPITType *ptrSPITType; + { + for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) { + ptrSPITType = i->second; + i = s_SPITTypes.erase(i); + delete ptrSPITType; + if (i == s_SPITTypes.end()) { + break; + } + } + } +} +void SPITType::clearSPITTypesRemote() { + SPITType *ptrSPITType; + { + for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) { + ptrSPITType = i->second; + i = s_SPITTypesRemote.erase(i); + delete ptrSPITType; + if (i == s_SPITTypesRemote.end()) { + break; + } + } + } +} + +void SPITType::eventProjectClosed() { + SPITType *ptrSPITType; + for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) { + ptrSPITType = i->second; + if (ptrSPITType->getCreatedByClient() == true) { + continue; + } + i = s_SPITTypes.erase(i); + delete ptrSPITType; + if (i == s_SPITTypes.end()) { + break; + } + } + // Remote + for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) { + ptrSPITType = i->second; + i = s_SPITTypesRemote.erase(i); + delete ptrSPITType; + if (i == s_SPITTypesRemote.end()) { + break; + } + } +} + +/** + * Sets confirmed = false for all SPITTypes.
+ * This should be called when the client has loaded a project.
+ */ +void SPITType::setConfirmedFalse() { + SPITType *ptrSPITType; + { + for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) { + ptrSPITType = i->second; + ptrSPITType->setConfirmed(false); + } + } +} - /** - * Sets confirmed = false for all SPITTypes.
- * This should be called when the client has loaded a project.
- */ - void SPITType::setConfirmedFalse() { - SPITType* ptrSPITType; - { - for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) { - ptrSPITType = i->second; - ptrSPITType->setConfirmed(false); - } - } - } - - - - - - SPITType::SPITType() { - initMembers(); + initMembers(); } /* SPITType::SPITType(const SPITType& orig) { - m_Confirmed = orig.getConfirmed(); - m_DefaultDelay = orig.getDefaultDelay(); - m_DefaultDuration = orig.getDefaultDuration(); - m_Fixed = orig.getFixed(); - m_GroupName = orig.getGroupName(); - m_ID = orig.getID(); - m_Name = orig.getName(); - m_ServerProjectIndepended = orig.getProjectIndepended(); - m_ServerRemote = orig.getServerRemote(); + m_Confirmed = orig.getConfirmed(); + m_DefaultDelay = orig.getDefaultDelay(); + m_DefaultDuration = orig.getDefaultDuration(); + m_Fixed = orig.getFixed(); + m_GroupName = orig.getGroupName(); + m_ID = orig.getID(); + m_Name = orig.getName(); + m_ServerProjectIndepended = orig.getProjectIndepended(); + m_ServerRemote = orig.getServerRemote(); } */ -SPITType::SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended,long long p_DefaultDelay, long long p_DefaultDuration) { - initMembers(); - m_ActionAssigned = false; - m_Confirmed = false; - m_ID = p_ID; - m_GroupName = p_GroupName; - m_Name = p_Name; - m_Fixed = p_Fixed; - m_ServerProjectIndepended = p_ProjectIndepended; - m_DefaultDelay = p_DefaultDelay; - m_DefaultDuration = p_DefaultDuration; +SPITType::SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended, long long p_DefaultDelay, long long p_DefaultDuration) { + initMembers(); + m_ActionAssigned = false; + m_Confirmed = false; + m_ID = p_ID; + m_GroupName = p_GroupName; + m_Name = p_Name; + m_Fixed = p_Fixed; + m_ServerProjectIndepended = p_ProjectIndepended; + m_DefaultDelay = p_DefaultDelay; + m_DefaultDuration = p_DefaultDuration; } SPITType::~SPITType() { } void SPITType::initMembers() { - m_Confirmed = false; - m_DefaultDelay = 0; - m_DefaultDuration = 0; - m_Fixed = false; - m_GroupName = ""; - m_ID = createGUID(); - m_Name = ""; - m_ServerProjectIndepended = false; - m_ServerRemote = false; + m_Confirmed = false; + m_DefaultDelay = 0; + m_DefaultDuration = 0; + m_Fixed = false; + m_GroupName = ""; + m_ID = createGUID(); + m_Name = ""; + m_ServerProjectIndepended = false; + m_ServerRemote = false; } - - void SPITType::setCreatedByClient(bool p_CreatedByClient) { - m_CreatedByClient = p_CreatedByClient; + m_CreatedByClient = p_CreatedByClient; } +void SPITType::setID(string p_ID) { + m_ID = p_ID; +} - void SPITType::setID(string p_ID) { - m_ID = p_ID; - } - - /** - * This is used by the server and client to tell if the other side has registered the changes. - * @param p_Confirmed - * @return if m_Confirmed has changed - */ - bool SPITType::setConfirmed(bool p_Confirmed) { - if (m_Confirmed == p_Confirmed) return false; - m_Confirmed = p_Confirmed; - return true; - } - - bool SPITType::setGroupName(string p_GroupName) { - if (m_GroupName == p_GroupName) return false; - m_GroupName = p_GroupName; - m_Confirmed = false; - return true; - } - bool SPITType::setName(string p_Name) { - if (m_Name == p_Name) return false; - m_Name = p_Name; - m_Confirmed = false; - return true; - } - bool SPITType::setServerRemote(bool p_BelongstoServer) { - if (m_ServerRemote == p_BelongstoServer) return false; - m_ServerRemote = p_BelongstoServer; - m_Confirmed = false; - return true; - } - bool SPITType::setProjectIndepended(bool p_ProjectIndepended) { - if (m_ServerProjectIndepended == p_ProjectIndepended) return false; - m_ServerProjectIndepended = p_ProjectIndepended; - m_Confirmed = false; - return true; - } - bool SPITType::setFixed(bool p_Fixed) { - if (m_Fixed == p_Fixed) return false; - m_Fixed = p_Fixed; - m_Confirmed = false; - return true; - } - bool SPITType::setDefaultDelay(long long p_Delay) { - if (m_DefaultDelay == p_Delay) return false; - m_DefaultDelay = p_Delay; - m_Confirmed = false; - return true; - } - bool SPITType::setDefaultDuration(long long p_Duration) { - if (m_DefaultDuration == p_Duration) return false; - m_DefaultDuration = p_Duration; - m_Confirmed = false; - return true; - } - - /** - * Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
- * This can used to setActionAssigned to all SPITObjects with this SPITType.
- * This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.
- * @return true = the m_ActionAssigned has changed. - */ - bool SPITType::setActionAssigned(bool p_ActionAssigned) { - if (m_ActionAssigned == p_ActionAssigned) return false; - m_ActionAssigned = p_ActionAssigned; - m_Confirmed = false; - return true; - } +/** + * This is used by the server and client to tell if the other side has registered the changes. + * @param p_Confirmed + * @return if m_Confirmed has changed + */ +bool SPITType::setConfirmed(bool p_Confirmed) { + if (m_Confirmed == p_Confirmed) + return false; + m_Confirmed = p_Confirmed; + return true; +} - /** - * Set the content of the SPITType as received from the server - * @param p_ReportSPITType - * @return true = the SPITType is changed
- * false = the SPITType is NOT changed, because it is not allowed to change. - */ - bool SPITType::setMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType) { - bool boolChangeAllowed; - bool boolChanged = false; - - if (m_CreatedByClient == true && m_Fixed == true) { - boolChangeAllowed = false; - } - else { - boolChangeAllowed = true; - } - - //Confirmation should be changable - if (m_CreatedByClient) { - //Server reports a client created SPITType -> the type is confirmed - m_Confirmed = true; - } - else { - //type is NOT client created -> the client has to confirm the SPITtype - m_Confirmed = p_ReportSPITType->getConfirmed(); - } - if (m_DefaultDelay != p_ReportSPITType->getDelay()) { - if (boolChangeAllowed == false) throw new exception(); - m_DefaultDelay = p_ReportSPITType->getDelay(); - boolChanged = true; - } - if (m_DefaultDuration != p_ReportSPITType->getDuration()) { - if (boolChangeAllowed == false) throw new exception(); - m_DefaultDuration = p_ReportSPITType->getDuration(); - boolChanged = true; - } - if (m_Fixed != p_ReportSPITType->getFixed()) { - if (boolChangeAllowed == false) throw new exception(); - m_Fixed = p_ReportSPITType->getFixed(); - boolChanged = true; - } - if (m_GroupName != p_ReportSPITType->getGroupName()) { - if (boolChangeAllowed == false) throw new exception(); - m_GroupName = p_ReportSPITType->getGroupName(); - boolChanged = true; - } - if (m_ID != p_ReportSPITType->getID()) { - if (boolChangeAllowed == false) throw new exception(); - m_ID = p_ReportSPITType->getID(); - boolChanged = true; - } - if (m_Name != p_ReportSPITType->getName()) { - if (boolChangeAllowed == false) throw new exception(); - m_Name = p_ReportSPITType->getName(); - boolChanged = true; - } - if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) { - if (boolChangeAllowed == false) throw new exception(); - m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended(); - boolChanged = true; - } - if (m_ServerRemote != p_ReportSPITType->getServerRemote()) { - if (boolChangeAllowed == false) throw new exception(); - m_ServerRemote = p_ReportSPITType->getServerRemote(); - boolChanged = true; - } - return boolChanged; - } - - void SPITType::fillMessageOP(SPIT_Message::ReportSPITType* ptrSMReportSPITType) { - ptrSMReportSPITType->setConfirmed(m_Confirmed); - ptrSMReportSPITType->setDelay(m_DefaultDelay); - ptrSMReportSPITType->setDuration(m_DefaultDuration); - ptrSMReportSPITType->setFixed(m_Fixed); - ptrSMReportSPITType->setGroupName(m_GroupName); - ptrSMReportSPITType->setID(m_ID); - ptrSMReportSPITType->setName(m_Name); - ptrSMReportSPITType->setServerProjectIndepended(m_ServerProjectIndepended); - ptrSMReportSPITType->setServerRemote(m_ServerRemote); - } - void SPITType::fillMessageOP(SPIT_Message::RemoveSPITType* ptrSMRemoveSPITType) { - ptrSMRemoveSPITType->setID(m_ID); - } +bool SPITType::setGroupName(string p_GroupName) { + if (m_GroupName == p_GroupName) + return false; + m_GroupName = p_GroupName; + m_Confirmed = false; + return true; +} +bool SPITType::setName(string p_Name) { + if (m_Name == p_Name) + return false; + m_Name = p_Name; + m_Confirmed = false; + return true; +} +bool SPITType::setServerRemote(bool p_BelongstoServer) { + if (m_ServerRemote == p_BelongstoServer) + return false; + m_ServerRemote = p_BelongstoServer; + m_Confirmed = false; + return true; +} +bool SPITType::setProjectIndepended(bool p_ProjectIndepended) { + if (m_ServerProjectIndepended == p_ProjectIndepended) + return false; + m_ServerProjectIndepended = p_ProjectIndepended; + m_Confirmed = false; + return true; +} +bool SPITType::setFixed(bool p_Fixed) { + if (m_Fixed == p_Fixed) + return false; + m_Fixed = p_Fixed; + m_Confirmed = false; + return true; +} +bool SPITType::setDefaultDelay(long long p_Delay) { + if (m_DefaultDelay == p_Delay) + return false; + m_DefaultDelay = p_Delay; + m_Confirmed = false; + return true; +} +bool SPITType::setDefaultDuration(long long p_Duration) { + if (m_DefaultDuration == p_Duration) + return false; + m_DefaultDuration = p_Duration; + m_Confirmed = false; + return true; +} + +/** + * Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
+ * This can used to setActionAssigned to all SPITObjects with this SPITType.
+ * This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.
+ * @return true = the m_ActionAssigned has changed. + */ +bool SPITType::setActionAssigned(bool p_ActionAssigned) { + if (m_ActionAssigned == p_ActionAssigned) + return false; + m_ActionAssigned = p_ActionAssigned; + m_Confirmed = false; + return true; +} + +/** + * Set the content of the SPITType as received from the server + * @param p_ReportSPITType + * @return true = the SPITType is changed
+ * false = the SPITType is NOT changed, because it is not allowed to change. + */ +bool SPITType::setMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType) { + bool boolChangeAllowed; + bool boolChanged = false; + + if (m_CreatedByClient == true && m_Fixed == true) { + boolChangeAllowed = false; + } else { + boolChangeAllowed = true; + } + + // Confirmation should be changable + if (m_CreatedByClient) { + // Server reports a client created SPITType -> the type is confirmed + m_Confirmed = true; + } else { + // type is NOT client created -> the client has to confirm the SPITtype + m_Confirmed = p_ReportSPITType->getConfirmed(); + } + if (m_DefaultDelay != p_ReportSPITType->getDelay()) { + if (boolChangeAllowed == false) + throw new exception(); + m_DefaultDelay = p_ReportSPITType->getDelay(); + boolChanged = true; + } + if (m_DefaultDuration != p_ReportSPITType->getDuration()) { + if (boolChangeAllowed == false) + throw new exception(); + m_DefaultDuration = p_ReportSPITType->getDuration(); + boolChanged = true; + } + if (m_Fixed != p_ReportSPITType->getFixed()) { + if (boolChangeAllowed == false) + throw new exception(); + m_Fixed = p_ReportSPITType->getFixed(); + boolChanged = true; + } + if (m_GroupName != p_ReportSPITType->getGroupName()) { + if (boolChangeAllowed == false) + throw new exception(); + m_GroupName = p_ReportSPITType->getGroupName(); + boolChanged = true; + } + if (m_ID != p_ReportSPITType->getID()) { + if (boolChangeAllowed == false) + throw new exception(); + m_ID = p_ReportSPITType->getID(); + boolChanged = true; + } + if (m_Name != p_ReportSPITType->getName()) { + if (boolChangeAllowed == false) + throw new exception(); + m_Name = p_ReportSPITType->getName(); + boolChanged = true; + } + if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) { + if (boolChangeAllowed == false) + throw new exception(); + m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended(); + boolChanged = true; + } + if (m_ServerRemote != p_ReportSPITType->getServerRemote()) { + if (boolChangeAllowed == false) + throw new exception(); + m_ServerRemote = p_ReportSPITType->getServerRemote(); + boolChanged = true; + } + return boolChanged; +} + +void SPITType::fillMessageOP(SPIT_Message::ReportSPITType *ptrSMReportSPITType) { + ptrSMReportSPITType->setConfirmed(m_Confirmed); + ptrSMReportSPITType->setDelay(m_DefaultDelay); + ptrSMReportSPITType->setDuration(m_DefaultDuration); + ptrSMReportSPITType->setFixed(m_Fixed); + ptrSMReportSPITType->setGroupName(m_GroupName); + ptrSMReportSPITType->setID(m_ID); + ptrSMReportSPITType->setName(m_Name); + ptrSMReportSPITType->setServerProjectIndepended(m_ServerProjectIndepended); + ptrSMReportSPITType->setServerRemote(m_ServerRemote); +} +void SPITType::fillMessageOP(SPIT_Message::RemoveSPITType *ptrSMRemoveSPITType) { + ptrSMRemoveSPITType->setID(m_ID); +} diff --git a/components/spit/src/SPIT_Client.cpp b/components/spit/src/SPIT_Client.cpp index f9ac013..ad14445 100644 --- a/components/spit/src/SPIT_Client.cpp +++ b/components/spit/src/SPIT_Client.cpp @@ -4,78 +4,75 @@ * and open the template in the editor. */ -/* - * SPIt_Client handles the SPIT_Message transfer and - * fires eventxxx functions to the SPIT_ClientInterface (implemented by the user app). - * +/* + * SPIt_Client handles the SPIT_Message transfer and + * fires eventxxx functions to the SPIT_ClientInterface (implemented by the user app). + * * File: SPIT_Client.cpp * Author: Hagi - * + * * Created on 7. April 2019, 08:50 */ - #include "SPIT_Client.h" #include "esp_log.h" -static const char * TAG = "SPIT"; +static const char *TAG = "SPIT"; /** * Create a new SPIT_client instance, should be done once by the user app.
* @param p_SPITClientInterface the user app should implement the SPIT_ClientInterface. */ SPIT_Client::SPIT_Client(string name, string projName, Callbacks calls) - : I_SAD_Client(), mCallbacks(calls), m_Name(name), m_ProjName(projName) { - m_ConnectionStatus = CONNECTION_NONE; + : I_SAD_Client(), mCallbacks(calls), m_Name(name), m_ProjName(projName) { + m_ConnectionStatus = CONNECTION_NONE; - m_ID = createGUID(); - m_ComputerName = getClientHostName(); - auto ip = SPITSocket::getAdaptersInfo(); - mSPITSocket = new SPITSocket(ip); - m_MessageNumber_Send = 1; - m_MessageNumber_Received = -1; //set to -1 because the first received message will set the number (1..255) + m_ID = createGUID(); + m_ComputerName = getClientHostName(); + auto ip = SPITSocket::getAdaptersInfo(); + mSPITSocket = new SPITSocket(ip); + m_MessageNumber_Send = 1; + m_MessageNumber_Received = -1; // set to -1 because the first received message will set the number (1..255) } SPIT_Client::~SPIT_Client() { - stopServerAutoDetect(); - disconnectInternal(CONNECTION_NONE); + stopServerAutoDetect(); + disconnectInternal(CONNECTION_NONE); } - -void SPIT_Client::clientProjectClose() { - if (m_ConnectionStatus == CONNECTION_OK) { - ESP_LOGI(TAG, " ... tidy up ressources"); - SPIT_Message::CloseSPITProject sMCloseSPITProject; - sMCloseSPITProject.setProjectID(m_ProjName); - if (sendSPITMessage(sMCloseSPITProject) < 0) { - ESP_LOGD(TAG, "SPIT_Client could not send Client's ReportSPITProject"); - } - } +void SPIT_Client::clientProjectClose() { + if (m_ConnectionStatus == CONNECTION_OK) { + ESP_LOGI(TAG, " ... tidy up ressources"); + SPIT_Message::CloseSPITProject sMCloseSPITProject; + sMCloseSPITProject.setProjectID(m_ProjName); + if (sendSPITMessage(sMCloseSPITProject) < 0) { + ESP_LOGD(TAG, "SPIT_Client could not send Client's ReportSPITProject"); + } + } } void SPIT_Client::clientProjectLoaded() { - //set confirmed = false for all SPITTypes and SPITObjects - SPITType::setConfirmedFalse(); - SPITObject::setConfirmedFalse(); - - if (m_ConnectionStatus == CONNECTION_OK) { - //send ReportSPITProject to the server - SPIT_Message::ReportSPITProject sMReportSPITProject; - sMReportSPITProject.setProjectID(m_ProjName); - sMReportSPITProject.setProjectName(m_ProjName); - sMReportSPITProject.setFramesPerSecond(0); - if (sendSPITMessage(sMReportSPITProject) < 0) { - ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send Client's ReportSPITProject"); - } - - //send RequestProjectTransfer - SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer; - if (sendSPITMessage(sMRequestProjectTransfer) < 0) { - ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send RequestProjectTransfer"); - } - } -} + // set confirmed = false for all SPITTypes and SPITObjects + SPITType::setConfirmedFalse(); + SPITObject::setConfirmedFalse(); + if (m_ConnectionStatus == CONNECTION_OK) { + // send ReportSPITProject to the server + SPIT_Message::ReportSPITProject sMReportSPITProject; + sMReportSPITProject.setProjectID(m_ProjName); + sMReportSPITProject.setProjectName(m_ProjName); + sMReportSPITProject.setFramesPerSecond(0); + if (sendSPITMessage(sMReportSPITProject) < 0) { + ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send Client's ReportSPITProject"); + } + + // send RequestProjectTransfer + SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer; + if (sendSPITMessage(sMRequestProjectTransfer) < 0) { + ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send RequestProjectTransfer"); + } + } +} /** * Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.
@@ -86,25 +83,27 @@ void SPIT_Client::clientProjectLoaded() { * @param p_ActionAssigned */ void SPIT_Client::setActionSPITType(string p_SPITTypeID, bool p_ActionAssigned) { - SPITType* ptrSPITType; - SPITObject* ptrSPITObject; - { - ptrSPITType = SPITType::getSPITType(p_SPITTypeID); - if (ptrSPITType == NULL) return; - if (ptrSPITType->setActionAssigned(p_ActionAssigned) == true) { - sendSPITTypeInternal(ptrSPITType); + SPITType *ptrSPITType; + SPITObject *ptrSPITObject; + { + ptrSPITType = SPITType::getSPITType(p_SPITTypeID); + if (ptrSPITType == NULL) + return; + if (ptrSPITType->setActionAssigned(p_ActionAssigned) == true) { + sendSPITTypeInternal(ptrSPITType); - for (int i = 0; i < SPITObject::getSPITObjectCount(); i++) { - ptrSPITObject = SPITObject::getSPITObject(i); - if (ptrSPITObject == NULL) continue; - if (ptrSPITObject->getSPITTypeID() == ptrSPITType->getID()) { - if (ptrSPITObject->setActionAssignedType(p_ActionAssigned) == true) { - sendSPITObjectInternal(ptrSPITObject); - } - } - } - } - } + for (int i = 0; i < SPITObject::getSPITObjectCount(); i++) { + ptrSPITObject = SPITObject::getSPITObject(i); + if (ptrSPITObject == NULL) + continue; + if (ptrSPITObject->getSPITTypeID() == ptrSPITType->getID()) { + if (ptrSPITObject->setActionAssignedType(p_ActionAssigned) == true) { + sendSPITObjectInternal(ptrSPITObject); + } + } + } + } + } } /** @@ -113,14 +112,15 @@ void SPIT_Client::setActionSPITType(string p_SPITTypeID, bool p_ActionAssigned) * @param p_ActionAssigned */ void SPIT_Client::setActionSPITObject(string p_SPITObjectID, bool p_ActionAssigned) { - SPITObject* ptrSPITObject; - { - ptrSPITObject = SPITObject::getSPITObject(p_SPITObjectID); - if (ptrSPITObject == NULL) return; - if (ptrSPITObject->setActionAssigned(p_ActionAssigned) == true) { - sendSPITObjectInternal(ptrSPITObject); - } - } + SPITObject *ptrSPITObject; + { + ptrSPITObject = SPITObject::getSPITObject(p_SPITObjectID); + if (ptrSPITObject == NULL) + return; + if (ptrSPITObject->setActionAssigned(p_ActionAssigned) == true) { + sendSPITObjectInternal(ptrSPITObject); + } + } } //---------- ServerAutoDetection SAD ----------- @@ -128,54 +128,49 @@ void SPIT_Client::setActionSPITObject(string p_SPITObjectID, bool p_ActionAssign * If a SPITServer is detected in the locale network an eventServerDetected occurs. */ void SPIT_Client::startServerAutoDetect() { - if (m_DisconnectedByServer == true) { - //Server has previously disconnected -> do not start ServerAutodetect directly - //sleep a little to give the SPITServer time to clean up its stuff - - fos::Task::delayMs(1000); - } + if (m_DisconnectedByServer == true) { + // Server has previously disconnected -> do not start ServerAutodetect directly + // sleep a little to give the SPITServer time to clean up its stuff - + fos::Task::delayMs(1000); + } SAD_DetectedServer::clearDetectedServers(); if (!sThread) { - sThread = new fos::TaskT(SPIT_Client::processSocketTask, *this, "spitSock", fos::Task::DefaultStackSize*2 ); + sThread = new fos::TaskT(SPIT_Client::processSocketTask, *this, "spitSock", fos::Task::DefaultStackSize * 2); } abortSearch = false; sStartSad.give(); - } /** * Stops the auto detection of SPIT servers. */ void SPIT_Client::stopServerAutoDetect() { - abortSearch = true; + abortSearch = true; } - /** - * If a new server was found by the ServerAutoDetect mechanism, this function is called.
- * To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.
- * If a server can be reached via several IP addresses, the IP address is selected according to the following preference:
- * 1.) If a loopback address is available, it is used.
- * 2.) If an IP4 address is available, it is used.
- * 3.) In the other cases the IP6 address is used.
- * @param p_ID the id of the server (every started server should generate an id) - * @param p_Name the name of the SPIT server - * @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running - * @param p_IP the selected ip address of the SPIT server - * @param p_Port the port of the SPIT server - * @param p_Addition sometimes server may have additional informations - * @param p_IsIP4 the server ip is a ip4 address - */ -void SPIT_Client::eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) { - try { - SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID); - mCallbacks.onServerEvent(ServerEvent::Detect, o_RefDetectedServer); - +/** + * If a new server was found by the ServerAutoDetect mechanism, this function is called.
+ * To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.
+ * If a server can be reached via several IP addresses, the IP address is selected according to the following preference:
+ * 1.) If a loopback address is available, it is used.
+ * 2.) If an IP4 address is available, it is used.
+ * 3.) In the other cases the IP6 address is used.
+ * @param p_ID the id of the server (every started server should generate an id) + * @param p_Name the name of the SPIT server + * @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running + * @param p_IP the selected ip address of the SPIT server + * @param p_Port the port of the SPIT server + * @param p_Addition sometimes server may have additional informations + */ +void SPIT_Client::eventServerDetected(SAD_DetectedServer &server) { + mCallbacks.onServerEvent(ServerEvent::Detect, server); // If a connection has been established and the connection is lost -> reconnect if (_doReconnect) { - if (m_ServerID == o_RefDetectedServer.getID()) { + if (m_ServerID == server.getID()) { stopServerAutoDetect(); - ESP_LOGI(TAG, "reconnect to %s", o_RefDetectedServer.getIP().data()); + ESP_LOGI(TAG, "reconnect to %s", server.getIP().data()); // ClientPort = "0" meeans use any port - if (connect(o_RefDetectedServer.getIP(), o_RefDetectedServer.getPort(), o_RefDetectedServer.getClientIP(), "0")) { + if (connect(server.getIP(), server.getPort(), server.getClientIP(), "0")) { return; } } @@ -183,72 +178,52 @@ void SPIT_Client::eventServerDetected(string p_ID, string p_Name, string p_Compu // Stop auto detection because a suitable server was found stopServerAutoDetect(); - ESP_LOGI(TAG, "connect to %s", o_RefDetectedServer.getIP().data()); + ESP_LOGI(TAG, "connect to %s", server.getIP().data()); // ClientPort = "0" meeans use any port - if (not connect(o_RefDetectedServer.getIP(), o_RefDetectedServer.getPort(), o_RefDetectedServer.getClientIP(), "0")) { + if (not connect(server.getIP(), server.getPort(), server.getClientIP(), "0")) { // connection message could not be sent -> better to restart AutoDetection startServerAutoDetect(); } - - } - catch (...) { - return; - } } - /** - * If a SPITServer is not more found, this function is called. - * To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.
- * @param p_ID the id of the server (every started server should generate an id) - * @param p_Name the name of the SPIT server - * @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running - * @param p_IP the selected ip address of the SPIT server - * @param p_Port the port of the SPIT server - * @param p_Addition sometimes server may have additional informations - * @param p_IsIP4 the server ip is a ip4 address - */ -void SPIT_Client::eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) { - try { - SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID); - mCallbacks.onServerEvent(ServerEvent::Lost, o_RefDetectedServer); - } - catch (...) { - return; - } +/** + * If a SPITServer is not more found, this function is called. + * To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.
+ * @param p_ID the id of the server (every started server should generate an id) + * @param p_Name the name of the SPIT server + * @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running + * @param p_IP the selected ip address of the SPIT server + * @param p_Port the port of the SPIT server + * @param p_Addition sometimes server may have additional informations + */ +void SPIT_Client::eventServerLost(SAD_DetectedServer &server) { + mCallbacks.onServerEvent(ServerEvent::Lost, server); } -void SPIT_Client::eventServerChanged(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) { - try { - SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID); - mCallbacks.onServerEvent(ServerEvent::Changed, o_RefDetectedServer); - // tryConnection(p_DetectedServer); - } - catch (...) { - return; - } +void SPIT_Client::eventServerChanged(SAD_DetectedServer &server) { + mCallbacks.onServerEvent(ServerEvent::Changed, server); + // tryConnection(p_DetectedServer); } - - // void MyApp::tryConnection(const SAD_DetectedServer& p_DetectedServer) { // //fetch the infoemations from the p_DetectedServer // bool boolPossibleConnect; // bool boolSuccess; - + // boolPossibleConnect = checkPossibleConnection(p_DetectedServer); - + // if (boolPossibleConnect == false) return; - + // // -------------------------------------- // // You have three Options to use the detected server // // OPTION 1 Use the first server found // // OPTION 2 Use the first server found that fulfills specific conditions // // OPTION 3 take a copy of the p_DetectedServer and do connection later -// // SAD_DetectedServer o_DetectedServer = p_DetectedServer; //this will call the copy constructor +// // SAD_DetectedServer o_DetectedServer = p_DetectedServer; //this will call the copy constructor // // --------------------------------------- // //Excample use the first detected LOOPBACK server, means the server runs on the same computer as this client -// //if (p_DetectedServer.getIpIsLoopback() == true) { //omit the if condition if you want to use the first server found - +// //if (p_DetectedServer.getIpIsLoopback() == true) { //omit the if condition if you want to use the first server found + // boolSuccess = false; // //Stop auto detection because a suitable server was found // stopServerAutoDetect(); @@ -272,817 +247,802 @@ void SPIT_Client::eventServerChanged(string p_ID, string p_Name, string p_Comput // else { // //WAITING FOR CONNECTION ANSWER // //If the Server is closed in the meantime no answer will return -// //-> connect(..) has started the watchdog +// //-> connect(..) has started the watchdog // } - + // // } //Excample // } -void SPIT_Client::fillHeader(SPIT_Message::Header* p_Header) { - if (p_Header == NULL) return; - p_Header->setClientID(m_ID); - p_Header->setServerID(m_ServerID); +void SPIT_Client::fillHeader(SPIT_Message::Header *p_Header) { + if (p_Header == NULL) + return; + p_Header->setClientID(m_ID); + p_Header->setServerID(m_ServerID); } -int SPIT_Client::sendSPITMessage(SPIT_Message::OPPart& spitMessageOPPart) { - if (m_StopReceiveSPITMessages == true) { - return -1; - } +int SPIT_Client::sendSPITMessage(SPIT_Message::OPPart &spitMessageOPPart) { + if (m_StopReceiveSPITMessages == true) { + return -1; + } - fillHeader(spitMessageOPPart.getHeader()); + fillHeader(spitMessageOPPart.getHeader()); - if (m_MessageNumber_Send == 255) m_MessageNumber_Send = 1; - else m_MessageNumber_Send++; - spitMessageOPPart.getHeader()->setMessageNumber(m_MessageNumber_Send); + if (m_MessageNumber_Send == 255) + m_MessageNumber_Send = 1; + else + m_MessageNumber_Send++; + spitMessageOPPart.getHeader()->setMessageNumber(m_MessageNumber_Send); - SPIT_Message* ptrSPIT_Message; - ptrSPIT_Message = new SPIT_Message(&spitMessageOPPart); - const char* ptrMessageBytes = ptrSPIT_Message->getMessageBytes(); - int intByteCount = ptrSPIT_Message->getMesageByteCount(); + SPIT_Message *ptrSPIT_Message; + ptrSPIT_Message = new SPIT_Message(&spitMessageOPPart); + const char *ptrMessageBytes = ptrSPIT_Message->getMessageBytes(); + int intByteCount = ptrSPIT_Message->getMesageByteCount(); - if (ptrMessageBytes == NULL) { - return -1; - } - try { - int intResult = mSPITSocket->sendMessage(ptrMessageBytes, intByteCount); - if (intResult < 0) { - ESP_LOGD(TAG, "SPIT_Client::sendSPITMessage could not send message OPFlage: %d", ptrSPIT_Message->getOPFlag()); - } - return intResult; - } - catch (...) { - ESP_LOGD(TAG, "Exception SPIT_Client::sendSPITMessage OPFlag: %d", ptrSPIT_Message->getOPFlag()); - return -1; - } + if (ptrMessageBytes == NULL) { + return -1; + } + try { + int intResult = mSPITSocket->sendMessage(ptrMessageBytes, intByteCount); + if (intResult < 0) { + ESP_LOGD(TAG, "SPIT_Client::sendSPITMessage could not send message OPFlage: %d", ptrSPIT_Message->getOPFlag()); + } + return intResult; + } catch (...) { + ESP_LOGD(TAG, "Exception SPIT_Client::sendSPITMessage OPFlag: %d", ptrSPIT_Message->getOPFlag()); + return -1; + } } bool SPIT_Client::startReceiveSPITMessages() { - { - if (mSPITSocket->getBoundClientFamily() <= 0) return false; - m_StopReceiveSPITMessages = false; - m_ThreadReceive = new fos::TaskT(receiveSPITMessage, *this, "receiveTask", fos::Task::DefaultStackSize *4); - } - return true; + { + if (mSPITSocket->getBoundClientFamily() <= 0) + return false; + m_StopReceiveSPITMessages = false; + m_ThreadReceive = new fos::TaskT(receiveSPITMessage, *this, "receiveTask", fos::Task::DefaultStackSize * 4); + } + return true; } void SPIT_Client::stopReceiveSPITMessages() { - { - if (m_StopReceiveSPITMessages == true) return; - m_StopReceiveSPITMessages = true; - } + { + if (m_StopReceiveSPITMessages == true) + return; + m_StopReceiveSPITMessages = true; + } } -void SPIT_Client::receiveSPITMessage(SPIT_Client& rM) { - - char buffer[MAXSPITMESSAGEBYTECOUNT]; - int intResult; - while (rM.m_StopReceiveSPITMessages == false) { - if ( rM.m_StopReceiveSPITMessages == true) { - return; - } - intResult = rM.mSPITSocket->receiveMessage(rM.mSPITSocket->getBoundClientFamily(), buffer, MAXSPITMESSAGEBYTECOUNT, NULL); - if (intResult < 0) { - if (rM.m_StopReceiveSPITMessages) { - return;; - } - continue; - } - auto ptrSPIT_Message = make_unique(buffer, intResult); - unsigned int intActualMessageNumber = (int)(ptrSPIT_Message->getHeader()->getMessageNumber() & 0xFF); - rM.parseSPIT_Message(move(ptrSPIT_Message)); - // rM.checkParseSPIT_Message(move(ptrSPIT_Message)); - } +void SPIT_Client::receiveSPITMessage(SPIT_Client &rM) { + + char buffer[MAXSPITMESSAGEBYTECOUNT]; + int intResult; + while (rM.m_StopReceiveSPITMessages == false) { + if (rM.m_StopReceiveSPITMessages == true) { + return; + } + intResult = rM.mSPITSocket->receiveMessage(rM.mSPITSocket->getBoundClientFamily(), buffer, MAXSPITMESSAGEBYTECOUNT, NULL); + if (intResult < 0) { + if (rM.m_StopReceiveSPITMessages) { + return; + ; + } + continue; + } + auto ptrSPIT_Message = make_unique(buffer, intResult); + unsigned int intActualMessageNumber = (int)(ptrSPIT_Message->getHeader()->getMessageNumber() & 0xFF); + rM.parseSPIT_Message(move(ptrSPIT_Message)); + // rM.checkParseSPIT_Message(move(ptrSPIT_Message)); + } } void SPIT_Client::resetMessageNumberReceived() { - SPIT_Message* ptrOvertakingSPIT_Message; - - m_MessageNumber_Received = -1; - for (auto it = m_OvertakingSPIT_Messages.begin(); it != m_OvertakingSPIT_Messages.end(); it++) { - ptrOvertakingSPIT_Message = *it; - delete ptrOvertakingSPIT_Message; -// m_OvertakingSPIT_Messages.erase(it); - } - m_OvertakingSPIT_Messages.clear(); + SPIT_Message *ptrOvertakingSPIT_Message; + + m_MessageNumber_Received = -1; + for (auto it = m_OvertakingSPIT_Messages.begin(); it != m_OvertakingSPIT_Messages.end(); it++) { + ptrOvertakingSPIT_Message = *it; + delete ptrOvertakingSPIT_Message; + // m_OvertakingSPIT_Messages.erase(it); + } + m_OvertakingSPIT_Messages.clear(); } void SPIT_Client::checkParseSPIT_Message(unique_ptr p_SPITMessage) { - answerWatchdog(); - if (p_SPITMessage == NULL) { - ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message Parameter == NULL\n"); - return; - } - if (p_SPITMessage->getHeader() == NULL) { - ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no Header\n"); - return; - } - if (p_SPITMessage->getOPPart() == NULL) { - ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no OPPart\n"); - return; - } - - int intActualMessageNumber; - int intNextMessageNumber; - SPIT_Message* ptrOvertakingSPIT_Message; + answerWatchdog(); + if (p_SPITMessage == NULL) { + ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message Parameter == NULL\n"); + return; + } + if (p_SPITMessage->getHeader() == NULL) { + ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no Header\n"); + return; + } + if (p_SPITMessage->getOPPart() == NULL) { + ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no OPPart\n"); + return; + } - intActualMessageNumber = (int)(p_SPITMessage->getHeader()->getMessageNumber() & 0xFF); + int intActualMessageNumber; + int intNextMessageNumber; + SPIT_Message *ptrOvertakingSPIT_Message; - if (intActualMessageNumber == 0) { - parseSPIT_Message(std::move(p_SPITMessage)); - return; - } - if (m_MessageNumber_Received < 0) { - m_MessageNumber_Received = intActualMessageNumber; - parseSPIT_Message(std::move(p_SPITMessage)); - return; - } - - intNextMessageNumber = m_MessageNumber_Received +1; - if (intNextMessageNumber > 255 || intNextMessageNumber < 1) intNextMessageNumber = 1; - - if (intActualMessageNumber == intNextMessageNumber) { - m_MessageNumber_Received = intActualMessageNumber; - parseSPIT_Message(std::move(p_SPITMessage)); - - //check overtaking messages - auto it = m_OvertakingSPIT_Messages.begin(); - while (m_OvertakingSPIT_Messages.size() > 0) { - - intNextMessageNumber = m_MessageNumber_Received +1; - if (intNextMessageNumber > 255 || intNextMessageNumber < 1) intNextMessageNumber = 1; - - ptrOvertakingSPIT_Message = *it; - intActualMessageNumber = (int)(ptrOvertakingSPIT_Message->getHeader()->getMessageNumber() & 0xFF); - - if (intActualMessageNumber == intNextMessageNumber) { - m_MessageNumber_Received = intActualMessageNumber; - // parseSPIT_Message(ptrOvertakingSPIT_Message); - m_OvertakingSPIT_Messages.erase(it); - - it = m_OvertakingSPIT_Messages.begin(); - } - else { - break; - } - } - - } - else { - //p_SPITMessage has overtaken another message - addOvertakingSPIT_Message(p_SPITMessage.get()); - } + intActualMessageNumber = (int)(p_SPITMessage->getHeader()->getMessageNumber() & 0xFF); + + if (intActualMessageNumber == 0) { + parseSPIT_Message(std::move(p_SPITMessage)); + return; + } + if (m_MessageNumber_Received < 0) { + m_MessageNumber_Received = intActualMessageNumber; + parseSPIT_Message(std::move(p_SPITMessage)); + return; + } + + intNextMessageNumber = m_MessageNumber_Received + 1; + if (intNextMessageNumber > 255 || intNextMessageNumber < 1) + intNextMessageNumber = 1; + + if (intActualMessageNumber == intNextMessageNumber) { + m_MessageNumber_Received = intActualMessageNumber; + parseSPIT_Message(std::move(p_SPITMessage)); + + // check overtaking messages + auto it = m_OvertakingSPIT_Messages.begin(); + while (m_OvertakingSPIT_Messages.size() > 0) { + + intNextMessageNumber = m_MessageNumber_Received + 1; + if (intNextMessageNumber > 255 || intNextMessageNumber < 1) + intNextMessageNumber = 1; + + ptrOvertakingSPIT_Message = *it; + intActualMessageNumber = (int)(ptrOvertakingSPIT_Message->getHeader()->getMessageNumber() & 0xFF); + + if (intActualMessageNumber == intNextMessageNumber) { + m_MessageNumber_Received = intActualMessageNumber; + // parseSPIT_Message(ptrOvertakingSPIT_Message); + m_OvertakingSPIT_Messages.erase(it); + + it = m_OvertakingSPIT_Messages.begin(); + } else { + break; + } + } + + } else { + // p_SPITMessage has overtaken another message + addOvertakingSPIT_Message(p_SPITMessage.get()); + } } int SPIT_Client::s_MAX_OVERTAKING_SPIT_MESSAGES = 10; -void SPIT_Client::addOvertakingSPIT_Message(SPIT_Message* p_SPIT_Message) { - if (p_SPIT_Message == nullptr) return; - int intMessageNumber; - SPIT_Message* ptrOvertakingSPIT_Message; - int intOvertakingMessageNumber; - - if (m_OvertakingSPIT_Messages.size() > s_MAX_OVERTAKING_SPIT_MESSAGES) { - printf("SPIT_Client receiveing: perhaps message lost !!!!!"); - } - - intMessageNumber = (int)(p_SPIT_Message->getHeader()->getMessageNumber() & 0xFF); - for (auto it = m_OvertakingSPIT_Messages.begin(); it != m_OvertakingSPIT_Messages.end(); it++) { - ptrOvertakingSPIT_Message = *it; - intOvertakingMessageNumber = (int)(ptrOvertakingSPIT_Message->getHeader()->getMessageNumber() & 0xFF); - if (intMessageNumber < intOvertakingMessageNumber) { - m_OvertakingSPIT_Messages.insert(it, p_SPIT_Message); - return; - } - } - m_OvertakingSPIT_Messages.push_back(p_SPIT_Message); +void SPIT_Client::addOvertakingSPIT_Message(SPIT_Message *p_SPIT_Message) { + if (p_SPIT_Message == nullptr) + return; + int intMessageNumber; + SPIT_Message *ptrOvertakingSPIT_Message; + int intOvertakingMessageNumber; + + if (m_OvertakingSPIT_Messages.size() > s_MAX_OVERTAKING_SPIT_MESSAGES) { + ESP_LOGD(TAG, "SPIT_Client receiveing: perhaps message lost !!!!!"); + } + + intMessageNumber = (int)(p_SPIT_Message->getHeader()->getMessageNumber() & 0xFF); + for (auto it = m_OvertakingSPIT_Messages.begin(); it != m_OvertakingSPIT_Messages.end(); it++) { + ptrOvertakingSPIT_Message = *it; + intOvertakingMessageNumber = (int)(ptrOvertakingSPIT_Message->getHeader()->getMessageNumber() & 0xFF); + if (intMessageNumber < intOvertakingMessageNumber) { + m_OvertakingSPIT_Messages.insert(it, p_SPIT_Message); + return; + } + } + m_OvertakingSPIT_Messages.push_back(p_SPIT_Message); } void SPIT_Client::parseSPIT_Message(unique_ptr p_SPITMessage) { - answerWatchdog(); - if (!p_SPITMessage) { - ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message Parameter == NULL"); - return; - } - if (p_SPITMessage->getHeader() == nullptr) { - ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no Header"); - return; - } - if (p_SPITMessage->getOPPart() == nullptr) { - ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no OPPart"); - return; - } - //----- Connection ----- - if (p_SPITMessage->getOPFlag() == SPIT_Message::ConnectAnswer::OPFLAG) { - SPIT_Message::ConnectAnswer* o_ConnectAnswer = (SPIT_Message::ConnectAnswer*) p_SPITMessage->getOPPart(); - parseConnectAnswer(o_ConnectAnswer); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::Disconnect::OPFLAG) { - SPIT_Message::Disconnect* o_Disconnect = (SPIT_Message::Disconnect*) p_SPITMessage->getOPPart(); - parseDisconnect(o_Disconnect); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITProject::OPFLAG) { - SPIT_Message::ReportSPITProject* o_ReportSPITProject = (SPIT_Message::ReportSPITProject*) p_SPITMessage->getOPPart(); - parseReportSPITProject(o_ReportSPITProject); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::Watchdog::OPFLAG) { - SPIT_Message::Watchdog* o_Watchdog = (SPIT_Message::Watchdog*) p_SPITMessage->getOPPart(); - parseWatchdog(o_Watchdog); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::WatchdogAnswer::OPFLAG) { - SPIT_Message::WatchdogAnswer* o_WatchdogAnswer = (SPIT_Message::WatchdogAnswer*) p_SPITMessage->getOPPart(); - parseWatchdogAnswer(o_WatchdogAnswer); - } - //----- SPIT Project ----- - else if (p_SPITMessage->getOPFlag() == SPIT_Message::StartProjectTransfer::OPFLAG) { - SPIT_Message::StartProjectTransfer* o_StartProjectTransfer = (SPIT_Message::StartProjectTransfer*) p_SPITMessage->getOPPart(); - parseStartProjectTransfer(o_StartProjectTransfer); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::CloseSPITProject::OPFLAG) { - SPIT_Message::CloseSPITProject* o_CloseSPITProjectr = (SPIT_Message::CloseSPITProject*) p_SPITMessage->getOPPart(); - parseCloseSPITProject(o_CloseSPITProjectr); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::RequestProjectTransfer::OPFLAG) { - SPIT_Message::RequestProjectTransfer* o_RequestProjectTransfer = (SPIT_Message::RequestProjectTransfer*) p_SPITMessage->getOPPart(); - parseRequestProjectTransfer(o_RequestProjectTransfer); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::StartProjectTransfer::OPFLAG) { - SPIT_Message::StartProjectTransfer* o_StartProjectTransfer = (SPIT_Message::StartProjectTransfer*) p_SPITMessage->getOPPart(); - parseStartProjectTransfer(o_StartProjectTransfer); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::EndProjectTransfer::OPFLAG) { - SPIT_Message::EndProjectTransfer* o_EndProjectTransfer = (SPIT_Message::EndProjectTransfer*) p_SPITMessage->getOPPart(); - parseEndProjectTransfer(o_EndProjectTransfer); - } - //----- SPIT Types ------ - else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITType::OPFLAG) { - SPIT_Message::ReportSPITType* o_ReportSPITType = (SPIT_Message::ReportSPITType*) p_SPITMessage->getOPPart(); - parseReportSPITType(o_ReportSPITType); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::RemoveSPITType::OPFLAG) { - SPIT_Message::RemoveSPITType* o_RemoveSPITType = (SPIT_Message::RemoveSPITType*) p_SPITMessage->getOPPart(); - parseRemoveSPITType(o_RemoveSPITType); - } - //----- SPIT Objects ------ - else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITObject::OPFLAG) { - SPIT_Message::ReportSPITObject* o_ReportSPITObject = (SPIT_Message::ReportSPITObject*) p_SPITMessage->getOPPart(); - parseReportSPITObject(o_ReportSPITObject); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::RemoveSPITObject::OPFLAG) { - SPIT_Message::RemoveSPITObject* o_RemoveSPITObject = (SPIT_Message::RemoveSPITObject*) p_SPITMessage->getOPPart(); - parseRemoveSPITObject(o_RemoveSPITObject); - } - //----- Play SPIT Objects ------ - else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITStart::OPFLAG) { - SPIT_Message::PlaySPITStart* o_PlaySPITStart = (SPIT_Message::PlaySPITStart*) p_SPITMessage->getOPPart(); - parsePlaySPITStart(o_PlaySPITStart); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITObject::OPFLAG) { - SPIT_Message::PlaySPITObject* o_PlaySPITObject = (SPIT_Message::PlaySPITObject*) p_SPITMessage->getOPPart(); - parsePlaySPITObject(o_PlaySPITObject); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITEnd::OPFLAG) { - SPIT_Message::PlaySPITEnd* o_PlaySPITEnd = (SPIT_Message::PlaySPITEnd*) p_SPITMessage->getOPPart(); - parsePlaySPITEnd(o_PlaySPITEnd); - } - else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportPlayStatus::OPFLAG) { - SPIT_Message::ReportPlayStatus* o_ReportPlayStatus = (SPIT_Message::ReportPlayStatus*) p_SPITMessage->getOPPart(); - parseReportPlayStatus(o_ReportPlayStatus); - } - else { - ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message: Unknown Message"); - } + answerWatchdog(); + if (!p_SPITMessage) { + ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message Parameter == NULL"); + return; + } + if (p_SPITMessage->getHeader() == nullptr) { + ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no Header"); + return; + } + if (p_SPITMessage->getOPPart() == nullptr) { + ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no OPPart"); + return; + } + //----- Connection ----- + if (p_SPITMessage->getOPFlag() == SPIT_Message::ConnectAnswer::OPFLAG) { + SPIT_Message::ConnectAnswer *o_ConnectAnswer = (SPIT_Message::ConnectAnswer *)p_SPITMessage->getOPPart(); + parseConnectAnswer(o_ConnectAnswer); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::Disconnect::OPFLAG) { + SPIT_Message::Disconnect *o_Disconnect = (SPIT_Message::Disconnect *)p_SPITMessage->getOPPart(); + parseDisconnect(o_Disconnect); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITProject::OPFLAG) { + SPIT_Message::ReportSPITProject *o_ReportSPITProject = (SPIT_Message::ReportSPITProject *)p_SPITMessage->getOPPart(); + parseReportSPITProject(o_ReportSPITProject); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::Watchdog::OPFLAG) { + SPIT_Message::Watchdog *o_Watchdog = (SPIT_Message::Watchdog *)p_SPITMessage->getOPPart(); + parseWatchdog(o_Watchdog); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::WatchdogAnswer::OPFLAG) { + SPIT_Message::WatchdogAnswer *o_WatchdogAnswer = (SPIT_Message::WatchdogAnswer *)p_SPITMessage->getOPPart(); + parseWatchdogAnswer(o_WatchdogAnswer); + } + //----- SPIT Project ----- + else if (p_SPITMessage->getOPFlag() == SPIT_Message::StartProjectTransfer::OPFLAG) { + SPIT_Message::StartProjectTransfer *o_StartProjectTransfer = (SPIT_Message::StartProjectTransfer *)p_SPITMessage->getOPPart(); + parseStartProjectTransfer(o_StartProjectTransfer); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::CloseSPITProject::OPFLAG) { + SPIT_Message::CloseSPITProject *o_CloseSPITProjectr = (SPIT_Message::CloseSPITProject *)p_SPITMessage->getOPPart(); + parseCloseSPITProject(o_CloseSPITProjectr); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::RequestProjectTransfer::OPFLAG) { + SPIT_Message::RequestProjectTransfer *o_RequestProjectTransfer = (SPIT_Message::RequestProjectTransfer *)p_SPITMessage->getOPPart(); + parseRequestProjectTransfer(o_RequestProjectTransfer); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::StartProjectTransfer::OPFLAG) { + SPIT_Message::StartProjectTransfer *o_StartProjectTransfer = (SPIT_Message::StartProjectTransfer *)p_SPITMessage->getOPPart(); + parseStartProjectTransfer(o_StartProjectTransfer); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::EndProjectTransfer::OPFLAG) { + SPIT_Message::EndProjectTransfer *o_EndProjectTransfer = (SPIT_Message::EndProjectTransfer *)p_SPITMessage->getOPPart(); + parseEndProjectTransfer(o_EndProjectTransfer); + } + //----- SPIT Types ------ + else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITType::OPFLAG) { + SPIT_Message::ReportSPITType *o_ReportSPITType = (SPIT_Message::ReportSPITType *)p_SPITMessage->getOPPart(); + parseReportSPITType(o_ReportSPITType); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::RemoveSPITType::OPFLAG) { + SPIT_Message::RemoveSPITType *o_RemoveSPITType = (SPIT_Message::RemoveSPITType *)p_SPITMessage->getOPPart(); + parseRemoveSPITType(o_RemoveSPITType); + } + //----- SPIT Objects ------ + else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITObject::OPFLAG) { + SPIT_Message::ReportSPITObject *o_ReportSPITObject = (SPIT_Message::ReportSPITObject *)p_SPITMessage->getOPPart(); + parseReportSPITObject(o_ReportSPITObject); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::RemoveSPITObject::OPFLAG) { + SPIT_Message::RemoveSPITObject *o_RemoveSPITObject = (SPIT_Message::RemoveSPITObject *)p_SPITMessage->getOPPart(); + parseRemoveSPITObject(o_RemoveSPITObject); + } + //----- Play SPIT Objects ------ + else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITStart::OPFLAG) { + SPIT_Message::PlaySPITStart *o_PlaySPITStart = (SPIT_Message::PlaySPITStart *)p_SPITMessage->getOPPart(); + parsePlaySPITStart(o_PlaySPITStart); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITObject::OPFLAG) { + SPIT_Message::PlaySPITObject *o_PlaySPITObject = (SPIT_Message::PlaySPITObject *)p_SPITMessage->getOPPart(); + parsePlaySPITObject(o_PlaySPITObject); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITEnd::OPFLAG) { + SPIT_Message::PlaySPITEnd *o_PlaySPITEnd = (SPIT_Message::PlaySPITEnd *)p_SPITMessage->getOPPart(); + parsePlaySPITEnd(o_PlaySPITEnd); + } else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportPlayStatus::OPFLAG) { + SPIT_Message::ReportPlayStatus *o_ReportPlayStatus = (SPIT_Message::ReportPlayStatus *)p_SPITMessage->getOPPart(); + parseReportPlayStatus(o_ReportPlayStatus); + } else { + ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message: Unknown Message"); + } } - //----- Connection ------ /** * Tries to connect to a SPITServer.
* @param p_ServerIP the ip address of the SPIT server * @param p_ServerPort the port number of the SPIT server * @param p_ClientIP the local IP address of the client - * @param p_ClientPort the port number of the Client, if "0" the OS uses any possible port number + * @param p_ClientPort the port number of the Client, if "0" the OS uses any possible port number * @param p_LoginName login user name (liveSHOW does not use this -> mayby "" * @param p_LoginPassword login user password (liveSHOW does not use this -> mayby "" * @return false = an error has occured, true = the connect was sent to the server */ bool SPIT_Client::connect(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort, string p_LoginName, string p_LoginPassword) { - int intResult; - disconnect(); - { - mSPITSocket->setConnectionParams(p_ServerIP, p_ServerPort, p_ClientIP, p_ClientPort); - intResult = mSPITSocket->bindSocket(p_ServerIP, p_ClientIP, p_ClientPort); - if (intResult < 0) { - m_StopReceiveSPITMessages = true; - return false; - } - } - SPIT_Message::Connect sMConnect; - sMConnect.setClientComputerName(m_ComputerName); - sMConnect.setClientName(m_Name); - sMConnect.setLoginName(p_LoginName); - sMConnect.setLoginPassword(p_LoginPassword); - sMConnect.setServerIP(p_ServerIP); - if (p_ServerPort.length() <= 0) { - p_ServerPort = "0"; - } - int intServerPort; - intServerPort = stoi(p_ServerPort); - sMConnect.setServerPort(intServerPort); - - if (startReceiveSPITMessages() == false) { - m_StopReceiveSPITMessages = true; - return false; - } - resetMessageNumberReceived(); - int intOldConnectionStatus = m_ConnectionStatus; + int intResult; + disconnect(); + { + mSPITSocket->setConnectionParams(p_ServerIP, p_ServerPort, p_ClientIP, p_ClientPort); + intResult = mSPITSocket->bindSocket(p_ServerIP, p_ClientIP, p_ClientPort); + if (intResult < 0) { + m_StopReceiveSPITMessages = true; + return false; + } + } + SPIT_Message::Connect sMConnect; + sMConnect.setClientComputerName(m_ComputerName); + sMConnect.setClientName(m_Name); + sMConnect.setLoginName(p_LoginName); + sMConnect.setLoginPassword(p_LoginPassword); + sMConnect.setServerIP(p_ServerIP); + if (p_ServerPort.length() <= 0) { + p_ServerPort = "0"; + } + int intServerPort; + intServerPort = stoi(p_ServerPort); + sMConnect.setServerPort(intServerPort); - m_ConnectionStatus = CONNECTION_TRYCONNECTION; - mCallbacks.onConnectionStatus(m_ServerID, m_ServerComputerName, m_ServerName, m_ServerStepTime, - m_ConnectionStatus, intOldConnectionStatus); + if (startReceiveSPITMessages() == false) { + m_StopReceiveSPITMessages = true; + return false; + } + resetMessageNumberReceived(); + int intOldConnectionStatus = m_ConnectionStatus; - //sleep a little to make sure that the reception of the messages is started - fos::Task::delayMs(500); - intResult = sendSPITMessage(sMConnect); - if (intResult < 0) { - m_ConnectionStatus = CONNECTION_NONE; - m_StopReceiveSPITMessages = true; - return false; - } - return true; + m_ConnectionStatus = CONNECTION_TRYCONNECTION; + mCallbacks.onConnectionStatus(m_ServerID, m_ServerComputerName, m_ServerName, m_ServerStepTime, + m_ConnectionStatus, intOldConnectionStatus); + + // sleep a little to make sure that the reception of the messages is started + fos::Task::delayMs(500); + intResult = sendSPITMessage(sMConnect); + if (intResult < 0) { + m_ConnectionStatus = CONNECTION_NONE; + m_StopReceiveSPITMessages = true; + return false; + } + return true; } /** * Terminates the connection to the SPITServer. */ void SPIT_Client::disconnect() { - disconnectInternal(CONNECTION_NONE); + disconnectInternal(CONNECTION_NONE); } void SPIT_Client::disconnectInternal(int p_Cause) { - int intOldConnectionStatus = m_ConnectionStatus; - int intResult; - - m_ConnectionStatus = p_Cause; - switch (m_ConnectionStatus) { - case CONNECTION_LOST: - break; - case CONNECTION_NONE: - { - SPIT_Message::Disconnect sMDisconnect; - intResult = sendSPITMessage(sMDisconnect); - if (intResult < 0) { - } - } - break; - case CONNECTION_NONESERVER: - break; - } - stopReceiveSPITMessages(); - mCallbacks.onConnectionStatus(m_ServerID, m_ServerComputerName, m_ServerName, m_ServerStepTime, - m_ConnectionStatus, intOldConnectionStatus); + int intOldConnectionStatus = m_ConnectionStatus; + int intResult; - if (intOldConnectionStatus != CONNECTION_NONE && intOldConnectionStatus != CONNECTION_NONESERVER) { - ESP_LOGI(TAG, "eventConnectionStatus %d ", m_ConnectionStatus); - switch (m_ConnectionStatus) { - case SPIT_Client::CONNECTION_NONE: - ESP_LOGD(TAG, "not connected"); - break; - case SPIT_Client::CONNECTION_NONESERVER: - ESP_LOGD(TAG, "connection terminated by server"); - // call eventProjectClosed because this may not be sended by the server, - // when the connection is closed - mCallbacks.onProjectClosed(m_ServerProjectID); + m_ConnectionStatus = p_Cause; + switch (m_ConnectionStatus) { + case CONNECTION_LOST: + break; + case CONNECTION_NONE: { + SPIT_Message::Disconnect sMDisconnect; + intResult = sendSPITMessage(sMDisconnect); + if (intResult < 0) { + } + } break; + case CONNECTION_NONESERVER: + break; + } + stopReceiveSPITMessages(); + mCallbacks.onConnectionStatus(m_ServerID, m_ServerComputerName, m_ServerName, m_ServerStepTime, + m_ConnectionStatus, intOldConnectionStatus); - // Server has terminated the connection -> start a new game - // _doReconnect = false; - startServerAutoDetect(); - break; - case SPIT_Client::CONNECTION_LOST: - ESP_LOGD(TAG, "connection lost"); - // Maybe you want to reconnect, see eventServerDetected(...) - // We have lost the connection -> set the flag to true and start the autodetection to reconnect at eventServerDetected(...) - // _doReconnect = true; - startServerAutoDetect(); - break; - } - } + if (intOldConnectionStatus != CONNECTION_NONE && intOldConnectionStatus != CONNECTION_NONESERVER) { + ESP_LOGI(TAG, "eventConnectionStatus %d ", m_ConnectionStatus); + switch (m_ConnectionStatus) { + case SPIT_Client::CONNECTION_NONE: + ESP_LOGD(TAG, "not connected"); + break; + case SPIT_Client::CONNECTION_NONESERVER: + ESP_LOGD(TAG, "connection terminated by server"); + // call eventProjectClosed because this may not be sended by the server, + // when the connection is closed + mCallbacks.onProjectUpdate(ProjUpdate::ServerClosed, m_ServerProjectID); + + // Server has terminated the connection -> start a new game + // _doReconnect = false; + startServerAutoDetect(); + break; + case SPIT_Client::CONNECTION_LOST: + ESP_LOGD(TAG, "connection lost"); + // Maybe you want to reconnect, see eventServerDetected(...) + // We have lost the connection -> set the flag to true and start the autodetection to reconnect at eventServerDetected(...) + // _doReconnect = true; + startServerAutoDetect(); + break; + } + } } -void SPIT_Client::parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswer) { - int intOldConnectionStatus; - intOldConnectionStatus = m_ConnectionStatus; +void SPIT_Client::parseConnectAnswer(SPIT_Message::ConnectAnswer *p_ConnectAnswer) { + int intOldConnectionStatus; + intOldConnectionStatus = m_ConnectionStatus; - if (p_ConnectAnswer->getClientID() != m_ID) return; + if (p_ConnectAnswer->getClientID() != m_ID) + return; - m_ServerID = p_ConnectAnswer->getServerID(); - m_ServerComputerName = p_ConnectAnswer->getServerComputerName(); - m_ServerName = p_ConnectAnswer->getServerName(); - m_ServerStepTime = p_ConnectAnswer->getStepTime(); - - if (p_ConnectAnswer->getConnected() == false) { - disconnectInternal(CONNECTION_NONESERVER); - } - else { - p_ConnectAnswer->getStepTime(); - m_ConnectionStatus = CONNECTION_OK; - m_DisconnectedByServer = false; - ESP_LOGD(TAG, "connection established"); - stopServerAutoDetect(); // normally you should stop the autodetection before you try a connection - // This is redundand - m_StopReceiveSPITMessages = false; + m_ServerID = p_ConnectAnswer->getServerID(); + m_ServerComputerName = p_ConnectAnswer->getServerComputerName(); + m_ServerName = p_ConnectAnswer->getServerName(); + m_ServerStepTime = p_ConnectAnswer->getStepTime(); - // Maybe you want to reconnect, see eventServerDetected(...) - // Here the connection is established -> don't reconnect at eventServerDetected(...) - // _doReconnect = false; - } + if (p_ConnectAnswer->getConnected() == false) { + disconnectInternal(CONNECTION_NONESERVER); + } else { + p_ConnectAnswer->getStepTime(); + m_ConnectionStatus = CONNECTION_OK; + m_DisconnectedByServer = false; + ESP_LOGD(TAG, "connection established"); + stopServerAutoDetect(); // normally you should stop the autodetection before you try a connection + // This is redundand + m_StopReceiveSPITMessages = false; + + // Maybe you want to reconnect, see eventServerDetected(...) + // Here the connection is established -> don't reconnect at eventServerDetected(...) + // _doReconnect = false; + } } /** * The SPIT server was closed * @param p_Disconnect */ -void SPIT_Client::parseDisconnect(SPIT_Message::Disconnect* p_Disconnect) { - int intCauseDisconnect = CONNECTION_NONESERVER; - /* - function o_Callable = bind(&SPIT_Client::disconnectInternal, this, intCauseDisconnect); - SPIT_Handler::addCallable(o_Callable); - */ - m_DisconnectedByServer = true; - SPIT_Client::disconnectInternal(intCauseDisconnect); +void SPIT_Client::parseDisconnect(SPIT_Message::Disconnect *p_Disconnect) { + int intCauseDisconnect = CONNECTION_NONESERVER; + /* + function o_Callable = bind(&SPIT_Client::disconnectInternal, this, intCauseDisconnect); + SPIT_Handler::addCallable(o_Callable); + */ + m_DisconnectedByServer = true; + SPIT_Client::disconnectInternal(intCauseDisconnect); } - //----- Watchdog ------ /** * The SPIT server sends a watchdog message at regular intervals. The client responds immediately with WatchdogAnswer
* Conversely, the client also sends a watchdog message at regular intervals and waits for a WatchdogAnswer message.
- * This is used to check if the other side is still present.
+ * This is used to check if the other side is still present.
* @param p_Watchdog */ -void SPIT_Client::parseWatchdog(SPIT_Message::Watchdog* p_Watchdog) { -// printf("parse Watchdog \n"); - SPIT_Message::WatchdogAnswer o_WatchdogAnswer; - ; - int intResult = sendSPITMessage(o_WatchdogAnswer); - if (intResult < 0) { - } +void SPIT_Client::parseWatchdog(SPIT_Message::Watchdog *p_Watchdog) { + // printf("parse Watchdog \n"); + SPIT_Message::WatchdogAnswer o_WatchdogAnswer; + ; + int intResult = sendSPITMessage(o_WatchdogAnswer); + if (intResult < 0) { + } } /** * The SPIT server sends a watchdog message at regular intervals. The client responds immediately with WatchdogAnswer
* Conversely, the client also sends a watchdog message at regular intervals and waits for a WatchdogAnswer message.
- * This is used to check if the other side is still present.
+ * This is used to check if the other side is still present.
* @param p_Watchdog */ -void SPIT_Client::parseWatchdogAnswer(SPIT_Message::WatchdogAnswer* p_WatchdogAnswer) { - answerWatchdog();; //is also done by parseSPIT_Message +void SPIT_Client::parseWatchdogAnswer(SPIT_Message::WatchdogAnswer *p_WatchdogAnswer) { + answerWatchdog(); + ; // is also done by parseSPIT_Message } void SPIT_Client::sendWatchdog() { - int intResult; - SPIT_Message::Watchdog sMWatchdog; - intResult = sendSPITMessage(sMWatchdog); - if (intResult < 0) { + int intResult; + SPIT_Message::Watchdog sMWatchdog; + intResult = sendSPITMessage(sMWatchdog); + if (intResult < 0) { ESP_LOGW("WDT", "Failed to send Watchdog msg"); - } + } } void SPIT_Client::eventWatchdogLost() { - if (m_ConnectionStatus == CONNECTION_TRYCONNECTION) { - disconnectInternal(CONNECTION_NONESERVER); - } - else { - disconnectInternal(CONNECTION_LOST); - } + if (m_ConnectionStatus == CONNECTION_TRYCONNECTION) { + disconnectInternal(CONNECTION_NONESERVER); + } else { + disconnectInternal(CONNECTION_LOST); + } } //----- SPIT Project ------ -void SPIT_Client::parseReportSPITProject(SPIT_Message::ReportSPITProject* p_ReportSPITProject) { -// printf("parse ReportSPITProject \n"); - if (p_ReportSPITProject == NULL) return; - m_ServerProjectID = p_ReportSPITProject->getProjectID(); - m_ServerProjectName = p_ReportSPITProject->getProjectName(); - m_ServerFramesPerSecond = p_ReportSPITProject->getFramesPerSecond(); - mCallbacks.onProjectReport(m_ServerProjectID, m_ServerProjectName, m_ServerFramesPerSecond); - - //Set all SPITTypes and SPITObjects confirmed = false - SPITType::setConfirmedFalse(); - SPITObject::setConfirmedFalse(); - - - //Send RequestProjectTransfer - SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer; - if (sendSPITMessage(sMRequestProjectTransfer) < 0) { - printf("SPIT_Client::parseReportSPITProject could not send RequestProjectTransfer\n"); - } +void SPIT_Client::parseReportSPITProject(SPIT_Message::ReportSPITProject *p_ReportSPITProject) { + // printf("parse ReportSPITProject \n"); + if (p_ReportSPITProject == NULL) + return; + m_ServerProjectID = p_ReportSPITProject->getProjectID(); + m_ServerProjectName = p_ReportSPITProject->getProjectName(); + m_ServerFramesPerSecond = p_ReportSPITProject->getFramesPerSecond(); + mCallbacks.onProjectUpdate(ProjUpdate::ServerLoaded, m_ServerProjectID); - // todo Don't send the ReportSPITProject here it should be sended after parseEndProjectTransfer - //Send client's ReportSPITProject - SPIT_Message::ReportSPITProject sMReportSPITProject; - sMReportSPITProject.setProjectID(m_ProjName); - sMReportSPITProject.setProjectName(m_ProjName); - sMReportSPITProject.setFramesPerSecond(0); - if (sendSPITMessage(sMReportSPITProject) < 0) { - printf("SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject"); - } -} -void SPIT_Client::parseCloseSPITProject(SPIT_Message::CloseSPITProject* p_CloseSPITProject) { -// printf("parse CloseSPITProject \n"); - if (p_CloseSPITProject == NULL) return; - string stringProjectID; - mCallbacks.onProjectClosed(p_CloseSPITProject->getProjectID()); -} + // Set all SPITTypes and SPITObjects confirmed = false + SPITType::setConfirmedFalse(); + SPITObject::setConfirmedFalse(); + // Send RequestProjectTransfer + SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer; + if (sendSPITMessage(sMRequestProjectTransfer) < 0) { + ESP_LOGD(TAG, "SPIT_Client::parseReportSPITProject could not send RequestProjectTransfer\n"); + } + + // todo Don't send the ReportSPITProject here it should be sended after parseEndProjectTransfer + // Send client's ReportSPITProject + SPIT_Message::ReportSPITProject sMReportSPITProject; + sMReportSPITProject.setProjectID(m_ProjName); + sMReportSPITProject.setProjectName(m_ProjName); + sMReportSPITProject.setFramesPerSecond(0); + if (sendSPITMessage(sMReportSPITProject) < 0) { + ESP_LOGD(TAG, "SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject"); + } +} +void SPIT_Client::parseCloseSPITProject(SPIT_Message::CloseSPITProject *p_CloseSPITProject) { + // printf("parse CloseSPITProject \n"); + if (p_CloseSPITProject == NULL) + return; + string stringProjectID; + mCallbacks.onProjectUpdate(ProjUpdate::ServerClosed, p_CloseSPITProject->getProjectID()); +} string SPIT_Client::getServerProjectID() { return m_ServerProjectID; } string SPIT_Client::getServerProjectName() { return m_ServerProjectName; } int SPIT_Client::getServerFramesPerSecond() { return m_ServerFramesPerSecond; } -void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer) { -// printf("parse RequestProjectTransfer \n"); - //StartProjectTransfer - SPIT_Message::StartProjectTransfer sMStartProjectTransfer; - fillHeader(sMStartProjectTransfer.getHeader()); - int intResult = sendSPITMessage(sMStartProjectTransfer); - if (intResult < 0) { - return; - } - - { - //send all listes SPITTypes - int intCount = SPITType::getSPITTypeCount(); - for (int i = 0; i < intCount; i++) { - SPITType* ptrSPITType = SPITType::getSPITType(i); - if (ptrSPITType == NULL) break; - sendSPITTypeInternal(ptrSPITType); - fos::Task::delayMs(10); - } - } - - { - int intCount = SPITObject::getSPITObjectCount(); - for (int i = 0; i < intCount; i++) { - SPITObject* ptrSPITObject = SPITObject::getSPITObject(i); - if (ptrSPITObject == NULL) break; - sendSPITObjectInternal(ptrSPITObject); - fos::Task::delayMs(10); - } - } +void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer *p_RequestProjectTransfer) { + // printf("parse RequestProjectTransfer \n"); + // StartProjectTransfer + SPIT_Message::StartProjectTransfer sMStartProjectTransfer; + fillHeader(sMStartProjectTransfer.getHeader()); + int intResult = sendSPITMessage(sMStartProjectTransfer); + if (intResult < 0) { + return; + } - //EndProjectTransfer - SPIT_Message::EndProjectTransfer sMEndProjectTransfer; - fillHeader(sMEndProjectTransfer.getHeader()); - intResult = sendSPITMessage(sMEndProjectTransfer); - if (intResult < 0) { - } + { + // send all listes SPITTypes + int intCount = SPITType::getSPITTypeCount(); + for (int i = 0; i < intCount; i++) { + SPITType *ptrSPITType = SPITType::getSPITType(i); + if (ptrSPITType == NULL) + break; + sendSPITTypeInternal(ptrSPITType); + fos::Task::delayMs(10); + } + } + + { + int intCount = SPITObject::getSPITObjectCount(); + for (int i = 0; i < intCount; i++) { + SPITObject *ptrSPITObject = SPITObject::getSPITObject(i); + if (ptrSPITObject == NULL) + break; + sendSPITObjectInternal(ptrSPITObject); + fos::Task::delayMs(10); + } + } + + // EndProjectTransfer + SPIT_Message::EndProjectTransfer sMEndProjectTransfer; + fillHeader(sMEndProjectTransfer.getHeader()); + intResult = sendSPITMessage(sMEndProjectTransfer); + if (intResult < 0) { + } } - -/* NEW IMPLEMENTATION +/* NEW IMPLEMENTATION void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer) { // printf("parse RequestProjectTransfer \n"); - thread* o_ThreadSend; - o_ThreadSend = new thread(&this->sendProject, this); - // int intResult; - // SPIT_Message::StartProjectTransfer* ptrSMStartProjectTransfer; - // SPIT_Message::EndProjectTransfer* ptrSMEndProjectTransfer; - // int intCount; - // SPITType* ptrSPITType; - // SPITObject* ptrSPITObject; - - - // //StartProjectTransfer - // NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(m_SPITClientInterface); - // SPIT_Handler::addRunnable(o_RunnableStart); + thread* o_ThreadSend; + o_ThreadSend = new thread(&this->sendProject, this); + // int intResult; + // SPIT_Message::StartProjectTransfer* ptrSMStartProjectTransfer; + // SPIT_Message::EndProjectTransfer* ptrSMEndProjectTransfer; + // int intCount; + // SPITType* ptrSPITType; + // SPITObject* ptrSPITObject; - // ptrSMStartProjectTransfer = new SPIT_Message::StartProjectTransfer(); - // intResult = sendSPITMessage(ptrSMStartProjectTransfer); - // if (intResult < 0) { - // return; - // } - // m_Watchdog->answerWatchdog(); - // { - // //send all listes SPITTypes - // unique_lock o_LockType(*SPITType::getMutex()); - // intCount = SPITType::getSPITTypeCount(); - // for (int i = 0; i < intCount; i++) { - // ptrSPITType = SPITType::getSPITType(i); - // if (ptrSPITType == NULL) continue; - // intResult = sendSPITTypeInternal(ptrSPITType); - // if (intResult < 0) return; - // m_Watchdog->answerWatchdog(); - // this_thread::sleep_for(chrono::milliseconds(7)); - // } - // } - - // { - // unique_lock o_LockObject(*SPITObject::getMutex()); - // intCount = SPITObject::getSPITObjectCount(); - // for (int i = 0; i < intCount; i++) { - // ptrSPITObject = SPITObject::getSPITObject(i); - // if (ptrSPITObject == NULL) continue; - // intResult = sendSPITObjectInternal(ptrSPITObject); - // if (intResult < 0) return; - // m_Watchdog->answerWatchdog(); - // this_thread::sleep_for(chrono::milliseconds(7)); - // } - // } - // //EndProjectTransfer - // ptrSMEndProjectTransfer = new SPIT_Message::EndProjectTransfer(); - // intResult = sendSPITMessage(ptrSMEndProjectTransfer); - // if (intResult < 0) { - // return; - // } - // m_Watchdog->answerWatchdog(); - // NotifyEndProjectTransfer_Client* o_RunnableEnd = new NotifyEndProjectTransfer_Client(m_SPITClientInterface); - // SPIT_Handler::addRunnable(o_RunnableEnd); - - // //Send act + // //StartProjectTransfer + // NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(m_SPITClientInterface); + // SPIT_Handler::addRunnable(o_RunnableStart); + + // ptrSMStartProjectTransfer = new SPIT_Message::StartProjectTransfer(); + // intResult = sendSPITMessage(ptrSMStartProjectTransfer); + // if (intResult < 0) { + // return; + // } + // m_Watchdog->answerWatchdog(); + // { + // //send all listes SPITTypes + // unique_lock o_LockType(*SPITType::getMutex()); + // intCount = SPITType::getSPITTypeCount(); + // for (int i = 0; i < intCount; i++) { + // ptrSPITType = SPITType::getSPITType(i); + // if (ptrSPITType == NULL) continue; + // intResult = sendSPITTypeInternal(ptrSPITType); + // if (intResult < 0) return; + // m_Watchdog->answerWatchdog(); + // this_thread::sleep_for(chrono::milliseconds(7)); + // } + // } + + // { + // unique_lock o_LockObject(*SPITObject::getMutex()); + // intCount = SPITObject::getSPITObjectCount(); + // for (int i = 0; i < intCount; i++) { + // ptrSPITObject = SPITObject::getSPITObject(i); + // if (ptrSPITObject == NULL) continue; + // intResult = sendSPITObjectInternal(ptrSPITObject); + // if (intResult < 0) return; + // m_Watchdog->answerWatchdog(); + // this_thread::sleep_for(chrono::milliseconds(7)); + // } + // } + + // //EndProjectTransfer + // ptrSMEndProjectTransfer = new SPIT_Message::EndProjectTransfer(); + // intResult = sendSPITMessage(ptrSMEndProjectTransfer); + // if (intResult < 0) { + // return; + // } + // m_Watchdog->answerWatchdog(); + // NotifyEndProjectTransfer_Client* o_RunnableEnd = new NotifyEndProjectTransfer_Client(m_SPITClientInterface); + // SPIT_Handler::addRunnable(o_RunnableEnd); + + // //Send act } */ -void SPIT_Client::sendProject(SPIT_Client* p_PtrSPIT_Client) { -// int intResult; -// SPIT_Message::StartProjectTransfer* ptrSMStartProjectTransfer; -// SPIT_Message::EndProjectTransfer* ptrSMEndProjectTransfer; -// int intCount; -// SPITType* ptrSPITType; -// SPITObject* ptrSPITObject; - -// //StartProjectTransfer -// NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(p_PtrSPIT_Client->getSPITClientInterface()); -// SPIT_Handler::addRunnable(o_RunnableStart); +void SPIT_Client::sendProject(SPIT_Client *p_PtrSPIT_Client) { + // int intResult; + // SPIT_Message::StartProjectTransfer* ptrSMStartProjectTransfer; + // SPIT_Message::EndProjectTransfer* ptrSMEndProjectTransfer; + // int intCount; + // SPITType* ptrSPITType; + // SPITObject* ptrSPITObject; -// ptrSMStartProjectTransfer = new SPIT_Message::StartProjectTransfer(); -// intResult = p_PtrSPIT_Client->sendSPITMessage(ptrSMStartProjectTransfer); -// if (intResult < 0) { -// return; -// } + // //StartProjectTransfer + // NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(p_PtrSPIT_Client->getSPITClientInterface()); + // SPIT_Handler::addRunnable(o_RunnableStart); -// // m_Watchdog->answerWatchdog(); -// // { -// //send all listes SPITTypes -// // unique_lock o_LockType(*SPITType::getMutex()); -// intCount = SPITType::getSPITTypeCount(); -// for (int i = 0; i < intCount; i++) { -// ptrSPITType = SPITType::getSPITType(i); -// if (ptrSPITType == NULL) continue; -// if (ptrSPITType->getCreatedByClient() == false) continue; -// intResult = p_PtrSPIT_Client->sendSPITTypeInternal(ptrSPITType); -// if (intResult < 0) return; -// // m_Watchdog->answerWatchdog(); -// this_thread::sleep_for(chrono::milliseconds(7)); -// } -// // } - -// // { -// // unique_lock o_LockObject(*SPITObject::getMutex()); -// intCount = SPITObject::getSPITObjectCount(); -// for (int i = 0; i < intCount; i++) { -// ptrSPITObject = SPITObject::getSPITObject(i); -// if (ptrSPITObject == NULL) continue; -// if (ptrSPITObject->getCreatedByClient() == false) continue; -// intResult = p_PtrSPIT_Client->sendSPITObjectInternal(ptrSPITObject); -// if (intResult < 0) return; -// // m_Watchdog->answerWatchdog(); -// this_thread::sleep_for(chrono::milliseconds(7)); -// } -// // } + // ptrSMStartProjectTransfer = new SPIT_Message::StartProjectTransfer(); + // intResult = p_PtrSPIT_Client->sendSPITMessage(ptrSMStartProjectTransfer); + // if (intResult < 0) { + // return; + // } -// //EndProjectTransfer -// ptrSMEndProjectTransfer = new SPIT_Message::EndProjectTransfer(); -// intResult = p_PtrSPIT_Client->sendSPITMessage(ptrSMEndProjectTransfer); -// if (intResult < 0) { -// return; -// } -// // m_Watchdog->answerWatchdog(); -// NotifyEndProjectTransfer_Client* o_RunnableEnd = new NotifyEndProjectTransfer_Client(p_PtrSPIT_Client->getSPITClientInterface()); -// SPIT_Handler::addRunnable(o_RunnableEnd); - -// //Send act + // // m_Watchdog->answerWatchdog(); + // // { + // //send all listes SPITTypes + // // unique_lock o_LockType(*SPITType::getMutex()); + // intCount = SPITType::getSPITTypeCount(); + // for (int i = 0; i < intCount; i++) { + // ptrSPITType = SPITType::getSPITType(i); + // if (ptrSPITType == NULL) continue; + // if (ptrSPITType->getCreatedByClient() == false) continue; + // intResult = p_PtrSPIT_Client->sendSPITTypeInternal(ptrSPITType); + // if (intResult < 0) return; + // // m_Watchdog->answerWatchdog(); + // this_thread::sleep_for(chrono::milliseconds(7)); + // } + // // } + + // // { + // // unique_lock o_LockObject(*SPITObject::getMutex()); + // intCount = SPITObject::getSPITObjectCount(); + // for (int i = 0; i < intCount; i++) { + // ptrSPITObject = SPITObject::getSPITObject(i); + // if (ptrSPITObject == NULL) continue; + // if (ptrSPITObject->getCreatedByClient() == false) continue; + // intResult = p_PtrSPIT_Client->sendSPITObjectInternal(ptrSPITObject); + // if (intResult < 0) return; + // // m_Watchdog->answerWatchdog(); + // this_thread::sleep_for(chrono::milliseconds(7)); + // } + // // } + + // //EndProjectTransfer + // ptrSMEndProjectTransfer = new SPIT_Message::EndProjectTransfer(); + // intResult = p_PtrSPIT_Client->sendSPITMessage(ptrSMEndProjectTransfer); + // if (intResult < 0) { + // return; + // } + // // m_Watchdog->answerWatchdog(); + // NotifyEndProjectTransfer_Client* o_RunnableEnd = new NotifyEndProjectTransfer_Client(p_PtrSPIT_Client->getSPITClientInterface()); + // SPIT_Handler::addRunnable(o_RunnableEnd); + + // //Send act } - -void SPIT_Client::parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer) { - mCallbacks.onStartProjectTransfer(); +void SPIT_Client::parseStartProjectTransfer(SPIT_Message::StartProjectTransfer *p_StartProjectTransfer) { + mCallbacks.onProjectUpdate(ProjUpdate::StartTransfer, m_ServerProjectID); } -void SPIT_Client::parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer) { - SPITObject::clearUnconfirmedSPITObjects(); - mCallbacks.onEndProjectTransfer(); +void SPIT_Client::parseEndProjectTransfer(SPIT_Message::EndProjectTransfer *p_EndProjectTransfer) { + SPITObject::clearUnconfirmedSPITObjects(); + mCallbacks.onProjectUpdate(ProjUpdate::EndTransfer, m_ServerProjectID); - //Send SPIT_Message::ReportSPITProject after the m_SPITClientInterface is notfied of EndProjectTransfer - SPIT_Message::ReportSPITProject ptrSMReportSPITProject; - ptrSMReportSPITProject.setProjectID(m_ProjName); - ptrSMReportSPITProject.setProjectName(m_ProjName); - ptrSMReportSPITProject.setFramesPerSecond(0); - if (sendSPITMessage(ptrSMReportSPITProject) < 0) { - printf("SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject"); - } + // Send SPIT_Message::ReportSPITProject after the m_SPITClientInterface is notfied of EndProjectTransfer + SPIT_Message::ReportSPITProject ptrSMReportSPITProject; + ptrSMReportSPITProject.setProjectID(m_ProjName); + ptrSMReportSPITProject.setProjectName(m_ProjName); + ptrSMReportSPITProject.setFramesPerSecond(0); + if (sendSPITMessage(ptrSMReportSPITProject) < 0) { + ESP_LOGD(TAG, "SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject"); + } } //----- SPIT Types ------ -void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPITType) { -// printf("parse ReportSPITType ID %s Name %s \n",p_ReportSPITType->getID(), p_ReportSPITType->getName()); - if (p_ReportSPITType == NULL) return; - SPITType* ptrSPITType; - bool boolNew = false; - bool boolChanged = false; - { - if (p_ReportSPITType->getServerRemote() == false) { - ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID()); - if (ptrSPITType == NULL) { - //The user's app my veto the SPITType - if (mCallbacks.onCheckSpitTypeVeto(p_ReportSPITType) == false) { - return; - } - ptrSPITType = new SPITType(); - boolNew = true; - } - } - else { - ptrSPITType = SPITType::getSPITTypeRemote(p_ReportSPITType->getID()); - if (ptrSPITType == NULL) { - ptrSPITType = new SPITType(); - boolNew = true; - } - } - try { - boolChanged = ptrSPITType->setMessageOP(p_ReportSPITType); - } - catch (...) { - //SPITType is not changable -> send back to the server - sendSPITTypeInternal(ptrSPITType); - return; - } - - //add or change SPITType - if (ptrSPITType->getServerRemote() == false) { - SPITType::addSPITType(ptrSPITType); - mCallbacks.onSpitType(boolNew, *ptrSPITType); - } - else { - SPITType::addSPITTypeRemote(ptrSPITType); - mCallbacks.onSpitTypeRemote(boolNew, *ptrSPITType); - } - - if (ptrSPITType != NULL) { - if (ptrSPITType->setConfirmed(true) == true || boolChanged == true) { - sendSPITTypeInternal(ptrSPITType); - } - } - } -} -void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType* p_RemoveSPITType) { -// printf("parse RemoveSPITType %s\n", p_RemoveSPITType->getID()); - if (p_RemoveSPITType == NULL) return; - string stringSPITTypeID; - bool boolRemote = false; - SPITType* ptrSPITType; - stringSPITTypeID = p_RemoveSPITType->getID(); - - { - ptrSPITType = SPITType::getSPITTypeRemote(stringSPITTypeID); - if (ptrSPITType != NULL) { - boolRemote = true; - } - else { - ptrSPITType = SPITType::getSPITType(stringSPITTypeID); - if (ptrSPITType != NULL) { - boolRemote = false; - } - else { - //No SPITType with stringSPITTypeID is listet - return; - } - } - - if (ptrSPITType->getCreatedByClient() && ptrSPITType->getFixed()) { - //the SPITyte is created by client himself and it is fixed -> don't remove the SPITType!! - //Send the SPITTyp back to the server - sendSPITTypeInternal(ptrSPITType); - return; - } +void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType *p_ReportSPITType) { + // printf("parse ReportSPITType ID %s Name %s \n",p_ReportSPITType->getID(), p_ReportSPITType->getName()); + if (p_ReportSPITType == NULL) + return; + SPITType *ptrSPITType; + bool boolNew = false; + bool boolChanged = false; + { + if (p_ReportSPITType->getServerRemote() == false) { + ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID()); + if (ptrSPITType == NULL) { + // The user's app my veto the SPITType + if (mCallbacks.onCheckSpitTypeVeto(p_ReportSPITType) == false) { + return; + } + ptrSPITType = new SPITType(); + boolNew = true; + } + } else { + ptrSPITType = SPITType::getSPITTypeRemote(p_ReportSPITType->getID()); + if (ptrSPITType == NULL) { + ptrSPITType = new SPITType(); + boolNew = true; + } + } + try { + boolChanged = ptrSPITType->setMessageOP(p_ReportSPITType); + } catch (...) { + // SPITType is not changable -> send back to the server + sendSPITTypeInternal(ptrSPITType); + return; + } - if (boolRemote == false) { - mCallbacks.onSpitTypeRemoved(*ptrSPITType); - SPITType::removeSPITType(ptrSPITType); - } - else { - mCallbacks.onSpitTypeRemoteRemoved(*ptrSPITType); - SPITType::removeSPITTypeRemote(ptrSPITType); - } - delete ptrSPITType; - } -} + auto eventType = boolNew ? ObjectEvent::Created : ObjectEvent::Changed; + // add or change SPITType + if (ptrSPITType->getServerRemote() == false) { + SPITType::addSPITType(ptrSPITType); + mCallbacks.onSpitType(eventType, *ptrSPITType); + } else { + SPITType::addSPITTypeRemote(ptrSPITType); + mCallbacks.onSpitTypeRemote(eventType, *ptrSPITType); + } + if (ptrSPITType != NULL) { + if (ptrSPITType->setConfirmed(true) == true || boolChanged == true) { + sendSPITTypeInternal(ptrSPITType); + } + } + } +} +void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType *p_RemoveSPITType) { + // printf("parse RemoveSPITType %s\n", p_RemoveSPITType->getID()); + if (p_RemoveSPITType == NULL) + return; + string stringSPITTypeID; + bool boolRemote = false; + SPITType *ptrSPITType; + stringSPITTypeID = p_RemoveSPITType->getID(); + + { + ptrSPITType = SPITType::getSPITTypeRemote(stringSPITTypeID); + if (ptrSPITType != NULL) { + boolRemote = true; + } else { + ptrSPITType = SPITType::getSPITType(stringSPITTypeID); + if (ptrSPITType != NULL) { + boolRemote = false; + } else { + // No SPITType with stringSPITTypeID is listet + return; + } + } + + if (ptrSPITType->getCreatedByClient() && ptrSPITType->getFixed()) { + // the SPITyte is created by client himself and it is fixed -> don't remove the SPITType!! + // Send the SPITTyp back to the server + sendSPITTypeInternal(ptrSPITType); + return; + } + + if (boolRemote == false) { + mCallbacks.onSpitType(ObjectEvent::Deleted, *ptrSPITType); + SPITType::removeSPITType(ptrSPITType); + } else { + mCallbacks.onSpitTypeRemote(ObjectEvent::Deleted, *ptrSPITType); + SPITType::removeSPITTypeRemote(ptrSPITType); + } + delete ptrSPITType; + } +} /** * If a client has changed a SPITType, it should send it to the server to transmit the changes.
* If the SPITType is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the changes.
- * @param p_SPITType the pointer to the changed SPITType + * @param p_SPITType the pointer to the changed SPITType * @return 0 = is sended, -1 = is not sended */ -int SPIT_Client::sendSPITTypeInternal(SPITType* p_SPITType) { - if (p_SPITType == NULL) return -1; - SPIT_Message::ReportSPITType ptrSMReportSPITType; - p_SPITType->fillMessageOP(&ptrSMReportSPITType); - return sendSPITMessage(ptrSMReportSPITType); +int SPIT_Client::sendSPITTypeInternal(SPITType *p_SPITType) { + if (p_SPITType == NULL) + return -1; + SPIT_Message::ReportSPITType ptrSMReportSPITType; + p_SPITType->fillMessageOP(&ptrSMReportSPITType); + return sendSPITMessage(ptrSMReportSPITType); } /** @@ -1090,255 +1050,256 @@ int SPIT_Client::sendSPITTypeInternal(SPITType* p_SPITType) { * @param p_SPITType the SPITType vont * @return true = changed, false = not changed maybe p_SPITType is NULL or the SPITType doesn't exists */ -bool SPIT_Client::changeSPITType(SPITType* p_SPITType) { - if (p_SPITType == NULL) return false; - SPITType* ptrSPITType; - { - ptrSPITType = SPITType::getSPITType(p_SPITType->getID()); - if (ptrSPITType == NULL) return false; - - ptrSPITType->setDefaultDelay(p_SPITType->getDefaultDelay()); - ptrSPITType->setDefaultDuration(p_SPITType->getDefaultDuration()); - ptrSPITType->setFixed(p_SPITType->getFixed()); - ptrSPITType->setGroupName(p_SPITType->getGroupName()); - ptrSPITType->setName(p_SPITType->getName()); - ptrSPITType->setProjectIndepended(p_SPITType->getProjectIndepended()); - - mCallbacks.onSpitType(false, *ptrSPITType); - sendSPITTypeInternal(ptrSPITType); - } - return true; +bool SPIT_Client::changeSPITType(SPITType *p_SPITType) { + if (p_SPITType == NULL) + return false; + SPITType *ptrSPITType; + { + ptrSPITType = SPITType::getSPITType(p_SPITType->getID()); + if (ptrSPITType == NULL) + return false; + + ptrSPITType->setDefaultDelay(p_SPITType->getDefaultDelay()); + ptrSPITType->setDefaultDuration(p_SPITType->getDefaultDuration()); + ptrSPITType->setFixed(p_SPITType->getFixed()); + ptrSPITType->setGroupName(p_SPITType->getGroupName()); + ptrSPITType->setName(p_SPITType->getName()); + ptrSPITType->setProjectIndepended(p_SPITType->getProjectIndepended()); + + mCallbacks.onSpitType(ObjectEvent::Changed, *ptrSPITType); + sendSPITTypeInternal(ptrSPITType); + } + return true; } /** * If a client has removed a SPITType where id == p_SPITTypeID, it should send it to the server.
* The corresponding SPITType if listet in SPITType will be deleted.
* An eventRemoveSPITType will occur.
* If a connection to a SPITServer is established, the SPITServer may dicard the deletion an an eventSPITType will occur
- * -> the SPITType will be listet again.
- * @param p_SPITType the id of the SPITType ro remove + * -> the SPITType will be listet again.
+ * @param p_SPITType the id of the SPITType ro remove * @return 0 = is sended, -1 = is not sended */ int SPIT_Client::removeSPITType(string p_SPITTypeID) { - if (p_SPITTypeID.length() <= 0) return -1; - SPITType* ptrSPITType; - { - ptrSPITType = SPITType::getSPITType(p_SPITTypeID); - if (ptrSPITType == NULL) return -1; - SPIT_Message::RemoveSPITType sMRemoveSPITType; - ptrSPITType->fillMessageOP(&sMRemoveSPITType); - mCallbacks.onSpitTypeRemoved(*ptrSPITType); - SPITType::removeSPITType(ptrSPITType); - delete ptrSPITType; - return sendSPITMessage(sMRemoveSPITType); - } - return -1; + if (p_SPITTypeID.length() <= 0) + return -1; + SPITType *ptrSPITType; + { + ptrSPITType = SPITType::getSPITType(p_SPITTypeID); + if (ptrSPITType == NULL) + return -1; + SPIT_Message::RemoveSPITType sMRemoveSPITType; + ptrSPITType->fillMessageOP(&sMRemoveSPITType); + mCallbacks.onSpitType(ObjectEvent::Deleted, *ptrSPITType); + SPITType::removeSPITType(ptrSPITType); + delete ptrSPITType; + return sendSPITMessage(sMRemoveSPITType); + } + return -1; } - -SPITType* SPIT_Client::createSPITTypeFixed(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration) { - return createSPITType(p_ID, p_GroupName, p_Name, p_DefaultDelay, p_DefaultDuration, true, true); +SPITType *SPIT_Client::createSPITTypeFixed(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration) { + return createSPITType(p_ID, p_GroupName, p_Name, p_DefaultDelay, p_DefaultDuration, true, true); } -SPITType* SPIT_Client::createSPITType(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration, bool p_FIxed, bool p_ProjectIndepended) { - SPITType* ptrSPITType; - bool boolNew; - { - ptrSPITType = SPITType::getSPITType(p_ID); - if (ptrSPITType == NULL) { - ptrSPITType = new SPITType(p_ID, p_GroupName, p_Name, p_FIxed, p_ProjectIndepended, p_DefaultDelay, p_DefaultDuration); - ptrSPITType->setCreatedByClient(true); - boolNew = true; - } - else { - ptrSPITType->setID(p_ID); - ptrSPITType->setGroupName(p_GroupName); - ptrSPITType->setName(p_Name); - ptrSPITType->setFixed(p_FIxed); - ptrSPITType->setProjectIndepended(p_ProjectIndepended); - ptrSPITType->setDefaultDelay(p_DefaultDelay); - ptrSPITType->setDefaultDuration(p_DefaultDuration); - boolNew = false; - } - } - SPITType::addSPITType(ptrSPITType); - mCallbacks.onSpitType(boolNew, *ptrSPITType); - sendSPITTypeInternal(ptrSPITType); - return ptrSPITType; +SPITType *SPIT_Client::createSPITType(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration, bool p_FIxed, bool p_ProjectIndepended) { + SPITType *ptrSPITType; + bool boolNew; + { + ptrSPITType = SPITType::getSPITType(p_ID); + if (ptrSPITType == NULL) { + ptrSPITType = new SPITType(p_ID, p_GroupName, p_Name, p_FIxed, p_ProjectIndepended, p_DefaultDelay, p_DefaultDuration); + ptrSPITType->setCreatedByClient(true); + boolNew = true; + } else { + ptrSPITType->setID(p_ID); + ptrSPITType->setGroupName(p_GroupName); + ptrSPITType->setName(p_Name); + ptrSPITType->setFixed(p_FIxed); + ptrSPITType->setProjectIndepended(p_ProjectIndepended); + ptrSPITType->setDefaultDelay(p_DefaultDelay); + ptrSPITType->setDefaultDuration(p_DefaultDuration); + boolNew = false; + } + } + + auto eventType = boolNew ? ObjectEvent::Created : ObjectEvent::Changed; + SPITType::addSPITType(ptrSPITType); + mCallbacks.onSpitType(eventType, *ptrSPITType); + sendSPITTypeInternal(ptrSPITType); + return ptrSPITType; } //----- SPIT Objects ------ -void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject* p_ReportSPITObject) { - -//printf("parse ReportSPITObject %s\n", p_ReportSPITObject->getID()); - if (p_ReportSPITObject == NULL) return; - SPITObject* ptrSPITObject; - SPITType* ptrSPITType; - bool boolNew = false; - bool boolRemote = false; - bool boolChanged = false; - { - if (p_ReportSPITObject->getServerRemote() == false) { - boolRemote = false; - ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITObject->getID()); - ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID()); - +void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject *p_ReportSPITObject) { + ESP_LOGD(TAG, "parse ReportSPITObject %s\n", p_ReportSPITObject->getID().c_str()); + if (p_ReportSPITObject == NULL) + return; + SPITObject *ptrSPITObject; + SPITType *ptrSPITType; + bool boolNew = false; + bool boolRemote = false; + bool boolChanged = false; + { + if (p_ReportSPITObject->getServerRemote() == false) { + boolRemote = false; + ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITObject->getID()); + ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID()); - if (ptrSPITType == NULL) { - //No associated SPITType found - if (ptrSPITObject != NULL) { - //SpitObject exists but has no corresponding SPITType -> remove the SPITObject without sending a message - //Maybe the SPITObject has changed the SPITTypeID to a SPITTypeID of another board - SPITObject::removeSPITObject(ptrSPITObject); - delete ptrSPITObject; - } - return; - } - if (ptrSPITObject == NULL) { - //The user's app my veto the SPITType - if (mCallbacks.onCheckSpitObjectVeto(p_ReportSPITObject) == false) { - return; - } - - ptrSPITObject = new SPITObject(); - boolNew = true; - } - else { - //The user's app my veto the SPITType - if (mCallbacks.onCheckSpitObjectVeto(p_ReportSPITObject) == false) { - //SpitObject exists and User APp denied the SPITObject -> remove the SPITObject without sending a message - SPITObject::removeSPITObject(ptrSPITObject); - delete ptrSPITObject; - return; - } - } - } - else { - boolRemote = true; - ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportSPITObject->getID()); - ptrSPITType = SPITType::getSPITTypeRemote(p_ReportSPITObject->getSPITTypeID()); - if (ptrSPITType == NULL) { - //No associated SPITType found - return; - } - if (ptrSPITObject == NULL) { - ptrSPITObject = new SPITObject(); - boolNew = true; - } - } - - try { - boolChanged = ptrSPITObject->setMessageOP(p_ReportSPITObject); - } - catch (...) { - //setMessageOP error - the SPITObject can't be changed, it may be fixed and crated by this client - sendSPITObjectInternal(ptrSPITObject); - return; - } + if (ptrSPITType == NULL) { + // No associated SPITType found + if (ptrSPITObject != NULL) { + // SpitObject exists but has no corresponding SPITType -> remove the SPITObject without sending a message + // Maybe the SPITObject has changed the SPITTypeID to a SPITTypeID of another board + SPITObject::removeSPITObject(ptrSPITObject); + delete ptrSPITObject; + } + return; + } + if (ptrSPITObject == NULL) { + // The user's app my veto the SPITType + if (mCallbacks.onCheckSpitObjectVeto(p_ReportSPITObject) == false) { + ESP_LOGD(TAG, "ObjectVeto %s / %s", p_ReportSPITObject->getID().c_str(), p_ReportSPITObject->getName().c_str()); + return; + } + ptrSPITObject = new SPITObject(); + boolNew = true; + } else { + // The user's app my veto the SPITType + if (mCallbacks.onCheckSpitObjectVeto(p_ReportSPITObject) == false) { + // SpitObject exists and User APp denied the SPITObject -> remove the SPITObject without sending a message + SPITObject::removeSPITObject(ptrSPITObject); + ESP_LOGD(TAG, "TypeVeto %s / %s", p_ReportSPITObject->getID().c_str(), p_ReportSPITObject->getName().c_str()); + delete ptrSPITObject; + return; + } + } + } else { + boolRemote = true; + ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportSPITObject->getID()); + ptrSPITType = SPITType::getSPITTypeRemote(p_ReportSPITObject->getSPITTypeID()); + if (ptrSPITType == NULL) { + // No associated SPITType found + return; + } + if (ptrSPITObject == NULL) { + ptrSPITObject = new SPITObject(); + boolNew = true; + } + } - if (boolRemote == false) { - //set the virtual action assignment - ptrSPITObject->setActionAssignedType(ptrSPITType->getActionAssigned()); - SPITObject::addSPITObject(ptrSPITObject); - } - else { - SPITObject::addSPITObjectRemote(ptrSPITObject); - } - - if (boolRemote) { - mCallbacks.onSpitObjectRemote(boolNew, *ptrSPITType, *ptrSPITObject); - } - else { - mCallbacks.onSpitObject(boolNew, *ptrSPITType, *ptrSPITObject); - } + try { + boolChanged = ptrSPITObject->setMessageOP(p_ReportSPITObject); + } catch (...) { + // setMessageOP error - the SPITObject can't be changed, it may be fixed and crated by this client + sendSPITObjectInternal(ptrSPITObject); + return; + } - if (ptrSPITObject->setConfirmed(true) == true || boolChanged == true) { - //Confirmation has changed - sendSPITObjectInternal(ptrSPITObject); - } - - } + if (boolRemote == false) { + // set the virtual action assignment + ptrSPITObject->setActionAssignedType(ptrSPITType->getActionAssigned()); + SPITObject::addSPITObject(ptrSPITObject); + } else { + SPITObject::addSPITObjectRemote(ptrSPITObject); + } + + auto eventType = boolNew ? ObjectEvent::Created : ObjectEvent::Changed; + if (boolRemote) { + mCallbacks.onSpitObjectRemote(eventType, *ptrSPITType, *ptrSPITObject); + } else { + mCallbacks.onSpitObject(eventType, *ptrSPITType, *ptrSPITObject); + } + + if (ptrSPITObject->setConfirmed(true) == true || boolChanged == true) { + // Confirmation has changed + sendSPITObjectInternal(ptrSPITObject); + } + } } -void SPIT_Client::parseRemoveSPITObject(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject) { -//printf("parse RemoveSPITObject %s\n", p_RemoveSPITObject->getID()); - if (p_RemoveSPITObject == NULL) return; - bool boolRemote = false; - SPITObject* ptrSPITObject; - SPITType* ptrSPITType; - - { - ptrSPITObject = SPITObject::getSPITObjectRemote(p_RemoveSPITObject->getID()); - if (ptrSPITObject != NULL) { - boolRemote = true; - ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID()); - if (ptrSPITType != NULL) { - if (boolRemote) { - mCallbacks.onSpitObjectRemoteRemoved(*ptrSPITType, *ptrSPITObject); - } - else { - mCallbacks.onSpitObjectRemoved(*ptrSPITType, *ptrSPITObject); - } - } - else { - //No associated SPITType found - //delete the SPITObject without a notification - } - SPITObject::removeSPITObjectRemote(ptrSPITObject); - delete ptrSPITObject; - } - else { - //call removeSPITObject, this will notify the server that the object is removed - removeSPITObject(p_RemoveSPITObject->getID()); - } +void SPIT_Client::parseRemoveSPITObject(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject) { + // printf("parse RemoveSPITObject %s\n", p_RemoveSPITObject->getID()); + if (p_RemoveSPITObject == NULL) + return; + bool boolRemote = false; + SPITObject *ptrSPITObject; + SPITType *ptrSPITType; - } + { + ptrSPITObject = SPITObject::getSPITObjectRemote(p_RemoveSPITObject->getID()); + if (ptrSPITObject != NULL) { + boolRemote = true; + ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID()); + if (ptrSPITType != NULL) { + if (boolRemote) { + mCallbacks.onSpitObjectRemote(ObjectEvent::Deleted, *ptrSPITType, *ptrSPITObject); + } else { + mCallbacks.onSpitObject(ObjectEvent::Deleted, *ptrSPITType, *ptrSPITObject); + } + } else { + // No associated SPITType found + // delete the SPITObject without a notification + } + SPITObject::removeSPITObjectRemote(ptrSPITObject); + delete ptrSPITObject; + } else { + // call removeSPITObject, this will notify the server that the object is removed + removeSPITObject(p_RemoveSPITObject->getID()); + } + } } -int SPIT_Client::sendSPITObjectInternal(SPITObject* ptrSPITObject) { - if (ptrSPITObject == NULL) return -1; - SPIT_Message::ReportSPITObject ptrSMReportSPITObject; - ptrSPITObject->fillMessageOP(&ptrSMReportSPITObject); +int SPIT_Client::sendSPITObjectInternal(SPITObject *ptrSPITObject) { + if (ptrSPITObject == NULL) + return -1; + SPIT_Message::ReportSPITObject ptrSMReportSPITObject; + ptrSPITObject->fillMessageOP(&ptrSMReportSPITObject); - return sendSPITMessage(ptrSMReportSPITObject); + return sendSPITMessage(ptrSMReportSPITObject); } /** * When the client changes an existing SPITObject (normally the client should not do this), then he should send the changes to the SPITServer.
* An eventSPITObject occurs.
* The SPITServer may discard the changes and a second eventSPITObject occurs to correct the changes.
* @param p_SPITObject the pointer to the changed SPITObject.
- * CAUTION: The SPITObject must already exist. + * CAUTION: The SPITObject must already exist. * @return true = SPITObject is changed, false = not changed, maybe p_SPITObject is NULL or the SPITObject doesn't exists */ -bool SPIT_Client::changeSPITObject(SPITObject* p_SPITObject) { - if (p_SPITObject == NULL) return false; - SPITObject* ptrSPITObject; - SPITType* ptrSPITType; - { - ptrSPITObject = SPITObject::getSPITObject(p_SPITObject->getID()); - if (ptrSPITObject == NULL) return false; - ptrSPITType = SPITType::getSPITType(p_SPITObject->getID()); - if(ptrSPITObject == NULL) return false; - - ptrSPITObject->setActionAssigned(p_SPITObject->getActionAssigned());; - ptrSPITObject->setDelay(p_SPITObject->getDelay()); - ptrSPITObject->setDuration(p_SPITObject->getDelay()); - ptrSPITObject->setFixed(p_SPITObject->getFixed()); - ptrSPITObject->setFrameFadeInLength(p_SPITObject->getFrameFadeInLength()); - ptrSPITObject->setFrameFadeOutLength(p_SPITObject->getFrameFadeOutLength()); - ptrSPITObject->setFrameLength(p_SPITObject->getFrameLength()); - ptrSPITObject->setFrameStart(p_SPITObject->getFrameStart()); - ptrSPITObject->setName(p_SPITObject->getName()); - ptrSPITObject->setRemark(p_SPITObject->getRemark()); - ptrSPITObject->setSPITTypeID(p_SPITObject->getSPITTypeID()); - ptrSPITObject->setServerParams(p_SPITObject->getServerParams()); - ptrSPITObject->setTrack(p_SPITObject->getTrack()); - ptrSPITObject->setValueFactor(p_SPITObject->getValueFactor()); - ptrSPITObject->setValueUse(p_SPITObject->getValueUse()); +bool SPIT_Client::changeSPITObject(SPITObject *p_SPITObject) { + if (p_SPITObject == NULL) + return false; + SPITObject *ptrSPITObject; + SPITType *ptrSPITType; + { + ptrSPITObject = SPITObject::getSPITObject(p_SPITObject->getID()); + if (ptrSPITObject == NULL) + return false; + ptrSPITType = SPITType::getSPITType(p_SPITObject->getID()); + if (ptrSPITObject == NULL) + return false; - mCallbacks.onSpitObject(false, *ptrSPITType, *ptrSPITObject); - sendSPITObjectInternal(ptrSPITObject); - } - return true; + ptrSPITObject->setActionAssigned(p_SPITObject->getActionAssigned()); + ; + ptrSPITObject->setDelay(p_SPITObject->getDelay()); + ptrSPITObject->setDuration(p_SPITObject->getDelay()); + ptrSPITObject->setFixed(p_SPITObject->getFixed()); + ptrSPITObject->setFrameFadeInLength(p_SPITObject->getFrameFadeInLength()); + ptrSPITObject->setFrameFadeOutLength(p_SPITObject->getFrameFadeOutLength()); + ptrSPITObject->setFrameLength(p_SPITObject->getFrameLength()); + ptrSPITObject->setFrameStart(p_SPITObject->getFrameStart()); + ptrSPITObject->setName(p_SPITObject->getName()); + ptrSPITObject->setRemark(p_SPITObject->getRemark()); + ptrSPITObject->setSPITTypeID(p_SPITObject->getSPITTypeID()); + ptrSPITObject->setServerParams(p_SPITObject->getServerParams()); + ptrSPITObject->setTrack(p_SPITObject->getTrack()); + ptrSPITObject->setValueFactor(p_SPITObject->getValueFactor()); + ptrSPITObject->setValueUse(p_SPITObject->getValueUse()); + + mCallbacks.onSpitObject(ObjectEvent::Changed, *ptrSPITType, *ptrSPITObject); + sendSPITObjectInternal(ptrSPITObject); + } + return true; } /** @@ -1349,168 +1310,150 @@ bool SPIT_Client::changeSPITObject(SPITObject* p_SPITObject) { * -> the SPITObject is listet again.
* @param p_SPITObjectID the id of the SPITObject to remove. * @return 0 = sended to the SPITServer, -1 = not sended to the SPITServer or nos SPITObject with id == p_SPITObjectID exists. - */ + */ int SPIT_Client::removeSPITObject(string p_SPITObjectID) { - if (p_SPITObjectID.length() <= 0) return -1; - SPITType* ptrSPITType; - SPITObject* ptrSPITObject; - { - SPIT_Message::RemoveSPITObject sMRemoveSPITObject; - - ptrSPITObject = SPITObject::getSPITObject(p_SPITObjectID); - if (ptrSPITObject == NULL) return -1; - ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID()); - if (ptrSPITType == NULL) return -1; - ptrSPITObject->fillMessageOP(&sMRemoveSPITObject); - mCallbacks.onSpitObjectRemoved(*ptrSPITType, *ptrSPITObject); - SPITObject::removeSPITObject(ptrSPITObject); - delete ptrSPITObject; - return sendSPITMessage(sMRemoveSPITObject); - } - return -1; -} + if (p_SPITObjectID.length() <= 0) + return -1; + SPITType *ptrSPITType; + SPITObject *ptrSPITObject; + { + SPIT_Message::RemoveSPITObject sMRemoveSPITObject; + ptrSPITObject = SPITObject::getSPITObject(p_SPITObjectID); + if (ptrSPITObject == NULL) + return -1; + ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID()); + if (ptrSPITType == NULL) + return -1; + ptrSPITObject->fillMessageOP(&sMRemoveSPITObject); + mCallbacks.onSpitObject(ObjectEvent::Deleted, *ptrSPITType, *ptrSPITObject); + SPITObject::removeSPITObject(ptrSPITObject); + delete ptrSPITObject; + return sendSPITMessage(sMRemoveSPITObject); + } + return -1; +} //----- Play SPIT Objects ------ -void SPIT_Client::parsePlaySPITStart(SPIT_Message::PlaySPITStart* p_PlaySPITStart) { -// printf("parse PlaySPITStart ID: %s Name: %s Running: %d\n", p_PlaySPITStart->getPlayerID(), p_PlaySPITStart->getPlayerName(), p_PlaySPITStart->getPlayerIsRunning()); - SPITPlayer* ptrSPITPlayer; - { - ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITStart->getPlayerID()); - if (ptrSPITPlayer == NULL) return; - ptrSPITPlayer->setIsRunning(p_PlaySPITStart->getPlayerIsRunning()); - ptrSPITPlayer->setName(p_PlaySPITStart->getPlayerName()); - ptrSPITPlayer->setType(p_PlaySPITStart->getPlayerType()); - ptrSPITPlayer->setTime(p_PlaySPITStart->getTime()); - ptrSPITPlayer->startPlaySequence(); +void SPIT_Client::parsePlaySPITStart(SPIT_Message::PlaySPITStart *p_PlaySPITStart) { + ESP_LOGD(TAG, "parse PlaySPITStart ID: %s Name: %s Running: %d", p_PlaySPITStart->getPlayerID().c_str(), p_PlaySPITStart->getPlayerName().c_str(), (int)p_PlaySPITStart->getPlayerIsRunning()); + SPITPlayer *ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITStart->getPlayerID()); + if (ptrSPITPlayer == NULL) + return; + ptrSPITPlayer->setIsRunning(p_PlaySPITStart->getPlayerIsRunning()); + ptrSPITPlayer->setName(p_PlaySPITStart->getPlayerName()); + ptrSPITPlayer->setType(p_PlaySPITStart->getPlayerType()); + ptrSPITPlayer->setTime(p_PlaySPITStart->getTime()); + ptrSPITPlayer->startPlaySequence(); - mCallbacks.onPlay(ptrSPITPlayer->getID(), ptrSPITPlayer->getName(), ptrSPITPlayer->getType(), ptrSPITPlayer->getIsRunning(), ptrSPITPlayer->getTime()); - } + mCallbacks.onPlay(ptrSPITPlayer->getID(), ptrSPITPlayer->getName(), ptrSPITPlayer->getType(), ptrSPITPlayer->getIsRunning(), ptrSPITPlayer->getTime()); } -void SPIT_Client::parsePlaySPITObject(SPIT_Message::PlaySPITObject* p_PlaySPITObject) { -// printf("parse RPlaySPITObject Object:%s\n", p_PlaySPITObject->getSPITObjectID()); - SPITPlayer* ptrSPITPlayer; - SPITPlayer::PlaySPITType* ptrPlaySPITType; - SPITObject* ptrSPITObject; - { - ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITObject->getPlayerID()); - if (ptrSPITPlayer == NULL) return; +void SPIT_Client::parsePlaySPITObject(SPIT_Message::PlaySPITObject *p_PlaySPITObject) { + SPITPlayer *ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITObject->getPlayerID()); + if (ptrSPITPlayer == NULL) + return; - //Fetch infoemations from SPITObject - ptrSPITObject = SPITObject::getSPITObject(p_PlaySPITObject->getSPITObjectID()); - if (ptrSPITObject == NULL) { - return; - } - ptrPlaySPITType = ptrSPITPlayer->addSPITType_Playing(ptrSPITObject->getSPITTypeID()); - if (ptrPlaySPITType == NULL) { - - return; - } - ptrPlaySPITType->setPlayerIsRunning(ptrSPITPlayer->getIsRunning()); - ptrPlaySPITType->addValue(((double)p_PlaySPITObject->getValue()/1000000), ((double)ptrSPITObject->getValueFactor()/1000000)); - } - + SPITObject *ptrSPITObject = SPITObject::getSPITObject(p_PlaySPITObject->getSPITObjectID()); + if (ptrSPITObject == NULL) { + return; + } + SPITPlayer::PlaySPITType *ptrPlaySPITType = ptrSPITPlayer->addSPITType_Playing(ptrSPITObject->getSPITTypeID()); + if (ptrPlaySPITType == NULL) { + return; + } + ptrPlaySPITType->setPlayerIsRunning(ptrSPITPlayer->getIsRunning()); + ptrPlaySPITType->addValue(((double)p_PlaySPITObject->getValue() / 1000000), ((double)ptrSPITObject->getValueFactor() / 1000000)); } -void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd* p_PlaySPITEnd) { -// printf("parse PlaySPITEnd \n"); - SPITPlayer* ptrSPITPlayer; - SPITType* ptrSPITType = NULL; - - // { - // ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID()); - // if (ptrSPITPlayer == NULL) return; +void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd *p_PlaySPITEnd) { + SPITPlayer *ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID()); + if (ptrSPITPlayer == NULL) + return; - // unordered_map* ptrPlayObjects; - // SPITPlayer::PlayObject* ptrPlayObject; - // bool boolStarted; - // bool boolStopped; + // unordered_map* ptrPlayObjects; + // bool boolStarted; + // bool boolStopped; - // ptrPlayObjects = ptrSPITPlayer->getPlayObjects(); - // for (auto i = ptrPlayObjects->begin(); i != ptrPlayObjects->end(); i++) { - // ptrPlayObject = i->second; - // boolStarted = false; - // boolStopped = false; - // if (ptrPlayObject->getIsNew()) { - // boolStarted = true; - // } - // if (ptrPlayObject->getIsPlayed() == false) { - // boolStopped = true; - // } - // { - // ptrSPITObject = SPITObject::getSPITObject(ptrPlayObject->getSPITObjectID()); - // if (ptrSPITObject == NULL) { - // return; - // } - // ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID()); - // if (ptrSPITType == NULL) { - // return; - // } + // SPITPlayer::PlaySPITType* ptrPlayObject = ptrSPITPlayer->getPlayObjects(); + // for (auto i = ptrPlayObjects->begin(); i != ptrPlayObjects->end(); i++) { + // ptrPlayObject = i->second; + // boolStarted = false; + // boolStopped = false; + // if (ptrPlayObject->getIsNew()) { + // boolStarted = true; + // } + // if (ptrPlayObject->getIsPlayed() == false) { + // boolStopped = true; + // } + // { + // ptrSPITObject = SPITObject::getSPITObject(ptrPlayObject->getSPITObjectID()); + // if (ptrSPITObject == NULL) { + // return; + // } + // SPITType *ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID()); + // if (ptrSPITType == NULL) { + // return; + // } - // mCallbacks.onPlaySpitType(ptrPlayObject->getPlayerID(), boolStarted, boolStopped, *ptrSPITType, *ptrSPITObject, *ptrPlayObject); - // } - // } - // ptrSPITPlayer->endPlaySequence(); - // } + // mCallbacks.onPlaySpitType(ptrPlayObject->getPlayerID(), boolStarted, boolStopped, *ptrSPITType, *ptrSPITObject, *ptrPlayObject); + // } + // } + // ptrSPITPlayer->endPlaySequence(); - ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID()); - if (ptrSPITPlayer == NULL) return; - - unordered_map* ptrPlaySPITTypes = ptrSPITPlayer->getPlaySPITTypes(); - for (auto i = ptrPlaySPITTypes->begin(); i != ptrPlaySPITTypes->end(); i++) { - SPITPlayer::PlaySPITType* ptrPlaySPITType = i->second; - bool boolStarted = false; - bool boolStopped = false; - if (ptrPlaySPITType->getIsNew()) { - boolStarted = true; - } - if (ptrPlaySPITType->getIsPlayed() == false) { - boolStopped = true; - } - { - ptrSPITType = SPITType::getSPITType(ptrPlaySPITType->getSPITTypeID()); - if (ptrSPITType == NULL) { - //set isplayed to false, the ptrPlayObject will be removed by ptrSPITPlayer->endPlaySequence() - ptrPlaySPITType->setIsPlayed(false); - continue; - } - mCallbacks.onPlaySpitType(ptrPlaySPITType->getPlayerID(), ptrPlaySPITType->getSPITTypeID(), ptrPlaySPITType->getPlayerIsRunning(), boolStarted, boolStopped, ptrPlaySPITType->getValue() ); - } - } - ptrSPITPlayer->endPlaySequence(); + // SPITPlayer *ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID()); + // if (ptrSPITPlayer == NULL) + // return; + unordered_map *ptrPlaySPITTypes = ptrSPITPlayer->getPlaySPITTypes(); + for (auto i = ptrPlaySPITTypes->begin(); i != ptrPlaySPITTypes->end(); i++) { + SPITPlayer::PlaySPITType *ptrPlaySPITType = i->second; + bool boolStarted = false; + bool boolStopped = false; + if (ptrPlaySPITType->getIsNew()) { + boolStarted = true; + } + if (ptrPlaySPITType->getIsPlayed() == false) { + boolStopped = true; + } + { + SPITType *ptrSPITType = SPITType::getSPITType(ptrPlaySPITType->getSPITTypeID()); + if (ptrSPITType == NULL) { + // set isplayed to false, the ptrPlayObject will be removed by ptrSPITPlayer->endPlaySequence() + ptrPlaySPITType->setIsPlayed(false); + continue; + } + mCallbacks.onPlaySpitType(ptrPlaySPITType->getPlayerID(), ptrPlaySPITType->getSPITTypeID(), ptrPlaySPITType->getPlayerIsRunning(), boolStarted, boolStopped, ptrPlaySPITType->getValue()); + } + } + ptrSPITPlayer->endPlaySequence(); } -void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_ReportPlayStatus) { - //only REMOTE server -> client - //printf(" parseReportPlayStatus "); - SPITType* ptrSPITType = NULL; - SPITObject* ptrSPITObject = NULL; - { - +void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus *p_ReportPlayStatus) { + ESP_LOGD(TAG, "parseReportPlayStatus"); + SPITType *ptrSPITType = NULL; + { - ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportPlayStatus->getID()); - if (ptrSPITObject == NULL) { - ptrSPITObject = SPITObject::getSPITObject(p_ReportPlayStatus->getID()); - if (ptrSPITObject == NULL) { - return; - } - } - if (ptrSPITObject->getServerRemote() == false) { - ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID()); - } - else { - ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID()); - } + SPITObject *ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportPlayStatus->getID()); + if (ptrSPITObject == NULL) { + ptrSPITObject = SPITObject::getSPITObject(p_ReportPlayStatus->getID()); + if (ptrSPITObject == NULL) { + return; + } + } + if (ptrSPITObject->getServerRemote() == false) { + ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID()); + } else { + ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID()); + } - if (ptrSPITType == NULL) { - return; - } - mCallbacks.onPlayRemoteObjectStatus(*ptrSPITType, *ptrSPITObject, p_ReportPlayStatus->getFrameInsideObject(), p_ReportPlayStatus->getValue()); - } + if (ptrSPITType == NULL) { + return; + } + mCallbacks.onPlayRemoteObjectStatus(*ptrSPITType, *ptrSPITObject, p_ReportPlayStatus->getFrameInsideObject(), p_ReportPlayStatus->getValue()); + } } - //--------- Remote ---------- +//--------- Remote ---------- /** * Send a remote control command to the SPITServer.
@@ -1527,43 +1470,44 @@ void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_Report * VALUEFLAG_DECREASE (0x01) The server decreases his existing value by p_Valueppm */ void SPIT_Client::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p_ValueFlag) { - SPITObject* ptrRemoteSPITObject; - { - ptrRemoteSPITObject = SPITObject::getSPITObjectRemote(p_SPITObjectID); - if (ptrRemoteSPITObject == NULL) return; - - SPIT_Message::PlaySPITStart playSPITStart; - playSPITStart.setPlayerID(m_ID); - playSPITStart.setPlayerName(m_ProjName); - playSPITStart.setPlayerIsRunning(false); - playSPITStart.setPlayerType(PLAYERTYPE_DISCRETE); - playSPITStart.setTime(0); - sendSPITMessage(playSPITStart); - - SPIT_Message::PlaySPITObject playSPITObject; - playSPITObject.setID(ptrRemoteSPITObject->getID()); - playSPITObject.setPlayPrePosition(false); - playSPITObject.setPlayerID(m_ID); - playSPITObject.setValue(p_Valueppm); - playSPITObject.setValueFlag(p_ValueFlag); - sendSPITMessage(playSPITObject); - - SPIT_Message::PlaySPITEnd playSPITEnd; - playSPITEnd.setPlayerID(m_ID); - sendSPITMessage(playSPITEnd); - } + SPITObject *ptrRemoteSPITObject; + { + ptrRemoteSPITObject = SPITObject::getSPITObjectRemote(p_SPITObjectID); + if (ptrRemoteSPITObject == NULL) + return; + + SPIT_Message::PlaySPITStart playSPITStart; + playSPITStart.setPlayerID(m_ID); + playSPITStart.setPlayerName(m_ProjName); + playSPITStart.setPlayerIsRunning(false); + playSPITStart.setPlayerType(PLAYERTYPE_DISCRETE); + playSPITStart.setTime(0); + sendSPITMessage(playSPITStart); + + SPIT_Message::PlaySPITObject playSPITObject; + playSPITObject.setID(ptrRemoteSPITObject->getID()); + playSPITObject.setPlayPrePosition(false); + playSPITObject.setPlayerID(m_ID); + playSPITObject.setValue(p_Valueppm); + playSPITObject.setValueFlag(p_ValueFlag); + sendSPITMessage(playSPITObject); + + SPIT_Message::PlaySPITEnd playSPITEnd; + playSPITEnd.setPlayerID(m_ID); + sendSPITMessage(playSPITEnd); + } } fos::Semaphore SPIT_Client::sStartSad; -void SPIT_Client::processSocketTask(SPIT_Client & instance) { - ESP_LOGI(TAG, "Starting Socket managing"); +void SPIT_Client::processSocketTask(SPIT_Client &instance) { + ESP_LOGI(TAG, "Starting Socket managing"); -static const string SERVERAUTODETECT_PRECODE = "#SAD#"; -static const string SERVERAUTODETECT_SEPERATOR = "#,#"; -static const string SERVERAUTODETECT_TASKID = "#spit#"; // -> "#SAD##,##spit#" -static const string SERVERAUTODETECT_PORT = "15110"; -static constexpr int WATCHDOGTIME = 3000; + static const string SERVERAUTODETECT_PRECODE = "#SAD#"; + static const string SERVERAUTODETECT_SEPERATOR = "#,#"; + static const string SERVERAUTODETECT_TASKID = "#spit#"; // -> "#SAD##,##spit#" + static const string SERVERAUTODETECT_PORT = "15110"; + static constexpr int WATCHDOGTIME = 3000; string stringDatagram = SERVERAUTODETECT_PRECODE + SERVERAUTODETECT_SEPERATOR + SERVERAUTODETECT_TASKID; int intDatagramLength = stringDatagram.length(); @@ -1623,14 +1567,14 @@ static constexpr int WATCHDOGTIME = 3000; intIndex++; } stringParts[SAD_DetectedServer::PARAMINDEX_IP] = stringServerIP; - SAD_DetectedServer::addDetectedServer(true, stringParts[SAD_DetectedServer::PARAMINDEX_ID], stringParts); + SAD_DetectedServer::addDetectedServer(stringParts[SAD_DetectedServer::PARAMINDEX_ID], stringParts); } fos::Task::delayMs(100); SAD_DetectedServer::cycleEnd(instance); - + instance.abortSearch = false; - // if(instance.m_ConnectionStatus == CONNECTION_OK) break; - fos::Task::delayMs(1000); + // if(instance.m_ConnectionStatus == CONNECTION_OK) break; + fos::Task::delayMs(1000); } instance.mSPITSocket->setBroadcast(false); @@ -1639,23 +1583,24 @@ static constexpr int WATCHDOGTIME = 3000; auto nextWdTrigger = fos::Timing::getMilliSec() + WATCHDOGTIME; auto nextWdCheck = nextWdTrigger + WATCHDOGTIME; while (true) { - auto time = fos::Timing::getMilliSec(); - if (time > nextWdTrigger) { - instance.sAnswered = false; - instance.sendWatchdog(); - nextWdTrigger = nextWdCheck + WATCHDOGTIME; - } + // auto time = fos::Timing::getMilliSec(); + // if (time > nextWdTrigger) { + // instance.sAnswered = false; + // // instance.sendWatchdog(); + // nextWdTrigger = nextWdCheck + WATCHDOGTIME; + // } - if (time > nextWdCheck) { - if (!instance.sAnswered) { - ESP_LOGW(TAG, "TimeOut"); - instance.eventWatchdogLost(); - break; - } - nextWdCheck = nextWdTrigger + WATCHDOGTIME; - } + // if (time > nextWdCheck) { + // if (!instance.sAnswered) { + // ESP_LOGW(TAG, "TimeOut"); + // instance.eventWatchdogLost(); + // break; + // } + // nextWdCheck = nextWdTrigger + WATCHDOGTIME; + // } fos::Task::delayMs(25); - if(instance.m_StopReceiveSPITMessages) break; + // if (instance.m_StopReceiveSPITMessages) + // break; } } } \ No newline at end of file diff --git a/components/spit/src/SPIT_Message.cpp b/components/spit/src/SPIT_Message.cpp index 8aef300..b88d531 100644 --- a/components/spit/src/SPIT_Message.cpp +++ b/components/spit/src/SPIT_Message.cpp @@ -4,1830 +4,1890 @@ * and open the template in the editor. */ -/* +/* * SPIT_Message contains all SPIT messages. * A SPIT_Message contains a Header and an OPPart. - * + * * File: SPIT_Message.cpp * Author: Hagi - * + * * Created on 3. April 2019, 08:51 */ #include "SPIT_Message.h" SPIT_Message::SPIT_Message() { - initMembers(); + initMembers(); } //---------- Receive --------- -SPIT_Message::SPIT_Message(char* p_MessageBytes, int p_MessageByteCount) { - initMembers(); - m_MessageBytes = p_MessageBytes; - if (m_MessageBytes == NULL) { - m_MessageByteCount = 0; - return; - } - m_MessageByteCount = p_MessageByteCount; - if (parse() == NULL) { - } +SPIT_Message::SPIT_Message(char *p_MessageBytes, int p_MessageByteCount) { + initMembers(); + m_MessageBytes = p_MessageBytes; + if (m_MessageBytes == NULL) { + m_MessageByteCount = 0; + return; + } + m_MessageByteCount = p_MessageByteCount; + if (parse() == NULL) { + } } SPIT_Message::~SPIT_Message() { - delete m_OPPart; - if (m_MessageBytesCreated && m_MessageBytes != NULL) { - free(m_MessageBytes); - } + delete m_OPPart; + if (m_MessageBytesCreated && m_MessageBytes != NULL) { + free(m_MessageBytes); + } } void SPIT_Message::initMembers() { - m_MessageBytes = NULL; - m_MessageByteCount = 0; - m_Header = NULL; - m_OPPart = NULL; - m_MessageBytesCreated = false; + m_MessageBytes = NULL; + m_MessageByteCount = 0; + m_Header = NULL; + m_OPPart = NULL; + m_MessageBytesCreated = false; } - - //Receive -SPIT_Message::OPPart* SPIT_Message::parse() { - if (m_MessageBytes == NULL) return NULL; - m_OPPart = NULL; - m_MessageBytesCreated = false; - //parse Header - m_Header = new Header(); - if (m_Header->parse(m_MessageBytes, m_MessageByteCount) == false) { - m_Header = NULL; - m_OPPart = NULL; - return NULL; - } - - //parse OP - switch (m_Header->getOPFlag()) { - //Connection - case SPIT_Message::Connect::OPFLAG: { - m_OPPart = new Connect(m_Header); - } - break; - case SPIT_Message::ConnectAnswer::OPFLAG: { - m_OPPart = new ConnectAnswer(m_Header); - } - break; - case Disconnect::OPFLAG: { - m_OPPart = new Disconnect(m_Header); - } - break; - case Watchdog::OPFLAG: { - m_OPPart = new Watchdog(m_Header); - } - break; - case WatchdogAnswer::OPFLAG: { - m_OPPart = new WatchdogAnswer(m_Header); - } - break; - - //SPITProject - case ReportSPITProject::OPFLAG: { - m_OPPart = new ReportSPITProject(m_Header); - } - break; - case CloseSPITProject::OPFLAG: { - m_OPPart = new CloseSPITProject(m_Header); - } - break; - case RequestProjectTransfer::OPFLAG: { - m_OPPart = new RequestProjectTransfer(m_Header); - } - break; - case StartProjectTransfer::OPFLAG: { - m_OPPart = new StartProjectTransfer(m_Header); - } - break; - case EndProjectTransfer::OPFLAG: { - m_OPPart = new EndProjectTransfer(m_Header); - } - break; - - //SPITType - case ReportSPITType::OPFLAG: { - m_OPPart = new ReportSPITType(m_Header); - } - break; - case RemoveSPITType::OPFLAG: { - m_OPPart = new RemoveSPITType(m_Header); - } - break; - - //SPITObject - case ReportSPITObject::OPFLAG: { - m_OPPart = new ReportSPITObject(m_Header); - } - break; - case RemoveSPITObject::OPFLAG: { - m_OPPart = new RemoveSPITObject(m_Header); - } - break; - //PlaySPITObjects - case PlaySPITStart::OPFLAG: { - m_OPPart = new PlaySPITStart(m_Header); - } - break; - case PlaySPITObject::OPFLAG: { - m_OPPart = new PlaySPITObject(m_Header); - } - break; - case PlaySPITEnd::OPFLAG: { - m_OPPart = new PlaySPITEnd(m_Header); - } - break; - case ReportPlayStatus::OPFLAG: { - m_OPPart = new ReportPlayStatus(m_Header); - } - break; - default: - m_OPPart = NULL; - break; - } - if (m_OPPart != NULL) { - if (m_OPPart->parse(m_MessageBytes, m_MessageByteCount) == false) { - delete m_OPPart; - m_Header = NULL; - m_OPPart = NULL; - return NULL; - } - } - return m_OPPart; +// Receive + +SPIT_Message::OPPart *SPIT_Message::parse() { + if (m_MessageBytes == NULL) + return NULL; + m_OPPart = NULL; + m_MessageBytesCreated = false; + // parse Header + m_Header = new Header(); + if (m_Header->parse(m_MessageBytes, m_MessageByteCount) == false) { + m_Header = NULL; + m_OPPart = NULL; + return NULL; + } + + // parse OP + switch (m_Header->getOPFlag()) { + // Connection + case SPIT_Message::Connect::OPFLAG: { + m_OPPart = new Connect(m_Header); + } break; + case SPIT_Message::ConnectAnswer::OPFLAG: { + m_OPPart = new ConnectAnswer(m_Header); + } break; + case Disconnect::OPFLAG: { + m_OPPart = new Disconnect(m_Header); + } break; + case Watchdog::OPFLAG: { + m_OPPart = new Watchdog(m_Header); + } break; + case WatchdogAnswer::OPFLAG: { + m_OPPart = new WatchdogAnswer(m_Header); + } break; + + // SPITProject + case ReportSPITProject::OPFLAG: { + m_OPPart = new ReportSPITProject(m_Header); + } break; + case CloseSPITProject::OPFLAG: { + m_OPPart = new CloseSPITProject(m_Header); + } break; + case RequestProjectTransfer::OPFLAG: { + m_OPPart = new RequestProjectTransfer(m_Header); + } break; + case StartProjectTransfer::OPFLAG: { + m_OPPart = new StartProjectTransfer(m_Header); + } break; + case EndProjectTransfer::OPFLAG: { + m_OPPart = new EndProjectTransfer(m_Header); + } break; + + // SPITType + case ReportSPITType::OPFLAG: { + m_OPPart = new ReportSPITType(m_Header); + } break; + case RemoveSPITType::OPFLAG: { + m_OPPart = new RemoveSPITType(m_Header); + } break; + + // SPITObject + case ReportSPITObject::OPFLAG: { + m_OPPart = new ReportSPITObject(m_Header); + } break; + case RemoveSPITObject::OPFLAG: { + m_OPPart = new RemoveSPITObject(m_Header); + } break; + // PlaySPITObjects + case PlaySPITStart::OPFLAG: { + m_OPPart = new PlaySPITStart(m_Header); + } break; + case PlaySPITObject::OPFLAG: { + m_OPPart = new PlaySPITObject(m_Header); + } break; + case PlaySPITEnd::OPFLAG: { + m_OPPart = new PlaySPITEnd(m_Header); + } break; + case ReportPlayStatus::OPFLAG: { + m_OPPart = new ReportPlayStatus(m_Header); + } break; + default: + m_OPPart = NULL; + break; + } + if (m_OPPart != NULL) { + if (m_OPPart->parse(m_MessageBytes, m_MessageByteCount) == false) { + delete m_OPPart; + m_Header = NULL; + m_OPPart = NULL; + return NULL; + } + } + return m_OPPart; } //---------- Send ---------- -SPIT_Message::SPIT_Message(OPPart* p_OPPart) { - initMembers(); - if (p_OPPart == NULL) return; - m_OPPart = p_OPPart; - m_Header = m_OPPart->getHeader(); - if (m_Header == NULL) { - m_OPPart = NULL; - return; - } +SPIT_Message::SPIT_Message(OPPart *p_OPPart) { + initMembers(); + if (p_OPPart == NULL) + return; + m_OPPart = p_OPPart; + m_Header = m_OPPart->getHeader(); + if (m_Header == NULL) { + m_OPPart = NULL; + return; + } } bool SPIT_Message::fillBytes() { - if (m_OPPart == NULL) return false; - try { - if (m_MessageBytes == NULL) m_MessageBytes = createByteArray(m_OPPart, &m_MessageByteCount); - if (m_MessageBytes == NULL) return false; - m_MessageBytesCreated = true; - return m_OPPart->fillBytes(m_MessageBytes, m_MessageByteCount); - } - catch(...) { - return false; - } - return true; + if (m_OPPart == NULL) + return false; + try { + if (m_MessageBytes == NULL) + m_MessageBytes = createByteArray(m_OPPart, &m_MessageByteCount); + if (m_MessageBytes == NULL) + return false; + m_MessageBytesCreated = true; + return m_OPPart->fillBytes(m_MessageBytes, m_MessageByteCount); + } catch (...) { + return false; + } + return true; } -const char* SPIT_Message::getMessageBytes() { - if (m_OPPart == NULL) return NULL; - if (fillBytes() == false) return NULL; - return m_MessageBytes; +const char *SPIT_Message::getMessageBytes() { + if (m_OPPart == NULL) + return NULL; + if (fillBytes() == false) + return NULL; + return m_MessageBytes; } - - //----------- Header ----------- - SPIT_Message::Header::~Header() { - } - SPIT_Message::Header::Header(const Header& orig) { - initMembers(); - m_MessageNumber = orig.getMessageNumber(); - m_ServerID = orig.getServerID(); - m_ClientID = orig.getClientID(); - } - //Receive - SPIT_Message::Header::Header() { - initMembers(); - } - - void SPIT_Message::Header::initMembers() { - m_SPITID = &SPITID[0]; - m_SPITVersion = SPITVERSION; - m_MessageNumber = 0; - m_BytesCount = BYTESLENGTH; - m_ServerID = ""; - m_ClientID = ""; - } - - bool SPIT_Message::Header::parse(char* p_MessageBytes, int p_MessageBytesLength) { - if (p_MessageBytes == NULL) return false; - string stringSPIT_ID; - try { - m_ParseOffset = 0; - //SPIT ID - stringSPIT_ID = getString(p_MessageBytes, p_MessageBytesLength, m_ParseOffset, 7); - m_ParseOffset += 7; - if (SPITID != stringSPIT_ID) return false; - m_SPITVersion = getInt(p_MessageBytes, p_MessageBytesLength, m_ParseOffset); - if (m_SPITVersion < 0) return false; - m_ParseOffset += 4; - m_MessageNumber = getByte(p_MessageBytes, p_MessageBytesLength, m_ParseOffset); - m_ParseOffset += 1; - m_BytesCount = getInt(p_MessageBytes, p_MessageBytesLength, m_ParseOffset); - if (m_BytesCount < 0) return false; - m_ParseOffset += 4; - m_ServerID = getString(p_MessageBytes, p_MessageBytesLength, m_ParseOffset, 41); - m_ParseOffset += 41; - m_ClientID = getString(p_MessageBytes, p_MessageBytesLength, m_ParseOffset, 41); - m_ParseOffset += 41; - m_OPFlag = p_MessageBytes[m_ParseOffset] & 0xFF; - m_ParseOffset += 1; - } - catch (...) { - return false; - } - return true; - } - - //Send - SPIT_Message::Header::Header(int p_SPITVersion, int p_OPFlag) { - initMembers(); - m_SPITVersion = p_SPITVersion; - m_OPFlag = p_OPFlag; - } - - void SPIT_Message::Header::setMessageNumber(unsigned char p_MessageNumber) { - m_MessageNumber = p_MessageNumber; - } - - void SPIT_Message::Header::setServerID(string p_ID) { - m_ServerID = p_ID; - } - void SPIT_Message::Header::setClientID(string p_ID) { - m_ClientID = p_ID; - } - void SPIT_Message::Header::setOPFlag(int p_OPFlag) { - m_OPFlag = p_OPFlag; - } - bool SPIT_Message::Header::fillBytes(char* p_Bytes, int p_ByteCount) { - if (p_Bytes == NULL) return false; - try { - m_ParseOffset = 0; - m_ParseOffset += setString(m_SPITID, p_Bytes, p_ByteCount, m_ParseOffset, 7); - m_ParseOffset += setInt(SPITVERSION, p_Bytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setByte(m_MessageNumber, p_Bytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setInt(m_BytesCount, p_Bytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_ServerID, p_Bytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setString(m_ClientID, p_Bytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setByte(m_OPFlag, p_Bytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } +SPIT_Message::Header::~Header() { +} +SPIT_Message::Header::Header(const Header &orig) { + initMembers(); + m_MessageNumber = orig.getMessageNumber(); + m_ServerID = orig.getServerID(); + m_ClientID = orig.getClientID(); +} +// Receive +SPIT_Message::Header::Header() { + initMembers(); +} + +void SPIT_Message::Header::initMembers() { + m_SPITID = &SPITID[0]; + m_SPITVersion = SPITVERSION; + m_MessageNumber = 0; + m_BytesCount = BYTESLENGTH; + m_ServerID = ""; + m_ClientID = ""; +} + +bool SPIT_Message::Header::parse(char *p_MessageBytes, int p_MessageBytesLength) { + if (p_MessageBytes == NULL) + return false; + string stringSPIT_ID; + try { + m_ParseOffset = 0; + // SPIT ID + stringSPIT_ID = getString(p_MessageBytes, p_MessageBytesLength, m_ParseOffset, 7); + m_ParseOffset += 7; + if (SPITID != stringSPIT_ID) + return false; + m_SPITVersion = getInt(p_MessageBytes, p_MessageBytesLength, m_ParseOffset); + if (m_SPITVersion < 0) + return false; + m_ParseOffset += 4; + m_MessageNumber = getByte(p_MessageBytes, p_MessageBytesLength, m_ParseOffset); + m_ParseOffset += 1; + m_BytesCount = getInt(p_MessageBytes, p_MessageBytesLength, m_ParseOffset); + if (m_BytesCount < 0) + return false; + m_ParseOffset += 4; + m_ServerID = getString(p_MessageBytes, p_MessageBytesLength, m_ParseOffset, 41); + m_ParseOffset += 41; + m_ClientID = getString(p_MessageBytes, p_MessageBytesLength, m_ParseOffset, 41); + m_ParseOffset += 41; + m_OPFlag = p_MessageBytes[m_ParseOffset] & 0xFF; + m_ParseOffset += 1; + } catch (...) { + return false; + } + return true; +} + +// Send +SPIT_Message::Header::Header(int p_SPITVersion, int p_OPFlag) { + initMembers(); + m_SPITVersion = p_SPITVersion; + m_OPFlag = p_OPFlag; +} + +void SPIT_Message::Header::setMessageNumber(unsigned char p_MessageNumber) { + m_MessageNumber = p_MessageNumber; +} + +void SPIT_Message::Header::setServerID(string p_ID) { + m_ServerID = p_ID; +} +void SPIT_Message::Header::setClientID(string p_ID) { + m_ClientID = p_ID; +} +void SPIT_Message::Header::setOPFlag(int p_OPFlag) { + m_OPFlag = p_OPFlag; +} +bool SPIT_Message::Header::fillBytes(char *p_Bytes, int p_ByteCount) { + if (p_Bytes == NULL) + return false; + try { + m_ParseOffset = 0; + m_ParseOffset += setString(m_SPITID, p_Bytes, p_ByteCount, m_ParseOffset, 7); + m_ParseOffset += setInt(SPITVERSION, p_Bytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setByte(m_MessageNumber, p_Bytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setInt(m_BytesCount, p_Bytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_ServerID, p_Bytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setString(m_ClientID, p_Bytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setByte(m_OPFlag, p_Bytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} - - //----------- OPPart ----------- - SPIT_Message::OPPart::~OPPart() { - if (m_Header != NULL) { - delete m_Header; - } - m_Header = NULL; - } - void SPIT_Message::OPPart::initMembers() { - m_Header = NULL; - m_ParseOffset = 0; - m_BytesCount = 0; - } +SPIT_Message::OPPart::~OPPart() { + if (m_Header != NULL) { + delete m_Header; + } + m_Header = NULL; +} +void SPIT_Message::OPPart::initMembers() { + m_Header = NULL; + m_ParseOffset = 0; + m_BytesCount = 0; +} + +// Receive +SPIT_Message::OPPart::OPPart(Header *p_Header, int p_OPFlag) { + initMembers(); + m_Header = p_Header; + if (m_Header != NULL) { + m_ParseOffset = Header::BYTESLENGTH; + m_Header->setOPFlag(p_OPFlag); + } +} +void SPIT_Message::OPPart::setHeader(Header *p_Header) { + m_Header = p_Header; + if (m_Header != NULL) { + m_ParseOffset = Header::BYTESLENGTH; + } +} + +// Send +SPIT_Message::OPPart::OPPart() { + initMembers(); +} - //Receive - SPIT_Message::OPPart::OPPart(Header* p_Header, int p_OPFlag) { - initMembers(); - m_Header = p_Header; - if (m_Header != NULL) { - m_ParseOffset = Header::BYTESLENGTH; - m_Header->setOPFlag(p_OPFlag); - } - } - void SPIT_Message::OPPart::setHeader(Header* p_Header) { - m_Header = p_Header; - if (m_Header != NULL) { - m_ParseOffset = Header::BYTESLENGTH; - } - } - - //Send - SPIT_Message::OPPart::OPPart() { - initMembers(); - } - //--------------------------- Connection -------------------------------- - - + //----------- Connect ----------- - SPIT_Message::Connect::~Connect(){ - } +SPIT_Message::Connect::~Connect() { +} /* SPIT_Message::Connect::Connect(const Connect& orig) : OPPart(new Header(*orig.getHeader()), OPFLAG) { - initMembers(); - if (orig.getHeader() == NULL) return; - m_ClientComputerName = stringCopy(orig.getClientComputerName()); - m_ClientName = stringCopy(orig.getClientName()); - m_LoginName = stringCopy(orig.getLoginName()); - m_LoginPassword = stringCopy(orig.getLoginPassword()); - m_ServerIP = stringCopy(orig.getServerIP()); - m_ServerPort = orig.getServerPort(); - } + initMembers(); + if (orig.getHeader() == NULL) return; + m_ClientComputerName = stringCopy(orig.getClientComputerName()); + m_ClientName = stringCopy(orig.getClientName()); + m_LoginName = stringCopy(orig.getLoginName()); + m_LoginPassword = stringCopy(orig.getLoginPassword()); + m_ServerIP = stringCopy(orig.getServerIP()); + m_ServerPort = orig.getServerPort(); + } */ - //Receive - SPIT_Message::Connect::Connect(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - - void SPIT_Message::Connect::initMembers() { - m_ClientComputerName = ""; - m_ClientName = ""; - m_LoginName = ""; - m_LoginPassword = ""; - m_ServerIP = ""; - m_ServerPort = 0; - m_BytesCount = BYTESLENGTH; - } - - bool SPIT_Message::Connect::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_ClientComputerName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_ClientName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_LoginName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_LoginPassword = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_ServerIP = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 40); - m_ParseOffset += 40; - m_ServerPort = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - - //Send - SPIT_Message::Connect::Connect() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - void SPIT_Message::Connect::setClientComputerName(string p_ComputerName) { - m_ClientComputerName = p_ComputerName; - } - void SPIT_Message::Connect::setClientName(string p_ClientName) { - m_ClientName = p_ClientName; - } - void SPIT_Message::Connect::setLoginName(string p_LoginName) { - m_LoginName = p_LoginName; - } - void SPIT_Message::Connect::setLoginPassword(string p_LoginPassword) { - m_LoginPassword = p_LoginPassword; - } - void SPIT_Message::Connect::setServerIP(string p_ServerIP) { - m_ServerIP = p_ServerIP; - } - void SPIT_Message::Connect::setServerPort(int p_ServerPort) { - if (p_ServerPort < 0 || p_ServerPort > 65535) p_ServerPort = 0; - m_ServerPort = p_ServerPort; - } - bool SPIT_Message::Connect::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_ClientComputerName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setString(m_ClientName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setString(m_LoginName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setString(m_LoginPassword, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setString(m_ServerIP, p_MessageBytes, p_ByteCount, m_ParseOffset, 40); - m_ParseOffset += setInt(m_ServerPort, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } - +// Receive +SPIT_Message::Connect::Connect(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} + +void SPIT_Message::Connect::initMembers() { + m_ClientComputerName = ""; + m_ClientName = ""; + m_LoginName = ""; + m_LoginPassword = ""; + m_ServerIP = ""; + m_ServerPort = 0; + m_BytesCount = BYTESLENGTH; +} + +bool SPIT_Message::Connect::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_ClientComputerName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_ClientName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_LoginName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_LoginPassword = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_ServerIP = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 40); + m_ParseOffset += 40; + m_ServerPort = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} + +// Send +SPIT_Message::Connect::Connect() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} +void SPIT_Message::Connect::setClientComputerName(string p_ComputerName) { + m_ClientComputerName = p_ComputerName; +} +void SPIT_Message::Connect::setClientName(string p_ClientName) { + m_ClientName = p_ClientName; +} +void SPIT_Message::Connect::setLoginName(string p_LoginName) { + m_LoginName = p_LoginName; +} +void SPIT_Message::Connect::setLoginPassword(string p_LoginPassword) { + m_LoginPassword = p_LoginPassword; +} +void SPIT_Message::Connect::setServerIP(string p_ServerIP) { + m_ServerIP = p_ServerIP; +} +void SPIT_Message::Connect::setServerPort(int p_ServerPort) { + if (p_ServerPort < 0 || p_ServerPort > 65535) + p_ServerPort = 0; + m_ServerPort = p_ServerPort; +} +bool SPIT_Message::Connect::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_ClientComputerName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setString(m_ClientName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setString(m_LoginName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setString(m_LoginPassword, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setString(m_ServerIP, p_MessageBytes, p_ByteCount, m_ParseOffset, 40); + m_ParseOffset += setInt(m_ServerPort, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} + //----------- ConnectAnswer ----------- - - void SPIT_Message::ConnectAnswer::initMembers() { - m_ServerComputerName = ""; - m_ServerName = ""; - m_Connected = false; - m_BytesCount = BYTESLENGTH; - m_StepTime = 40; - } - SPIT_Message::ConnectAnswer::~ConnectAnswer() { - } - SPIT_Message::ConnectAnswer::ConnectAnswer(const ConnectAnswer& orig) { - - } - //Receive - SPIT_Message::ConnectAnswer::ConnectAnswer(Header* p_Header) : OPPart(p_Header, OPFLAG) { - initMembers(); - } - bool SPIT_Message::ConnectAnswer::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_ServerComputerName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_ServerName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_StepTime = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_Connected = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - } - catch (...) { - return false; - } - return true; - } - - //Send - SPIT_Message::ConnectAnswer::ConnectAnswer() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - void SPIT_Message::ConnectAnswer::setServerComputerName(string p_ServerComputerName) { - m_ServerComputerName = p_ServerComputerName; - } - void SPIT_Message::ConnectAnswer::setServerName(string p_ServerName) { - m_ServerName = p_ServerName; - } - void SPIT_Message::ConnectAnswer::setConnected(bool p_Connected) { - m_Connected = p_Connected; - } - void SPIT_Message::ConnectAnswer::setStepTime(int p_StepTime_ms) { - if (p_StepTime_ms < 0) p_StepTime_ms = 1; - m_StepTime = p_StepTime_ms; - } - bool SPIT_Message::ConnectAnswer::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_ServerComputerName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setString(m_ServerName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setInt(m_StepTime, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_Connected, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } - + +void SPIT_Message::ConnectAnswer::initMembers() { + m_ServerComputerName = ""; + m_ServerName = ""; + m_Connected = false; + m_BytesCount = BYTESLENGTH; + m_StepTime = 40; +} +SPIT_Message::ConnectAnswer::~ConnectAnswer() { +} +SPIT_Message::ConnectAnswer::ConnectAnswer(const ConnectAnswer &orig) { +} +// Receive +SPIT_Message::ConnectAnswer::ConnectAnswer(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::ConnectAnswer::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_ServerComputerName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_ServerName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_StepTime = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_Connected = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + } catch (...) { + return false; + } + return true; +} + +// Send +SPIT_Message::ConnectAnswer::ConnectAnswer() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} +void SPIT_Message::ConnectAnswer::setServerComputerName(string p_ServerComputerName) { + m_ServerComputerName = p_ServerComputerName; +} +void SPIT_Message::ConnectAnswer::setServerName(string p_ServerName) { + m_ServerName = p_ServerName; +} +void SPIT_Message::ConnectAnswer::setConnected(bool p_Connected) { + m_Connected = p_Connected; +} +void SPIT_Message::ConnectAnswer::setStepTime(int p_StepTime_ms) { + if (p_StepTime_ms < 0) + p_StepTime_ms = 1; + m_StepTime = p_StepTime_ms; +} +bool SPIT_Message::ConnectAnswer::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_ServerComputerName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setString(m_ServerName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setInt(m_StepTime, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_Connected, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} + //----------- Disconnect ----------- - - void SPIT_Message::Disconnect::initMembers() { - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::Disconnect::~Disconnect() { - } - //Receive - SPIT_Message::Disconnect::Disconnect(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::Disconnect::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - - // Send - SPIT_Message::Disconnect::Disconnect() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - } - - bool SPIT_Message::Disconnect::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - +void SPIT_Message::Disconnect::initMembers() { + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::Disconnect::~Disconnect() { +} +// Receive +SPIT_Message::Disconnect::Disconnect(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::Disconnect::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} + +// Send +SPIT_Message::Disconnect::Disconnect() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); +} + +bool SPIT_Message::Disconnect::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} + //----------- Watchdog ----------- - void SPIT_Message::Watchdog::initMembers() { - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::Watchdog::~Watchdog() { - - } +void SPIT_Message::Watchdog::initMembers() { + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::Watchdog::~Watchdog() { +} + +// Receive +SPIT_Message::Watchdog::Watchdog(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::Watchdog::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} + +// Send +SPIT_Message::Watchdog::Watchdog() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} +bool SPIT_Message::Watchdog::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} - //Receive - SPIT_Message::Watchdog::Watchdog(Header* p_Header) : OPPart(p_Header, OPFLAG) { - initMembers(); - } - bool SPIT_Message::Watchdog::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - - // Send - SPIT_Message::Watchdog::Watchdog() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - bool SPIT_Message::Watchdog::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - //----------- WatchdogAnswer ----------- - void SPIT_Message::WatchdogAnswer::initMembers() { - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::WatchdogAnswer::~WatchdogAnswer() { +void SPIT_Message::WatchdogAnswer::initMembers() { + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::WatchdogAnswer::~WatchdogAnswer() { +} - } +// Receive +SPIT_Message::WatchdogAnswer::WatchdogAnswer(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::WatchdogAnswer::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} + +// Send +SPIT_Message::WatchdogAnswer::WatchdogAnswer() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} +bool SPIT_Message::WatchdogAnswer::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} - //Receive - SPIT_Message::WatchdogAnswer::WatchdogAnswer(Header* p_Header) : OPPart(p_Header, OPFLAG) { - initMembers(); - } - bool SPIT_Message::WatchdogAnswer::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - - - // Send - SPIT_Message::WatchdogAnswer::WatchdogAnswer() : OPPart(){ - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - bool SPIT_Message::WatchdogAnswer::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - - - - - //--------------------------- SPITProject -------------------------------- - + //----------- ReportSPITProject ----------- - void SPIT_Message::ReportSPITProject::initMembers() { - m_ProjectID = ""; - m_ProjectName = ""; - m_BytesCount = BYTESLENGTH; - m_FramesPerSecond = 1000; - } - SPIT_Message::ReportSPITProject::~ReportSPITProject() { - } - //Receive - SPIT_Message::ReportSPITProject::ReportSPITProject(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::ReportSPITProject::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_ProjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - m_ProjectName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_FramesPerSecond = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::ReportSPITProject::ReportSPITProject() : OPPart(){ - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::ReportSPITProject::setProjectID(string p_ProjectID) { - m_ProjectID = p_ProjectID; - } - void SPIT_Message::ReportSPITProject::setProjectName(string p_ProjectName) { - m_ProjectName = p_ProjectName; - } - void SPIT_Message::ReportSPITProject::setFramesPerSecond(const int p_FramesPerSecond) { - m_FramesPerSecond = p_FramesPerSecond; - } - bool SPIT_Message::ReportSPITProject::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_ProjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setString(m_ProjectName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setInt(m_FramesPerSecond, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } +void SPIT_Message::ReportSPITProject::initMembers() { + m_ProjectID = ""; + m_ProjectName = ""; + m_BytesCount = BYTESLENGTH; + m_FramesPerSecond = 1000; +} +SPIT_Message::ReportSPITProject::~ReportSPITProject() { +} +// Receive +SPIT_Message::ReportSPITProject::ReportSPITProject(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::ReportSPITProject::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_ProjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + m_ProjectName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_FramesPerSecond = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::ReportSPITProject::ReportSPITProject() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::ReportSPITProject::setProjectID(string p_ProjectID) { + m_ProjectID = p_ProjectID; +} +void SPIT_Message::ReportSPITProject::setProjectName(string p_ProjectName) { + m_ProjectName = p_ProjectName; +} +void SPIT_Message::ReportSPITProject::setFramesPerSecond(const int p_FramesPerSecond) { + m_FramesPerSecond = p_FramesPerSecond; +} +bool SPIT_Message::ReportSPITProject::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_ProjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setString(m_ProjectName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setInt(m_FramesPerSecond, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} //----------- StartProjectTransfer ----------- - void SPIT_Message::CloseSPITProject::initMembers() { - m_ProjectID = ""; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::CloseSPITProject::~CloseSPITProject() { - } - //Receive - SPIT_Message::CloseSPITProject::CloseSPITProject(Header* p_Header) : OPPart(p_Header, OPFLAG) { - initMembers(); - } - bool SPIT_Message::CloseSPITProject::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_ProjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::CloseSPITProject::CloseSPITProject() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::CloseSPITProject::setProjectID(string p_ProjectID) { - m_ProjectID = p_ProjectID; - } - bool SPIT_Message::CloseSPITProject::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_ProjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - } - catch (...) { - return false; - } - return true; - } +void SPIT_Message::CloseSPITProject::initMembers() { + m_ProjectID = ""; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::CloseSPITProject::~CloseSPITProject() { +} +// Receive +SPIT_Message::CloseSPITProject::CloseSPITProject(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::CloseSPITProject::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_ProjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::CloseSPITProject::CloseSPITProject() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::CloseSPITProject::setProjectID(string p_ProjectID) { + m_ProjectID = p_ProjectID; +} +bool SPIT_Message::CloseSPITProject::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_ProjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + } catch (...) { + return false; + } + return true; +} //----------- RequestProjectTransfer ----------- - - void SPIT_Message::RequestProjectTransfer::initMembers() { - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::RequestProjectTransfer::~RequestProjectTransfer() { - - } - //Receive - SPIT_Message::RequestProjectTransfer::RequestProjectTransfer(Header* p_Header) : OPPart(p_Header, OPFLAG) { - initMembers(); - } - bool SPIT_Message::RequestProjectTransfer::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::RequestProjectTransfer::RequestProjectTransfer() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - bool SPIT_Message::RequestProjectTransfer::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } - + +void SPIT_Message::RequestProjectTransfer::initMembers() { + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::RequestProjectTransfer::~RequestProjectTransfer() { +} +// Receive +SPIT_Message::RequestProjectTransfer::RequestProjectTransfer(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::RequestProjectTransfer::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::RequestProjectTransfer::RequestProjectTransfer() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} +bool SPIT_Message::RequestProjectTransfer::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} + //----------- StartProjectTransfer ----------- - - void SPIT_Message::StartProjectTransfer::initMembers() { - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::StartProjectTransfer::~StartProjectTransfer() { - } - //Receive - SPIT_Message::StartProjectTransfer::StartProjectTransfer(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::StartProjectTransfer::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::StartProjectTransfer::StartProjectTransfer() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - bool SPIT_Message::StartProjectTransfer::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } + +void SPIT_Message::StartProjectTransfer::initMembers() { + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::StartProjectTransfer::~StartProjectTransfer() { +} +// Receive +SPIT_Message::StartProjectTransfer::StartProjectTransfer(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::StartProjectTransfer::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::StartProjectTransfer::StartProjectTransfer() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +bool SPIT_Message::StartProjectTransfer::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} //----------- ENdProjectTransfer ----------- - - void SPIT_Message::EndProjectTransfer::initMembers() { - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::EndProjectTransfer::~EndProjectTransfer() { - - } - //Receive - SPIT_Message::EndProjectTransfer::EndProjectTransfer(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::EndProjectTransfer::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::EndProjectTransfer::EndProjectTransfer() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - bool SPIT_Message::EndProjectTransfer::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } - - - - - +void SPIT_Message::EndProjectTransfer::initMembers() { + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::EndProjectTransfer::~EndProjectTransfer() { +} +// Receive +SPIT_Message::EndProjectTransfer::EndProjectTransfer(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::EndProjectTransfer::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::EndProjectTransfer::EndProjectTransfer() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} +bool SPIT_Message::EndProjectTransfer::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} + //--------------------------- SPITType --------------------------------- - //----------- ReportSPITType ----------- - - void SPIT_Message::ReportSPITType::initMembers() { - m_Confirmed = false; - m_SPITTypeID = ""; - m_Fixed = false; - m_ServerRemote = false; - m_ServerProjectIndepended = false; - m_SPITTypeGroupName = ""; - m_SPITTypeName = ""; - m_Delay = 0; - m_Duration = 0; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::ReportSPITType::~ReportSPITType() { - } - //Receive - SPIT_Message::ReportSPITType::ReportSPITType(Header* p_Header) : OPPart(p_Header, OPFLAG) { - initMembers(); - } - bool SPIT_Message::ReportSPITType::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_Confirmed = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_SPITTypeID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - m_Fixed = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_ServerRemote = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_ServerProjectIndepended = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_SPITTypeGroupName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 39); - m_ParseOffset += 39; - m_SPITTypeName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_Delay = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_Duration = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::ReportSPITType::ReportSPITType() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::ReportSPITType::setConfirmed(bool p_Confirmed) { - m_Confirmed = p_Confirmed; - } - void SPIT_Message::ReportSPITType::setID(string p_ID) { - m_SPITTypeID = p_ID; - } - void SPIT_Message::ReportSPITType::setFixed(bool p_Fixed) { - m_Fixed = p_Fixed; - } - void SPIT_Message::ReportSPITType::setServerRemote(bool p_IsServerRemote) { - m_ServerRemote = p_IsServerRemote; - } - void SPIT_Message::ReportSPITType::setServerProjectIndepended(bool p_ProjectIndpended) { - m_ServerProjectIndepended = p_ProjectIndpended; - } - void SPIT_Message::ReportSPITType::setGroupName(string p_GroupName) { - m_SPITTypeGroupName = p_GroupName; - } - void SPIT_Message::ReportSPITType::setName(string p_Name) { - m_SPITTypeName = p_Name; - } - void SPIT_Message::ReportSPITType::setDelay(long long p_Delay) { - m_Delay = p_Delay; - } - void SPIT_Message::ReportSPITType::setDuration(long long p_Duration) { - m_Duration = p_Duration; - } - bool SPIT_Message::ReportSPITType::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = m_Header->BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_Confirmed, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_SPITTypeID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setBoolean(m_Fixed, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_ServerRemote, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_ServerProjectIndepended, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_SPITTypeGroupName, p_MessageBytes, p_ByteCount, m_ParseOffset, 39); - m_ParseOffset += setString(m_SPITTypeName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setLong(m_Delay, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setLong(m_Duration, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } - - //----------- ReportSPITType ----------- - - void SPIT_Message::RemoveSPITType::initMembers() { - m_SPITTypeID = ""; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::RemoveSPITType::~RemoveSPITType() { - } - //Receive - SPIT_Message::RemoveSPITType::RemoveSPITType(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::RemoveSPITType::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_SPITTypeID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::RemoveSPITType::RemoveSPITType() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::RemoveSPITType::setID(string p_ID) { - m_SPITTypeID = p_ID; - } - bool SPIT_Message::RemoveSPITType::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_SPITTypeID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - } - catch (...) { - return false; - } - return true; - } - +void SPIT_Message::ReportSPITType::initMembers() { + m_Confirmed = false; + m_SPITTypeID = ""; + m_Fixed = false; + m_ServerRemote = false; + m_ServerProjectIndepended = false; + m_SPITTypeGroupName = ""; + m_SPITTypeName = ""; + m_Delay = 0; + m_Duration = 0; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::ReportSPITType::~ReportSPITType() { +} +// Receive +SPIT_Message::ReportSPITType::ReportSPITType(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::ReportSPITType::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_Confirmed = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_SPITTypeID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + m_Fixed = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_ServerRemote = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_ServerProjectIndepended = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_SPITTypeGroupName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 39); + m_ParseOffset += 39; + m_SPITTypeName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_Delay = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_Duration = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::ReportSPITType::ReportSPITType() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::ReportSPITType::setConfirmed(bool p_Confirmed) { + m_Confirmed = p_Confirmed; +} +void SPIT_Message::ReportSPITType::setID(string p_ID) { + m_SPITTypeID = p_ID; +} +void SPIT_Message::ReportSPITType::setFixed(bool p_Fixed) { + m_Fixed = p_Fixed; +} +void SPIT_Message::ReportSPITType::setServerRemote(bool p_IsServerRemote) { + m_ServerRemote = p_IsServerRemote; +} +void SPIT_Message::ReportSPITType::setServerProjectIndepended(bool p_ProjectIndpended) { + m_ServerProjectIndepended = p_ProjectIndpended; +} +void SPIT_Message::ReportSPITType::setGroupName(string p_GroupName) { + m_SPITTypeGroupName = p_GroupName; +} +void SPIT_Message::ReportSPITType::setName(string p_Name) { + m_SPITTypeName = p_Name; +} +void SPIT_Message::ReportSPITType::setDelay(long long p_Delay) { + m_Delay = p_Delay; +} +void SPIT_Message::ReportSPITType::setDuration(long long p_Duration) { + m_Duration = p_Duration; +} +bool SPIT_Message::ReportSPITType::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = m_Header->BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_Confirmed, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_SPITTypeID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setBoolean(m_Fixed, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_ServerRemote, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_ServerProjectIndepended, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_SPITTypeGroupName, p_MessageBytes, p_ByteCount, m_ParseOffset, 39); + m_ParseOffset += setString(m_SPITTypeName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setLong(m_Delay, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setLong(m_Duration, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} + +//----------- ReportSPITType ----------- + +void SPIT_Message::RemoveSPITType::initMembers() { + m_SPITTypeID = ""; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::RemoveSPITType::~RemoveSPITType() { +} +// Receive +SPIT_Message::RemoveSPITType::RemoveSPITType(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::RemoveSPITType::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_SPITTypeID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::RemoveSPITType::RemoveSPITType() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::RemoveSPITType::setID(string p_ID) { + m_SPITTypeID = p_ID; +} +bool SPIT_Message::RemoveSPITType::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_SPITTypeID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + } catch (...) { + return false; + } + return true; +} + //---------------------------- SPITObjects ---------------------------------- - + //----------- ReportSPITObject ----------- - void SPIT_Message::ReportSPITObject::initMembers() { - m_Confirmed = false; - m_SPITObjectID = ""; - m_Fixed = false; - m_ServerRemote = false; - m_SPITObjectName = ""; - m_SPITTypeID = ""; - m_ServerParams = ""; - m_FrameStart = 0; - m_FrameLength = 0; - m_FrameFadeInLength = 0; - m_FrameFadeOutLength = 0; - m_ValueFactor = 0; - m_ValueUse = VALUEUSE_DISCARD; - m_Track = 0; - m_Remark = ""; - m_Delay = 0; - m_Duration = 0; - m_ActionAssigned = false; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::ReportSPITObject::~ReportSPITObject() { - } - //Receive - SPIT_Message::ReportSPITObject::ReportSPITObject(Header* p_Header) : OPPart(p_Header, OPFLAG) { - initMembers(); - } - bool SPIT_Message::ReportSPITObject::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_Confirmed = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_SPITObjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - m_Fixed = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_ServerRemote = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_SPITObjectName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_SPITTypeID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - m_ServerParams = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_FrameStart = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_FrameLength = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_FrameFadeInLength = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_FrameFadeOutLength = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_ValueFactor = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_ValueUse = getByte(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_Track = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_Remark = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_Delay = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_Duration = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_ActionAssigned = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::ReportSPITObject::ReportSPITObject() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::ReportSPITObject::setConfirmed(bool p_Confirmed) { - m_Confirmed = p_Confirmed; - } - void SPIT_Message::ReportSPITObject::setID(string p_ID) { - m_SPITObjectID = p_ID; - } - void SPIT_Message::ReportSPITObject::setFixed(bool p_Fixed) { - m_Fixed = p_Fixed; - } - void SPIT_Message::ReportSPITObject::setServerRemote(bool p_IsRemote) { - m_ServerRemote = p_IsRemote; - } - void SPIT_Message::ReportSPITObject::setName(string p_Name) { - m_SPITObjectName = p_Name; - } - void SPIT_Message::ReportSPITObject::setSPITTypeID(string p_ID) { - m_SPITTypeID = p_ID; - } - void SPIT_Message::ReportSPITObject::setServerParams(string p_Parameters) { - m_ServerParams = p_Parameters; - } - void SPIT_Message::ReportSPITObject::setFrameStart(long long p_StartTime) { - m_FrameStart = p_StartTime; - } - void SPIT_Message::ReportSPITObject::setFrameLength(long long p_Length) { - m_FrameLength = p_Length; - } - void SPIT_Message::ReportSPITObject::setFrameFadeInLength(long long p_FadeInTime) { - m_FrameFadeInLength = p_FadeInTime; - } - void SPIT_Message::ReportSPITObject::setFrameFadeOutLength(long long p_FadeOutTime) { - m_FrameFadeOutLength = p_FadeOutTime; - } - void SPIT_Message::ReportSPITObject::setValueFactor(int p_Volume) { - m_ValueFactor = p_Volume; - } - void SPIT_Message::ReportSPITObject::setValueUse(char p_ValueUse) { - m_ValueUse = p_ValueUse; - } - void SPIT_Message::ReportSPITObject::setTrack(int p_Track) { - m_Track = p_Track; - } - void SPIT_Message::ReportSPITObject::setRemark(string p_Description) { - m_Remark = p_Description; - } - void SPIT_Message::ReportSPITObject::setDelay(long long p_Delay) { - if (p_Delay < 0) p_Delay = 0; - m_Delay = p_Delay; - } - void SPIT_Message::ReportSPITObject::setDuration(long long p_Duration) { - if (p_Duration < 0) p_Duration = 0; - m_Duration = p_Duration; - } - - void SPIT_Message::ReportSPITObject::setActionAssigned(bool p_ActionAssigned) { - m_ActionAssigned = p_ActionAssigned; - } - bool SPIT_Message::ReportSPITObject::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_Confirmed, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_SPITObjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setBoolean(m_Fixed, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_ServerRemote, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_SPITObjectName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setString(m_SPITTypeID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setString(m_ServerParams, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setLong(m_FrameStart, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setLong(m_FrameLength, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setLong(m_FrameFadeInLength, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setLong(m_FrameFadeOutLength, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setInt(m_ValueFactor, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setByte(m_ValueUse, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setInt(m_Track, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_Remark, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setLong(m_Delay, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setLong(m_Duration, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_ActionAssigned, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } +void SPIT_Message::ReportSPITObject::initMembers() { + m_Confirmed = false; + m_SPITObjectID = ""; + m_Fixed = false; + m_ServerRemote = false; + m_SPITObjectName = ""; + m_SPITTypeID = ""; + m_ServerParams = ""; + m_FrameStart = 0; + m_FrameLength = 0; + m_FrameFadeInLength = 0; + m_FrameFadeOutLength = 0; + m_ValueFactor = 0; + m_ValueUse = VALUEUSE_DISCARD; + m_Track = 0; + m_Remark = ""; + m_Delay = 0; + m_Duration = 0; + m_ActionAssigned = false; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::ReportSPITObject::~ReportSPITObject() { +} +// Receive +SPIT_Message::ReportSPITObject::ReportSPITObject(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::ReportSPITObject::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_Confirmed = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_SPITObjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + m_Fixed = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_ServerRemote = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_SPITObjectName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_SPITTypeID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + m_ServerParams = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_FrameStart = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_FrameLength = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_FrameFadeInLength = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_FrameFadeOutLength = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_ValueFactor = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_ValueUse = getByte(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_Track = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_Remark = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_Delay = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_Duration = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_ActionAssigned = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::ReportSPITObject::ReportSPITObject() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::ReportSPITObject::setConfirmed(bool p_Confirmed) { + m_Confirmed = p_Confirmed; +} +void SPIT_Message::ReportSPITObject::setID(string p_ID) { + m_SPITObjectID = p_ID; +} +void SPIT_Message::ReportSPITObject::setFixed(bool p_Fixed) { + m_Fixed = p_Fixed; +} +void SPIT_Message::ReportSPITObject::setServerRemote(bool p_IsRemote) { + m_ServerRemote = p_IsRemote; +} +void SPIT_Message::ReportSPITObject::setName(string p_Name) { + m_SPITObjectName = p_Name; +} +void SPIT_Message::ReportSPITObject::setSPITTypeID(string p_ID) { + m_SPITTypeID = p_ID; +} +void SPIT_Message::ReportSPITObject::setServerParams(string p_Parameters) { + m_ServerParams = p_Parameters; +} +void SPIT_Message::ReportSPITObject::setFrameStart(long long p_StartTime) { + m_FrameStart = p_StartTime; +} +void SPIT_Message::ReportSPITObject::setFrameLength(long long p_Length) { + m_FrameLength = p_Length; +} +void SPIT_Message::ReportSPITObject::setFrameFadeInLength(long long p_FadeInTime) { + m_FrameFadeInLength = p_FadeInTime; +} +void SPIT_Message::ReportSPITObject::setFrameFadeOutLength(long long p_FadeOutTime) { + m_FrameFadeOutLength = p_FadeOutTime; +} +void SPIT_Message::ReportSPITObject::setValueFactor(int p_Volume) { + m_ValueFactor = p_Volume; +} +void SPIT_Message::ReportSPITObject::setValueUse(char p_ValueUse) { + m_ValueUse = p_ValueUse; +} +void SPIT_Message::ReportSPITObject::setTrack(int p_Track) { + m_Track = p_Track; +} +void SPIT_Message::ReportSPITObject::setRemark(string p_Description) { + m_Remark = p_Description; +} +void SPIT_Message::ReportSPITObject::setDelay(long long p_Delay) { + if (p_Delay < 0) + p_Delay = 0; + m_Delay = p_Delay; +} +void SPIT_Message::ReportSPITObject::setDuration(long long p_Duration) { + if (p_Duration < 0) + p_Duration = 0; + m_Duration = p_Duration; +} + +void SPIT_Message::ReportSPITObject::setActionAssigned(bool p_ActionAssigned) { + m_ActionAssigned = p_ActionAssigned; +} +bool SPIT_Message::ReportSPITObject::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_Confirmed, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_SPITObjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setBoolean(m_Fixed, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_ServerRemote, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_SPITObjectName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setString(m_SPITTypeID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setString(m_ServerParams, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setLong(m_FrameStart, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setLong(m_FrameLength, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setLong(m_FrameFadeInLength, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setLong(m_FrameFadeOutLength, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setInt(m_ValueFactor, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setByte(m_ValueUse, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setInt(m_Track, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_Remark, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setLong(m_Delay, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setLong(m_Duration, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_ActionAssigned, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} //----------- RemoveSPITObject ----------- - void SPIT_Message::RemoveSPITObject::initMembers() { - m_SPITObjectID = ""; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::RemoveSPITObject::~RemoveSPITObject() { - } - //Receive - SPIT_Message::RemoveSPITObject::RemoveSPITObject(Header* p_Header) : OPPart(p_Header, OPFLAG) { - initMembers(); - } - bool SPIT_Message::RemoveSPITObject::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_SPITObjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - } - catch (...) { - return false; - } - return true; - } - - // Send - SPIT_Message::RemoveSPITObject::RemoveSPITObject() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::RemoveSPITObject::setID(string p_ID) { - m_SPITObjectID = p_ID; - } - bool SPIT_Message::RemoveSPITObject::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_SPITObjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - } - catch (...) { - return false; - } - return true; - } - +void SPIT_Message::RemoveSPITObject::initMembers() { + m_SPITObjectID = ""; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::RemoveSPITObject::~RemoveSPITObject() { +} +// Receive +SPIT_Message::RemoveSPITObject::RemoveSPITObject(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::RemoveSPITObject::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_SPITObjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + } catch (...) { + return false; + } + return true; +} + +// Send +SPIT_Message::RemoveSPITObject::RemoveSPITObject() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::RemoveSPITObject::setID(string p_ID) { + m_SPITObjectID = p_ID; +} +bool SPIT_Message::RemoveSPITObject::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_SPITObjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + } catch (...) { + return false; + } + return true; +} + //---------------------------- SPITPlayer ---------------------------------- - + //----------- PlaySPITStart ----------- - void SPIT_Message::PlaySPITStart::initMembers() { - m_PlayerID = ""; - m_PlayerName = ""; - m_PlayerType = 0x00; - m_Time = 0; - m_PlayerIsRunning = false; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::PlaySPITStart::~PlaySPITStart() { - } - //Receive - SPIT_Message::PlaySPITStart::PlaySPITStart(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::PlaySPITStart::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_PlayerID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - m_PlayerName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += 64; - m_PlayerType = getByte(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_PlayerIsRunning = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_Time = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset+= 8; - } - catch (...) { - return false; - } - return true; - } - - // Send - SPIT_Message::PlaySPITStart::PlaySPITStart() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::PlaySPITStart::setPlayerID(string p_PlayerID) { - m_PlayerID = p_PlayerID; - } - void SPIT_Message::PlaySPITStart::setPlayerName(string p_PlayerName) { - m_PlayerName = p_PlayerName; - } - void SPIT_Message::PlaySPITStart::setPlayerType(char p_PlayerType) { - m_PlayerType = p_PlayerType; - } - void SPIT_Message::PlaySPITStart::setPlayerIsRunning(bool p_IsPlaying) { - m_PlayerIsRunning = p_IsPlaying; - } - void SPIT_Message::PlaySPITStart::setTime(long long p_Time) { - m_Time = p_Time; - } - bool SPIT_Message::PlaySPITStart::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_PlayerID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setString(m_PlayerName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); - m_ParseOffset += setByte(m_PlayerType, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_PlayerIsRunning, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setLong(m_Time, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } - +void SPIT_Message::PlaySPITStart::initMembers() { + m_PlayerID = ""; + m_PlayerName = ""; + m_PlayerType = 0x00; + m_Time = 0; + m_PlayerIsRunning = false; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::PlaySPITStart::~PlaySPITStart() { +} +// Receive +SPIT_Message::PlaySPITStart::PlaySPITStart(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::PlaySPITStart::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_PlayerID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + m_PlayerName = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += 64; + m_PlayerType = getByte(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_PlayerIsRunning = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_Time = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + } catch (...) { + return false; + } + return true; +} + +// Send +SPIT_Message::PlaySPITStart::PlaySPITStart() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::PlaySPITStart::setPlayerID(string p_PlayerID) { + m_PlayerID = p_PlayerID; +} +void SPIT_Message::PlaySPITStart::setPlayerName(string p_PlayerName) { + m_PlayerName = p_PlayerName; +} +void SPIT_Message::PlaySPITStart::setPlayerType(char p_PlayerType) { + m_PlayerType = p_PlayerType; +} +void SPIT_Message::PlaySPITStart::setPlayerIsRunning(bool p_IsPlaying) { + m_PlayerIsRunning = p_IsPlaying; +} +void SPIT_Message::PlaySPITStart::setTime(long long p_Time) { + m_Time = p_Time; +} +bool SPIT_Message::PlaySPITStart::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_PlayerID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setString(m_PlayerName, p_MessageBytes, p_ByteCount, m_ParseOffset, 64); + m_ParseOffset += setByte(m_PlayerType, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_PlayerIsRunning, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setLong(m_Time, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} + //----------- PlaySPITObject ----------- - void SPIT_Message::PlaySPITObject::initMembers() { - m_PlayerID = ""; - m_SPITObjectID = ""; - m_FrameInsideObject = 0; - m_Value = 0; - m_ValueFlag = VALUEFLAG_DIRECT; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::PlaySPITObject::~PlaySPITObject() { - } - //Receive - SPIT_Message::PlaySPITObject::PlaySPITObject(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::PlaySPITObject::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_PlayerID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - m_SPITObjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - m_FrameInsideObject = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_PlayPrePosition = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - m_Value = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_ValueFlag = getByte(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 1; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::PlaySPITObject::PlaySPITObject() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - void SPIT_Message::PlaySPITObject::setPlayerID(string p_PlayerID) { - m_PlayerID = p_PlayerID; - } - void SPIT_Message::PlaySPITObject::setID(string p_ID) { - m_SPITObjectID = p_ID; - } - void SPIT_Message::PlaySPITObject::setFrameInsideObject(long long p_TimeInside) { - m_FrameInsideObject = p_TimeInside; - } - void SPIT_Message::PlaySPITObject::setPlayPrePosition(bool p_PlayOldPosition) { - m_PlayPrePosition = p_PlayOldPosition; - } - void SPIT_Message::PlaySPITObject::setValue(int p_Value) { - m_Value = p_Value; - } - void SPIT_Message::PlaySPITObject::setValueFlag(char p_ValueFlag) { - m_ValueFlag = p_ValueFlag; - } - bool SPIT_Message::PlaySPITObject::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_PlayerID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setString(m_SPITObjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setLong(m_FrameInsideObject, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setBoolean(m_PlayPrePosition, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setInt(m_Value, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setByte(m_ValueFlag, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } - +void SPIT_Message::PlaySPITObject::initMembers() { + m_PlayerID = ""; + m_SPITObjectID = ""; + m_FrameInsideObject = 0; + m_Value = 0; + m_ValueFlag = VALUEFLAG_DIRECT; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::PlaySPITObject::~PlaySPITObject() { +} +// Receive +SPIT_Message::PlaySPITObject::PlaySPITObject(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::PlaySPITObject::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_PlayerID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + m_SPITObjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + m_FrameInsideObject = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_PlayPrePosition = getBoolean(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + m_Value = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_ValueFlag = getByte(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 1; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::PlaySPITObject::PlaySPITObject() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} +void SPIT_Message::PlaySPITObject::setPlayerID(string p_PlayerID) { + m_PlayerID = p_PlayerID; +} +void SPIT_Message::PlaySPITObject::setID(string p_ID) { + m_SPITObjectID = p_ID; +} +void SPIT_Message::PlaySPITObject::setFrameInsideObject(long long p_TimeInside) { + m_FrameInsideObject = p_TimeInside; +} +void SPIT_Message::PlaySPITObject::setPlayPrePosition(bool p_PlayOldPosition) { + m_PlayPrePosition = p_PlayOldPosition; +} +void SPIT_Message::PlaySPITObject::setValue(int p_Value) { + m_Value = p_Value; +} +void SPIT_Message::PlaySPITObject::setValueFlag(char p_ValueFlag) { + m_ValueFlag = p_ValueFlag; +} +bool SPIT_Message::PlaySPITObject::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_PlayerID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setString(m_SPITObjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setLong(m_FrameInsideObject, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setBoolean(m_PlayPrePosition, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setInt(m_Value, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setByte(m_ValueFlag, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} + //----------- PlaySPITEnd ----------- - void SPIT_Message::PlaySPITEnd::initMembers() { - m_PlayerID = ""; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::PlaySPITEnd::~PlaySPITEnd() { - } - //Receive - SPIT_Message::PlaySPITEnd::PlaySPITEnd(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::PlaySPITEnd::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_PlayerID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::PlaySPITEnd::PlaySPITEnd() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::PlaySPITEnd::setPlayerID(string p_PlayerID) { - m_PlayerID = p_PlayerID; - } - bool SPIT_Message::PlaySPITEnd::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_PlayerID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - } - catch (...) { - return false; - } - return true; - } +void SPIT_Message::PlaySPITEnd::initMembers() { + m_PlayerID = ""; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::PlaySPITEnd::~PlaySPITEnd() { +} +// Receive +SPIT_Message::PlaySPITEnd::PlaySPITEnd(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::PlaySPITEnd::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_PlayerID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::PlaySPITEnd::PlaySPITEnd() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::PlaySPITEnd::setPlayerID(string p_PlayerID) { + m_PlayerID = p_PlayerID; +} +bool SPIT_Message::PlaySPITEnd::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_PlayerID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + } catch (...) { + return false; + } + return true; +} //----------- ReportPlayStatus ----------- - - void SPIT_Message::ReportPlayStatus::initMembers() { - m_SPITObjectID = ""; - m_FrameInsideObject = 0; - m_Value = 0; - m_BytesCount = BYTESLENGTH; - } - SPIT_Message::ReportPlayStatus::~ReportPlayStatus() { - } - //Receive - SPIT_Message::ReportPlayStatus::ReportPlayStatus(Header* p_Header) : OPPart(p_Header, OPFLAG){ - initMembers(); - } - bool SPIT_Message::ReportPlayStatus::parse(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - int intOPFlag = m_Header->getOPFlag(); - if (intOPFlag != OPFLAG) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - m_SPITObjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += 41; - m_FrameInsideObject = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 8; - m_Value = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += 4; - } - catch (...) { - return false; - } - return true; - } - // Send - SPIT_Message::ReportPlayStatus::ReportPlayStatus() : OPPart() { - initMembers(); - m_Header = new Header(SPITVERSION, OPFLAG); - setHeader(m_Header); - m_ParseOffset = Header::BYTESLENGTH; - } - - void SPIT_Message::ReportPlayStatus::setID(string p_ID) { - m_SPITObjectID = p_ID; - } - void SPIT_Message::ReportPlayStatus::setFrameInsideObject(long long p_TimeInside) { - m_FrameInsideObject = p_TimeInside; - } - void SPIT_Message::ReportPlayStatus::setValue(int p_Value) { - m_Value = p_Value; - } - bool SPIT_Message::ReportPlayStatus::fillBytes(char* p_MessageBytes, int p_ByteCount) { - if (p_MessageBytes == NULL) return false; - if (m_Header == NULL) return false; - if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) return false; - try { - m_ParseOffset = Header::BYTESLENGTH; - m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setString(m_SPITObjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); - m_ParseOffset += setLong(m_FrameInsideObject, p_MessageBytes, p_ByteCount, m_ParseOffset); - m_ParseOffset += setInt(m_Value, p_MessageBytes, p_ByteCount, m_ParseOffset); - } - catch (...) { - return false; - } - return true; - } - - + +void SPIT_Message::ReportPlayStatus::initMembers() { + m_SPITObjectID = ""; + m_FrameInsideObject = 0; + m_Value = 0; + m_BytesCount = BYTESLENGTH; +} +SPIT_Message::ReportPlayStatus::~ReportPlayStatus() { +} +// Receive +SPIT_Message::ReportPlayStatus::ReportPlayStatus(Header *p_Header) : OPPart(p_Header, OPFLAG) { + initMembers(); +} +bool SPIT_Message::ReportPlayStatus::parse(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + int intOPFlag = m_Header->getOPFlag(); + if (intOPFlag != OPFLAG) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_BytesCount = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + m_SPITObjectID = getString(p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += 41; + m_FrameInsideObject = getLong(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 8; + m_Value = getInt(p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += 4; + } catch (...) { + return false; + } + return true; +} +// Send +SPIT_Message::ReportPlayStatus::ReportPlayStatus() : OPPart() { + initMembers(); + m_Header = new Header(SPITVERSION, OPFLAG); + setHeader(m_Header); + m_ParseOffset = Header::BYTESLENGTH; +} + +void SPIT_Message::ReportPlayStatus::setID(string p_ID) { + m_SPITObjectID = p_ID; +} +void SPIT_Message::ReportPlayStatus::setFrameInsideObject(long long p_TimeInside) { + m_FrameInsideObject = p_TimeInside; +} +void SPIT_Message::ReportPlayStatus::setValue(int p_Value) { + m_Value = p_Value; +} +bool SPIT_Message::ReportPlayStatus::fillBytes(char *p_MessageBytes, int p_ByteCount) { + if (p_MessageBytes == NULL) + return false; + if (m_Header == NULL) + return false; + if (m_Header->fillBytes(p_MessageBytes, p_ByteCount) == false) + return false; + try { + m_ParseOffset = Header::BYTESLENGTH; + m_ParseOffset += setInt(m_BytesCount, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setString(m_SPITObjectID, p_MessageBytes, p_ByteCount, m_ParseOffset, 41); + m_ParseOffset += setLong(m_FrameInsideObject, p_MessageBytes, p_ByteCount, m_ParseOffset); + m_ParseOffset += setInt(m_Value, p_MessageBytes, p_ByteCount, m_ParseOffset); + } catch (...) { + return false; + } + return true; +} + //---------------------------- static helper functions ----------------------- - bool SPIT_Message::isSystemLittleEndian() { - // todo replace with #include then if constexpr (std::endian::native == std::endian::big) - int intOne = 1; - char* firstByte; - firstByte = (char*)&intOne; - if (*firstByte > 0) { - return false; - } - return true; - } - - int SPIT_Message::getInt(char* p_Bytes, int p_ByteCount, int p_Offset) { - if (p_Offset < 0) throw "ParseError_received"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + 4) throw "ParseError_received"; - //low byte first - int intValue = 0; - if (isSystemLittleEndian() == false) { - intValue += ((p_Bytes[p_Offset+0] & 0x000000ff)); - intValue += ((p_Bytes[p_Offset+1] & 0x000000ff)<<8); - intValue += ((p_Bytes[p_Offset+2] & 0x000000ff)<<16); - intValue += ((p_Bytes[p_Offset+3] & 0x000000ff)<<24); - } - else { - intValue += ((p_Bytes[p_Offset+3] & 0x000000ff)); - intValue += ((p_Bytes[p_Offset+2] & 0x000000ff)<<8); - intValue += ((p_Bytes[p_Offset+1] & 0x000000ff)<<16); - intValue += ((p_Bytes[p_Offset+0] & 0x000000ff)<<24); - } - return intValue; - } +bool SPIT_Message::isSystemLittleEndian() { + // todo replace with #include then if constexpr (std::endian::native == std::endian::big) + int intOne = 1; + char *firstByte; + firstByte = (char *)&intOne; + if (*firstByte > 0) { + return false; + } + return true; +} - int SPIT_Message::setInt(int p_Value, char* p_Bytes, int p_ByteCount, int p_Offset) { - if (p_Offset < 0) throw "ParseError_send"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + 4) throw "ParseError_send"; - //low byte first - int intTest; - if (isSystemLittleEndian() == false) { - p_Bytes[p_Offset+0] = (char)(p_Value & 0x000000ff); - p_Bytes[p_Offset+1] = (char)((p_Value & 0x0000ff00)>>8); - p_Bytes[p_Offset+2] = (char)((p_Value & 0x00ff0000)>>16); - p_Bytes[p_Offset+3] = (char)((p_Value & 0xff000000)>>24); - - intTest = getInt(p_Bytes, p_ByteCount, p_Offset); - } - else { - p_Bytes[p_Offset+3] = (char)(p_Value & 0x000000ff); - p_Bytes[p_Offset+2] = (char)((p_Value & 0x0000ff00)>>8); - p_Bytes[p_Offset+1] = (char)((p_Value & 0x00ff0000)>>16); - p_Bytes[p_Offset+0] = (char)((p_Value & 0xff000000)>>24); +int SPIT_Message::getInt(char *p_Bytes, int p_ByteCount, int p_Offset) { + if (p_Offset < 0) + throw "ParseError_received"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + 4) + throw "ParseError_received"; + // low byte first + int intValue = 0; + if (isSystemLittleEndian() == false) { + intValue += ((p_Bytes[p_Offset + 0] & 0x000000ff)); + intValue += ((p_Bytes[p_Offset + 1] & 0x000000ff) << 8); + intValue += ((p_Bytes[p_Offset + 2] & 0x000000ff) << 16); + intValue += ((p_Bytes[p_Offset + 3] & 0x000000ff) << 24); + } else { + intValue += ((p_Bytes[p_Offset + 3] & 0x000000ff)); + intValue += ((p_Bytes[p_Offset + 2] & 0x000000ff) << 8); + intValue += ((p_Bytes[p_Offset + 1] & 0x000000ff) << 16); + intValue += ((p_Bytes[p_Offset + 0] & 0x000000ff) << 24); + } + return intValue; +} - intTest = getInt(p_Bytes, p_ByteCount, p_Offset); - } - return 4; - } - long long SPIT_Message::getLong(char* p_Bytes, int p_ByteCount, int p_Offset) { - if (p_Offset < 0) throw "ParseError_received"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + 8) throw "ParseError_received"; - //low byte first - long long intValue = 0; - if (isSystemLittleEndian() == false) { - intValue += ((long long)(p_Bytes[p_Offset] & 0x000000ff)); - intValue += ((long long)(p_Bytes[p_Offset+1] & 0x000000ff)<<8); - intValue += ((long long)(p_Bytes[p_Offset+2] & 0x000000ff)<<16); - intValue += ((long long)(p_Bytes[p_Offset+3] & 0x000000ff)<<24); - intValue += ((long long)(p_Bytes[p_Offset+4] & 0x000000ff)<<32); - intValue += ((long long)(p_Bytes[p_Offset+5] & 0x000000ff)<<40); - intValue += ((long long)(p_Bytes[p_Offset+6] & 0x000000ff)<<48); - intValue += ((long long)(p_Bytes[p_Offset+7] & 0x000000ff)<<56); - } - else { - intValue += ((long long)(p_Bytes[p_Offset+7] & 0x000000ff)); - intValue += ((long long)(p_Bytes[p_Offset+6] & 0x000000ff)<<8); - intValue += ((long long)(p_Bytes[p_Offset+5] & 0x000000ff)<<16); - intValue += ((long long)(p_Bytes[p_Offset+4] & 0x000000ff)<<24); - intValue += ((long long)(p_Bytes[p_Offset+3] & 0x000000ff)<<32); - intValue += ((long long)(p_Bytes[p_Offset+2] & 0x000000ff)<<40); - intValue += ((long long)(p_Bytes[p_Offset+1] & 0x000000ff)<<48); - intValue += ((long long)(p_Bytes[p_Offset+0] & 0x000000ff)<<56); - } - return intValue; - } - int SPIT_Message::setLong(long long p_Value, char* p_Bytes, int p_ByteCount, int p_Offset) { - if (p_Offset < 0) throw "ParseError_send"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + 8) throw "ParseError_send"; - //low byte first - if (isSystemLittleEndian() == false) { - p_Bytes[p_Offset+0] = (char)((p_Value & 0x00000000000000ff)); - p_Bytes[p_Offset+1] = (char)((p_Value & 0x000000000000ff00)>>8); - p_Bytes[p_Offset+2] = (char)((p_Value & 0x0000000000ff0000)>>16); - p_Bytes[p_Offset+3] = (char)((p_Value & 0x00000000ff000000)>>24); - p_Bytes[p_Offset+4] = (char)((p_Value & 0x000000ff00000000)>>32); - p_Bytes[p_Offset+5] = (char)((p_Value & 0x0000ff0000000000)>>40); - p_Bytes[p_Offset+6] = (char)((p_Value & 0x00ff000000000000)>>48); - p_Bytes[p_Offset+7] = (char)((p_Value & 0xff00000000000000)>>56); - } - else { - p_Bytes[p_Offset+7] = (char)((p_Value & 0x00000000000000ff)); - p_Bytes[p_Offset+6] = (char)((p_Value & 0x000000000000ff00)>>8); - p_Bytes[p_Offset+5] = (char)((p_Value & 0x0000000000ff0000)>>16); - p_Bytes[p_Offset+4] = (char)((p_Value & 0x00000000ff000000)>>24); - p_Bytes[p_Offset+3] = (char)((p_Value & 0x000000ff00000000)>>32); - p_Bytes[p_Offset+2] = (char)((p_Value & 0x0000ff0000000000)>>40); - p_Bytes[p_Offset+1] = (char)((p_Value & 0x00ff000000000000)>>48); - p_Bytes[p_Offset+0] = (char)((p_Value & 0xff00000000000000)>>56); - } - return 8; - } - bool SPIT_Message::getBoolean(char* p_Bytes, int p_ByteCount, int p_Offset) { - if (p_Offset < 0) throw "ParseError_received"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + 1) throw "ParseError_received"; - //low byte first - if (p_Bytes[p_Offset] > 0x00) return true; - else return false; - } - int SPIT_Message::setBoolean(bool p_Value, char* p_Bytes, int p_ByteCount, int p_Offset) { - if (p_Offset < 0) throw "ParseError_send"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + 1) throw "ParseError_send"; - if (p_Value == false) { - p_Bytes[p_Offset] = 0x00; - } - else { - p_Bytes[p_Offset] = 0x01; - } - return 1; - } - char SPIT_Message::getByte(char* p_Bytes, int p_ByteCount, int p_Offset) { - if (p_Offset < 0) throw "ParseError_received"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + 1) throw "ParseError_received"; - //low byte first - return p_Bytes[p_Offset]; - } - int SPIT_Message::setByte(int p_Value, char* p_Bytes, int p_ByteCount, int p_Offset) { - if (p_Offset < 0) throw "ParseError_send"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + 1) throw "ParseError_send"; - p_Bytes[p_Offset] = (char)(p_Value & 0xff); - return 1; - } - string SPIT_Message::getString(char* p_Bytes, int p_ByteCount, int p_Offset, int p_Length) { - if (p_Offset < 0) throw "ParseError_received getString()"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + p_Length) throw "ParseError_received getString()"; - int intPos; - //get Length of String - for (intPos = 0; intPos < p_Length; intPos++) { - if (p_Bytes[p_Offset + intPos] == 0x00) break; - } - if (intPos >= p_Length) throw "ParseError_received getString()"; - string stringResult; - stringResult = &p_Bytes[p_Offset]; - return stringResult; - } - - int SPIT_Message::setString(string p_String, char* p_Bytes, int p_ByteCount, int p_Offset, int p_Length) { - if (p_Offset < 0) throw "ParseError_send"; - int intChar = 0; - bool boolNullChar = false; - if (p_Length < 1) throw "ParseError_send"; - if (p_Bytes == NULL || p_ByteCount < p_Offset + p_Length) throw "ParseError_send"; - - int intLength; - if (p_String.length()+1 > p_Length) { - intLength = p_Length; - } - else { - intLength = p_String.length()+1; - } - while(intChar < intLength) { - p_Bytes[p_Offset + intChar] = p_String.data()[intChar]; - if (p_String[intChar] == nullChar[0]) { - boolNullChar = true; - break; - } - intChar++; - } - if (boolNullChar == false) { - p_Bytes[p_Offset + intLength -1] = nullChar[0]; - } - return p_Length; - } - - - - char* SPIT_Message::createByteArray(const OPPart* p_OPPart, int* p_ByteCount) { - if (p_OPPart == NULL) return NULL; - int intBytesCount = 0; - char* o_ByteArray; - try { - intBytesCount = Header::BYTESLENGTH; - intBytesCount += p_OPPart->getBytesCount(); - o_ByteArray = (char*) malloc(intBytesCount); - *p_ByteCount = intBytesCount; - } - catch (...) { - return NULL; - } - return o_ByteArray; - } +int SPIT_Message::setInt(int p_Value, char *p_Bytes, int p_ByteCount, int p_Offset) { + if (p_Offset < 0) + throw "ParseError_send"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + 4) + throw "ParseError_send"; + // low byte first + int intTest; + if (isSystemLittleEndian() == false) { + p_Bytes[p_Offset + 0] = (char)(p_Value & 0x000000ff); + p_Bytes[p_Offset + 1] = (char)((p_Value & 0x0000ff00) >> 8); + p_Bytes[p_Offset + 2] = (char)((p_Value & 0x00ff0000) >> 16); + p_Bytes[p_Offset + 3] = (char)((p_Value & 0xff000000) >> 24); + + intTest = getInt(p_Bytes, p_ByteCount, p_Offset); + } else { + p_Bytes[p_Offset + 3] = (char)(p_Value & 0x000000ff); + p_Bytes[p_Offset + 2] = (char)((p_Value & 0x0000ff00) >> 8); + p_Bytes[p_Offset + 1] = (char)((p_Value & 0x00ff0000) >> 16); + p_Bytes[p_Offset + 0] = (char)((p_Value & 0xff000000) >> 24); + + intTest = getInt(p_Bytes, p_ByteCount, p_Offset); + } + return 4; +} +long long SPIT_Message::getLong(char *p_Bytes, int p_ByteCount, int p_Offset) { + if (p_Offset < 0) + throw "ParseError_received"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + 8) + throw "ParseError_received"; + // low byte first + long long intValue = 0; + if (isSystemLittleEndian() == false) { + intValue += ((long long)(p_Bytes[p_Offset] & 0x000000ff)); + intValue += ((long long)(p_Bytes[p_Offset + 1] & 0x000000ff) << 8); + intValue += ((long long)(p_Bytes[p_Offset + 2] & 0x000000ff) << 16); + intValue += ((long long)(p_Bytes[p_Offset + 3] & 0x000000ff) << 24); + intValue += ((long long)(p_Bytes[p_Offset + 4] & 0x000000ff) << 32); + intValue += ((long long)(p_Bytes[p_Offset + 5] & 0x000000ff) << 40); + intValue += ((long long)(p_Bytes[p_Offset + 6] & 0x000000ff) << 48); + intValue += ((long long)(p_Bytes[p_Offset + 7] & 0x000000ff) << 56); + } else { + intValue += ((long long)(p_Bytes[p_Offset + 7] & 0x000000ff)); + intValue += ((long long)(p_Bytes[p_Offset + 6] & 0x000000ff) << 8); + intValue += ((long long)(p_Bytes[p_Offset + 5] & 0x000000ff) << 16); + intValue += ((long long)(p_Bytes[p_Offset + 4] & 0x000000ff) << 24); + intValue += ((long long)(p_Bytes[p_Offset + 3] & 0x000000ff) << 32); + intValue += ((long long)(p_Bytes[p_Offset + 2] & 0x000000ff) << 40); + intValue += ((long long)(p_Bytes[p_Offset + 1] & 0x000000ff) << 48); + intValue += ((long long)(p_Bytes[p_Offset + 0] & 0x000000ff) << 56); + } + return intValue; +} +int SPIT_Message::setLong(long long p_Value, char *p_Bytes, int p_ByteCount, int p_Offset) { + if (p_Offset < 0) + throw "ParseError_send"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + 8) + throw "ParseError_send"; + // low byte first + if (isSystemLittleEndian() == false) { + p_Bytes[p_Offset + 0] = (char)((p_Value & 0x00000000000000ff)); + p_Bytes[p_Offset + 1] = (char)((p_Value & 0x000000000000ff00) >> 8); + p_Bytes[p_Offset + 2] = (char)((p_Value & 0x0000000000ff0000) >> 16); + p_Bytes[p_Offset + 3] = (char)((p_Value & 0x00000000ff000000) >> 24); + p_Bytes[p_Offset + 4] = (char)((p_Value & 0x000000ff00000000) >> 32); + p_Bytes[p_Offset + 5] = (char)((p_Value & 0x0000ff0000000000) >> 40); + p_Bytes[p_Offset + 6] = (char)((p_Value & 0x00ff000000000000) >> 48); + p_Bytes[p_Offset + 7] = (char)((p_Value & 0xff00000000000000) >> 56); + } else { + p_Bytes[p_Offset + 7] = (char)((p_Value & 0x00000000000000ff)); + p_Bytes[p_Offset + 6] = (char)((p_Value & 0x000000000000ff00) >> 8); + p_Bytes[p_Offset + 5] = (char)((p_Value & 0x0000000000ff0000) >> 16); + p_Bytes[p_Offset + 4] = (char)((p_Value & 0x00000000ff000000) >> 24); + p_Bytes[p_Offset + 3] = (char)((p_Value & 0x000000ff00000000) >> 32); + p_Bytes[p_Offset + 2] = (char)((p_Value & 0x0000ff0000000000) >> 40); + p_Bytes[p_Offset + 1] = (char)((p_Value & 0x00ff000000000000) >> 48); + p_Bytes[p_Offset + 0] = (char)((p_Value & 0xff00000000000000) >> 56); + } + return 8; +} +bool SPIT_Message::getBoolean(char *p_Bytes, int p_ByteCount, int p_Offset) { + if (p_Offset < 0) + throw "ParseError_received"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + 1) + throw "ParseError_received"; + // low byte first + if (p_Bytes[p_Offset] > 0x00) + return true; + else + return false; +} +int SPIT_Message::setBoolean(bool p_Value, char *p_Bytes, int p_ByteCount, int p_Offset) { + if (p_Offset < 0) + throw "ParseError_send"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + 1) + throw "ParseError_send"; + if (p_Value == false) { + p_Bytes[p_Offset] = 0x00; + } else { + p_Bytes[p_Offset] = 0x01; + } + return 1; +} +char SPIT_Message::getByte(char *p_Bytes, int p_ByteCount, int p_Offset) { + if (p_Offset < 0) + throw "ParseError_received"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + 1) + throw "ParseError_received"; + // low byte first + return p_Bytes[p_Offset]; +} +int SPIT_Message::setByte(int p_Value, char *p_Bytes, int p_ByteCount, int p_Offset) { + if (p_Offset < 0) + throw "ParseError_send"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + 1) + throw "ParseError_send"; + p_Bytes[p_Offset] = (char)(p_Value & 0xff); + return 1; +} +string SPIT_Message::getString(char *p_Bytes, int p_ByteCount, int p_Offset, int p_Length) { + if (p_Offset < 0) + throw "ParseError_received getString()"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + p_Length) + throw "ParseError_received getString()"; + int intPos; + // get Length of String + for (intPos = 0; intPos < p_Length; intPos++) { + if (p_Bytes[p_Offset + intPos] == 0x00) + break; + } + if (intPos >= p_Length) + throw "ParseError_received getString()"; + string stringResult; + stringResult = &p_Bytes[p_Offset]; + return stringResult; +} + +int SPIT_Message::setString(string p_String, char *p_Bytes, int p_ByteCount, int p_Offset, int p_Length) { + if (p_Offset < 0) + throw "ParseError_send"; + int intChar = 0; + bool boolNullChar = false; + if (p_Length < 1) + throw "ParseError_send"; + if (p_Bytes == NULL || p_ByteCount < p_Offset + p_Length) + throw "ParseError_send"; + + int intLength; + if (p_String.length() + 1 > p_Length) { + intLength = p_Length; + } else { + intLength = p_String.length() + 1; + } + while (intChar < intLength) { + p_Bytes[p_Offset + intChar] = p_String.data()[intChar]; + if (p_String[intChar] == nullChar[0]) { + boolNullChar = true; + break; + } + intChar++; + } + if (boolNullChar == false) { + p_Bytes[p_Offset + intLength - 1] = nullChar[0]; + } + return p_Length; +} + +char *SPIT_Message::createByteArray(const OPPart *p_OPPart, int *p_ByteCount) { + if (p_OPPart == NULL) + return NULL; + int intBytesCount = 0; + char *o_ByteArray; + try { + intBytesCount = Header::BYTESLENGTH; + intBytesCount += p_OPPart->getBytesCount(); + o_ByteArray = (char *)malloc(intBytesCount); + *p_ByteCount = intBytesCount; + } catch (...) { + return NULL; + } + return o_ByteArray; +} diff --git a/components/watchFace/CMakeLists.txt b/components/watchFace/CMakeLists.txt new file mode 100644 index 0000000..8af9e6b --- /dev/null +++ b/components/watchFace/CMakeLists.txt @@ -0,0 +1,4 @@ +idf_component_register( + INCLUDE_DIRS "." + REQUIRES devHal +) diff --git a/components/watchFace/watchFace.hpp b/components/watchFace/watchFace.hpp new file mode 100644 index 0000000..c7ceca3 --- /dev/null +++ b/components/watchFace/watchFace.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include "StepperDrv8833.hpp" +#include "stepperMotor.hpp" +#include + +class WatchMotor { + static constexpr uint8_t Positions = 6; + + public: + WatchMotor(StepperMotor &stepper, OutputPort &sleep) + : _stepper(stepper), + _motorSleep(sleep) { + _motorSleep.write(false); + } + + void moveTo(uint8_t sign, uint8_t profile = 0) { + sign = sign % 6; + + float delta = 2.0F * std::numbers::pi; + float corr = 0.0F; + float currentPos = _stepper.getScaledPos() * 6; + if ((_currentIndex > 4) && (currentPos < 2)) { + corr = 6 - _currentIndex - currentPos; + } else if ((_currentIndex < 2) && (currentPos > 2)) { + corr = _currentIndex + 6 - currentPos; + } else { + corr = _currentIndex - currentPos; + } + + // stepper.getScaledPos() * 6 + if (_currentIndex < sign) { + delta = delta / 6 * (sign - _currentIndex); + } else if (_currentIndex > sign) { + delta = delta / 6 * (sign + 6 - _currentIndex); + } + ESP_LOGD("MV", "Moving to %d by %.2f + %.2f", sign, delta, corr); + + _stepper.moveBy(delta + corr, profile); + _currentIndex = sign; + } + + float getScaled() { return _stepper.getScaledPos() * 6; } + uint8_t getIndex() { return _currentIndex; } + + private: + StepperMotor &_stepper; + OutputPort &_motorSleep; + uint8_t _currentIndex{}; +}; diff --git a/core b/core index 3041a17..c85bfa2 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 3041a17851ae8a9ddfe420134affa5517edb52c2 +Subproject commit c85bfa2afc665dbfc2b80af81e4919f613001ed4 diff --git a/doc/InitRun.md b/doc/InitRun.md new file mode 100644 index 0000000..c4538e5 --- /dev/null +++ b/doc/InitRun.md @@ -0,0 +1,312 @@ +I (23) boot: ESP-IDF v5.3 2nd stage bootloader +I (24) boot: compile time Feb 15 2025 17:51:30 +I (24) boot: chip revision: v0.0 +I (26) boot.esp32c6: SPI Speed : 80MHz +I (31) boot.esp32c6: SPI Mode : DIO +I (36) boot.esp32c6: SPI Flash Size : 8MB +I (41) boot: Enabling RNG early entropy source... +I (46) boot: Partition Table: +I (50) boot: ## Label Usage Type ST Offset Length +I (57) boot: 0 nvs WiFi data 01 02 00009000 00006000 +I (64) boot: 1 phy_init RF data 01 01 0000f000 00001000 +I (72) boot: 2 factory factory app 00 00 00010000 00100000 +I (79) boot: End of partition table +I (83) esp_image: segment 0: paddr=00010020 vaddr=42070020 size=29b54h (170836) map +I (127) esp_image: segment 1: paddr=00039b7c vaddr=40800000 size=0649ch ( 25756) load +I (134) esp_image: segment 2: paddr=00040020 vaddr=42000020 size=6a434h (435252) map +I (225) esp_image: segment 3: paddr=000aa45c vaddr=4080649c size=07d28h ( 32040) load +I (233) esp_image: segment 4: paddr=000b218c vaddr=4080e1d0 size=01c00h ( 7168) load +I (239) boot: Loaded app from partition at offset 0x10000 +I (239) boot: Disabling RNG early entropy source... +I (253) cpu_start: Unicore app +I (262) cpu_start: Pro cpu start user code +I (262) cpu_start: cpu freq: 160000000 Hz +I (263) app_init: Application information: +I (265) app_init: Project name: X_WatchController_FW +I (271) app_init: App version: 3ec39a2-dirty +I (277) app_init: Compile time: Mar 29 2025 16:21:16 +I (283) app_init: ELF file SHA256: c5ad318a2... +I (288) app_init: ESP-IDF: v5.3 +I (292) efuse_init: Min chip rev: v0.0 +I (297) efuse_init: Max chip rev: v0.99 +I (302) efuse_init: Chip rev: v0.0 +I (307) heap_init: Initializing. RAM available for dynamic allocation: +I (314) heap_init: At 40812190 len 0006A480 (425 KiB): RAM +I (320) heap_init: At 4087C610 len 00002F54 (11 KiB): RAM +I (326) heap_init: At 50000000 len 00003FE8 (15 KiB): RTCRAM +I (334) spi_flash: detected chip: generic +I (337) spi_flash: flash io: dio +I (343) sleep: Configure to isolate all GPIO pins in sleep state +I (348) sleep: Enable automatic switching of GPIO sleep configuration +I (355) coexist: coex firmware version: dab85ae96 +I (383) coexist: coexist rom version 5b8dcfa +I (383) main_task: Started on CPU0 +I (383) main_task: Calling app_main() +I (393) esp_eth.netif.netif_glue: 42:4c:ca:ff:fe:4e +I (393) esp_eth.netif.netif_glue: ethernet attached to netif +I (403) Watch: Ethernet Started +I (403) Watch: Start Lighting +I (403) gpio: GPIO[10]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 1| Pulldown: 0| Intr:0 +I (413) gpio: GPIO[11]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 1| Pulldown: 0| Intr:0 +I (423) Watch: Start Stepper +I (423) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 +I (433) gpio: GPIO[8]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 +I (443) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 +I (453) TMR: Create timer handle +I (453) TMR: Setup timer +I (453) Stepper: Find Home +I (463) Stepper: Homing ... +I (463) Stepper: Fast find right side of home sensor +I (483) gpio: GPIO[1]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 +I (2133) Stepper: Find right side of home sensor +I (2313) Stepper: Find end of sensor +I (2403) Watch: Ethernet Link Up +I (2403) Watch: Ethernet Link Up +I (2403) Watch: Ethernet HW Addr 00:00:00:00:00:00 +I (3403) esp_netif_handlers: eth ip: 172.16.17.56, mask: 255.255.0.0, gw: 172.16.0.1 +I (3403) Watch: Ethernet Got IP Address +I (3403) Watch: ~~~~~~~~~~~ +I (3403) Watch: ETHIP:172.16.17.56 +I (3413) Watch: ETHMASK:255.255.0.0 +I (3413) Watch: ETHGW:172.16.0.1 +I (3413) Watch: ~~~~~~~~~~~ +I (3423) Watch: Start net services +I (3423) Watch: Starting Telnet task +I (3423) Watch: Starting ArtNet task +I (3423) Watch: Starting SPIT task +I (3433) SPIT: Connected to eth +I (3443) SPIT: - IPv4 address: 172.16.17.56, +I (3443) SPIT: - IPv4 netmask: 255.255.0.0, +I (3423) UDP: Starting syslog session to 172.16.16.10 +I (3433) TCP: Socket created +I (3433) UDP: Socket bound, port 6454 +I (3453) Watch: NEW SPIT-Type ID: ActionStartShuffle GroupName: CatasWatchMovement Name: ActionStartShuffle confirmed: 0 +I (3453) SysLog: Starting Syslog Task +I (3463) TCP: Socket bound, port 23 +I (3473) Watch: NEW SPIT-Type ID: ActionMoveTo1 GroupName: CatasWatchMovement Name: ActionMoveTo1 confirmed: 0 +I (3493) Watch: NEW SPIT-Type ID: ActionMoveTo2 GroupName: CatasWatchMovement Name: ActionMoveTo2 confirmed: 0 +I (3483) Telnet: Socket waiting for connect +I (3483) UDP: Socket bound, port 514 +I (3503) Watch: NEW SPIT-Type ID: ActionMoveTo3 GroupName: CatasWatchMovement Name: ActionMoveTo3 confirmed: 0 +I (3523) Watch: NEW SPIT-Type ID: ActionMoveTo4 GroupName: CatasWatchMovement Name: ActionMoveTo4 confirmed: 0 +I (3533) Watch: NEW SPIT-Type ID: ActionMoveTo5 GroupName: CatasWatchMovement Name: ActionMoveTo5 confirmed: 0 +I (3543) Watch: NEW SPIT-Type ID: ActionMoveTo6 GroupName: CatasWatchMovement Name: ActionMoveTo6 confirmed: 0 +I (3553) SPIT: Starting Socket managing +I (5713) Stepper: Find left side of home sensor +I (6183) Stepper: Move back to mid position 145 +I (7633) Stepper: Reset position +I (7633) Watch: Fist Position is 0.000000.2 +I (7663) Watch: SERVER DETECTED +I (7663) Watch: Name: liveShowSPIT +I (7663) Watch: ID: 698a3e4f-1ae9-4dd8-9015-29332d29629e +I (7663) Watch: Computer: GgP17 +I (7663) Watch: IP: 172.16.16.10 +I (7673) Watch: Port: 15120 +I (7673) Watch: Addition: +I (7673) Watch: ClientIP: 172.16.17.56 +I (7683) SPIT: connect to 172.16.16.10 +I (7683) Watch: MySPITApp: eventConnectionStatus 0 +I (7663) Watch: Changing picto-Illum to pos = 1 +I (7693) Watch: Current color set r128 g128 b128 +I (7693) Watch: MySPITApp: eventConnectionStatus 4 +I (8203) Watch: eventProjectReport ID: CatasWatchProject Name: CatasWatchProject FramesPerSecond: 44100 +I (8203) Watch: eventStartProjectTransfer +I (8283) Watch: SPIT-Type CHANGED ID: ActionMoveTo5 GroupName: CatasWatchMovement Name: ActionMoveTo5 confirmed: 1 +I (8283) Watch: SPIT-Type CHANGED ID: ActionMoveTo4 GroupName: CatasWatchMovement Name: ActionMoveTo4 confirmed: 1 +I (8293) Watch: SPIT-Type CHANGED ID: ActionMoveTo3 GroupName: CatasWatchMovement Name: ActionMoveTo3 confirmed: 1 +I (8303) Watch: SPIT-Type CHANGED ID: ActionMoveTo6 GroupName: CatasWatchMovement Name: ActionMoveTo6 confirmed: 1 +I (8313) Watch: NEW SPIT-REMOTE-Type ID: playControlStart GroupName: Playcontrol Name: start confirmed: 1 +I (8323) Watch: NEW SPIT-REMOTE-Type ID: playControlPause GroupName: Playcontrol Name: pause confirmed: 1 +I (8343) Watch: NEW SPIT-REMOTE-Type ID: nextSceneBridge GroupName: Playcontrol Name: next scene confirmed: 1 +I (8353) Watch: NEW SPIT-REMOTE-Type ID: nextMainSceneBridge GroupName: Playcontrol Name: next main scene confirmed: 1 +I (8373) Watch: NEW SPIT-REMOTE-Type ID: previuosSceneBridge GroupName: Playcontrol Name: previous scene confirmed: 1 +I (8383) Watch: NEW SPIT-REMOTE-Type ID: previousMainSceneBridge GroupName: Playcontrol Name: previous main scene confirmed: 1 +I (8403) Watch: NEW SPIT-REMOTE-Type ID: mainmixerSound_Volume00 GroupName: Main Mixer Name: Sound confirmed: 1 +I (8423) Watch: NEW SPIT-REMOTE-Type ID: mainmixerDMX_Dimmer00 GroupName: Main Mixer Name: confirmed: 1 +I (8433) Watch: NEW SPIT-REMOTE-Type ID: mainmixerDMX_RGB00 GroupName: Main Mixer Name: confirmed: 1 +I (8453) Watch: NEW SPIT-REMOTE-Type ID: mainmixerDMX_RGB10 GroupName: Main Mixer Name: confirmed: 1 +I (8463) Watch: NEW SPIT-REMOTE-Type ID: mainmixerDMX_RGB20 GroupName: Main Mixer Name: confirmed: 1 +I (8483) Watch: NEW SPIT-REMOTE-Type ID: mainmixerDMX_RGB30 GroupName: Main Mixer Name: confirmed: 1 +I (8503) Watch: NEW SPIT-REMOTE-Type ID: mainmixerDMX_RGB40 GroupName: Main Mixer Name: confirmed: 1 +I (8513) Watch: NEW SPIT-REMOTE-Type ID: mainmixerDMX_RGB50 GroupName: Main Mixer Name: confirmed: 1 +I (8533) Watch: NEW SPIT-REMOTE-Type ID: mainmixerMedia_SoundVolume00 GroupName: Main Mixer Name: Media confirmed: 1 +I (8543) Watch: NEW SPIT-REMOTE-Type ID: mainmixerMedia_Transparency00 GroupName: Main Mixer Name: Media confirmed: 1 +I (8563) Watch: NEW SPIT-REMOTE-Type ID: selectedJingles GroupName: Playcontrol Name: selected Jingles confirmed: 1 +I (8573) Watch: NEW SPIT-REMOTE-Type ID: selectedJingleGroups GroupName: Playcontrol Name: selected Jinglegroups confirmed: 1 +I (8593) Watch: NEW SPIT-REMOTE-Type ID: 00000m8uedyyt0000000000000000lo0va8bom GroupName: MainScene Name: ChangingPositionScene confirmed: 1 +I (8603) Watch: NEW SPIT-REMOTE-Type ID: 00000m8uedyyt0000000000000000m70va8bom GroupName: MainScene Name: InPosition1Scene confirmed: 1 +I (8623) Watch: NEW SPIT-REMOTE-Type ID: 00000m8uedyyt0000000000000000mh0va8bom GroupName: MainScene Name: InPosition2Scene confirmed: 1 +I (8633) Watch: NEW SPIT-REMOTE-Type ID: 00000m8uedyyt0000000000000000mr0va8bom GroupName: MainScene Name: InPosition3Scene confirmed: 1 +I (8653) Watch: NEW SPIT-REMOTE-Type ID: 00000m8uedyyt0000000000000000nk0va8bom GroupName: MainScene Name: InPosition4Scene confirmed: 1 +I (8673) Watch: NEW SPIT-REMOTE-Type ID: 00000m8uedyyt0000000000000000nu0va8bom GroupName: MainScene Name: InPosition5Scene confirmed: 1 +I (8683) Watch: NEW SPIT-REMOTE-Type ID: 00000m8uedyyt0000000000000000o40va8bom GroupName: MainScene Name: InPosition6Scene confirmed: 1 +I (8703) Watch: NEW SPIT-REMOTE-Object ID: playControlStart Name: start -> SPITType: start +I (8703) Watch: eventPlayRemoteObjectStatus RemoteSPITType: start RemoteSPITObject: start Position: 0 Value: 0 +I (8713) Watch: NEW SPIT-REMOTE-Object ID: playControlPause Name: pause -> SPITType: pause +I (8723) Watch: eventPlayRemoteObjectStatus RemoteSPITType: pause RemoteSPITObject: pause Position: 0 Value: 0 +I (8733) Watch: NEW SPIT-REMOTE-Object ID: nextSceneBridge Name: next scene -> SPITType: next scene +I (8743) Watch: eventPlayRemoteObjectStatus RemoteSPITType: next scene RemoteSPITObject: next scene Position: 0 Value: 0 +I (8753) Watch: NEW SPIT-REMOTE-Object ID: nextMainSceneBridge Name: next main scene -> SPITType: next main scene +I (8763) Watch: eventPlayRemoteObjectStatus RemoteSPITType: next main scene RemoteSPITObject: next main scene Position: 0 Value: 0 +I (8773) Watch: NEW SPIT-REMOTE-Object ID: previuosSceneBridge Name: previous scene -> SPITType: previous scene +I (8783) Watch: eventPlayRemoteObjectStatus RemoteSPITType: previous scene RemoteSPITObject: previous scene Position: 0 Value: 0 +I (8793) Watch: NEW SPIT-REMOTE-Object ID: previousMainSceneBridge Name: previous main scene -> SPITType: previous main scene +I (8813) Watch: eventPlayRemoteObjectStatus RemoteSPITType: previous main scene RemoteSPITObject: previous main scene Position: 0 Value: 0 +I (8823) Watch: NEW SPIT-REMOTE-Object ID: mainmixerSound_Volume00 Name: Sound Volume -> SPITType: Sound +I (8833) Watch: eventPlayRemoteObjectStatus RemoteSPITType: Sound RemoteSPITObject: Sound Volume Position: 0 Value: 500000 +I (8843) Watch: NEW SPIT-REMOTE-Object ID: mainmixerDMX_Dimmer00 Name: Dimmer -> SPITType: +I (8853) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Dimmer Position: 0 Value: 1000000 +I (8863) Watch: NEW SPIT-REMOTE-Object ID: mainmixerDMX_RGB00 Name: Red -> SPITType: +I (8873) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Red Position: 0 Value: 1000000 +I (8883) Watch: NEW SPIT-REMOTE-Object ID: mainmixerDMX_RGB10 Name: Green -> SPITType: +I (8893) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Green Position: 0 Value: 1000000 +I (8903) Watch: NEW SPIT-REMOTE-Object ID: mainmixerDMX_RGB20 Name: Blue -> SPITType: +I (8913) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Blue Position: 0 Value: 1000000 +I (8923) Watch: NEW SPIT-REMOTE-Object ID: mainmixerDMX_RGB30 Name: Cyan -> SPITType: +I (8933) Watch: NEW SPIT-REMOTE-Object ID: mainmixerDMX_RGB40 Name: Magenta -> SPITType: +I (8943) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Magenta Position: 0 Value: 0 +I (8953) Watch: NEW SPIT-REMOTE-Object ID: mainmixerDMX_RGB50 Name: Yellow -> SPITType: +I (8963) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Yellow Position: 0 Value: 0 +I (8973) Watch: NEW SPIT-REMOTE-Object ID: mainmixerMedia_SoundVolume00 Name: Sound Volume -> SPITType: Media +I (8983) Watch: NEW SPIT-REMOTE-Object ID: mainmixerMedia_Transparency00 Name: Media Transparency -> SPITType: Media +I (8993) Watch: eventPlayRemoteObjectStatus RemoteSPITType: Media RemoteSPITObject: Media Transparency Position: 0 Value: 1000000 +I (9003) Watch: NEW SPIT-REMOTE-Object ID: selectedJinglesps Name: Play / Stop -> SPITType: selected Jingles +I (9013) Watch: eventPlayRemoteObjectStatus RemoteSPITType: selected Jingles RemoteSPITObject: Play / Stop Position: 0 Value: 0 +I (9023) Watch: NEW SPIT-REMOTE-Object ID: selectedJinglespf Name: Play / Fade Out -> SPITType: selected Jingles +I (9033) Watch: NEW SPIT-REMOTE-Object ID: selectedJingleGroupsps Name: Play / Stop -> SPITType: selected Jinglegroups +I (9053) Watch: eventPlayRemoteObjectStatus RemoteSPITType: selected Jinglegroups RemoteSPITObject: Play / Stop Position: 0 Value: 0 +I (9063) Watch: NEW SPIT-REMOTE-Object ID: selectedJingleGroupspf Name: Play / Fade Out -> SPITType: selected Jinglegroups +I (9073) Watch: NEW SPIT-REMOTE-Object ID: 00000m8uedyyt0000000000000000lo0va8bom Name: play -> SPITType: ChangingPositionScene +I (9083) Watch: NEW SPIT-REMOTE-Object ID: 00000m8uedyyt0000000000000000m70va8bom Name: play -> SPITType: InPosition1Scene +I (9093) Watch: eventPlayRemoteObjectStatus RemoteSPITType: InPosition1Scene RemoteSPITObject: play Position: 0 Value: 0 +I (9103) Watch: NEW SPIT-REMOTE-Object ID: 00000m8uedyyt0000000000000000mh0va8bom Name: play -> SPITType: InPosition2Scene +I (9123) Watch: NEW SPIT-REMOTE-Object ID: 00000m8uedyyt0000000000000000mr0va8bom Name: play -> SPITType: InPosition3Scene +I (9133) Watch: NEW SPIT-REMOTE-Object ID: 00000m8uedyyt0000000000000000nk0va8bom Name: play -> SPITType: InPosition4Scene +I (9143) Watch: eventPlayRemoteObjectStatus RemoteSPITType: InPosition4Scene RemoteSPITObject: play Position: 0 Value: 0 +I (9153) Watch: NEW SPIT-REMOTE-Object ID: 00000m8uedyyt0000000000000000nu0va8bom Name: play -> SPITType: InPosition5Scene +I (9163) Watch: NEW SPIT-REMOTE-Object ID: 00000m8uedyyt0000000000000000o40va8bom Name: play -> SPITType: InPosition6Scene +I (9183) Watch: eventEndProjectTransfer +W (9203) SPIT: Finished searching +W (9203) SPIT: Start working +I (9253) Watch: SPIT-Type CHANGED ID: ActionMoveTo5 GroupName: CatasWatchMovement Name: ActionMoveTo5 confirmed: 1 +I (9253) Watch: SPIT-Type CHANGED ID: ActionMoveTo4 GroupName: CatasWatchMovement Name: ActionMoveTo4 confirmed: 1 +I (9263) Watch: SPIT-Type CHANGED ID: ActionMoveTo3 GroupName: CatasWatchMovement Name: ActionMoveTo3 confirmed: 1 +I (9273) Watch: SPIT-Type CHANGED ID: ActionMoveTo6 GroupName: CatasWatchMovement Name: ActionMoveTo6 confirmed: 1 +I (9283) Watch: SPIT-Type CHANGED ID: ActionMoveTo2 GroupName: CatasWatchMovement Name: ActionMoveTo2 confirmed: 1 +I (9293) Watch: SPIT-Type CHANGED ID: ActionMoveTo1 GroupName: CatasWatchMovement Name: ActionMoveTo1 confirmed: 1 +I (459853) Watch: SPIT-Type CHANGED ID: ActionMoveTo1 GroupName: CatasWatchMovement Name: ActionMoveTo1 confirmed: 1 +I (459853) Watch: SPIT-Type CHANGED ID: ActionMoveTo1 GroupName: CatasWatchMovement Name: ActionMoveTo1 confirmed: 1 +I (459863) Watch: SPIT-Type CHANGED ID: ActionMoveTo6 GroupName: CatasWatchMovement Name: ActionMoveTo6 confirmed: 1 +I (459883) Watch: SPIT-Type CHANGED ID: ActionMoveTo6 GroupName: CatasWatchMovement Name: ActionMoveTo6 confirmed: 1 +I (459893) Watch: SPIT-Type CHANGED ID: ActionMoveTo4 GroupName: CatasWatchMovement Name: ActionMoveTo4 confirmed: 1 +I (459903) Watch: SPIT-Type CHANGED ID: ActionMoveTo4 GroupName: CatasWatchMovement Name: ActionMoveTo4 confirmed: 1 +I (466093) Watch: NEW SPIT-Object ID: 00000m8uedyyt0000000000000000zq0va8bom Name: -> SPITType: ActionStartShuffle +I (466733) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt0000000000000000zq0va8bom Name: -> SPITType: ActionStartShuffle +I (468643) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt0000000000000000zq0va8bom Name: -> SPITType: ActionStartShuffle +I (471243) Watch: NEW SPIT-Object ID: 00000m8uedyyt00000000000000010u0va8bom Name: -> SPITType: ActionMoveTo1 +I (472153) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000010u0va8bom Name: -> SPITType: ActionMoveTo1 +I (473403) Watch: NEW SPIT-Object ID: 00000m8uedyyt00000000000000011a0va8bom Name: -> SPITType: ActionMoveTo2 +I (474763) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000011a0va8bom Name: -> SPITType: ActionMoveTo2 +I (483183) Watch: NEW SPIT-Object ID: 00000m8uedyyt00000000000000011s0va8bom Name: -> SPITType: ActionMoveTo3 +I (483283) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000011s0va8bom Name: -> SPITType: ActionMoveTo3 +I (483333) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000011s0va8bom Name: -> SPITType: ActionMoveTo3 +I (483703) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000011s0va8bom Name: -> SPITType: ActionMoveTo3 +I (484613) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000011s0va8bom Name: -> SPITType: ActionMoveTo3 +I (485993) Watch: NEW SPIT-Object ID: 00000m8uedyyt00000000000000012m0va8bom Name: -> SPITType: ActionMoveTo4 +I (486063) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000012m0va8bom Name: -> SPITType: ActionMoveTo4 +I (486593) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000012m0va8bom Name: -> SPITType: ActionMoveTo4 +I (488103) Watch: NEW SPIT-Object ID: 00000m8uedyyt0000000000000001330va8bom Name: -> SPITType: ActionMoveTo5 +I (489273) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt0000000000000001330va8bom Name: -> SPITType: ActionMoveTo5 +I (490913) Watch: NEW SPIT-Object ID: 00000m8uedyyt00000000000000013r0va8bom Name: -> SPITType: ActionMoveTo6 +I (491043) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000013r0va8bom Name: -> SPITType: ActionMoveTo6 +I (491083) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000013r0va8bom Name: -> SPITType: ActionMoveTo6 +I (493163) Watch: NEW SPIT-Object ID: 00000m8uedyyt0000000000000001470va8bom Name: -> SPITType: ActionMoveTo6 +I (493243) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt0000000000000001470va8bom Name: -> SPITType: ActionMoveTo6 +I (493353) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt0000000000000001470va8bom Name: -> SPITType: ActionMoveTo6 +I (493883) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt0000000000000001470va8bom Name: -> SPITType: ActionMoveTo6 +I (503223) Watch: eventProjectReport ID: CatasWatchProject Name: CatasWatchProject FramesPerSecond: 44100 +I (503373) Watch: eventStartProjectTransfer +I (503373) Watch: SPIT-Type CHANGED ID: ActionStartShuffle GroupName: CatasWatchMovement Name: ActionStartShuffle confirmed: 1 +I (503373) Watch: SPIT-Type CHANGED ID: ActionMoveTo5 GroupName: CatasWatchMovement Name: ActionMoveTo5 confirmed: 1 +I (503383) Watch: SPIT-Type CHANGED ID: ActionMoveTo4 GroupName: CatasWatchMovement Name: ActionMoveTo4 confirmed: 1 +I (503393) Watch: SPIT-Type CHANGED ID: ActionMoveTo1 GroupName: CatasWatchMovement Name: ActionMoveTo1 confirmed: 1 +I (503413) Watch: SPIT-Type CHANGED ID: ActionMoveTo3 GroupName: CatasWatchMovement Name: ActionMoveTo3 confirmed: 1 +I (503423) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000011s0va8bom Name: -> SPITType: ActionMoveTo3 +I (503433) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt00000000000000012m0va8bom Name: -> SPITType: ActionMoveTo4 +I (503443) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt0000000000000001330va8bom Name: -> SPITType: ActionMoveTo5 +I (503453) Watch: SPIT-Object CHANGED ID: 00000m8uedyyt0000000000000001470va8bom Name: -> SPITType: ActionMoveTo6 +I (503463) Watch: SPIT-REMOTE-Type CHANGED ID: playControlStart GroupName: Playcontrol Name: start confirmed: 1 +I (503473) Watch: SPIT-REMOTE-Type CHANGED ID: playControlPause GroupName: Playcontrol Name: pause confirmed: 1 +I (503483) Watch: SPIT-REMOTE-Type CHANGED ID: nextSceneBridge GroupName: Playcontrol Name: next scene confirmed: 1 +I (503493) Watch: SPIT-REMOTE-Type CHANGED ID: nextMainSceneBridge GroupName: Playcontrol Name: next main scene confirmed: 1 +I (503513) Watch: SPIT-REMOTE-Type CHANGED ID: previuosSceneBridge GroupName: Playcontrol Name: previous scene confirmed: 1 +I (503523) Watch: SPIT-REMOTE-Type CHANGED ID: previousMainSceneBridge GroupName: Playcontrol Name: previous main scene confirmed: 1 +I (503543) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerSound_Volume00 GroupName: Main Mixer Name: Sound confirmed: 1 +I (503553) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerDMX_Dimmer00 GroupName: Main Mixer Name: confirmed: 1 +I (503573) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerDMX_RGB00 GroupName: Main Mixer Name: confirmed: 1 +I (503583) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerDMX_RGB10 GroupName: Main Mixer Name: confirmed: 1 +I (503603) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerDMX_RGB20 GroupName: Main Mixer Name: confirmed: 1 +I (503613) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerDMX_RGB30 GroupName: Main Mixer Name: confirmed: 1 +I (503633) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerDMX_RGB40 GroupName: Main Mixer Name: confirmed: 1 +I (503653) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerDMX_RGB50 GroupName: Main Mixer Name: confirmed: 1 +I (503663) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerMedia_SoundVolume00 GroupName: Main Mixer Name: Media confirmed: 1 +I (503683) Watch: SPIT-REMOTE-Type CHANGED ID: mainmixerMedia_Transparency00 GroupName: Main Mixer Name: Media confirmed: 1 +I (503693) Watch: SPIT-REMOTE-Type CHANGED ID: selectedJingles GroupName: Playcontrol Name: selected Jingles confirmed: 1 +I (503713) Watch: SPIT-REMOTE-Type CHANGED ID: selectedJingleGroups GroupName: Playcontrol Name: selected Jinglegroups confirmed: 1 +I (503723) Watch: SPIT-REMOTE-Type CHANGED ID: 00000m8uedyyt0000000000000000lo0va8bom GroupName: MainScene Name: ChangingPositionScene confirmed: 1 +I (503743) Watch: SPIT-REMOTE-Type CHANGED ID: 00000m8uedyyt0000000000000000m70va8bom GroupName: MainScene Name: InPosition1Scene confirmed: 1 +I (503753) Watch: SPIT-REMOTE-Type CHANGED ID: 00000m8uedyyt0000000000000000mh0va8bom GroupName: MainScene Name: InPosition2Scene confirmed: 1 +I (503773) Watch: SPIT-REMOTE-Type CHANGED ID: 00000m8uedyyt0000000000000000mr0va8bom GroupName: MainScene Name: InPosition3Scene confirmed: 1 +I (503793) Watch: SPIT-REMOTE-Type CHANGED ID: 00000m8uedyyt0000000000000000nk0va8bom GroupName: MainScene Name: InPosition4Scene confirmed: 1 +I (503803) Watch: SPIT-REMOTE-Type CHANGED ID: 00000m8uedyyt0000000000000000nu0va8bom GroupName: MainScene Name: InPosition5Scene confirmed: 1 +I (503823) Watch: SPIT-REMOTE-Type CHANGED ID: 00000m8uedyyt0000000000000000o40va8bom GroupName: MainScene Name: InPosition6Scene confirmed: 1 +I (503833) Watch: SPIT-REMOTE-Object CHANGED ID: playControlStart Name: start -> SPITType: start +I (503833) Watch: eventPlayRemoteObjectStatus RemoteSPITType: start RemoteSPITObject: start Position: 0 Value: 0 +I (503853) Watch: SPIT-REMOTE-Object CHANGED ID: playControlPause Name: pause -> SPITType: pause +I (503853) Watch: eventPlayRemoteObjectStatus RemoteSPITType: pause RemoteSPITObject: pause Position: 0 Value: 0 +I (503863) Watch: SPIT-REMOTE-Object CHANGED ID: nextSceneBridge Name: next scene -> SPITType: next scene +I (503873) Watch: eventPlayRemoteObjectStatus RemoteSPITType: next scene RemoteSPITObject: next scene Position: 0 Value: 0 +I (503883) Watch: SPIT-REMOTE-Object CHANGED ID: nextMainSceneBridge Name: next main scene -> SPITType: next main scene +I (503903) Watch: eventPlayRemoteObjectStatus RemoteSPITType: next main scene RemoteSPITObject: next main scene Position: 0 Value: 0 +I (503913) Watch: SPIT-REMOTE-Object CHANGED ID: previuosSceneBridge Name: previous scene -> SPITType: previous scene +I (503923) Watch: eventPlayRemoteObjectStatus RemoteSPITType: previous scene RemoteSPITObject: previous scene Position: 0 Value: 0 +I (503933) Watch: SPIT-REMOTE-Object CHANGED ID: previousMainSceneBridge Name: previous main scene -> SPITType: previous main scene +I (503953) Watch: eventPlayRemoteObjectStatus RemoteSPITType: previous main scene RemoteSPITObject: previous main scene Position: 0 Value: 0 +I (503963) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerSound_Volume00 Name: Sound Volume -> SPITType: Sound +I (503973) Watch: eventPlayRemoteObjectStatus RemoteSPITType: Sound RemoteSPITObject: Sound Volume Position: 0 Value: 500000 +I (503983) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerDMX_Dimmer00 Name: Dimmer -> SPITType: +I (503993) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Dimmer Position: 0 Value: 1000000 +I (504003) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerDMX_RGB00 Name: Red -> SPITType: +I (504013) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Red Position: 0 Value: 1000000 +I (504023) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerDMX_RGB10 Name: Green -> SPITType: +I (504033) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Green Position: 0 Value: 1000000 +I (504043) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerDMX_RGB20 Name: Blue -> SPITType: +I (504053) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerDMX_RGB30 Name: Cyan -> SPITType: +I (504063) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Cyan Position: 0 Value: 0 +I (504073) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerDMX_RGB40 Name: Magenta -> SPITType: +I (504083) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerDMX_RGB50 Name: Yellow -> SPITType: +I (504093) Watch: eventPlayRemoteObjectStatus RemoteSPITType: RemoteSPITObject: Yellow Position: 0 Value: 0 +I (504103) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerMedia_SoundVolume00 Name: Sound Volume -> SPITType: Media +I (504113) Watch: eventPlayRemoteObjectStatus RemoteSPITType: Media RemoteSPITObject: Sound Volume Position: 0 Value: 500000 +I (504123) Watch: SPIT-REMOTE-Object CHANGED ID: mainmixerMedia_Transparency00 Name: Media Transparency -> SPITType: Media +I (504133) Watch: SPIT-REMOTE-Object CHANGED ID: selectedJinglesps Name: Play / Stop -> SPITType: selected Jingles +I (504143) Watch: eventPlayRemoteObjectStatus RemoteSPITType: selected Jingles RemoteSPITObject: Play / Stop Position: 0 Value: 0 +I (504163) Watch: SPIT-REMOTE-Object CHANGED ID: selectedJinglespf Name: Play / Fade Out -> SPITType: selected Jingles +I (504173) Watch: SPIT-REMOTE-Object CHANGED ID: selectedJingleGroupsps Name: Play / Stop -> SPITType: selected Jinglegroups +I (504183) Watch: eventPlayRemoteObjectStatus RemoteSPITType: selected Jinglegroups RemoteSPITObject: Play / Stop Position: 0 Value: 0 +I (504193) Watch: SPIT-REMOTE-Object CHANGED ID: selectedJingleGroupspf Name: Play / Fade Out -> SPITType: selected Jinglegroups +I (504213) Watch: SPIT-REMOTE-Object CHANGED ID: 00000m8uedyyt0000000000000000lo0va8bom Name: play -> SPITType: ChangingPositionScene +I (504223) Watch: eventPlayRemoteObjectStatus RemoteSPITType: ChangingPositionScene RemoteSPITObject: play Position: 0 Value: 0 +I (504233) Watch: SPIT-REMOTE-Object CHANGED ID: 00000m8uedyyt0000000000000000m70va8bom Name: play -> SPITType: InPosition1Scene +I (504243) Watch: SPIT-REMOTE-Object CHANGED ID: 00000m8uedyyt0000000000000000mh0va8bom Name: play -> SPITType: InPosition2Scene +I (504253) Watch: SPIT-REMOTE-Object CHANGED ID: 00000m8uedyyt0000000000000000mr0va8bom Name: play -> SPITType: InPosition3Scene +I (504273) Watch: SPIT-REMOTE-Object CHANGED ID: 00000m8uedyyt0000000000000000nk0va8bom Name: play -> SPITType: InPosition4Scene +I (504283) Watch: SPIT-REMOTE-Object CHANGED ID: 00000m8uedyyt0000000000000000nu0va8bom Name: play -> SPITType: InPosition5Scene +I (504293) Watch: SPIT-REMOTE-Object CHANGED ID: 00000m8uedyyt0000000000000000o40va8bom Name: play -> SPITType: InPosition6Scene +I (504303) Watch: eventEndProjectTransfer +I (504433) Watch: SPIT-Type CHANGED ID: ActionMoveTo5 GroupName: CatasWatchMovement Name: ActionMoveTo5 confirmed: 1 +I (504433) Watch: SPIT-Type CHANGED ID: ActionMoveTo4 GroupName: CatasWatchMovement Name: ActionMoveTo4 confirmed: 1 +I (504443) Watch: SPIT-Type CHANGED ID: ActionMoveTo3 GroupName: CatasWatchMovement Name: ActionMoveTo3 confirmed: 1 +I (504453) Watch: SPIT-Type CHANGED ID: ActionMoveTo6 GroupName: CatasWatchMovement Name: ActionMoveTo6 confirmed: 1 +I (504463) Watch: SPIT-Type CHANGED ID: ActionMoveTo2 GroupName: CatasWatchMovement Name: ActionMoveTo2 confirmed: 1 +I (504473) Watch: SPIT-Type CHANGED ID: ActionMoveTo1 GroupName: CatasWatchMovement Name: ActionMoveTo1 confirmed: 1 diff --git a/doc/LSS-Icon.afdesign b/doc/LSS-Icon.afdesign index 90a4b2d..732dad7 100644 Binary files a/doc/LSS-Icon.afdesign and b/doc/LSS-Icon.afdesign differ diff --git a/doc/LSS-Icon.jpg b/doc/LSS-Icon.jpg index fdc11a8..7c24feb 100644 Binary files a/doc/LSS-Icon.jpg and b/doc/LSS-Icon.jpg differ diff --git a/doc/LiveShowProject/CatasWatchProject.dpr b/doc/LiveShowProject/CatasWatchProject.dpr new file mode 100644 index 0000000..f698cde Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.dpr differ diff --git a/doc/LiveShowProject/CatasWatchProject.ldv b/doc/LiveShowProject/CatasWatchProject.ldv new file mode 100644 index 0000000..7e827f5 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.ldv differ diff --git a/doc/LiveShowProject/CatasWatchProject.lms b/doc/LiveShowProject/CatasWatchProject.lms new file mode 100644 index 0000000..fbb39bc Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lms differ diff --git a/doc/LiveShowProject/CatasWatchProject.lmv b/doc/LiveShowProject/CatasWatchProject.lmv new file mode 100644 index 0000000..7d346ae Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lmv differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsb b/doc/LiveShowProject/CatasWatchProject.lsb new file mode 100644 index 0000000..7323c01 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsb differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsc b/doc/LiveShowProject/CatasWatchProject.lsc new file mode 100644 index 0000000..b0c0567 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsc differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsd b/doc/LiveShowProject/CatasWatchProject.lsd new file mode 100644 index 0000000..d3b6637 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsd differ diff --git a/doc/LiveShowProject/CatasWatchProject.lse b/doc/LiveShowProject/CatasWatchProject.lse new file mode 100644 index 0000000..817353f Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lse differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsf b/doc/LiveShowProject/CatasWatchProject.lsf new file mode 100644 index 0000000..fbb39bc Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsf differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsh b/doc/LiveShowProject/CatasWatchProject.lsh new file mode 100644 index 0000000..c5f9c06 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsh differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsj b/doc/LiveShowProject/CatasWatchProject.lsj new file mode 100644 index 0000000..d78b90d Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsj differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsp b/doc/LiveShowProject/CatasWatchProject.lsp new file mode 100644 index 0000000..4cfe637 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsp differ diff --git a/doc/LiveShowProject/CatasWatchProject.lss b/doc/LiveShowProject/CatasWatchProject.lss new file mode 100644 index 0000000..7f842f9 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lss differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsu b/doc/LiveShowProject/CatasWatchProject.lsu new file mode 100644 index 0000000..a8a763e Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsu differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsv b/doc/LiveShowProject/CatasWatchProject.lsv new file mode 100644 index 0000000..435b4dd Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsv differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsx b/doc/LiveShowProject/CatasWatchProject.lsx new file mode 100644 index 0000000..de1b114 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.lsx differ diff --git a/doc/LiveShowProject/CatasWatchProject.rbo b/doc/LiveShowProject/CatasWatchProject.rbo new file mode 100644 index 0000000..f009b0c Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.rbo differ diff --git a/doc/LiveShowProject/CatasWatchProject.rtf b/doc/LiveShowProject/CatasWatchProject.rtf new file mode 100644 index 0000000..1740ec3 --- /dev/null +++ b/doc/LiveShowProject/CatasWatchProject.rtf @@ -0,0 +1,5 @@ +{\rtf1\ansi +{\fonttbl\f0\fnil Monospaced;} + +\par +} diff --git a/doc/LiveShowProject/CatasWatchProject.spi b/doc/LiveShowProject/CatasWatchProject.spi new file mode 100644 index 0000000..a184f1b Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.spi differ diff --git a/doc/LiveShowProject/CatasWatchProject.ssj b/doc/LiveShowProject/CatasWatchProject.ssj new file mode 100644 index 0000000..e9143e6 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.ssj differ diff --git a/doc/LiveShowProject/CatasWatchProject.uip b/doc/LiveShowProject/CatasWatchProject.uip new file mode 100644 index 0000000..efec254 Binary files /dev/null and b/doc/LiveShowProject/CatasWatchProject.uip differ diff --git a/main/watchMain.cpp b/main/watchMain.cpp index 059b10a..5c1bb8c 100644 --- a/main/watchMain.cpp +++ b/main/watchMain.cpp @@ -6,15 +6,18 @@ * @copyright Copyright (c) 2024 */ -// Conig-Key: -// -// -// +/* Watchface + 6/ + 5 / 1 + 4 2 + 3 +*/ struct { const char *syslogDest = "syslogDst"; // example: "172.16.16.10" - const char *mqttBroker = "mqttBroker"; // example: "172.16.17.62" + const char *mqttBroker = "mqttBroker"; // example: "172.16.16.10" const char *mqttPrefix = "mqttPrefix"; // example: "SomeTag" + const char *spitServer = "spitServer"; // example: "172.16.16.10" } ConfigKeys; // MQTT Topics @@ -27,6 +30,33 @@ struct { const char *changingPosition = /* / */ "watch/changingPosition"; } MqttTopics; +struct { + const char *expectedServer = ""; + struct { + const char *group = "CatasWatchMovement"; + const char *startShuffle = "ActionStartShuffle"; + const char *moveToX[6] = { + "ActionMoveTo1", + "ActionMoveTo2", + "ActionMoveTo3", + "ActionMoveTo4", + "ActionMoveTo5", + "ActionMoveTo6", + }; + } Provided; + struct { + const char *changingPos = "ChangingPositionScene"; + const char *inPosX[6] = { + "InPosition1Scene", + "InPosition2Scene", + "InPosition3Scene", + "InPosition4Scene", + "InPosition5Scene", + "InPosition6Scene", + }; + } Expected; +} SpitTypes; + // ToDo: // - MQTT Integration // - OTA @@ -36,8 +66,8 @@ struct { #include "watchMain.hpp" -string MyApp::s_ClientName = "CatasWatchDev"; -string MyApp::s_ProjectName = "CatastrphicProj"; +string ClientName = "CatasWatchDev"; +string ProjectName = "CatastrphicProj"; extern "C" { // This switch allows the ROS C-implementation to find this main void app_main(void); @@ -47,20 +77,29 @@ struct DeviceState { uint8_t minJumps{6}; uint8_t maxJumps{32}; uint8_t profile{}; - uint8_t restTime{}; + uint8_t shuffleRate{}; float speed = 1.0; // Rad/sec float accel = 1.0; // Rad/sec^2 Color color{0x80, 0x80, 0x80}; - uint8_t pictogram{}; // 0..5 active Pictogramm }; enum class MoveType { StepTo, + Demo, Shuffle, - Demo +}; +enum class ResponseType { + StepAt, + StartMoving, }; struct MoveCommand { MoveType type; + // 1..6 + uint8_t pos; +}; +struct WatchIndex { + ResponseType type; + // 1..6 uint8_t pos; }; struct PictoIllumCommand { @@ -68,6 +107,7 @@ struct PictoIllumCommand { }; static fos::Queue commandQueue(8); +static fos::Queue responseQueue(8); static fos::Queue pictoIllumQue(2); DeviceState activeState; @@ -245,7 +285,7 @@ static void UniverseCallback(const uint8_t *data, const uint16_t size) { Syslog::logv(Syslog::Severity::Debug, "Got DMX: r%0x g%0x b%0x i%0x m%i M%i p%i a%i w%i r%i", /* RGB*/ data[0], data[1], data[2], /*Intens*/ data[3], /* MinMaxJumps */ data[4], data[5], /*profile*/ data[6], /*accel/speed*/ data[7], data[8], - /*RestTime*/ data[9]); + /*shuffleRate*/ data[9]); float intens = (float)data[3] / UINT8_MAX; activeState.color = Color{ @@ -263,7 +303,7 @@ static void UniverseCallback(const uint8_t *data, const uint16_t size) { activeState.accel = (float)accel / 100 + 0.5; // min .5 / max 3 activeState.speed = (float)velo / 100 + 0.5; // min .5 / max 3 - activeState.restTime = data[9]; + activeState.shuffleRate = data[9]; } void moveToSubs(std::string data) { @@ -346,6 +386,7 @@ static void dmxSocketTask(int addrFamily) { } fos::Semaphore etherActive; +fos::Semaphore spitProjectFinish; /** Event handler for IP_EVENT_ETH_GOT_IP */ static void got_ip_event_handler(void *arg, esp_event_base_t event_base, @@ -437,7 +478,7 @@ namespace Effect { }; const Macro macDemoFlicker = { - {64, 1, &InitSlopeWave, StateMachine::UpdateWave, 0xFF}, + {16, 1, &InitSlopeWave, StateMachine::UpdateWave, 0xFF}, {32, 1, StateMachine::UpdateFlicker, 0xFF}, }; } @@ -472,14 +513,23 @@ void LightingTask() { processors[5].setEffect(Effect::macDark, &colorSource, 0); const std::array PictoEffects{ + Effect::macDemoPulse, // 1 Effect::macDemoPulse, Effect::macDemoPulse, Effect::macDemoPulse, - Effect::macDemoPulse, - Effect::macDemoPulse, - Effect::macStartFlicker}; + Effect::macStartFlicker, + Effect::macDemoPulse}; // 6 - uint8_t lastPicto = 0; + uint8_t lastPicto = 1; + + std::array startPoints{ + &(values[0][4]), // 1 + &(values[1][12]), + &(values[1][8]), + &(values[1][4]), + &(values[0][12]), + &(values[0][8]), // 6 + }; while (true) { auto onPos = pictoIllumQue.dequeue(0); @@ -504,14 +554,6 @@ void LightingTask() { } } - std::array startPoints{ - &(values[0][4]), - &(values[0][8]), - &(values[0][12]), - &(values[1][4]), - &(values[1][8]), - &(values[1][12]), - }; for (size_t i = 0; i < processors.size(); i++) { auto col = processors[i].tick(); auto sp = startPoints[i]; @@ -533,7 +575,7 @@ void MovementTask() { StepperDriverDrv8833::Pins stepperPins{ LEDC_TIMER_0, {LEDC_CHANNEL_0, LEDC_CHANNEL_1, LEDC_CHANNEL_2, LEDC_CHANNEL_3}, - {GPIO_NUM_23, GPIO_NUM_22, GPIO_NUM_21, GPIO_NUM_20}, + {GPIO_NUM_21, GPIO_NUM_20, GPIO_NUM_23, GPIO_NUM_22}, }; StepperDriverDrv8833 stepperDriver(stepperPins, MicroSteps, 0.25F); stepperDriver.setPos(0); @@ -549,25 +591,34 @@ void MovementTask() { StepperMotor stepper(stepperCfg, stepperDriver, initSens); + WatchMotor watch(stepper, motorSleep); + ESP_LOGI("Stepper", "Find Home"); stepper.findRef(); - // Illum 1 - pictoIllumQue.enqueue(std::make_unique(1)); + // Todo Set by User-Interface + for (size_t i = 0; i < 7; i++) { + stepper.fullStep(1); + fos::Task::delayMs(40); + } + (void)stepper.zeroPosition(); + while (!stepper.isIdle()) { + fos::Task::delayMs(40); + } + // watch.moveTo(1, ProfileGenerator::Unitform); + ESP_LOGI("Stepper", "Got to 1"); + // Illum 6 + pictoIllumQue.enqueue(std::make_unique(0)); - ESP_LOGI(TAG, "Fist Position is %f.2", stepper.getScaledPos() * 6); + ESP_LOGI(TAG, "Fist Position is %.2f", watch.getScaled()); fos::Task::delayMs(1000); - activeState.pictogram = 0; - while (true) { ESP_LOGD(TAG, "Waiting for command"); auto cmd = commandQueue.dequeue(); if (cmd->type == MoveType::StepTo) { if (stepper.isIdle()) { - pictoIllumQue.enqueue(std::make_unique(0)); int newPos = cmd->pos; if ((newPos >= 1) && (newPos <= 6)) { - auto idx = newPos - 1; Syslog::logv(Syslog::Severity::Informational, "Triggered movement to picto pos:%i ", newPos); } else { @@ -575,61 +626,368 @@ void MovementTask() { "Got invalid index for illuminated pictogram =%i ", newPos); continue; } - int delta = newPos - activeState.pictogram; - if (delta <= 0) { - delta += 6; + + int jumps = newPos - watch.getIndex(); + if (jumps <= 0) { + jumps += 6; } - delta = delta + (activeState.minJumps % 6) * 6; - if (delta < activeState.minJumps) { - delta += 6; + jumps = jumps + (activeState.minJumps % 6) * 6; + if (jumps < activeState.minJumps) { + jumps += 6; } Syslog::logv(Syslog::Severity::Notice, "Running Stepper by %i steps with prof=%i a=%.2f w=%.2f", - delta, activeState.profile, activeState.accel, activeState.speed); + jumps, activeState.profile, activeState.accel, activeState.speed); pictoIllumQue.enqueue(std::make_unique(0)); - stepper.moveBy(delta * std::numbers::pi / 3, - activeState.profile, activeState.accel, activeState.speed); + responseQueue.enqueue(std::make_unique(ResponseType::StartMoving, 0)); + watch.moveTo(newPos, activeState.profile); + pictoIllumQue.enqueue(std::make_unique(newPos)); - activeState.pictogram = newPos; + responseQueue.enqueue(std::make_unique(ResponseType::StepAt, newPos)); } } else if (cmd->type == MoveType::Demo) { - int i = 0; - while (i++ < 80) { - stepperDriver.step(1); - stepperDriver.getSubPos(); - fos::Task::delayMs(100); - } - ESP_LOGI("Stepper", "Find Home"); - stepper.findRef(); - activeState.pictogram = -1; - stepper.findRef(); - fos::Task::delayMs(1000); - for (size_t i = 0; i < 6; i++) { - stepper.moveBy(std::numbers::pi / 3); - while (!stepper.isIdle()) { - fos::Task::delayMs(100); + ESP_LOGI(TAG, "Running Demo"); + for (size_t i = ProfileGenerator::Smooth; i < ProfileGenerator::NumProfiles; i++) { + ESP_LOGI(TAG, "Running Profile %d ", i); + fos::Task::delayMs(1000); + int steps[3]{4, 2, 0}; + for (size_t j = 0; j < 3; j++) { + watch.moveTo(steps[j], i); + fos::Task::delayMs(1000); } - ESP_LOGI(TAG, "Position is %f.2", stepper.getScaledPos() * 6); } } else { fos::Task::delayMs(100); } } } +struct LocalSpitObj { + string iD; + string groupName; + string name; +}; +std::map ProvidedSpitActions; +std::map ExpectedObjects; + +void onServerEvent(SPIT_Client::ServerEvent event, const SAD_DetectedServer &p_DetectedServer) { + switch (event) { + case SPIT_Client::ServerEvent::Detect: + ESP_LOGI(TAG, "SERVER DETECTED"); + ESP_LOGI(TAG, " Name: %s", p_DetectedServer.getName().data()); + ESP_LOGI(TAG, " ID: %s", p_DetectedServer.getID().data()); + ESP_LOGI(TAG, " Computer: %s", p_DetectedServer.getComputerName().data()); + ESP_LOGI(TAG, " IP: %s", p_DetectedServer.getIP().data()); + ESP_LOGI(TAG, " Port: %s", p_DetectedServer.getPort().data()); + ESP_LOGI(TAG, " Addition: %s", p_DetectedServer.getAdditions().data()); + ESP_LOGI(TAG, " ClientIP: %s", p_DetectedServer.getClientIP().data()); + break; + case SPIT_Client::ServerEvent::Lost: + ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data()); + + break; + case SPIT_Client::ServerEvent::Changed: + ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data()); + break; + + default: + break; + } +} + +void onConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus) { + ESP_LOGI(TAG, "MySPITApp: eventConnectionStatus %d ", p_ConnectionStatus); +} + +// The transfer of the server's SPITTypes and SPITObjects is finished. +void onProjectUpdate(SPIT_Client::ProjUpdate state, string projectId) { + + switch (state) { + case SPIT_Client::ProjUpdate::ServerLoaded: + ESP_LOGI(TAG, "eventProjectReport ID: %s ", projectId.data()); + break; + case SPIT_Client::ProjUpdate::StartTransfer: + ESP_LOGI(TAG, "eventStartProjectTransfer"); + break; + case SPIT_Client::ProjUpdate::EndTransfer: + ESP_LOGI(TAG, "eventEndProjectTransfer"); + spitProjectFinish.give(); + break; + case SPIT_Client::ProjUpdate::ServerClosed: + ESP_LOGI(TAG, "eventProjectClosed ID: %s", projectId.data()); + // If we don't save SPITServer's project specific information + // perhaps close all SPITObjects and RemoteSPITObjects to avoid conflicts, when the SPITServer loads a new project + // SPITObject::clearSPITObjects(); + // SPITObject::clearSPITObjectsRemote(); + break; + + default: + break; + } +} + +/** + * The SPITCLientInterface (implemented by this) will be asked to veto the SPITType while SPIT_Client.parseReportSPITType.
+ * @param p_ReportSPITType + * @return false = the SPITType is denied, true = the SPITType is accepted + */ +bool onCheckSpitTypeVeto(SPIT_Message::ReportSPITType *p_ReportSPITType) { + return true; // Bypass veto + + if (p_ReportSPITType == NULL) + return true; + SPITType *ptrSPITType; + ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID()); + + // Don't allow foreign SPITTypes + if (ptrSPITType == NULL) { + // ESP_LOGW(TAG, "ObjectVeto NoSpitType"); + return false; + } + if (ptrSPITType->getCreatedByClient() == false) { + // ESP_LOGW(TAG, "getCreatedByClient"); + return false; + } + return true; +} + +bool onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject *p_ReportSPITObject) { + return true; // Bypass veto + + if (p_ReportSPITObject == NULL) + return true; + SPITType *ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID()); + if (ptrSPITType == NULL) { + // ESP_LOGW(TAG, "ObjectVeto NoSpitObj"); + return false; + } + + // Don't allow SPITObjects which refers to a SPITType which is not created by this client - other SPITTypes cannot be handled here + if (ptrSPITType->getCreatedByClient() == false) { + // ESP_LOGW(TAG, "getCreatedByClient"); + return false; + } + SPITObject *ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITObject->getID()); + // Don't allow foreign SPITTypes + if (ptrSPITObject == NULL) { + // ESP_LOGE(TAG, "Unknown ID"); + return false; + } + + return true; +} + +// Called when the server has created, loaded, changed or deleted a SPITType. +// May also occur when the server confirms a SPITType created or changed by the client. +void onSpitType(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType) { + if (event == SPIT_Client::ObjectEvent::Created) { + // Whenever you provide an action for this SPITType take this over in your code. + // call _SpitClient.setActionSPITType(p_SPITType.getID(), true); + ESP_LOGI(TAG, "NEW SPIT-Type ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed()); + } else if (event == SPIT_Client::ObjectEvent::Changed) { + ESP_LOGI(TAG, "SPIT-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed()); + } else if (event == SPIT_Client::ObjectEvent::Deleted) { + ESP_LOGI(TAG, "SPIT-Type Removed ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data()); + } +} + +/** + * Called when the server has created or changed a Remote SPITType. + * Remote SPITType are used in Remote SPITObjects. A Remote SPITObject is used to remote control the SPITServer. + * @param p_New true = server created a new SPITType / false = server changed a existing SPITType + */ +void onSpitTypeRemote(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType) { + if (event == SPIT_Client::ObjectEvent::Created) { + ESP_LOGI(TAG, "NEW SPIT-REMOTE-Type ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed()); + auto typeName = p_SPITType.getName(); + if (ExpectedObjects.contains(typeName)) { + ExpectedObjects[typeName] = p_SPITType.getID(); + } + } else if (event == SPIT_Client::ObjectEvent::Changed) { + // we had to inform all Remote SPITObjects using the p_SPITType + // perhaps the SPITObject uses information from the SPITType + SPITObject *ptrSPITObject; + int intSPITObjectCount; + intSPITObjectCount = SPITObject::getSPITObjectRemoteCount(); + for (int intObject = 0; intObject < intSPITObjectCount; intObject++) { + ptrSPITObject = SPITObject::getSPITObjectRemote(intObject); + if (ptrSPITObject == NULL) + continue; + if (ptrSPITObject->getSPITTypeID() == p_SPITType.getID()) { + // call ecentSPITObjectRemote + // onSpitObjectRemote(SPIT_Client::ObjectEvent::Changed, p_SPITType, *ptrSPITObject); + } + } + ESP_LOGI(TAG, "SPIT-REMOTE-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed()); + } else if (event == SPIT_Client::ObjectEvent::Deleted) { + ESP_LOGD(TAG, "SPIT-REMOTE-Type Removed ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data()); + } +} + +/** + * Called when the server has created, loaded or changed a SPITObject. + * May also occur when the server confirms a SPITObject created by the client, what the client should never do!!. + * false = server changed a existing SPITObject + * @param p_SPITType a reference to a copy of the associated SPITType instance. + * @param p_SPITObject a reference to a copy of the SPITObject instance. + */ +void onSpitObject(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject) { + if (event == SPIT_Client::ObjectEvent::Created) { + ESP_LOGI(TAG, "NEW SPIT-Object ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data()); + // check your actions + // Whenever you provide an action for this SPITObject take this over in your code. + // call _SpitClient.setActionSPITObject(p_SPITObject.getID(), true); + + // for our little excample as described in loadClientProject: + // We have only actions for SPITTypes - means every SPITObject with the associated "Actionx"-SPITTypes will trigger the action when it is played + //-> no need to do something here, because setActionSPITType has been set prior and the SPITObject will automatically inherits this + // SPITObjects with other SPITTypes asscciated will trigger no actions + + } else if (event == SPIT_Client::ObjectEvent::Changed) { + ESP_LOGI(TAG, "SPIT-Object CHANGED ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data()); + } else if (event == SPIT_Client::ObjectEvent::Deleted) { + ESP_LOGD(TAG, "SPIT-Object Removed ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data()); + // Check your actions + // take the removal of the SPITObject over in your code + + // CAUTION: Deleted SPITObjects can be added later again (perhaps per UNDO on the SPITServer) + //-> don't remove your assigned action immediately - keep it to reassign it later + } +} +/** + * Called when the server has created or changed a Remote SPITObject. + * A Remote SPITObject is used to remote control the SPITServer. + * @param p_New true = server created a new remote SPITObject + * false = server changed a existing remote SPITObject + * @param p_SPITType a reference to a copy of the associated SPITType instance. + * @param p_SPITObject a reference to a copy of the SPITObject instance. + */ +void onSpitObjectRemote(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject) { + if (event == SPIT_Client::ObjectEvent::Created) { + ESP_LOGI(TAG, "NEW SPIT-REMOTE-Object ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data()); + // This is a remote SPITObject which can be used to remote control the server. + // If you want you can list this for later use + } else if (event == SPIT_Client::ObjectEvent::Changed) { + ESP_LOGI(TAG, "SPIT-REMOTE-Object CHANGED ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data()); + } else if (event == SPIT_Client::ObjectEvent::Deleted) { + ESP_LOGD(TAG, "SPIT-REMOTE-Object Removed ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data()); + // This is a remote SPITObject + // If you have listet this prior you should remove it from the list + } +} + +// SPITServer may use several methods for playing SPITObjects. +// e.g. liveSHOWsoftware has the timeline and jingles which plays objects, where the timeline the main player is. +// SPIT distinguishes between the different players. All eventPlay... functions contain the information which player plays the SPIT object. +void onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames) { + ESP_LOGD(TAG, "eventPlay Player: %s Runs: %d Time: %lld", p_PlayerName.data(), p_PlayerIsRunning, p_TimeFrames); + + switch (p_PlayerType) { + case SPIT_Client::PLAYERTYPE_MAIN: + // p_FrameTimes contains the position inside the server's project, we can use it like a timecode + // int intMilliseconds = (int)(((double)p_TimeFrames / (double)m_ServerFramesPerSecond) * 1000); + break; + case SPIT_Client::PLAYERTYPE_CONTINOUS: + // The olayer is playing only single Object sequences sometime during the project + break; + case SPIT_Client::PLAYERTYPE_DISCRETE: + // Only discrete values where submitted, e.g the fader position of remote faders. + break; + } +} + +/** + * Called when the SPITServer plays a SPITObject. For every played SPITObject one eventPlayObject is called. + * You can decide here which action should be done or not. + */ +void onPlaySpitType(string p_PlayerID, string spitTypeId, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value) { + // double doubleValue = ((double)p_PlayObject.getValue() / 1000000) * ((double)p_PlayObject.getValueFactor() / 1000000); + + ESP_LOGD(TAG, "eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d", p_PlayerID.data(), p_PlayerIsRunning, p_Started, p_Ended); + // ESP_LOGD(TAG, " SPITType: %s SPITObject: %s Position: %lld Value: %f\n", spitTypeId.data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue); + ESP_LOGD(TAG, " SPITType: %s Value: %f\n", spitTypeId.data(), p_Value); + + if (!ProvidedSpitActions.contains(spitTypeId)) { + ESP_LOGE(TAG, "SPIT ID %s is not accepted", spitTypeId.c_str()); + return; + } + if (p_Started == true) { + auto command = ProvidedSpitActions[spitTypeId]; + ESP_LOGI(TAG, "Player: %s is running: %s Object", p_PlayerID.data(), spitTypeId.c_str()); + commandQueue.enqueue(std::make_unique(command)); + Syslog::logv(Syslog::Severity::Informational, "Got SPIT command for move ot : r%d", command.pos); + } +} + +/** + * Called when a remote SpitObject which value function is changed by the server. + * This allows the Client to adjust its display for the remote command. + * @param p_SPITType the assigned remote SPITType of p_SPITObject + * @param p_SPITObject the remote SPITObject which is changed + * @param p_FrameInsideObject can be discarded + * @param p_Value the new value + */ +void onPlayRemoteObjectStatus(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value) { + ESP_EARLY_LOGI(TAG, "eventPlayRemoteObjectStatus RemoteSPITType: %s RemoteSPITObject: %s Position: %lld Value: %d", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_FrameInsideObject, p_Value); +} void SpitClientApp() { - ESP_LOGI(TAG, "Starting SPIT task"); - auto ptrMyApp = std::make_unique(); + ESP_LOGI(TAG, "Starting SPIT task"); + auto &provided = SpitTypes.Provided; + auto &expected = SpitTypes.Expected; + std::vector ProvidedObj; + ProvidedSpitActions[provided.startShuffle] = MoveCommand{.type = MoveType::Shuffle, .pos = 0}; + ProvidedObj.push_back(LocalSpitObj{.iD = provided.startShuffle, .groupName = provided.group, .name = provided.startShuffle}); + ExpectedObjects[expected.changingPos] = ""; + for (size_t i = 0; i < 6; i++) { + ProvidedObj.push_back(LocalSpitObj{.iD = provided.moveToX[i], .groupName = provided.group, .name = provided.moveToX[i]}); + ProvidedSpitActions[provided.moveToX[i]] = MoveCommand{.type = MoveType::StepTo, .pos = (uint8_t)(i + 1)}; + ExpectedObjects[expected.inPosX[i]] = ""; + } - // load a client project and start auto detection of SPITServers - ptrMyApp->init(); - - while (true) { - fos::Task::delayMs(10000); - ESP_LOGI(TAG, "Test LiveShow"); - ptrMyApp->testLiveShowRemote(); //This is an excample how to remote control the liveSHOWsoftware - } + SPIT_Client spitClient(ClientName, ProjectName, + { + .onServerEvent = onServerEvent, + .onConnectionStatus = onConnectionStatus, + .onProjectUpdate = onProjectUpdate, + .onSpitType = onSpitType, + .onSpitTypeRemote = onSpitTypeRemote, + .onSpitObject = onSpitObject, + .onSpitObjectRemote = onSpitObjectRemote, + .onPlay = onPlay, + .onPlaySpitType = onPlaySpitType, + .onPlayRemoteObjectStatus = onPlayRemoteObjectStatus, + .onCheckSpitTypeVeto = onCheckSpitTypeVeto, + .onCheckSpitObjectVeto = onCheckSpitObjectVeto, + }); + + for (auto &obj : ProvidedObj) { + SPITType *ptrSPITType1Fix = spitClient.createSPITTypeFixed(obj.iD, obj.groupName, obj.name, 0, 0); + spitClient.setActionSPITType(ptrSPITType1Fix->getID(), true); // should be executed whenever a SPITObject with this SPITType is played + } + spitClient.clientProjectLoaded(); + spitClient.startServerAutoDetect(); + + spitProjectFinish.take(); + string serverProjectID = spitClient.getServerProjectID(); + string serverProjectName = spitClient.getClientProjectName(); + int serverFramesPerSecond = spitClient.getServerFramesPerSecond(); // set when the server reports his project, see eventProjectReport + ESP_LOGI(TAG, "eventProjectReport ID: %s Name: %s FramesPerSecond: %d", serverProjectID.data(), serverProjectName.data(), serverFramesPerSecond); + + for (auto &&obj : ExpectedObjects) { + if (obj.second == "") { + ESP_LOGE(TAG, "No matching Remote ID for %s", obj.first.c_str()); + } + } + + while (true) { + auto res = responseQueue.dequeue(); + if (res->type == ResponseType::StartMoving) { + spitClient.sendRemoteObject(ExpectedObjects[expected.changingPos]); + } else if (res->type == ResponseType::StepAt) { + spitClient.sendRemoteObject(ExpectedObjects[expected.inPosX[res->pos - 1]]); + } + } } void app_main(void) { @@ -641,17 +999,18 @@ void app_main(void) { ESP_ERROR_CHECK(ret); initialize_ethernet(); NvsApi::init(); - static fos::Task lightingTask(LightingTask, "Lights", 0x4000uL); - static fos::Task movementTask(MovementTask, "Motor", 0x4000uL); + static fos::Task lightingTask(LightingTask, "Lights", 0x8000uL); + static fos::Task movementTask(MovementTask, "Motor", 0x8000uL); etherActive.take(); + fos::Task::delayMs(10000); ESP_LOGI(TAG, "Start net services"); static int ipVersion = AF_INET; static fos::TaskT telnetSocket(telnetSocketTask, ipVersion, "tcpServer", 4096); static fos::TaskT dmxNode(dmxSocketTask, ipVersion, "dmxNode", 4096); // static Task otaUpdate(SystemFunctions::OtaTaskEntry, "otaTask", 8192); - static fos::Task spit(SpitClientApp,"SpitClient"); + static fos::Task spit(SpitClientApp, "SpitClient"); auto &store = NvsApi::getInstance(); auto logger = store.getValue(ConfigKeys.syslogDest); diff --git a/main/watchMain.hpp b/main/watchMain.hpp index 09aee55..dba95a0 100644 --- a/main/watchMain.hpp +++ b/main/watchMain.hpp @@ -7,8 +7,9 @@ #pragma once -#include -#include +#include +#include +#include #include "sdkconfig.h" #include "esp_event.h" #include "esp_log.h" @@ -36,7 +37,7 @@ #include "Processor.hpp" #include "nvsFunctions.hpp" #include "mqttClient.hpp" -#include "MyApp.h" +#include "watchFace.hpp" // #include "esp_chip_info.h" // #include "esp_flash.h" @@ -51,4 +52,13 @@ // #include "systemFunctions.hpp" // #include // #include -// #include \ No newline at end of file +// #include + +#include "SAD_DetectedServer.hpp" +#include "SPITObject.h" +#include "SPITPlayer.h" +#include "SPITType.h" +#include "SPIT_Client.h" +#include +#include +#include diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt new file mode 100644 index 0000000..1cd72f3 --- /dev/null +++ b/test/integration/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.16) + +set(EXTRA_COMPONENT_DIRS + "../../core/components" + "../../core/managed_components" + "../../components" + # "../../managed_components" +) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(INTEGRATION_TESTS_FW) + diff --git a/test/dependencies.lock b/test/integration/dependencies.lock similarity index 100% rename from test/dependencies.lock rename to test/integration/dependencies.lock diff --git a/test/integration/main/CMakeLists.txt b/test/integration/main/CMakeLists.txt new file mode 100644 index 0000000..39a435f --- /dev/null +++ b/test/integration/main/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "movementTests.cpp" + INCLUDE_DIRS ".") diff --git a/test/integration/main/movementTests.cpp b/test/integration/main/movementTests.cpp new file mode 100644 index 0000000..9fc745e --- /dev/null +++ b/test/integration/main/movementTests.cpp @@ -0,0 +1,322 @@ +/** + * @file watchMain.cpp + * @author Gustice + * @brief ChaosWatch Application + * + * @copyright Copyright (c) 2024 + */ + +/// NOTE: Create IDF shell navigate to directory ("test/integration") +// and run "idf.py -p COM9 flash monitor" + +#include "Processor.hpp" +#include "PwmExpanderPca9685.hpp" +#include "StepperDrv8833.hpp" +#include "Task.hpp" +#include "esp_event.h" +#include "esp_log.h" +#include "sdkconfig.h" +#include "stepperMotor.hpp" +#include "watchFace.hpp" +#include +#include +#include +#include + +/* Watchface Indicies + 6/ 5/ + 5 / 1 4 / 0 + 4 2 3 1 + 3 2 +*/ + +extern "C" { // This switch allows the ROS C-implementation to find this main +void app_main(void); +} + +static const char *TAG = "IT"; + +struct DeviceState { + uint8_t minJumps{6}; + uint8_t maxJumps{32}; + uint8_t profile{}; + uint8_t restTime{}; + float speed = 1.0; // Rad/sec + float accel = 1.0; // Rad/sec^2 + Color color{0x80, 0x80, 0x80}; + uint8_t pictogram{}; // 0..5 active Pictogramm +}; + +class IndexIllumination { + public: + IndexIllumination() + : master(I2C_NUM_0, /*sda=*/GPIO_NUM_10, /*scl=*/GPIO_NUM_11), + ledDriver1(master, /*iverted=*/false), + ledDriver2(master, /*iverted=*/false, 0x41), + pwmEnable(GPIO_NUM_1, GpioPort::Logic::Inverted), + RED{CRed.getColor()}, + GREEN{CGreen.getColor()}, + BLUE{CBlue.getColor()} { + pwmEnable.write(true); + clearColorData(); + syncToDevice(); + } + + void clearColorData() { + for (size_t i = 0; i < 2; i++) { + for (size_t j = 0; j < PmwExpanderPca9685::PwmChannels; j++) { + Values[i][j] = 0; + } + } + } + + void setColorOfIndexTo(uint8_t idx, Color::Rgbw color) { + if (idx >= 6) { + return; + } + auto sp = LedStartPoints[idx]; + sp[0] = (uint16_t)(color.white) << 5; + sp[1] = (uint16_t)(color.blue) << 5; + sp[2] = (uint16_t)(color.green) << 5; + sp[3] = (uint16_t)(color.red) << 5; + } + + void syncToDevice() { + ledDriver1.sendImage(Values[0]); + ledDriver2.sendImage(Values[1]); + } + + void flashAll(Color::Rgbw color, int duration = 200) { + clearColorData(); + for (size_t i = 0; i < 6; i++) { + setColorOfIndexTo(i, color); + } + syncToDevice(); + fos::Task::delayMs(duration); + clearColorData(); + syncToDevice(); + } + + private: + PmwExpanderPca9685::GrayValues Values[2]{}; + std::array LedStartPoints{ + &(Values[0][4]), // 1 + &(Values[1][12]), + &(Values[1][8]), + &(Values[1][4]), + &(Values[0][12]), + &(Values[0][8]), // 6 + }; + + I2cMaster master; + PmwExpanderPca9685 ledDriver1; + PmwExpanderPca9685 ledDriver2; + OutputPort pwmEnable; + const Color::Rgbw RED; + const Color::Rgbw GREEN; + const Color::Rgbw BLUE; +}; + +DeviceState activeState; + +void IndexColorSweep(IndexIllumination &illum) { + const auto RED = CRed.getColor(); + const auto GREEN = CGreen.getColor(); + const auto BLUE = CBlue.getColor(); + + illum.flashAll(RED); + fos::Task::delayMs(200); + illum.flashAll(GREEN); + fos::Task::delayMs(200); + illum.flashAll(BLUE); + fos::Task::delayMs(200); + + illum.clearColorData(); + illum.setColorOfIndexTo(0, GREEN); + illum.syncToDevice(); + fos::Task::delayMs(500); + + illum.clearColorData(); + illum.setColorOfIndexTo(0, RED); + illum.setColorOfIndexTo(1, GREEN); + illum.syncToDevice(); + fos::Task::delayMs(500); + + illum.clearColorData(); + illum.setColorOfIndexTo(1, RED); + illum.setColorOfIndexTo(2, GREEN); + illum.syncToDevice(); + fos::Task::delayMs(500); + + illum.clearColorData(); + illum.setColorOfIndexTo(2, RED); + illum.setColorOfIndexTo(3, GREEN); + illum.syncToDevice(); + fos::Task::delayMs(500); + + illum.clearColorData(); + illum.setColorOfIndexTo(3, RED); + illum.setColorOfIndexTo(4, GREEN); + illum.syncToDevice(); + fos::Task::delayMs(500); + + illum.clearColorData(); + illum.setColorOfIndexTo(4, RED); + illum.setColorOfIndexTo(5, GREEN); + illum.syncToDevice(); + fos::Task::delayMs(500); + + illum.clearColorData(); + illum.setColorOfIndexTo(5, RED); + illum.syncToDevice(); + fos::Task::delayMs(500); + + illum.clearColorData(); + illum.setColorOfIndexTo(0, GREEN); + illum.syncToDevice(); +} + +constexpr bool DoFlushAtBeginning = false; +constexpr bool DoFullTurns = false; +constexpr bool DoTurnSteps = false; +constexpr bool DoTurnProfiles = true; + +void testMovementTask() { + esp_log_level_set(TAG, ESP_LOG_DEBUG); + esp_log_level_set("STP", ESP_LOG_DEBUG); + ESP_LOGD(TAG, "Init Lights for signaling"); + + IndexIllumination illum; + + if constexpr (DoFlushAtBeginning) { + IndexColorSweep(illum); + } + const auto BLUE = CBlue.getColor(); + + ESP_LOGD(TAG, "Init Stepper"); + + constexpr int MicroSteps = 32; + constexpr float Intensity = 0.25; + constexpr float StepWidth = 1.8; + StepperDriverDrv8833::Pins stepperPins({LEDC_TIMER_0, + {LEDC_CHANNEL_0, LEDC_CHANNEL_1, LEDC_CHANNEL_2, LEDC_CHANNEL_3}, + {GPIO_NUM_21, GPIO_NUM_20, GPIO_NUM_23, GPIO_NUM_22}}); + StepperDriverDrv8833 stepperDriver(stepperPins, MicroSteps, Intensity); + StepperConfig stepperCfg(StepWidth, MicroSteps); + InputPort initSens(GPIO_NUM_18); + OutputPort motorSleep(GPIO_NUM_15, GpioPort::Logic::Inverted); + StepperMotor stepper(stepperCfg, stepperDriver, initSens); + + WatchMotor watch(stepper, motorSleep); + + /// + /// Full Turns with full steps + /// + if constexpr (DoFullTurns) { + ESP_LOGD(TAG, "Find Home"); + stepper.findRef(); + ESP_LOGD(TAG, "Fist Position is %3d / %.2f / Micro %d", stepper.getQuanted(), stepper.getScaledPos() * 6, stepper.getSubPos()); + fos::Task::delayMs(2000); + + ESP_LOGD(TAG, "Make one turns with full steps"); + // stepper.setPos(0); + illum.flashAll(BLUE); + int i = 0; + + ESP_LOGD(TAG, "Position at begin is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6); + while (i++ < 200) { + stepper.fullStep(1); + fos::Task::delayMs(100); + ESP_LOGD(TAG, "Position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6); + } + fos::Task::delayMs(2000); + + int spB = stepper.getSubPos(); + stepper.demoFullTurn(); + int spE = stepper.getSubPos(); + ESP_LOGD(TAG, "Fullsteps SubPos begin %d / end %d", spB, spE); + fos::Task::delayMs(2000); + + ESP_LOGD(TAG, "Position at begin is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6); + i = 0; + while (i++ < 64) { + stepper.step(1); + fos::Task::delayMs(100); + ESP_LOGD(TAG, "Position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6); + } + } + + /// + /// Homing + /// + ESP_LOGD(TAG, "Find Home"); + stepper.findRef(); + ESP_LOGD(TAG, "Fist Position is %3d / %.2f / Micro %d", stepper.getQuanted(), stepper.getScaledPos() * 6, stepper.getSubPos()); + for (size_t i = 0; i < 7; i++) { + stepper.fullStep(1); + fos::Task::delayMs(40); + } + illum.flashAll(BLUE); + fos::Task::delayMs(1000); + + auto ref = stepper.zeroPosition(); + ESP_LOGD(TAG, "Reference saved at %.2f ", ref); + ESP_LOGD(TAG, "Correct Home"); + + /// + /// Multiple Turns continuous + /// + if constexpr (DoTurnSteps) { + + ESP_LOGD(TAG, "Fist Position is %3d / %.2f / Micro %d", stepper.getQuanted(), stepper.getScaledPos() * 6, stepper.getSubPos()); + fos::Task::delayMs(1000); + ESP_LOGI(TAG, "Move to each index multiple times"); + illum.flashAll(BLUE); + for (size_t i = 1; i <= 2 * 3; i++) { + watch.moveTo(3 * i); + ESP_LOGD(TAG, "Position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6); + } + + ESP_LOGI(TAG, "Move to each index multiple times"); + illum.flashAll(BLUE); + for (size_t i = 1; i <= 6 * 3; i++) { + watch.moveTo(i); + ESP_LOGD(TAG, "Position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6); + } + } + + /// + /// All other Profiles + /// + if constexpr (DoTurnProfiles) { + for (size_t i = ProfileGenerator::Smooth; i < ProfileGenerator::NumProfiles; i++) { + // for (size_t i = ProfileGenerator::JumpIn; i < ProfileGenerator::NumProfiles; i++) { // If only part is needed + ESP_LOGI(TAG, "Running Profile %d ", i); + ESP_LOGD(TAG, "Fist Position is %3d / %.2f / Micro %d", stepper.getQuanted(), stepper.getScaledPos() * 6, stepper.getSubPos()); + fos::Task::delayMs(1000); + illum.flashAll(BLUE); + int steps[3]{4, 2, 0}; + for (size_t j = 0; j < 3; j++) { + watch.moveTo(steps[j], i); + ESP_LOGI(TAG, "Last position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6); + fos::Task::delayMs(1000); + } + } + } + + while (true) { + ESP_LOGI(TAG, "Finish"); + fos::Task::delayMs(60000); + } +} + +void app_main(void) { + ESP_LOGI(TAG, "Start Movement Integration Tests"); + + static fos::Task movementTest(testMovementTask, "Move", fos::Task::DefaultStackSize * 8); + + while (true) { + fos::Task::delayMs(5000); + // ESP_LOGI(TAG, "Finish"); + } +} diff --git a/test/integration/sdkconfig b/test/integration/sdkconfig new file mode 100644 index 0000000..7a210c2 --- /dev/null +++ b/test/integration/sdkconfig @@ -0,0 +1,2159 @@ +# +# Automatically generated file. DO NOT EDIT. +# Espressif IoT Development Framework (ESP-IDF) 5.3.0 Project Configuration +# +CONFIG_SOC_ADC_SUPPORTED=y +CONFIG_SOC_DEDICATED_GPIO_SUPPORTED=y +CONFIG_SOC_UART_SUPPORTED=y +CONFIG_SOC_GDMA_SUPPORTED=y +CONFIG_SOC_AHB_GDMA_SUPPORTED=y +CONFIG_SOC_GPTIMER_SUPPORTED=y +CONFIG_SOC_PCNT_SUPPORTED=y +CONFIG_SOC_MCPWM_SUPPORTED=y +CONFIG_SOC_TWAI_SUPPORTED=y +CONFIG_SOC_ETM_SUPPORTED=y +CONFIG_SOC_PARLIO_SUPPORTED=y +CONFIG_SOC_BT_SUPPORTED=y +CONFIG_SOC_IEEE802154_SUPPORTED=y +CONFIG_SOC_ASYNC_MEMCPY_SUPPORTED=y +CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED=y +CONFIG_SOC_TEMP_SENSOR_SUPPORTED=y +CONFIG_SOC_PHY_SUPPORTED=y +CONFIG_SOC_WIFI_SUPPORTED=y +CONFIG_SOC_SUPPORTS_SECURE_DL_MODE=y +CONFIG_SOC_ULP_SUPPORTED=y +CONFIG_SOC_LP_CORE_SUPPORTED=y +CONFIG_SOC_EFUSE_KEY_PURPOSE_FIELD=y +CONFIG_SOC_EFUSE_SUPPORTED=y +CONFIG_SOC_RTC_FAST_MEM_SUPPORTED=y +CONFIG_SOC_RTC_MEM_SUPPORTED=y +CONFIG_SOC_I2S_SUPPORTED=y +CONFIG_SOC_RMT_SUPPORTED=y +CONFIG_SOC_SDM_SUPPORTED=y +CONFIG_SOC_GPSPI_SUPPORTED=y +CONFIG_SOC_LEDC_SUPPORTED=y +CONFIG_SOC_I2C_SUPPORTED=y +CONFIG_SOC_SYSTIMER_SUPPORTED=y +CONFIG_SOC_SUPPORT_COEXISTENCE=y +CONFIG_SOC_AES_SUPPORTED=y +CONFIG_SOC_MPI_SUPPORTED=y +CONFIG_SOC_SHA_SUPPORTED=y +CONFIG_SOC_HMAC_SUPPORTED=y +CONFIG_SOC_DIG_SIGN_SUPPORTED=y +CONFIG_SOC_ECC_SUPPORTED=y +CONFIG_SOC_FLASH_ENC_SUPPORTED=y +CONFIG_SOC_SECURE_BOOT_SUPPORTED=y +CONFIG_SOC_SDIO_SLAVE_SUPPORTED=y +CONFIG_SOC_BOD_SUPPORTED=y +CONFIG_SOC_APM_SUPPORTED=y +CONFIG_SOC_PMU_SUPPORTED=y +CONFIG_SOC_PAU_SUPPORTED=y +CONFIG_SOC_LP_TIMER_SUPPORTED=y +CONFIG_SOC_LP_AON_SUPPORTED=y +CONFIG_SOC_LP_PERIPHERALS_SUPPORTED=y +CONFIG_SOC_LP_I2C_SUPPORTED=y +CONFIG_SOC_ULP_LP_UART_SUPPORTED=y +CONFIG_SOC_CLK_TREE_SUPPORTED=y +CONFIG_SOC_ASSIST_DEBUG_SUPPORTED=y +CONFIG_SOC_WDT_SUPPORTED=y +CONFIG_SOC_SPI_FLASH_SUPPORTED=y +CONFIG_SOC_RNG_SUPPORTED=y +CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y +CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y +CONFIG_SOC_MODEM_CLOCK_SUPPORTED=y +CONFIG_SOC_PM_SUPPORTED=y +CONFIG_SOC_XTAL_SUPPORT_40M=y +CONFIG_SOC_AES_SUPPORT_DMA=y +CONFIG_SOC_AES_GDMA=y +CONFIG_SOC_AES_SUPPORT_AES_128=y +CONFIG_SOC_AES_SUPPORT_AES_256=y +CONFIG_SOC_ADC_DIG_CTRL_SUPPORTED=y +CONFIG_SOC_ADC_DIG_IIR_FILTER_SUPPORTED=y +CONFIG_SOC_ADC_MONITOR_SUPPORTED=y +CONFIG_SOC_ADC_DMA_SUPPORTED=y +CONFIG_SOC_ADC_PERIPH_NUM=1 +CONFIG_SOC_ADC_MAX_CHANNEL_NUM=7 +CONFIG_SOC_ADC_ATTEN_NUM=4 +CONFIG_SOC_ADC_DIGI_CONTROLLER_NUM=1 +CONFIG_SOC_ADC_PATT_LEN_MAX=8 +CONFIG_SOC_ADC_DIGI_MAX_BITWIDTH=12 +CONFIG_SOC_ADC_DIGI_MIN_BITWIDTH=12 +CONFIG_SOC_ADC_DIGI_IIR_FILTER_NUM=2 +CONFIG_SOC_ADC_DIGI_MONITOR_NUM=2 +CONFIG_SOC_ADC_DIGI_RESULT_BYTES=4 +CONFIG_SOC_ADC_DIGI_DATA_BYTES_PER_CONV=4 +CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_HIGH=83333 +CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_LOW=611 +CONFIG_SOC_ADC_RTC_MIN_BITWIDTH=12 +CONFIG_SOC_ADC_RTC_MAX_BITWIDTH=12 +CONFIG_SOC_ADC_CALIBRATION_V1_SUPPORTED=y +CONFIG_SOC_ADC_SELF_HW_CALI_SUPPORTED=y +CONFIG_SOC_ADC_CALIB_CHAN_COMPENS_SUPPORTED=y +CONFIG_SOC_ADC_TEMPERATURE_SHARE_INTR=y +CONFIG_SOC_ADC_SHARED_POWER=y +CONFIG_SOC_BROWNOUT_RESET_SUPPORTED=y +CONFIG_SOC_SHARED_IDCACHE_SUPPORTED=y +CONFIG_SOC_CACHE_FREEZE_SUPPORTED=y +CONFIG_SOC_CPU_CORES_NUM=1 +CONFIG_SOC_CPU_INTR_NUM=32 +CONFIG_SOC_CPU_HAS_FLEXIBLE_INTC=y +CONFIG_SOC_INT_PLIC_SUPPORTED=y +CONFIG_SOC_CPU_HAS_CSR_PC=y +CONFIG_SOC_CPU_BREAKPOINTS_NUM=4 +CONFIG_SOC_CPU_WATCHPOINTS_NUM=4 +CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=0x80000000 +CONFIG_SOC_CPU_HAS_PMA=y +CONFIG_SOC_CPU_IDRAM_SPLIT_USING_PMP=y +CONFIG_SOC_DS_SIGNATURE_MAX_BIT_LEN=3072 +CONFIG_SOC_DS_KEY_PARAM_MD_IV_LENGTH=16 +CONFIG_SOC_DS_KEY_CHECK_MAX_WAIT_US=1100 +CONFIG_SOC_AHB_GDMA_VERSION=1 +CONFIG_SOC_GDMA_NUM_GROUPS_MAX=1 +CONFIG_SOC_GDMA_PAIRS_PER_GROUP_MAX=3 +CONFIG_SOC_GDMA_SUPPORT_ETM=y +CONFIG_SOC_GDMA_SUPPORT_SLEEP_RETENTION=y +CONFIG_SOC_ETM_GROUPS=1 +CONFIG_SOC_ETM_CHANNELS_PER_GROUP=50 +CONFIG_SOC_GPIO_PORT=1 +CONFIG_SOC_GPIO_PIN_COUNT=31 +CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER=y +CONFIG_SOC_GPIO_FLEX_GLITCH_FILTER_NUM=8 +CONFIG_SOC_GPIO_SUPPORT_ETM=y +CONFIG_SOC_GPIO_SUPPORT_RTC_INDEPENDENT=y +CONFIG_SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP=y +CONFIG_SOC_LP_IO_CLOCK_IS_INDEPENDENT=y +CONFIG_SOC_GPIO_IN_RANGE_MAX=30 +CONFIG_SOC_GPIO_OUT_RANGE_MAX=30 +CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK=0 +CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT=8 +CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x000000007FFFFF00 +CONFIG_SOC_GPIO_SUPPORT_FORCE_HOLD=y +CONFIG_SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP=y +CONFIG_SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX=y +CONFIG_SOC_CLOCKOUT_HAS_SOURCE_GATE=y +CONFIG_SOC_GPIO_CLOCKOUT_CHANNEL_NUM=3 +CONFIG_SOC_RTCIO_PIN_COUNT=8 +CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y +CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y +CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y +CONFIG_SOC_RTCIO_VALID_RTCIO_MASK=0xFF +CONFIG_SOC_DEDIC_GPIO_OUT_CHANNELS_NUM=8 +CONFIG_SOC_DEDIC_GPIO_IN_CHANNELS_NUM=8 +CONFIG_SOC_DEDIC_PERIPH_ALWAYS_ENABLE=y +CONFIG_SOC_I2C_NUM=2 +CONFIG_SOC_HP_I2C_NUM=1 +CONFIG_SOC_I2C_FIFO_LEN=32 +CONFIG_SOC_I2C_CMD_REG_NUM=8 +CONFIG_SOC_I2C_SUPPORT_SLAVE=y +CONFIG_SOC_I2C_SUPPORT_HW_FSM_RST=y +CONFIG_SOC_I2C_SUPPORT_HW_CLR_BUS=y +CONFIG_SOC_I2C_SUPPORT_XTAL=y +CONFIG_SOC_I2C_SUPPORT_RTC=y +CONFIG_SOC_I2C_SUPPORT_10BIT_ADDR=y +CONFIG_SOC_I2C_SLAVE_SUPPORT_BROADCAST=y +CONFIG_SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE=y +CONFIG_SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS=y +CONFIG_SOC_I2C_SLAVE_SUPPORT_SLAVE_UNMATCH=y +CONFIG_SOC_LP_I2C_NUM=1 +CONFIG_SOC_LP_I2C_FIFO_LEN=16 +CONFIG_SOC_I2S_NUM=1 +CONFIG_SOC_I2S_HW_VERSION_2=y +CONFIG_SOC_I2S_SUPPORTS_XTAL=y +CONFIG_SOC_I2S_SUPPORTS_PLL_F160M=y +CONFIG_SOC_I2S_SUPPORTS_PCM=y +CONFIG_SOC_I2S_SUPPORTS_PDM=y +CONFIG_SOC_I2S_SUPPORTS_PDM_TX=y +CONFIG_SOC_I2S_PDM_MAX_TX_LINES=2 +CONFIG_SOC_I2S_SUPPORTS_TDM=y +CONFIG_SOC_LEDC_SUPPORT_PLL_DIV_CLOCK=y +CONFIG_SOC_LEDC_SUPPORT_XTAL_CLOCK=y +CONFIG_SOC_LEDC_CHANNEL_NUM=6 +CONFIG_SOC_LEDC_TIMER_BIT_WIDTH=20 +CONFIG_SOC_LEDC_SUPPORT_FADE_STOP=y +CONFIG_SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED=y +CONFIG_SOC_LEDC_GAMMA_CURVE_FADE_RANGE_MAX=16 +CONFIG_SOC_LEDC_FADE_PARAMS_BIT_WIDTH=10 +CONFIG_SOC_MMU_PAGE_SIZE_CONFIGURABLE=y +CONFIG_SOC_MMU_PERIPH_NUM=1 +CONFIG_SOC_MMU_LINEAR_ADDRESS_REGION_NUM=1 +CONFIG_SOC_MMU_DI_VADDR_SHARED=y +CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000 +CONFIG_SOC_MPU_REGIONS_MAX_NUM=8 +CONFIG_SOC_PCNT_GROUPS=1 +CONFIG_SOC_PCNT_UNITS_PER_GROUP=4 +CONFIG_SOC_PCNT_CHANNELS_PER_UNIT=2 +CONFIG_SOC_PCNT_THRES_POINT_PER_UNIT=2 +CONFIG_SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE=y +CONFIG_SOC_RMT_GROUPS=1 +CONFIG_SOC_RMT_TX_CANDIDATES_PER_GROUP=2 +CONFIG_SOC_RMT_RX_CANDIDATES_PER_GROUP=2 +CONFIG_SOC_RMT_CHANNELS_PER_GROUP=4 +CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=48 +CONFIG_SOC_RMT_SUPPORT_RX_PINGPONG=y +CONFIG_SOC_RMT_SUPPORT_RX_DEMODULATION=y +CONFIG_SOC_RMT_SUPPORT_TX_ASYNC_STOP=y +CONFIG_SOC_RMT_SUPPORT_TX_LOOP_COUNT=y +CONFIG_SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP=y +CONFIG_SOC_RMT_SUPPORT_TX_SYNCHRO=y +CONFIG_SOC_RMT_SUPPORT_TX_CARRIER_DATA_ONLY=y +CONFIG_SOC_RMT_SUPPORT_XTAL=y +CONFIG_SOC_RMT_SUPPORT_RC_FAST=y +CONFIG_SOC_MCPWM_GROUPS=1 +CONFIG_SOC_MCPWM_TIMERS_PER_GROUP=3 +CONFIG_SOC_MCPWM_OPERATORS_PER_GROUP=3 +CONFIG_SOC_MCPWM_COMPARATORS_PER_OPERATOR=2 +CONFIG_SOC_MCPWM_GENERATORS_PER_OPERATOR=2 +CONFIG_SOC_MCPWM_TRIGGERS_PER_OPERATOR=2 +CONFIG_SOC_MCPWM_GPIO_FAULTS_PER_GROUP=3 +CONFIG_SOC_MCPWM_CAPTURE_TIMERS_PER_GROUP=y +CONFIG_SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER=3 +CONFIG_SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP=3 +CONFIG_SOC_MCPWM_SWSYNC_CAN_PROPAGATE=y +CONFIG_SOC_MCPWM_SUPPORT_ETM=y +CONFIG_SOC_MCPWM_CAPTURE_CLK_FROM_GROUP=y +CONFIG_SOC_PARLIO_GROUPS=1 +CONFIG_SOC_PARLIO_TX_UNITS_PER_GROUP=1 +CONFIG_SOC_PARLIO_RX_UNITS_PER_GROUP=1 +CONFIG_SOC_PARLIO_TX_UNIT_MAX_DATA_WIDTH=16 +CONFIG_SOC_PARLIO_RX_UNIT_MAX_DATA_WIDTH=16 +CONFIG_SOC_PARLIO_TX_RX_SHARE_INTERRUPT=y +CONFIG_SOC_MPI_MEM_BLOCKS_NUM=4 +CONFIG_SOC_MPI_OPERATIONS_NUM=3 +CONFIG_SOC_RSA_MAX_BIT_LEN=3072 +CONFIG_SOC_SHA_DMA_MAX_BUFFER_SIZE=3968 +CONFIG_SOC_SHA_SUPPORT_DMA=y +CONFIG_SOC_SHA_SUPPORT_RESUME=y +CONFIG_SOC_SHA_GDMA=y +CONFIG_SOC_SHA_SUPPORT_SHA1=y +CONFIG_SOC_SHA_SUPPORT_SHA224=y +CONFIG_SOC_SHA_SUPPORT_SHA256=y +CONFIG_SOC_SDM_GROUPS=1 +CONFIG_SOC_SDM_CHANNELS_PER_GROUP=4 +CONFIG_SOC_SDM_CLK_SUPPORT_PLL_F80M=y +CONFIG_SOC_SDM_CLK_SUPPORT_XTAL=y +CONFIG_SOC_SPI_PERIPH_NUM=2 +CONFIG_SOC_SPI_MAX_CS_NUM=6 +CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 +CONFIG_SOC_SPI_SUPPORT_DDRCLK=y +CONFIG_SOC_SPI_SLAVE_SUPPORT_SEG_TRANS=y +CONFIG_SOC_SPI_SUPPORT_CD_SIG=y +CONFIG_SOC_SPI_SUPPORT_CONTINUOUS_TRANS=y +CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2=y +CONFIG_SOC_SPI_SUPPORT_CLK_XTAL=y +CONFIG_SOC_SPI_SUPPORT_CLK_PLL_F80M=y +CONFIG_SOC_SPI_SUPPORT_CLK_RC_FAST=y +CONFIG_SOC_SPI_SCT_SUPPORTED=y +CONFIG_SOC_SPI_SCT_REG_NUM=14 +CONFIG_SOC_SPI_SCT_BUFFER_NUM_MAX=y +CONFIG_SOC_SPI_SCT_CONF_BITLEN_MAX=0x3FFFA +CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y +CONFIG_SOC_SPI_MAX_PRE_DIVIDER=16 +CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE=y +CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND=y +CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_RESUME=y +CONFIG_SOC_SPI_MEM_SUPPORT_IDLE_INTR=y +CONFIG_SOC_SPI_MEM_SUPPORT_SW_SUSPEND=y +CONFIG_SOC_SPI_MEM_SUPPORT_CHECK_SUS=y +CONFIG_SOC_SPI_MEM_SUPPORT_WRAP=y +CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y +CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y +CONFIG_SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED=y +CONFIG_SOC_SYSTIMER_COUNTER_NUM=2 +CONFIG_SOC_SYSTIMER_ALARM_NUM=3 +CONFIG_SOC_SYSTIMER_BIT_WIDTH_LO=32 +CONFIG_SOC_SYSTIMER_BIT_WIDTH_HI=20 +CONFIG_SOC_SYSTIMER_FIXED_DIVIDER=y +CONFIG_SOC_SYSTIMER_SUPPORT_RC_FAST=y +CONFIG_SOC_SYSTIMER_INT_LEVEL=y +CONFIG_SOC_SYSTIMER_ALARM_MISS_COMPENSATE=y +CONFIG_SOC_SYSTIMER_SUPPORT_ETM=y +CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 +CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 +CONFIG_SOC_TIMER_GROUPS=2 +CONFIG_SOC_TIMER_GROUP_TIMERS_PER_GROUP=1 +CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=54 +CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y +CONFIG_SOC_TIMER_GROUP_SUPPORT_RC_FAST=y +CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=2 +CONFIG_SOC_TIMER_SUPPORT_ETM=y +CONFIG_SOC_TIMER_SUPPORT_SLEEP_RETENTION=y +CONFIG_SOC_MWDT_SUPPORT_XTAL=y +CONFIG_SOC_TWAI_CONTROLLER_NUM=2 +CONFIG_SOC_TWAI_CLK_SUPPORT_XTAL=y +CONFIG_SOC_TWAI_BRP_MIN=2 +CONFIG_SOC_TWAI_BRP_MAX=32768 +CONFIG_SOC_TWAI_SUPPORTS_RX_STATUS=y +CONFIG_SOC_EFUSE_DIS_DOWNLOAD_ICACHE=y +CONFIG_SOC_EFUSE_DIS_PAD_JTAG=y +CONFIG_SOC_EFUSE_DIS_USB_JTAG=y +CONFIG_SOC_EFUSE_DIS_DIRECT_BOOT=y +CONFIG_SOC_EFUSE_SOFT_DIS_JTAG=y +CONFIG_SOC_EFUSE_DIS_ICACHE=y +CONFIG_SOC_EFUSE_BLOCK9_KEY_PURPOSE_QUIRK=y +CONFIG_SOC_SECURE_BOOT_V2_RSA=y +CONFIG_SOC_SECURE_BOOT_V2_ECC=y +CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS=3 +CONFIG_SOC_EFUSE_REVOKE_BOOT_KEY_DIGESTS=y +CONFIG_SOC_SUPPORT_SECURE_BOOT_REVOKE_KEY=y +CONFIG_SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX=64 +CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES=y +CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_128=y +CONFIG_SOC_CRYPTO_DPA_PROTECTION_SUPPORTED=y +CONFIG_SOC_UART_NUM=3 +CONFIG_SOC_UART_HP_NUM=2 +CONFIG_SOC_UART_LP_NUM=1 +CONFIG_SOC_UART_FIFO_LEN=128 +CONFIG_SOC_LP_UART_FIFO_LEN=16 +CONFIG_SOC_UART_BITRATE_MAX=5000000 +CONFIG_SOC_UART_SUPPORT_PLL_F80M_CLK=y +CONFIG_SOC_UART_SUPPORT_RTC_CLK=y +CONFIG_SOC_UART_SUPPORT_XTAL_CLK=y +CONFIG_SOC_UART_SUPPORT_WAKEUP_INT=y +CONFIG_SOC_UART_HAS_LP_UART=y +CONFIG_SOC_UART_SUPPORT_FSM_TX_WAIT_SEND=y +CONFIG_SOC_COEX_HW_PTI=y +CONFIG_SOC_EXTERNAL_COEX_ADVANCE=y +CONFIG_SOC_PHY_DIG_REGS_MEM_SIZE=21 +CONFIG_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH=12 +CONFIG_SOC_PM_SUPPORT_WIFI_WAKEUP=y +CONFIG_SOC_PM_SUPPORT_BEACON_WAKEUP=y +CONFIG_SOC_PM_SUPPORT_BT_WAKEUP=y +CONFIG_SOC_PM_SUPPORT_EXT1_WAKEUP=y +CONFIG_SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN=y +CONFIG_SOC_PM_SUPPORT_CPU_PD=y +CONFIG_SOC_PM_SUPPORT_MODEM_PD=y +CONFIG_SOC_PM_SUPPORT_XTAL32K_PD=y +CONFIG_SOC_PM_SUPPORT_RC32K_PD=y +CONFIG_SOC_PM_SUPPORT_RC_FAST_PD=y +CONFIG_SOC_PM_SUPPORT_VDDSDIO_PD=y +CONFIG_SOC_PM_SUPPORT_TOP_PD=y +CONFIG_SOC_PM_SUPPORT_HP_AON_PD=y +CONFIG_SOC_PM_SUPPORT_MAC_BB_PD=y +CONFIG_SOC_PM_SUPPORT_RTC_PERIPH_PD=y +CONFIG_SOC_PM_SUPPORT_PMU_MODEM_STATE=y +CONFIG_SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY=y +CONFIG_SOC_PM_CPU_RETENTION_BY_SW=y +CONFIG_SOC_PM_MODEM_RETENTION_BY_REGDMA=y +CONFIG_SOC_PM_RETENTION_HAS_CLOCK_BUG=y +CONFIG_SOC_PM_PAU_LINK_NUM=4 +CONFIG_SOC_CLK_RC_FAST_SUPPORT_CALIBRATION=y +CONFIG_SOC_MODEM_CLOCK_IS_INDEPENDENT=y +CONFIG_SOC_CLK_XTAL32K_SUPPORTED=y +CONFIG_SOC_CLK_OSC_SLOW_SUPPORTED=y +CONFIG_SOC_CLK_RC32K_SUPPORTED=y +CONFIG_SOC_RCC_IS_INDEPENDENT=y +CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC=y +CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_XTAL=y +CONFIG_SOC_TEMPERATURE_SENSOR_INTR_SUPPORT=y +CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_ETM=y +CONFIG_SOC_RNG_CLOCK_IS_INDEPENDENT=y +CONFIG_SOC_WIFI_HW_TSF=y +CONFIG_SOC_WIFI_FTM_SUPPORT=y +CONFIG_SOC_WIFI_GCMP_SUPPORT=y +CONFIG_SOC_WIFI_WAPI_SUPPORT=y +CONFIG_SOC_WIFI_CSI_SUPPORT=y +CONFIG_SOC_WIFI_MESH_SUPPORT=y +CONFIG_SOC_WIFI_HE_SUPPORT=y +CONFIG_SOC_BLE_SUPPORTED=y +CONFIG_SOC_BLE_MESH_SUPPORTED=y +CONFIG_SOC_ESP_NIMBLE_CONTROLLER=y +CONFIG_SOC_BLE_50_SUPPORTED=y +CONFIG_SOC_BLE_DEVICE_PRIVACY_SUPPORTED=y +CONFIG_SOC_BLE_POWER_CONTROL_SUPPORTED=y +CONFIG_SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED=y +CONFIG_SOC_BLUFI_SUPPORTED=y +CONFIG_SOC_BLE_MULTI_CONN_OPTIMIZATION=y +CONFIG_SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND=y +CONFIG_SOC_PHY_COMBO_MODULE=y +CONFIG_SOC_CAPS_NO_RESET_BY_ANA_BOD=y +CONFIG_SOC_LP_CORE_SINGLE_INTERRUPT_VECTOR=y +CONFIG_IDF_CMAKE=y +CONFIG_IDF_TOOLCHAIN="gcc" +CONFIG_IDF_TARGET_ARCH_RISCV=y +CONFIG_IDF_TARGET_ARCH="riscv" +CONFIG_IDF_TARGET="esp32c6" +CONFIG_IDF_INIT_VERSION="5.3.0" +CONFIG_IDF_TARGET_ESP32C6=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x000D + +# +# Build type +# +CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y +# CONFIG_APP_BUILD_TYPE_RAM is not set +CONFIG_APP_BUILD_GENERATE_BINARIES=y +CONFIG_APP_BUILD_BOOTLOADER=y +CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y +# CONFIG_APP_REPRODUCIBLE_BUILD is not set +# CONFIG_APP_NO_BLOBS is not set +# end of Build type + +# +# Bootloader config +# + +# +# Bootloader manager +# +CONFIG_BOOTLOADER_COMPILE_TIME_DATE=y +CONFIG_BOOTLOADER_PROJECT_VER=1 +# end of Bootloader manager + +CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set +CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y +# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +CONFIG_BOOTLOADER_LOG_LEVEL=3 + +# +# Serial Flash Configurations +# +# CONFIG_BOOTLOADER_FLASH_DC_AWARE is not set +CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y +# end of Serial Flash Configurations + +# CONFIG_BOOTLOADER_FACTORY_RESET is not set +# CONFIG_BOOTLOADER_APP_TEST is not set +CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y +CONFIG_BOOTLOADER_WDT_ENABLE=y +# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set +CONFIG_BOOTLOADER_WDT_TIME_MS=9000 +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set +CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 +# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +# end of Bootloader config + +# +# Security features +# +CONFIG_SECURE_BOOT_V2_RSA_SUPPORTED=y +CONFIG_SECURE_BOOT_V2_ECC_SUPPORTED=y +CONFIG_SECURE_BOOT_V2_PREFERRED=y +# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# CONFIG_SECURE_BOOT is not set +# CONFIG_SECURE_FLASH_ENC_ENABLED is not set +CONFIG_SECURE_ROM_DL_MODE_ENABLED=y +# end of Security features + +# +# Application manager +# +CONFIG_APP_COMPILE_TIME_DATE=y +# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set +# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set +# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set +CONFIG_APP_RETRIEVE_LEN_ELF_SHA=9 +# end of Application manager + +CONFIG_ESP_ROM_HAS_CRC_LE=y +CONFIG_ESP_ROM_HAS_CRC_BE=y +CONFIG_ESP_ROM_HAS_JPEG_DECODE=y +CONFIG_ESP_ROM_UART_CLK_IS_XTAL=y +CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=3 +CONFIG_ESP_ROM_HAS_RETARGETABLE_LOCKING=y +CONFIG_ESP_ROM_GET_CLK_FREQ=y +CONFIG_ESP_ROM_HAS_RVFPLIB=y +CONFIG_ESP_ROM_HAS_HAL_WDT=y +CONFIG_ESP_ROM_HAS_HAL_SYSTIMER=y +CONFIG_ESP_ROM_HAS_HEAP_TLSF=y +CONFIG_ESP_ROM_TLSF_CHECK_PATCH=y +CONFIG_ESP_ROM_MULTI_HEAP_WALK_PATCH=y +CONFIG_ESP_ROM_HAS_LAYOUT_TABLE=y +CONFIG_ESP_ROM_HAS_SPI_FLASH=y +CONFIG_ESP_ROM_HAS_REGI2C_BUG=y +CONFIG_ESP_ROM_HAS_NEWLIB=y +CONFIG_ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT=y +CONFIG_ESP_ROM_REV0_HAS_NO_ECDSA_INTERFACE=y +CONFIG_ESP_ROM_WDT_INIT_PATCH=y +CONFIG_ESP_ROM_NEEDS_SET_CACHE_MMU_SIZE=y +CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT=y +CONFIG_ESP_ROM_HAS_SW_FLOAT=y +CONFIG_ESP_ROM_USB_OTG_NUM=-1 +CONFIG_ESP_ROM_HAS_VERSION=y +CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y + +# +# Boot ROM Behavior +# +CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y +# CONFIG_BOOT_ROM_LOG_ALWAYS_OFF is not set +# CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH is not set +# CONFIG_BOOT_ROM_LOG_ON_GPIO_LOW is not set +# end of Boot ROM Behavior + +# +# Serial flasher config +# +# CONFIG_ESPTOOLPY_NO_STUB is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE_DIO=y +# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set +CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y +CONFIG_ESPTOOLPY_FLASHMODE="dio" +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set +# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set +CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT=y +CONFIG_ESPTOOLPY_FLASHFREQ="80m" +# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="8MB" +# CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE is not set +CONFIG_ESPTOOLPY_BEFORE_RESET=y +# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set +CONFIG_ESPTOOLPY_BEFORE="default_reset" +CONFIG_ESPTOOLPY_AFTER_RESET=y +# CONFIG_ESPTOOLPY_AFTER_NORESET is not set +CONFIG_ESPTOOLPY_AFTER="hard_reset" +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 +# end of Serial flasher config + +# +# Partition Table +# +CONFIG_PARTITION_TABLE_SINGLE_APP=y +# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set +# CONFIG_PARTITION_TABLE_TWO_OTA is not set +# CONFIG_PARTITION_TABLE_CUSTOM is not set +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y +# end of Partition Table + +# +# Compiler options +# +CONFIG_COMPILER_OPTIMIZATION_DEBUG=y +# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +# CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB is not set +CONFIG_COMPILER_FLOAT_LIB_FROM_RVFPLIB=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 +# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set +CONFIG_COMPILER_HIDE_PATHS_MACROS=y +CONFIG_COMPILER_CXX_EXCEPTIONS=y +CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0 +# CONFIG_COMPILER_CXX_RTTI is not set +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y +# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS is not set +# CONFIG_COMPILER_DISABLE_GCC12_WARNINGS is not set +# CONFIG_COMPILER_DISABLE_GCC13_WARNINGS is not set +# CONFIG_COMPILER_DUMP_RTL_FILES is not set +CONFIG_COMPILER_RT_LIB_GCCLIB=y +CONFIG_COMPILER_RT_LIB_NAME="gcc" +# CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING is not set +CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y +# end of Compiler options + +# +# Component config +# + +# +# Application Level Tracing +# +# CONFIG_APPTRACE_DEST_JTAG is not set +CONFIG_APPTRACE_DEST_NONE=y +# CONFIG_APPTRACE_DEST_UART1 is not set +# CONFIG_APPTRACE_DEST_UART2 is not set +CONFIG_APPTRACE_DEST_UART_NONE=y +CONFIG_APPTRACE_UART_TASK_PRIO=1 +CONFIG_APPTRACE_LOCK_ENABLE=y +# end of Application Level Tracing + +# +# Bluetooth +# +# CONFIG_BT_ENABLED is not set +CONFIG_BT_ALARM_MAX_NUM=50 +# end of Bluetooth + +# +# Console Library +# +# CONFIG_CONSOLE_SORTED_HELP is not set +# end of Console Library + +# +# Driver Configurations +# + +# +# TWAI Configuration +# +# CONFIG_TWAI_ISR_IN_IRAM is not set +# end of TWAI Configuration + +# +# Legacy ADC Driver Configuration +# +# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set + +# +# Legacy ADC Calibration Configuration +# +# CONFIG_ADC_CALI_SUPPRESS_DEPRECATE_WARN is not set +# end of Legacy ADC Calibration Configuration +# end of Legacy ADC Driver Configuration + +# +# Legacy MCPWM Driver Configurations +# +# CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set +# end of Legacy MCPWM Driver Configurations + +# +# Legacy Timer Group Driver Configurations +# +# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set +# end of Legacy Timer Group Driver Configurations + +# +# Legacy RMT Driver Configurations +# +# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set +# end of Legacy RMT Driver Configurations + +# +# Legacy I2S Driver Configurations +# +# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set +# end of Legacy I2S Driver Configurations + +# +# Legacy PCNT Driver Configurations +# +# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set +# end of Legacy PCNT Driver Configurations + +# +# Legacy SDM Driver Configurations +# +# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set +# end of Legacy SDM Driver Configurations + +# +# Legacy Temperature Sensor Driver Configurations +# +# CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN is not set +# end of Legacy Temperature Sensor Driver Configurations +# end of Driver Configurations + +# +# eFuse Bit Manager +# +# CONFIG_EFUSE_CUSTOM_TABLE is not set +# CONFIG_EFUSE_VIRTUAL is not set +CONFIG_EFUSE_MAX_BLK_LEN=256 +# end of eFuse Bit Manager + +# +# ESP-TLS +# +CONFIG_ESP_TLS_USING_MBEDTLS=y +CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y +# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set +# CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set +# CONFIG_ESP_TLS_SERVER_CERT_SELECT_HOOK is not set +# CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set +# CONFIG_ESP_TLS_PSK_VERIFICATION is not set +# CONFIG_ESP_TLS_INSECURE is not set +# end of ESP-TLS + +# +# ADC and ADC Calibration +# +# CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM is not set +# CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE is not set +# CONFIG_ADC_ENABLE_DEBUG_LOG is not set +# end of ADC and ADC Calibration + +# +# Wireless Coexistence +# +CONFIG_ESP_COEX_ENABLED=y +CONFIG_ESP_COEX_SW_COEXIST_ENABLE=y +# CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE is not set +# CONFIG_ESP_COEX_POWER_MANAGEMENT is not set +# end of Wireless Coexistence + +# +# Common ESP-related +# +CONFIG_ESP_ERR_TO_NAME_LOOKUP=y +# end of Common ESP-related + +# +# ESP-Driver:GPIO Configurations +# +# CONFIG_GPIO_CTRL_FUNC_IN_IRAM is not set +# end of ESP-Driver:GPIO Configurations + +# +# ESP-Driver:GPTimer Configurations +# +CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y +# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set +# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set +# CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:GPTimer Configurations + +# +# ESP-Driver:I2C Configurations +# +# CONFIG_I2C_ISR_IRAM_SAFE is not set +# CONFIG_I2C_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:I2C Configurations + +# +# ESP-Driver:I2S Configurations +# +# CONFIG_I2S_ISR_IRAM_SAFE is not set +# CONFIG_I2S_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:I2S Configurations + +# +# ESP-Driver:LEDC Configurations +# +# CONFIG_LEDC_CTRL_FUNC_IN_IRAM is not set +# end of ESP-Driver:LEDC Configurations + +# +# ESP-Driver:MCPWM Configurations +# +# CONFIG_MCPWM_ISR_IRAM_SAFE is not set +# CONFIG_MCPWM_CTRL_FUNC_IN_IRAM is not set +# CONFIG_MCPWM_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:MCPWM Configurations + +# +# ESP-Driver:Parallel IO Configurations +# +# CONFIG_PARLIO_ENABLE_DEBUG_LOG is not set +# CONFIG_PARLIO_ISR_IRAM_SAFE is not set +# end of ESP-Driver:Parallel IO Configurations + +# +# ESP-Driver:PCNT Configurations +# +# CONFIG_PCNT_CTRL_FUNC_IN_IRAM is not set +# CONFIG_PCNT_ISR_IRAM_SAFE is not set +# CONFIG_PCNT_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:PCNT Configurations + +# +# ESP-Driver:RMT Configurations +# +# CONFIG_RMT_ISR_IRAM_SAFE is not set +# CONFIG_RMT_RECV_FUNC_IN_IRAM is not set +# CONFIG_RMT_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:RMT Configurations + +# +# ESP-Driver:Sigma Delta Modulator Configurations +# +# CONFIG_SDM_CTRL_FUNC_IN_IRAM is not set +# CONFIG_SDM_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:Sigma Delta Modulator Configurations + +# +# ESP-Driver:SPI Configurations +# +# CONFIG_SPI_MASTER_IN_IRAM is not set +CONFIG_SPI_MASTER_ISR_IN_IRAM=y +# CONFIG_SPI_SLAVE_IN_IRAM is not set +CONFIG_SPI_SLAVE_ISR_IN_IRAM=y +# end of ESP-Driver:SPI Configurations + +# +# ESP-Driver:Temperature Sensor Configurations +# +# CONFIG_TEMP_SENSOR_ENABLE_DEBUG_LOG is not set +# CONFIG_TEMP_SENSOR_ISR_IRAM_SAFE is not set +# end of ESP-Driver:Temperature Sensor Configurations + +# +# ESP-Driver:UART Configurations +# +# CONFIG_UART_ISR_IN_IRAM is not set +# end of ESP-Driver:UART Configurations + +# +# ESP-Driver:USB Serial/JTAG Configuration +# +CONFIG_USJ_ENABLE_USB_SERIAL_JTAG=y +# end of ESP-Driver:USB Serial/JTAG Configuration + +# +# Ethernet +# +CONFIG_ETH_ENABLED=y +CONFIG_ETH_USE_SPI_ETHERNET=y +# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set +# CONFIG_ETH_SPI_ETHERNET_W5500 is not set +# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set +# CONFIG_ETH_USE_OPENETH is not set +# CONFIG_ETH_TRANSMIT_MUTEX is not set +# end of Ethernet + +# +# Event Loop Library +# +# CONFIG_ESP_EVENT_LOOP_PROFILING is not set +CONFIG_ESP_EVENT_POST_FROM_ISR=y +CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y +# end of Event Loop Library + +# +# GDB Stub +# +CONFIG_ESP_GDBSTUB_ENABLED=y +# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set +CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y +CONFIG_ESP_GDBSTUB_MAX_TASKS=32 +# end of GDB Stub + +# +# ESP HTTP client +# +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y +# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set +# CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set +# CONFIG_ESP_HTTP_CLIENT_ENABLE_CUSTOM_TRANSPORT is not set +# end of ESP HTTP client + +# +# HTTP Server +# +CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 +CONFIG_HTTPD_MAX_URI_LEN=512 +CONFIG_HTTPD_ERR_RESP_NO_DELAY=y +CONFIG_HTTPD_PURGE_BUF_LEN=32 +# CONFIG_HTTPD_LOG_PURGE_DATA is not set +# CONFIG_HTTPD_WS_SUPPORT is not set +# CONFIG_HTTPD_QUEUE_WORK_BLOCKING is not set +# end of HTTP Server + +# +# ESP HTTPS OTA +# +# CONFIG_ESP_HTTPS_OTA_DECRYPT_CB is not set +# CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP is not set +# end of ESP HTTPS OTA + +# +# ESP HTTPS server +# +# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set +# end of ESP HTTPS server + +# +# Hardware Settings +# + +# +# Chip revision +# +CONFIG_ESP32C6_REV_MIN_0=y +# CONFIG_ESP32C6_REV_MIN_1 is not set +CONFIG_ESP32C6_REV_MIN_FULL=0 +CONFIG_ESP_REV_MIN_FULL=0 + +# +# Maximum Supported ESP32-C6 Revision (Rev v0.99) +# +CONFIG_ESP32C6_REV_MAX_FULL=99 +CONFIG_ESP_REV_MAX_FULL=99 +# end of Chip revision + +# +# MAC Config +# +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_IEEE802154=y +CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP32C6_UNIVERSAL_MAC_ADDRESSES_TWO is not set +CONFIG_ESP32C6_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32C6_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP_MAC_USE_CUSTOM_MAC_AS_BASE_MAC is not set +# end of MAC Config + +# +# Sleep Config +# +# CONFIG_ESP_SLEEP_POWER_DOWN_FLASH is not set +CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND=y +# CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU is not set +CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y +CONFIG_ESP_SLEEP_WAIT_FLASH_READY_EXTRA_DELAY=0 +# CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION is not set +# CONFIG_ESP_SLEEP_DEBUG is not set +CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y +# end of Sleep Config + +# +# RTC Clock Config +# +CONFIG_RTC_CLK_SRC_INT_RC=y +# CONFIG_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_RTC_CLK_SRC_INT_RC32K is not set +CONFIG_RTC_CLK_CAL_CYCLES=1024 +# end of RTC Clock Config + +# +# Peripheral Control +# +CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y +# end of Peripheral Control + +# +# ETM Configuration +# +# CONFIG_ETM_ENABLE_DEBUG_LOG is not set +# end of ETM Configuration + +# +# GDMA Configurations +# +CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y +# CONFIG_GDMA_ISR_IRAM_SAFE is not set +# CONFIG_GDMA_ENABLE_DEBUG_LOG is not set +# end of GDMA Configurations + +# +# Main XTAL Config +# +CONFIG_XTAL_FREQ_40=y +CONFIG_XTAL_FREQ=40 +# end of Main XTAL Config + +# +# Crypto DPA Protection +# +CONFIG_ESP_CRYPTO_DPA_PROTECTION_AT_STARTUP=y +CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_LOW=y +# CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_MEDIUM is not set +# CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_HIGH is not set +CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL=1 +# end of Crypto DPA Protection + +CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y +# end of Hardware Settings + +# +# LCD and Touch Panel +# + +# +# LCD Touch Drivers are maintained in the IDF Component Registry +# + +# +# LCD Peripheral Configuration +# +# CONFIG_LCD_ENABLE_DEBUG_LOG is not set +# end of LCD Peripheral Configuration +# end of LCD and Touch Panel + +# +# ESP NETIF Adapter +# +CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 +CONFIG_ESP_NETIF_TCPIP_LWIP=y +# CONFIG_ESP_NETIF_LOOPBACK is not set +CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y +# CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set +# CONFIG_ESP_NETIF_L2_TAP is not set +# CONFIG_ESP_NETIF_BRIDGE_EN is not set +# end of ESP NETIF Adapter + +# +# Partition API Configuration +# +# end of Partition API Configuration + +# +# PHY +# +CONFIG_ESP_PHY_ENABLED=y +CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP_PHY_MAX_TX_POWER=20 +# CONFIG_ESP_PHY_REDUCE_TX_POWER is not set +CONFIG_ESP_PHY_RF_CAL_PARTIAL=y +# CONFIG_ESP_PHY_RF_CAL_NONE is not set +# CONFIG_ESP_PHY_RF_CAL_FULL is not set +CONFIG_ESP_PHY_CALIBRATION_MODE=0 +# CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set +# end of PHY + +# +# Power Management +# +# CONFIG_PM_ENABLE is not set +CONFIG_PM_SLP_DEFAULT_PARAMS_OPT=y +CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y +# CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is not set +# end of Power Management + +# +# ESP PSRAM +# + +# +# ESP Ringbuf +# +# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set +# end of ESP Ringbuf + +# +# ESP System Settings +# +# CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 is not set +# CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_120 is not set +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 +# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set +CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y +# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set +CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS=0 +CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE=y +CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y +CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y +# CONFIG_ESP_SYSTEM_USE_EH_FRAME is not set + +# +# Memory protection +# +CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT=y +# end of Memory protection + +CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 +CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y +# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 +CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_NONE is not set +# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set +CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y +CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y +CONFIG_ESP_CONSOLE_UART=y +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +CONFIG_ESP_INT_WDT=y +CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 +CONFIG_ESP_TASK_WDT_EN=y +CONFIG_ESP_TASK_WDT_INIT=y +# CONFIG_ESP_TASK_WDT_PANIC is not set +CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +# CONFIG_ESP_PANIC_HANDLER_IRAM is not set +# CONFIG_ESP_DEBUG_STUBS_ENABLE is not set +CONFIG_ESP_DEBUG_OCDAWARE=y +CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y + +# +# Brownout Detector +# +CONFIG_ESP_BROWNOUT_DET=y +CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set +CONFIG_ESP_BROWNOUT_DET_LVL=7 +# end of Brownout Detector + +CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y +CONFIG_ESP_SYSTEM_HW_STACK_GUARD=y +CONFIG_ESP_SYSTEM_BBPLL_RECALIB=y +CONFIG_ESP_SYSTEM_HW_PC_RECORD=y +# end of ESP System Settings + +# +# IPC (Inter-Processor Call) +# +CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 +# end of IPC (Inter-Processor Call) + +# +# ESP Timer (High Resolution Timer) +# +# CONFIG_ESP_TIMER_PROFILING is not set +CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y +CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y +CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 +CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 +# CONFIG_ESP_TIMER_SHOW_EXPERIMENTAL is not set +CONFIG_ESP_TIMER_TASK_AFFINITY=0x0 +CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0=y +CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0=y +# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set +CONFIG_ESP_TIMER_IMPL_SYSTIMER=y +# end of ESP Timer (High Resolution Timer) + +# +# Wi-Fi +# +CONFIG_ESP_WIFI_ENABLED=y +CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +# CONFIG_ESP_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y +# CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set +CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 +CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5 +# CONFIG_ESP_WIFI_CSI_ENABLED is not set +CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP_WIFI_TX_BA_WIN=6 +CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP_WIFI_RX_BA_WIN=6 +CONFIG_ESP_WIFI_NVS_ENABLED=y +CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP_WIFI_IRAM_OPT=y +CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y +CONFIG_ESP_WIFI_RX_IRAM_OPT=y +CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y +CONFIG_ESP_WIFI_ENABLE_SAE_PK=y +CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y +CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y +CONFIG_ESP_WIFI_SLP_IRAM_OPT=y +CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50 +CONFIG_ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME=10 +CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 +# CONFIG_ESP_WIFI_FTM_ENABLE is not set +CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE=y +# CONFIG_ESP_WIFI_GCMP_SUPPORT is not set +CONFIG_ESP_WIFI_GMAC_SUPPORT=y +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y +# CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT is not set +CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=7 +CONFIG_ESP_WIFI_MBEDTLS_CRYPTO=y +CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y +# CONFIG_ESP_WIFI_WAPI_PSK is not set +# CONFIG_ESP_WIFI_SUITE_B_192 is not set +# CONFIG_ESP_WIFI_11KV_SUPPORT is not set +# CONFIG_ESP_WIFI_MBO_SUPPORT is not set +# CONFIG_ESP_WIFI_DPP_SUPPORT is not set +# CONFIG_ESP_WIFI_11R_SUPPORT is not set +# CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR is not set +# CONFIG_ESP_WIFI_ENABLE_WIFI_TX_STATS is not set +# CONFIG_ESP_WIFI_ENABLE_WIFI_RX_STATS is not set +CONFIG_ESP_WIFI_TX_HETB_QUEUE_NUM=3 + +# +# WPS Configuration Options +# +# CONFIG_ESP_WIFI_WPS_STRICT is not set +# CONFIG_ESP_WIFI_WPS_PASSPHRASE is not set +# end of WPS Configuration Options + +# CONFIG_ESP_WIFI_DEBUG_PRINT is not set +# CONFIG_ESP_WIFI_TESTING_OPTIONS is not set +CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y +# CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set +# end of Wi-Fi + +# +# Core dump +# +# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set +# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set +CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y +# end of Core dump + +# +# FAT Filesystem support +# +CONFIG_FATFS_VOLUME_COUNT=2 +CONFIG_FATFS_LFN_NONE=y +# CONFIG_FATFS_LFN_HEAP is not set +# CONFIG_FATFS_LFN_STACK is not set +# CONFIG_FATFS_SECTOR_512 is not set +CONFIG_FATFS_SECTOR_4096=y +# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set +CONFIG_FATFS_CODEPAGE_437=y +# CONFIG_FATFS_CODEPAGE_720 is not set +# CONFIG_FATFS_CODEPAGE_737 is not set +# CONFIG_FATFS_CODEPAGE_771 is not set +# CONFIG_FATFS_CODEPAGE_775 is not set +# CONFIG_FATFS_CODEPAGE_850 is not set +# CONFIG_FATFS_CODEPAGE_852 is not set +# CONFIG_FATFS_CODEPAGE_855 is not set +# CONFIG_FATFS_CODEPAGE_857 is not set +# CONFIG_FATFS_CODEPAGE_860 is not set +# CONFIG_FATFS_CODEPAGE_861 is not set +# CONFIG_FATFS_CODEPAGE_862 is not set +# CONFIG_FATFS_CODEPAGE_863 is not set +# CONFIG_FATFS_CODEPAGE_864 is not set +# CONFIG_FATFS_CODEPAGE_865 is not set +# CONFIG_FATFS_CODEPAGE_866 is not set +# CONFIG_FATFS_CODEPAGE_869 is not set +# CONFIG_FATFS_CODEPAGE_932 is not set +# CONFIG_FATFS_CODEPAGE_936 is not set +# CONFIG_FATFS_CODEPAGE_949 is not set +# CONFIG_FATFS_CODEPAGE_950 is not set +CONFIG_FATFS_CODEPAGE=437 +CONFIG_FATFS_FS_LOCK=0 +CONFIG_FATFS_TIMEOUT_MS=10000 +CONFIG_FATFS_PER_FILE_CACHE=y +# CONFIG_FATFS_USE_FASTSEEK is not set +CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0 +# CONFIG_FATFS_IMMEDIATE_FSYNC is not set +# CONFIG_FATFS_USE_LABEL is not set +CONFIG_FATFS_LINK_LOCK=y +# end of FAT Filesystem support + +# +# FreeRTOS +# + +# +# Kernel +# +# CONFIG_FREERTOS_SMP is not set +CONFIG_FREERTOS_UNICORE=y +CONFIG_FREERTOS_HZ=100 +CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y +CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 +CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 +# CONFIG_FREERTOS_USE_IDLE_HOOK is not set +# CONFIG_FREERTOS_USE_TICK_HOOK is not set +CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 +# CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY is not set +CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME="Tmr Svc" +# CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU0 is not set +CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY=y +CONFIG_FREERTOS_TIMER_SERVICE_TASK_CORE_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 +CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 +CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 +CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1 +# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set +# CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES is not set +# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set +# CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG is not set +# end of Kernel + +# +# Port +# +CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y +# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set +CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y +# CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set +# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set +CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y +CONFIG_FREERTOS_ISR_STACKSIZE=1536 +CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y +CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y +# CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set +CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y +# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set +# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set +# end of Port + +CONFIG_FREERTOS_PORT=y +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +CONFIG_FREERTOS_DEBUG_OCDAWARE=y +CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y +CONFIG_FREERTOS_NUMBER_OF_CORES=1 +# end of FreeRTOS + +# +# Hardware Abstraction Layer (HAL) and Low Level (LL) +# +CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y +# CONFIG_HAL_ASSERTION_DISABLE is not set +# CONFIG_HAL_ASSERTION_SILENT is not set +# CONFIG_HAL_ASSERTION_ENABLE is not set +CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 +CONFIG_HAL_SYSTIMER_USE_ROM_IMPL=y +CONFIG_HAL_WDT_USE_ROM_IMPL=y +CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y +CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y +# end of Hardware Abstraction Layer (HAL) and Low Level (LL) + +# +# Heap memory debugging +# +CONFIG_HEAP_POISONING_DISABLED=y +# CONFIG_HEAP_POISONING_LIGHT is not set +# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set +CONFIG_HEAP_TRACING_OFF=y +# CONFIG_HEAP_TRACING_STANDALONE is not set +# CONFIG_HEAP_TRACING_TOHOST is not set +# CONFIG_HEAP_USE_HOOKS is not set +# CONFIG_HEAP_TASK_TRACKING is not set +# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set +CONFIG_HEAP_TLSF_USE_ROM_IMPL=y +# end of Heap memory debugging + +# +# IEEE 802.15.4 +# +CONFIG_IEEE802154_ENABLED=y +CONFIG_IEEE802154_RX_BUFFER_SIZE=20 +# CONFIG_IEEE802154_CCA_CARRIER is not set +CONFIG_IEEE802154_CCA_ED=y +# CONFIG_IEEE802154_CCA_CARRIER_OR_ED is not set +# CONFIG_IEEE802154_CCA_CARRIER_AND_ED is not set +CONFIG_IEEE802154_CCA_MODE=1 +CONFIG_IEEE802154_CCA_THRESHOLD=-60 +CONFIG_IEEE802154_PENDING_TABLE_SIZE=20 +# CONFIG_IEEE802154_MULTI_PAN_ENABLE is not set +# CONFIG_IEEE802154_TIMING_OPTIMIZATION is not set +# CONFIG_IEEE802154_DEBUG is not set +# end of IEEE 802.15.4 + +# +# Log output +# +# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set +# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set +# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set +# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +CONFIG_LOG_DEFAULT_LEVEL=3 +# CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT is not set +CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y +# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set +CONFIG_LOG_MAXIMUM_LEVEL=4 +# CONFIG_LOG_MASTER_LEVEL is not set +CONFIG_LOG_COLORS=y +CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y +# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set +# end of Log output + +# +# LWIP +# +CONFIG_LWIP_ENABLE=y +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# CONFIG_LWIP_NETIF_API is not set +CONFIG_LWIP_TCPIP_TASK_PRIO=18 +# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set +# CONFIG_LWIP_CHECK_THREAD_SAFETY is not set +CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y +# CONFIG_LWIP_L2_TO_L3_COPY is not set +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set +# CONFIG_LWIP_EXTRA_IRAM_OPTIMIZATION is not set +CONFIG_LWIP_TIMERS_ONDEMAND=y +CONFIG_LWIP_ND6=y +# CONFIG_LWIP_FORCE_ROUTER_FORWARDING is not set +CONFIG_LWIP_MAX_SOCKETS=10 +# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set +# CONFIG_LWIP_SO_LINGER is not set +CONFIG_LWIP_SO_REUSE=y +CONFIG_LWIP_SO_REUSE_RXTOALL=y +# CONFIG_LWIP_SO_RCVBUF is not set +# CONFIG_LWIP_NETBUF_RECVINFO is not set +CONFIG_LWIP_IP_DEFAULT_TTL=64 +CONFIG_LWIP_IP4_FRAG=y +CONFIG_LWIP_IP6_FRAG=y +# CONFIG_LWIP_IP4_REASSEMBLY is not set +# CONFIG_LWIP_IP6_REASSEMBLY is not set +CONFIG_LWIP_IP_REASS_MAX_PBUFS=10 +# CONFIG_LWIP_IP_FORWARD is not set +# CONFIG_LWIP_STATS is not set +CONFIG_LWIP_ESP_GRATUITOUS_ARP=y +CONFIG_LWIP_GARP_TMR_INTERVAL=60 +CONFIG_LWIP_ESP_MLDV6_REPORT=y +CONFIG_LWIP_MLDV6_TMR_INTERVAL=40 +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 +CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set +CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y +# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set +CONFIG_LWIP_DHCP_OPTIONS_LEN=68 +CONFIG_LWIP_NUM_NETIF_CLIENT_DATA=0 +CONFIG_LWIP_DHCP_COARSE_TIMER_SECS=1 + +# +# DHCP server +# +CONFIG_LWIP_DHCPS=y +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +CONFIG_LWIP_DHCPS_STATIC_ENTRIES=y +# end of DHCP server + +# CONFIG_LWIP_AUTOIP is not set +CONFIG_LWIP_IPV4=y +CONFIG_LWIP_IPV6=y +# CONFIG_LWIP_IPV6_AUTOCONFIG is not set +CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 +# CONFIG_LWIP_IPV6_FORWARD is not set +# CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set +CONFIG_LWIP_NETIF_LOOPBACK=y +CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 + +# +# TCP +# +CONFIG_LWIP_MAX_ACTIVE_TCP=16 +CONFIG_LWIP_MAX_LISTENING_TCP=16 +CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y +CONFIG_LWIP_TCP_MAXRTX=12 +CONFIG_LWIP_TCP_SYNMAXRTX=12 +CONFIG_LWIP_TCP_MSS=1440 +CONFIG_LWIP_TCP_TMR_INTERVAL=250 +CONFIG_LWIP_TCP_MSL=60000 +CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT=20000 +CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5760 +CONFIG_LWIP_TCP_WND_DEFAULT=5760 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 +CONFIG_LWIP_TCP_ACCEPTMBOX_SIZE=6 +CONFIG_LWIP_TCP_QUEUE_OOSEQ=y +CONFIG_LWIP_TCP_OOSEQ_TIMEOUT=6 +CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4 +# CONFIG_LWIP_TCP_SACK_OUT is not set +CONFIG_LWIP_TCP_OVERSIZE_MSS=y +# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set +CONFIG_LWIP_TCP_RTO_TIME=1500 +# end of TCP + +# +# UDP +# +CONFIG_LWIP_MAX_UDP_PCBS=16 +CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 +# end of UDP + +# +# Checksums +# +# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set +# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set +CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y +# end of Checksums + +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set +CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_LWIP_PPP_SUPPORT is not set +CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 +CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 +# CONFIG_LWIP_SLIP_SUPPORT is not set + +# +# ICMP +# +CONFIG_LWIP_ICMP=y +# CONFIG_LWIP_MULTICAST_PING is not set +# CONFIG_LWIP_BROADCAST_PING is not set +# end of ICMP + +# +# LWIP RAW API +# +CONFIG_LWIP_MAX_RAW_PCBS=16 +# end of LWIP RAW API + +# +# SNTP +# +CONFIG_LWIP_SNTP_MAX_SERVERS=1 +# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set +CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 +CONFIG_LWIP_SNTP_STARTUP_DELAY=y +CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY=5000 +# end of SNTP + +# +# DNS +# +CONFIG_LWIP_DNS_MAX_SERVERS=3 +# CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set +# end of DNS + +CONFIG_LWIP_BRIDGEIF_MAX_PORTS=7 +CONFIG_LWIP_ESP_LWIP_ASSERT=y + +# +# Hooks +# +# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set +CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y +# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set +CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y +# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set +# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set +CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y +# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set +# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set +CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_NONE=y +# CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_DEFAULT is not set +# CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM is not set +CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y +# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set +# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set +CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y +# CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT is not set +# CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM is not set +# end of Hooks + +# CONFIG_LWIP_DEBUG is not set +# end of LWIP + +# +# mbedTLS +# +CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y +# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set +# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set +CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 +# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# CONFIG_MBEDTLS_DEBUG is not set + +# +# mbedTLS v3.x related +# +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set +# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set +# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set +# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set +CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y +CONFIG_MBEDTLS_PKCS7_C=y +# end of mbedTLS v3.x related + +# +# Certificate Bundle +# +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set +# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEPRECATED_LIST is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 +# end of Certificate Bundle + +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +CONFIG_MBEDTLS_CMAC_C=y +CONFIG_MBEDTLS_HARDWARE_AES=y +CONFIG_MBEDTLS_AES_USE_INTERRUPT=y +CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0 +CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI=y +CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y +CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0 +CONFIG_MBEDTLS_HARDWARE_SHA=y +CONFIG_MBEDTLS_HARDWARE_ECC=y +CONFIG_MBEDTLS_ECC_OTHER_CURVES_SOFT_FALLBACK=y +CONFIG_MBEDTLS_ROM_MD5=y +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +CONFIG_MBEDTLS_SHA512_C=y +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +# CONFIG_MBEDTLS_TLS_DISABLED is not set +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Key Exchange Methods +# +# CONFIG_MBEDTLS_PSK_MODES is not set +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y +# end of TLS Key Exchange Methods + +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y +CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y + +# +# Symmetric Ciphers +# +CONFIG_MBEDTLS_AES_C=y +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +# CONFIG_MBEDTLS_NIST_KW_C is not set +# end of Symmetric Ciphers + +# CONFIG_MBEDTLS_RIPEMD160_C is not set + +# +# Certificates +# +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# end of Certificates + +CONFIG_MBEDTLS_ECP_C=y +# CONFIG_MBEDTLS_DHM_C is not set +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y +CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y +# CONFIG_MBEDTLS_POLY1305_C is not set +# CONFIG_MBEDTLS_CHACHA20_C is not set +# CONFIG_MBEDTLS_HKDF_C is not set +# CONFIG_MBEDTLS_THREADING_C is not set +CONFIG_MBEDTLS_ERROR_STRINGS=y +# end of mbedTLS + +# +# ESP-MQTT Configurations +# +CONFIG_MQTT_PROTOCOL_311=y +# CONFIG_MQTT_PROTOCOL_5 is not set +CONFIG_MQTT_TRANSPORT_SSL=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y +# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set +# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set +# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set +# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set +# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set +# CONFIG_MQTT_CUSTOM_OUTBOX is not set +# end of ESP-MQTT Configurations + +# +# Newlib +# +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +# CONFIG_NEWLIB_NANO_FORMAT is not set +CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y +# CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set +# CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set +# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set +# end of Newlib + +# +# NVS +# +# CONFIG_NVS_ENCRYPTION is not set +# CONFIG_NVS_ASSERT_ERROR_CHECK is not set +# CONFIG_NVS_LEGACY_DUP_KEYS_COMPATIBILITY is not set +# end of NVS + +# +# OpenThread +# +# CONFIG_OPENTHREAD_ENABLED is not set + +# +# Thread Operational Dataset +# +CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP" +CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX="fd00:db8:a0:0::/64" +CONFIG_OPENTHREAD_NETWORK_CHANNEL=15 +CONFIG_OPENTHREAD_NETWORK_PANID=0x1234 +CONFIG_OPENTHREAD_NETWORK_EXTPANID="dead00beef00cafe" +CONFIG_OPENTHREAD_NETWORK_MASTERKEY="00112233445566778899aabbccddeeff" +CONFIG_OPENTHREAD_NETWORK_PSKC="104810e2315100afd6bc9215a6bfac53" +# end of Thread Operational Dataset + +CONFIG_OPENTHREAD_XTAL_ACCURACY=130 +# CONFIG_OPENTHREAD_SPINEL_ONLY is not set +# CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE is not set + +# +# Thread Address Query Config +# +# end of Thread Address Query Config +# end of OpenThread + +# +# Protocomm +# +CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y +CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y +CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y +# end of Protocomm + +# +# PThreads +# +CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_STACK_MIN=768 +CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of PThreads + +# +# MMU Config +# +CONFIG_MMU_PAGE_SIZE_64KB=y +CONFIG_MMU_PAGE_MODE="64KB" +CONFIG_MMU_PAGE_SIZE=0x10000 +# end of MMU Config + +# +# Main Flash configuration +# + +# +# SPI Flash behavior when brownout +# +CONFIG_SPI_FLASH_BROWNOUT_RESET_XMC=y +CONFIG_SPI_FLASH_BROWNOUT_RESET=y +# end of SPI Flash behavior when brownout + +# +# Optional and Experimental Features (READ DOCS FIRST) +# + +# +# Features here require specific hardware (READ DOCS FIRST!) +# +CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50 +# end of Optional and Experimental Features (READ DOCS FIRST) +# end of Main Flash configuration + +# +# SPI Flash driver +# +# CONFIG_SPI_FLASH_VERIFY_WRITE is not set +# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +# CONFIG_SPI_FLASH_ROM_IMPL is not set +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set +# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set +CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y +CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 +CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 +CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 +# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set +# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set +# CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set + +# +# Auto-detect flash chips +# +CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORTED=y +# CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP is not set +# CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP is not set +# CONFIG_SPI_FLASH_SUPPORT_GD_CHIP is not set +# CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP is not set +# CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP is not set +# CONFIG_SPI_FLASH_SUPPORT_TH_CHIP is not set +# end of Auto-detect flash chips + +CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y +# end of SPI Flash driver + +# +# SPIFFS Configuration +# +CONFIG_SPIFFS_MAX_PARTITIONS=3 + +# +# SPIFFS Cache Configuration +# +CONFIG_SPIFFS_CACHE=y +CONFIG_SPIFFS_CACHE_WR=y +# CONFIG_SPIFFS_CACHE_STATS is not set +# end of SPIFFS Cache Configuration + +CONFIG_SPIFFS_PAGE_CHECK=y +CONFIG_SPIFFS_GC_MAX_RUNS=10 +# CONFIG_SPIFFS_GC_STATS is not set +CONFIG_SPIFFS_PAGE_SIZE=256 +CONFIG_SPIFFS_OBJ_NAME_LEN=32 +# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set +CONFIG_SPIFFS_USE_MAGIC=y +CONFIG_SPIFFS_USE_MAGIC_LENGTH=y +CONFIG_SPIFFS_META_LENGTH=4 +CONFIG_SPIFFS_USE_MTIME=y + +# +# Debug Configuration +# +# CONFIG_SPIFFS_DBG is not set +# CONFIG_SPIFFS_API_DBG is not set +# CONFIG_SPIFFS_GC_DBG is not set +# CONFIG_SPIFFS_CACHE_DBG is not set +# CONFIG_SPIFFS_CHECK_DBG is not set +# CONFIG_SPIFFS_TEST_VISUALISATION is not set +# end of Debug Configuration +# end of SPIFFS Configuration + +# +# TCP Transport +# + +# +# Websocket +# +CONFIG_WS_TRANSPORT=y +CONFIG_WS_BUFFER_SIZE=1024 +# CONFIG_WS_DYNAMIC_BUFFER is not set +# end of Websocket +# end of TCP Transport + +# +# Ultra Low Power (ULP) Co-processor +# +# CONFIG_ULP_COPROC_ENABLED is not set + +# +# ULP Debugging Options +# +# end of ULP Debugging Options +# end of Ultra Low Power (ULP) Co-processor + +# +# Unity unit testing library +# +CONFIG_UNITY_ENABLE_FLOAT=y +CONFIG_UNITY_ENABLE_DOUBLE=y +# CONFIG_UNITY_ENABLE_64BIT is not set +# CONFIG_UNITY_ENABLE_COLOR is not set +CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y +# CONFIG_UNITY_ENABLE_FIXTURE is not set +# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set +# end of Unity unit testing library + +# +# Virtual file system +# +CONFIG_VFS_SUPPORT_IO=y +CONFIG_VFS_SUPPORT_DIR=y +CONFIG_VFS_SUPPORT_SELECT=y +CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y +# CONFIG_VFS_SELECT_IN_RAM is not set +CONFIG_VFS_SUPPORT_TERMIOS=y +CONFIG_VFS_MAX_COUNT=8 + +# +# Host File System I/O (Semihosting) +# +CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +# end of Host File System I/O (Semihosting) +# end of Virtual file system + +# +# Wear Levelling +# +# CONFIG_WL_SECTOR_SIZE_512 is not set +CONFIG_WL_SECTOR_SIZE_4096=y +CONFIG_WL_SECTOR_SIZE=4096 +# end of Wear Levelling + +# +# Wi-Fi Provisioning Manager +# +CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 +CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 +# CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION is not set +CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y +# CONFIG_WIFI_PROV_STA_FAST_SCAN is not set +# end of Wi-Fi Provisioning Manager + +# +# mDNS +# +CONFIG_MDNS_MAX_INTERFACES=3 +CONFIG_MDNS_MAX_SERVICES=10 +CONFIG_MDNS_TASK_PRIORITY=1 +CONFIG_MDNS_ACTION_QUEUE_LEN=16 +CONFIG_MDNS_TASK_STACK_SIZE=4096 +# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_MDNS_TASK_AFFINITY_CPU0=y +CONFIG_MDNS_TASK_AFFINITY=0x0 +CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 +CONFIG_MDNS_TIMER_PERIOD_MS=100 +# CONFIG_MDNS_NETWORKING_SOCKET is not set +# CONFIG_MDNS_SKIP_SUPPRESSING_OWN_QUERIES is not set +# CONFIG_MDNS_ENABLE_DEBUG_PRINTS is not set +CONFIG_MDNS_ENABLE_CONSOLE_CLI=y +# CONFIG_MDNS_RESPOND_REVERSE_QUERIES is not set +CONFIG_MDNS_MULTIPLE_INSTANCE=y + +# +# MDNS Predefined interfaces +# +CONFIG_MDNS_PREDEF_NETIF_STA=y +CONFIG_MDNS_PREDEF_NETIF_AP=y +CONFIG_MDNS_PREDEF_NETIF_ETH=y +# end of MDNS Predefined interfaces +# end of mDNS + +# +# LittleFS +# +# CONFIG_LITTLEFS_SDMMC_SUPPORT is not set +CONFIG_LITTLEFS_MAX_PARTITIONS=3 +CONFIG_LITTLEFS_PAGE_SIZE=256 +CONFIG_LITTLEFS_OBJ_NAME_LEN=64 +CONFIG_LITTLEFS_READ_SIZE=128 +CONFIG_LITTLEFS_WRITE_SIZE=128 +CONFIG_LITTLEFS_LOOKAHEAD_SIZE=128 +CONFIG_LITTLEFS_CACHE_SIZE=512 +CONFIG_LITTLEFS_BLOCK_CYCLES=512 +CONFIG_LITTLEFS_USE_MTIME=y +# CONFIG_LITTLEFS_USE_ONLY_HASH is not set +# CONFIG_LITTLEFS_HUMAN_READABLE is not set +CONFIG_LITTLEFS_MTIME_USE_SECONDS=y +# CONFIG_LITTLEFS_MTIME_USE_NONCE is not set +# CONFIG_LITTLEFS_SPIFFS_COMPAT is not set +# CONFIG_LITTLEFS_FLUSH_FILE_EVERY_WRITE is not set +# CONFIG_LITTLEFS_FCNTL_GET_PATH is not set +# CONFIG_LITTLEFS_MULTIVERSION is not set +# CONFIG_LITTLEFS_MALLOC_STRATEGY_DISABLE is not set +CONFIG_LITTLEFS_MALLOC_STRATEGY_DEFAULT=y +# CONFIG_LITTLEFS_MALLOC_STRATEGY_INTERNAL is not set +CONFIG_LITTLEFS_ASSERTS=y +# end of LittleFS +# end of Component config + +# CONFIG_IDF_EXPERIMENTAL_FEATURES is not set + +# Deprecated options for backward compatibility +# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set +# CONFIG_NO_BLOBS is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set +CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y +# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set +CONFIG_LOG_BOOTLOADER_LEVEL=3 +# CONFIG_APP_ROLLBACK_ENABLE is not set +# CONFIG_FLASH_ENCRYPTION_ENABLED is not set +# CONFIG_FLASHMODE_QIO is not set +# CONFIG_FLASHMODE_QOUT is not set +CONFIG_FLASHMODE_DIO=y +# CONFIG_FLASHMODE_DOUT is not set +CONFIG_MONITOR_BAUD=115200 +CONFIG_OPTIMIZATION_LEVEL_DEBUG=y +CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y +CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set +CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y +# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set +CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2 +CONFIG_CXX_EXCEPTIONS=y +CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE=0 +CONFIG_STACK_CHECK_NONE=y +# CONFIG_STACK_CHECK_NORM is not set +# CONFIG_STACK_CHECK_STRONG is not set +# CONFIG_STACK_CHECK_ALL is not set +# CONFIG_WARN_WRITE_STRINGS is not set +# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set +CONFIG_ESP32_APPTRACE_DEST_NONE=y +CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_SW_COEXIST_ENABLE=y +CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y +CONFIG_ESP_WIFI_SW_COEXIST_ENABLE=y +# CONFIG_EXTERNAL_COEX_ENABLE is not set +# CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set +# CONFIG_MCPWM_ISR_IN_IRAM is not set +# CONFIG_EVENT_LOOP_PROFILING is not set +CONFIG_POST_EVENTS_FROM_ISR=y +CONFIG_POST_EVENTS_FROM_IRAM_ISR=y +CONFIG_GDBSTUB_SUPPORT_TASKS=y +CONFIG_GDBSTUB_MAX_TASKS=32 +# CONFIG_OTA_ALLOW_HTTP is not set +# CONFIG_ESP_SYSTEM_PD_FLASH is not set +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 +# CONFIG_REDUCE_PHY_TX_POWER is not set +# CONFIG_ESP32_REDUCE_PHY_TX_POWER is not set +CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y +CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_MAIN_TASK_STACK_SIZE=3584 +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_CONSOLE_UART_NONE is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART=y +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 +CONFIG_INT_WDT=y +CONFIG_INT_WDT_TIMEOUT_MS=300 +CONFIG_TASK_WDT=y +CONFIG_ESP_TASK_WDT=y +# CONFIG_TASK_WDT_PANIC is not set +CONFIG_TASK_WDT_TIMEOUT_S=5 +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +# CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set +CONFIG_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set +CONFIG_BROWNOUT_DET_LVL=7 +CONFIG_IPC_TASK_STACK_SIZE=1024 +CONFIG_TIMER_TASK_STACK_SIZE=3584 +CONFIG_ESP32_WIFI_ENABLED=y +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y +CONFIG_WPA_MBEDTLS_CRYPTO=y +CONFIG_WPA_MBEDTLS_TLS_CLIENT=y +# CONFIG_WPA_WAPI_PSK is not set +# CONFIG_WPA_SUITE_B_192 is not set +# CONFIG_WPA_11KV_SUPPORT is not set +# CONFIG_WPA_MBO_SUPPORT is not set +# CONFIG_WPA_DPP_SUPPORT is not set +# CONFIG_WPA_11R_SUPPORT is not set +# CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set +# CONFIG_WPA_WPS_STRICT is not set +# CONFIG_WPA_DEBUG_PRINT is not set +# CONFIG_WPA_TESTING_OPTIONS is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +CONFIG_TIMER_TASK_PRIORITY=1 +CONFIG_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_TIMER_QUEUE_LENGTH=10 +# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set +# CONFIG_HAL_ASSERTION_SILIENT is not set +# CONFIG_L2_TO_L3_COPY is not set +CONFIG_ESP_GRATUITOUS_ARP=y +CONFIG_GARP_TMR_INTERVAL=60 +CONFIG_TCPIP_RECVMBOX_SIZE=32 +CONFIG_TCP_MAXRTX=12 +CONFIG_TCP_SYNMAXRTX=12 +CONFIG_TCP_MSS=1440 +CONFIG_TCP_MSL=60000 +CONFIG_TCP_SND_BUF_DEFAULT=5760 +CONFIG_TCP_WND_DEFAULT=5760 +CONFIG_TCP_RECVMBOX_SIZE=6 +CONFIG_TCP_QUEUE_OOSEQ=y +CONFIG_TCP_OVERSIZE_MSS=y +# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_TCP_OVERSIZE_DISABLE is not set +CONFIG_UDP_RECVMBOX_SIZE=6 +CONFIG_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set +CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_PPP_SUPPORT is not set +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_STACK_MIN=768 +CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set +CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_SUPPORT_TERMIOS=y +CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +# End of deprecated options diff --git a/test/integration/sdkconfig.defaults b/test/integration/sdkconfig.defaults new file mode 100644 index 0000000..6ebada1 --- /dev/null +++ b/test/integration/sdkconfig.defaults @@ -0,0 +1,18 @@ +# +# Compiler options +# +CONFIG_COMPILER_CXX_EXCEPTIONS=y + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="8MB" + +# +# Log output +# +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y +CONFIG_LOG_MAXIMUM_LEVEL=4 diff --git a/test/unitOnHost/.vscode/settings.json b/test/unitOnHost/.vscode/settings.json new file mode 100644 index 0000000..7536b3f --- /dev/null +++ b/test/unitOnHost/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.cmakePath": "C:/msys64/usr/bin/cmake.exe" +} \ No newline at end of file diff --git a/utest/CMakeLists.txt b/test/unitOnHost/CMakeLists.txt similarity index 88% rename from utest/CMakeLists.txt rename to test/unitOnHost/CMakeLists.txt index 5fa8d11..197f034 100644 --- a/utest/CMakeLists.txt +++ b/test/unitOnHost/CMakeLists.txt @@ -20,7 +20,7 @@ project(UnitTests) find_package(doctest REQUIRED PATHS "/mingw64/lib/cmake") # target_link_libraries(${PROJECT_NAME} PRIVATE doctest::doctest) -addSubDirs_ofRoot("${CMAKE_CURRENT_LIST_DIR}/../components") +addSubDirs_ofRoot("${CMAKE_CURRENT_LIST_DIR}/../../components") diff --git a/utest/ReadMe.md b/test/unitOnHost/ReadMe.md similarity index 100% rename from utest/ReadMe.md rename to test/unitOnHost/ReadMe.md diff --git a/utest/test_core.cmake b/test/unitOnHost/test_core.cmake similarity index 100% rename from utest/test_core.cmake rename to test/unitOnHost/test_core.cmake diff --git a/test/CMakeLists.txt b/test/unitOnTarget/CMakeLists.txt similarity index 86% rename from test/CMakeLists.txt rename to test/unitOnTarget/CMakeLists.txt index ca1bb93..0f78a91 100644 --- a/test/CMakeLists.txt +++ b/test/unitOnTarget/CMakeLists.txt @@ -3,7 +3,10 @@ cmake_minimum_required(VERSION 3.16) # Include the components directory of the main application: # -set(EXTRA_COMPONENT_DIRS "../components ../managed_components") +set(EXTRA_COMPONENT_DIRS + "../../components" + # "../../managed_components" +) # Set the components to include the tests for. # This can be overriden from CMake cache: diff --git a/test/ReadMe.md b/test/unitOnTarget/ReadMe.md similarity index 100% rename from test/ReadMe.md rename to test/unitOnTarget/ReadMe.md diff --git a/test/unitOnTarget/dependencies.lock b/test/unitOnTarget/dependencies.lock new file mode 100644 index 0000000..68be0f1 --- /dev/null +++ b/test/unitOnTarget/dependencies.lock @@ -0,0 +1,9 @@ +dependencies: + idf: + component_hash: null + source: + type: idf + version: 5.3.0 +manifest_hash: c4f4ec05313d427eb56c633f78ce213e553379725bf2af3c511665f930571beb +target: esp32c6 +version: 1.0.0 diff --git a/test/main/CMakeLists.txt b/test/unitOnTarget/main/CMakeLists.txt similarity index 100% rename from test/main/CMakeLists.txt rename to test/unitOnTarget/main/CMakeLists.txt diff --git a/test/main/unitTest.cpp b/test/unitOnTarget/main/unitTest.cpp similarity index 100% rename from test/main/unitTest.cpp rename to test/unitOnTarget/main/unitTest.cpp diff --git a/test/sdkconfig b/test/unitOnTarget/sdkconfig similarity index 100% rename from test/sdkconfig rename to test/unitOnTarget/sdkconfig diff --git a/test/sdkconfig.defaults b/test/unitOnTarget/sdkconfig.defaults similarity index 100% rename from test/sdkconfig.defaults rename to test/unitOnTarget/sdkconfig.defaults