Vorlage für Projekt

Dependencies:   EthernetInterface mbed-rtos

Fork of Telemetrie_eth_h2m by Hochschule München

Committer:
HMFK03LST1
Date:
Sun Nov 22 14:18:03 2015 +0000
Revision:
5:a96e4e59c710
Parent:
3:94a735c744ff
Child:
6:abadad863420
CS to uint8

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HMFK03LST1 0:c0179f2ad295 1
HMFK03LST1 0:c0179f2ad295 2 #ifndef TELEMETRY
HMFK03LST1 0:c0179f2ad295 3 #define TELEMETRY
HMFK03LST1 0:c0179f2ad295 4
HMFK03LST1 1:2df3958877f2 5 //#define DEBUG
HMFK03LST1 0:c0179f2ad295 6
HMFK03LST1 0:c0179f2ad295 7 #include "mbed.h"
HMFK03LST1 0:c0179f2ad295 8 #include "EthernetInterface.h"
HMFK03LST1 3:94a735c744ff 9
HMFK03LST1 3:94a735c744ff 10 /** Ethernet Interface for send/receive Datastructs over udp
HMFK03LST1 3:94a735c744ff 11 *
HMFK03LST1 3:94a735c744ff 12 * By Sebastian Donner
HMFK03LST1 3:94a735c744ff 13 *
HMFK03LST1 3:94a735c744ff 14 * Permission is hereby granted, free of charge, to any person
HMFK03LST1 3:94a735c744ff 15 * obtaining a copy of this software and associated documentation
HMFK03LST1 3:94a735c744ff 16 * files (the "Software"), to deal in the Software without
HMFK03LST1 3:94a735c744ff 17 * restriction, including without limitation the rights to use,
HMFK03LST1 3:94a735c744ff 18 * copy, modify, merge, publish, distribute, sublicense, and/or sell
HMFK03LST1 3:94a735c744ff 19 * copies of the Software, and to permit persons to whom the
HMFK03LST1 3:94a735c744ff 20 * Software is furnished to do so, subject to the following
HMFK03LST1 3:94a735c744ff 21 * conditions:
HMFK03LST1 3:94a735c744ff 22 *
HMFK03LST1 3:94a735c744ff 23 * The above copyright notice and this permission notice shall be
HMFK03LST1 3:94a735c744ff 24 * included in all copies or substantial portions of the Software.
HMFK03LST1 3:94a735c744ff 25 *
HMFK03LST1 3:94a735c744ff 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
HMFK03LST1 3:94a735c744ff 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
HMFK03LST1 3:94a735c744ff 28 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
HMFK03LST1 3:94a735c744ff 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HMFK03LST1 3:94a735c744ff 30 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
HMFK03LST1 3:94a735c744ff 31 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
HMFK03LST1 3:94a735c744ff 32 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
HMFK03LST1 3:94a735c744ff 33 * OTHER DEALINGS IN THE SOFTWARE.
HMFK03LST1 3:94a735c744ff 34 *
HMFK03LST1 3:94a735c744ff 35 * @code
HMFK03LST1 3:94a735c744ff 36 * {
HMFK03LST1 3:94a735c744ff 37 * }
HMFK03LST1 3:94a735c744ff 38 * @endcode
HMFK03LST1 3:94a735c744ff 39 */
HMFK03LST1 3:94a735c744ff 40
HMFK03LST1 3:94a735c744ff 41
HMFK03LST1 0:c0179f2ad295 42
HMFK03LST1 0:c0179f2ad295 43 class Telemetry
HMFK03LST1 0:c0179f2ad295 44 {
HMFK03LST1 0:c0179f2ad295 45 public:
HMFK03LST1 3:94a735c744ff 46 //! Create Ethernet Interface
HMFK03LST1 0:c0179f2ad295 47 Telemetry();
HMFK03LST1 3:94a735c744ff 48
HMFK03LST1 3:94a735c744ff 49 //! IP Address of mbed Interface
HMFK03LST1 2:e19b937a29c1 50 char* ip_self;
HMFK03LST1 3:94a735c744ff 51
HMFK03LST1 3:94a735c744ff 52 //! IP Addess and Port of databank Server
HMFK03LST1 2:e19b937a29c1 53 Endpoint db_server;
HMFK03LST1 3:94a735c744ff 54
HMFK03LST1 5:a96e4e59c710 55 //! IP Addess and Port of control Server
HMFK03LST1 2:e19b937a29c1 56 Endpoint controller;
HMFK03LST1 3:94a735c744ff 57
HMFK03LST1 3:94a735c744ff 58 //! IP Addess and Port of incoming MSG
HMFK03LST1 2:e19b937a29c1 59 Endpoint input_Host;
HMFK03LST1 3:94a735c744ff 60
HMFK03LST1 2:e19b937a29c1 61
HMFK03LST1 0:c0179f2ad295 62 #ifdef DEBUG
HMFK03LST1 0:c0179f2ad295 63 void InitUSBSerialConnection();
HMFK03LST1 0:c0179f2ad295 64 #endif
HMFK03LST1 3:94a735c744ff 65
HMFK03LST1 3:94a735c744ff 66 //! init with DHCP
HMFK03LST1 0:c0179f2ad295 67 bool InitEthernetConnection();
HMFK03LST1 3:94a735c744ff 68
HMFK03LST1 3:94a735c744ff 69 //! init with Static IP
HMFK03LST1 0:c0179f2ad295 70 bool InitEthernetConnection(const char* IPAdress, const char* SubNetMask, const char* GateWay);
HMFK03LST1 3:94a735c744ff 71
HMFK03LST1 3:94a735c744ff 72
HMFK03LST1 3:94a735c744ff 73 //! Close Connection
HMFK03LST1 0:c0179f2ad295 74 void CloseEthernetConnection();
HMFK03LST1 3:94a735c744ff 75
HMFK03LST1 3:94a735c744ff 76
HMFK03LST1 3:94a735c744ff 77 //! Connect Port TCP
HMFK03LST1 3:94a735c744ff 78 void ConnectSocket_tcp(Endpoint Host);
HMFK03LST1 3:94a735c744ff 79
HMFK03LST1 3:94a735c744ff 80 //! Connect Port UDP receive
HMFK03LST1 3:94a735c744ff 81 void ConnectSocket_udp_rec(int Port);
HMFK03LST1 3:94a735c744ff 82
HMFK03LST1 3:94a735c744ff 83 //! Connect Port UDP send
HMFK03LST1 3:94a735c744ff 84 void ConnectSocket_udp_send();
HMFK03LST1 3:94a735c744ff 85
HMFK03LST1 3:94a735c744ff 86
HMFK03LST1 3:94a735c744ff 87 //! Close Port TCP
HMFK03LST1 3:94a735c744ff 88 void CloseSocket_tcp();
HMFK03LST1 0:c0179f2ad295 89
HMFK03LST1 3:94a735c744ff 90 //! Close Port UDP receive
HMFK03LST1 3:94a735c744ff 91 void CloseSocket_udp_rec();
HMFK03LST1 3:94a735c744ff 92
HMFK03LST1 3:94a735c744ff 93 //! Close Port UDP send
HMFK03LST1 3:94a735c744ff 94 void CloseSocket_udp_send();
HMFK03LST1 3:94a735c744ff 95
HMFK03LST1 3:94a735c744ff 96
HMFK03LST1 3:94a735c744ff 97 //! Struct Check Sum calc
HMFK03LST1 5:a96e4e59c710 98 uint8_t do_cs(char* buffer);
HMFK03LST1 3:94a735c744ff 99
HMFK03LST1 3:94a735c744ff 100 //! Read UDP Packet
HMFK03LST1 3:94a735c744ff 101 int Rec_Data_UDP(char *buffer, int size);
HMFK03LST1 2:e19b937a29c1 102
HMFK03LST1 3:94a735c744ff 103 //! Check UDP Packet of containing Struct
HMFK03LST1 3:94a735c744ff 104 bool Rec_Struct_UDP(char *buffer);
HMFK03LST1 3:94a735c744ff 105
HMFK03LST1 3:94a735c744ff 106 //! Read TCP Packet
HMFK03LST1 3:94a735c744ff 107 int Rec_Data_TCP(char *buffer, int size);
HMFK03LST1 3:94a735c744ff 108
HMFK03LST1 3:94a735c744ff 109
HMFK03LST1 3:94a735c744ff 110 //! Send UDP Packet
HMFK03LST1 3:94a735c744ff 111 void Send_Data_UDP(Endpoint Server, char* Daten, int size);
HMFK03LST1 3:94a735c744ff 112
HMFK03LST1 3:94a735c744ff 113 //! Send Struct as UDP Packet
HMFK03LST1 3:94a735c744ff 114 void Send_Struct_UDP(Endpoint Server, char* Daten);
HMFK03LST1 3:94a735c744ff 115
HMFK03LST1 3:94a735c744ff 116 //! Send TCP Packet
HMFK03LST1 3:94a735c744ff 117 void Send_Data_TCP(char* Host, char* Daten);
HMFK03LST1 2:e19b937a29c1 118
HMFK03LST1 0:c0179f2ad295 119
HMFK03LST1 3:94a735c744ff 120 private:
HMFK03LST1 3:94a735c744ff 121 bool InitSucceed;
HMFK03LST1 2:e19b937a29c1 122
HMFK03LST1 0:c0179f2ad295 123 };
HMFK03LST1 0:c0179f2ad295 124
HMFK03LST1 0:c0179f2ad295 125 #endif