Vorlage für Projekt

Dependencies:   EthernetInterface mbed-rtos

Fork of Telemetrie_eth_h2m by Hochschule München

Telemetry.h

Committer:
HMFK03LST1
Date:
2015-10-31
Revision:
2:e19b937a29c1
Parent:
1:2df3958877f2
Child:
3:94a735c744ff

File content as of revision 2:e19b937a29c1:

/*------------------------------------------------*/
/*Define LED:                                     */
/*  LEDSerial = LED1                              */
/*  LEDEthernet = LED2                            */
/*  LEDSOCKET = LED3                              */
/*  LEDWAITFORANSWER = LED4                       */
/*                                                */
/*Define DEBUG:                                   */
/*   Ausgabe über Serielle Schnittstelle          */
/*   (USBRX/USBTX)                                */
/*                                                */
/*Autor: Sebastian Hauzenberger                   */
/*------------------------------------------------*/

#ifndef TELEMETRY
#define TELEMETRY

//#define LED
//#define DEBUG

#include "mbed.h"
#include "EthernetInterface.h"
#include <string>
#include <sstream>

class Telemetry
{
    public:
        Telemetry();
        char* ip_self;
        Endpoint db_server;
        Endpoint controller;
        Endpoint input_Host;
        
        #ifdef DEBUG
        void InitUSBSerialConnection();
        #endif
        //Struct Check Sum calc
        char do_cs(char* buffer); 
        //init with DHCP
        bool InitEthernetConnection();
        //init with Static
        bool InitEthernetConnection(const char* IPAdress, const char* SubNetMask, const char* GateWay);
        //Close Connection
        void CloseEthernetConnection();
        
        //Connect Ports
        void ConnectSocket_tcp(Endpoint Host);
        void ConnectSocket_udp_rec(int Port);
        void ConnectSocket_udp_send();
        
        //Close Ports
        void CloseSocket_tcp();
        void CloseSocket_udp_rec();
        void CloseSocket_udp_send();
        
        
        int  Rec_Data_UDP(char *buffer, int size);
        bool Rec_Struct_UDP(char *buffer);
        
        int  Rec_Data_TCP(char *buffer, int size);
        
        void Send_Data_UDP(Endpoint Server, char* Daten, int size);
        void Send_Struct_UDP(Endpoint Server, char* Daten);
        
        void Send_Data_TCP(char* Host, string Daten, string Username, string Passwort);
        
};

#endif