Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MbedTransport/inc/MbedTransport.h@0:b9e1003fbee7, 2016-04-15 (annotated)
- Committer:
- Innomatix
- Date:
- Fri Apr 15 18:35:31 2016 +0000
- Revision:
- 0:b9e1003fbee7
v1.0.2 Rework to use USB for comms, rework example, add user guides
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Innomatix | 0:b9e1003fbee7 | 1 | /******************************************************************* |
| Innomatix | 0:b9e1003fbee7 | 2 | * |
| Innomatix | 0:b9e1003fbee7 | 3 | * File: MbedTransport.h |
| Innomatix | 0:b9e1003fbee7 | 4 | * |
| Innomatix | 0:b9e1003fbee7 | 5 | * Description: Communications transport layer API for Mbed |
| Innomatix | 0:b9e1003fbee7 | 6 | * |
| Innomatix | 0:b9e1003fbee7 | 7 | * Copyright 2015 Innomatix, LLC., All Rights Reserved |
| Innomatix | 0:b9e1003fbee7 | 8 | * |
| Innomatix | 0:b9e1003fbee7 | 9 | * THIS DOCUMENT AND ITS CONTENTS ARE INTELLECTUAL PROPERTY |
| Innomatix | 0:b9e1003fbee7 | 10 | * OF INNOMATIX, LLC. ANY DUPLICATION IN PART OR WHOLE |
| Innomatix | 0:b9e1003fbee7 | 11 | * WITHOUT PRIOR WRITTEN CONSENT IS STRICTLY PROHIBITED. |
| Innomatix | 0:b9e1003fbee7 | 12 | * |
| Innomatix | 0:b9e1003fbee7 | 13 | *******************************************************************/ |
| Innomatix | 0:b9e1003fbee7 | 14 | #ifndef _MBEDTRANSPORT_H_ |
| Innomatix | 0:b9e1003fbee7 | 15 | #define _MBEDTRANSPORT_H_ |
| Innomatix | 0:b9e1003fbee7 | 16 | |
| Innomatix | 0:b9e1003fbee7 | 17 | |
| Innomatix | 0:b9e1003fbee7 | 18 | #define DO_SERIAL_NET |
| Innomatix | 0:b9e1003fbee7 | 19 | |
| Innomatix | 0:b9e1003fbee7 | 20 | #ifndef DO_SERIAL_NET |
| Innomatix | 0:b9e1003fbee7 | 21 | #include "EthernetInterface.h" |
| Innomatix | 0:b9e1003fbee7 | 22 | #endif |
| Innomatix | 0:b9e1003fbee7 | 23 | |
| Innomatix | 0:b9e1003fbee7 | 24 | |
| Innomatix | 0:b9e1003fbee7 | 25 | #define ADDRESS_LENGTH 256 |
| Innomatix | 0:b9e1003fbee7 | 26 | |
| Innomatix | 0:b9e1003fbee7 | 27 | |
| Innomatix | 0:b9e1003fbee7 | 28 | typedef struct |
| Innomatix | 0:b9e1003fbee7 | 29 | { |
| Innomatix | 0:b9e1003fbee7 | 30 | char Address[ADDRESS_LENGTH]; |
| Innomatix | 0:b9e1003fbee7 | 31 | int Port; |
| Innomatix | 0:b9e1003fbee7 | 32 | #ifndef DO_SERIAL_NET |
| Innomatix | 0:b9e1003fbee7 | 33 | UDPSocket sendSocket; |
| Innomatix | 0:b9e1003fbee7 | 34 | UDPSocket receiveSocket; |
| Innomatix | 0:b9e1003fbee7 | 35 | Endpoint sendEndpoint; |
| Innomatix | 0:b9e1003fbee7 | 36 | Endpoint receiveEndpoint; |
| Innomatix | 0:b9e1003fbee7 | 37 | #endif |
| Innomatix | 0:b9e1003fbee7 | 38 | |
| Innomatix | 0:b9e1003fbee7 | 39 | }TransportHandle_t, *TransportHandle_p; |
| Innomatix | 0:b9e1003fbee7 | 40 | |
| Innomatix | 0:b9e1003fbee7 | 41 | /** |
| Innomatix | 0:b9e1003fbee7 | 42 | * Function to initialize ethernet, UDP socket sending and UDP socket receiving. |
| Innomatix | 0:b9e1003fbee7 | 43 | * |
| Innomatix | 0:b9e1003fbee7 | 44 | * @param h - TransportHandle that saves all of the socket information for future |
| Innomatix | 0:b9e1003fbee7 | 45 | use when we need to send/recieve information. |
| Innomatix | 0:b9e1003fbee7 | 46 | * @retval result - lets us know if there was a success or error. |
| Innomatix | 0:b9e1003fbee7 | 47 | ***********************************************************************************/ |
| Innomatix | 0:b9e1003fbee7 | 48 | int TransportInit( TransportHandle_p handle, const char *address, unsigned short port ); |
| Innomatix | 0:b9e1003fbee7 | 49 | |
| Innomatix | 0:b9e1003fbee7 | 50 | |
| Innomatix | 0:b9e1003fbee7 | 51 | |
| Innomatix | 0:b9e1003fbee7 | 52 | /***********************************************************************************/ |
| Innomatix | 0:b9e1003fbee7 | 53 | void TransportClose( TransportHandle_p handle ); |
| Innomatix | 0:b9e1003fbee7 | 54 | |
| Innomatix | 0:b9e1003fbee7 | 55 | |
| Innomatix | 0:b9e1003fbee7 | 56 | /** |
| Innomatix | 0:b9e1003fbee7 | 57 | * Function for sending a buffer via UDP with the socket we set up in Init. |
| Innomatix | 0:b9e1003fbee7 | 58 | * |
| Innomatix | 0:b9e1003fbee7 | 59 | * @param len - length of the buffer we want to send to the server. |
| Innomatix | 0:b9e1003fbee7 | 60 | * @param buff - the buffer we would like to send to the server. |
| Innomatix | 0:b9e1003fbee7 | 61 | * @retval result - lets us know if there was a success or error. |
| Innomatix | 0:b9e1003fbee7 | 62 | ******************************************************************************************/ |
| Innomatix | 0:b9e1003fbee7 | 63 | int TransportSend( TransportHandle_p handle, unsigned short len, const unsigned char *buff, int timeout); |
| Innomatix | 0:b9e1003fbee7 | 64 | |
| Innomatix | 0:b9e1003fbee7 | 65 | |
| Innomatix | 0:b9e1003fbee7 | 66 | /** |
| Innomatix | 0:b9e1003fbee7 | 67 | * Function for receving a buffer via UDP with the socket we set up in Init. |
| Innomatix | 0:b9e1003fbee7 | 68 | * |
| Innomatix | 0:b9e1003fbee7 | 69 | * @param maxlen - the maximum length of the buffer we want to receive from the server. |
| Innomatix | 0:b9e1003fbee7 | 70 | * @param buff - the buffer we would like to receiver from the server. |
| Innomatix | 0:b9e1003fbee7 | 71 | * @retval result - lets us know if there was a success or error. |
| Innomatix | 0:b9e1003fbee7 | 72 | ***********************************************************************************************/ |
| Innomatix | 0:b9e1003fbee7 | 73 | int TransportReceive( TransportHandle_p handle, unsigned short maxlen, unsigned char *buff, int timeout ); |
| Innomatix | 0:b9e1003fbee7 | 74 | |
| Innomatix | 0:b9e1003fbee7 | 75 | |
| Innomatix | 0:b9e1003fbee7 | 76 | #endif /* _MBEDTRANSPORT_H_ */ |