Added initial ControlCore code
This commit is contained in:
		
							parent
							
								
									f05ab5c742
								
							
						
					
					
						commit
						14e3499742
					
				
							
								
								
									
										39
									
								
								ControlCore/Messages.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								ControlCore/Messages.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | |||||||
|  | #include "Messages.h" | ||||||
|  | 
 | ||||||
|  | #pragma region IMessage | ||||||
|  | 
 | ||||||
|  | unsigned char *IMessage::Serialize() { return nullptr; } | ||||||
|  | 
 | ||||||
|  | bool IMessage::SendMsg(IMessage msg, unsigned char bufferSize) { | ||||||
|  |   return SendMsg(msg.Serialize(), bufferSize); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool IMessage::SendMsg(unsigned char *buffer, unsigned char bufferSize) { | ||||||
|  |   // SendBuffer(buffer, bufferSize);
 | ||||||
|  |   return false; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #pragma endregion | ||||||
|  | 
 | ||||||
|  | #pragma region Investigate | ||||||
|  | 
 | ||||||
|  | InvestigateMsg::InvestigateMsg(unsigned char thingId) { | ||||||
|  |   this->networkId = 0; | ||||||
|  |   this->thingId = thingId; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | unsigned char *InvestigateMsg::Serialize() { | ||||||
|  |   unsigned char *buffer = IMessage::buffer; | ||||||
|  |   buffer[0] = InvestigateMsg::id; | ||||||
|  |   buffer[1] = this->networkId; | ||||||
|  |   buffer[2] = this->thingId; | ||||||
|  |   return buffer; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool InvestigateMsg::Send(unsigned char thingId) { | ||||||
|  |   InvestigateMsg msg = InvestigateMsg(thingId); | ||||||
|  |   return SendMsg(msg, InvestigateMsg::length); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Investiaget
 | ||||||
|  | #pragma endregion | ||||||
							
								
								
									
										28
									
								
								ControlCore/Messages.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								ControlCore/Messages.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | |||||||
|  | namespace Passer::Control { | ||||||
|  | 
 | ||||||
|  | class IMessage { | ||||||
|  | public: | ||||||
|  |   static unsigned char buffer[256]; | ||||||
|  | 
 | ||||||
|  |   virtual unsigned char *Serialize(); | ||||||
|  | 
 | ||||||
|  |   static bool SendMsg(IMessage msg, unsigned char bufferSize); | ||||||
|  |   static bool SendMsg(unsigned char *buffer, unsigned char bufferSize); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | class InvestigateMsg : public IMessage { | ||||||
|  | public: | ||||||
|  |   static const unsigned char id = 0x81; | ||||||
|  |   static const unsigned char length = 3; | ||||||
|  |   unsigned char networkId; | ||||||
|  |   unsigned char thingId; | ||||||
|  | 
 | ||||||
|  |   InvestigateMsg(unsigned char thingId); | ||||||
|  | 
 | ||||||
|  |   virtual unsigned char *Serialize() override; | ||||||
|  | 
 | ||||||
|  |   static bool Send(unsigned char thingId); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | } // namespace Passer::Control
 | ||||||
|  | using namespace Passer::Control; | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Pascal Serrarens
						Pascal Serrarens