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@11:b28c0d6773bf, 2017-09-06 (annotated)
- Committer:
- Innomatix
- Date:
- Wed Sep 06 19:18:48 2017 +0000
- Revision:
- 11:b28c0d6773bf
Innomatix Support Library v1.0.7 (additional files)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Innomatix | 11:b28c0d6773bf | 1 | /******************************************************************* |
| Innomatix | 11:b28c0d6773bf | 2 | * |
| Innomatix | 11:b28c0d6773bf | 3 | * File: MbedTransport.h |
| Innomatix | 11:b28c0d6773bf | 4 | * |
| Innomatix | 11:b28c0d6773bf | 5 | * Description: Communications transport layer API for Mbed |
| Innomatix | 11:b28c0d6773bf | 6 | * |
| Innomatix | 11:b28c0d6773bf | 7 | * Copyright 2015 Innomatix, LLC., All Rights Reserved |
| Innomatix | 11:b28c0d6773bf | 8 | * |
| Innomatix | 11:b28c0d6773bf | 9 | * THIS DOCUMENT AND ITS CONTENTS ARE INTELLECTUAL PROPERTY |
| Innomatix | 11:b28c0d6773bf | 10 | * OF INNOMATIX, LLC. ANY DUPLICATION IN PART OR WHOLE |
| Innomatix | 11:b28c0d6773bf | 11 | * WITHOUT PRIOR WRITTEN CONSENT IS STRICTLY PROHIBITED. |
| Innomatix | 11:b28c0d6773bf | 12 | * |
| Innomatix | 11:b28c0d6773bf | 13 | *******************************************************************/ |
| Innomatix | 11:b28c0d6773bf | 14 | #ifndef _MBEDTRANSPORT_H_ |
| Innomatix | 11:b28c0d6773bf | 15 | #define _MBEDTRANSPORT_H_ |
| Innomatix | 11:b28c0d6773bf | 16 | |
| Innomatix | 11:b28c0d6773bf | 17 | |
| Innomatix | 11:b28c0d6773bf | 18 | #define DO_SERIAL_NET |
| Innomatix | 11:b28c0d6773bf | 19 | |
| Innomatix | 11:b28c0d6773bf | 20 | #ifndef DO_SERIAL_NET |
| Innomatix | 11:b28c0d6773bf | 21 | #include "EthernetInterface.h" |
| Innomatix | 11:b28c0d6773bf | 22 | #endif |
| Innomatix | 11:b28c0d6773bf | 23 | |
| Innomatix | 11:b28c0d6773bf | 24 | |
| Innomatix | 11:b28c0d6773bf | 25 | #define ADDRESS_LENGTH 256 |
| Innomatix | 11:b28c0d6773bf | 26 | |
| Innomatix | 11:b28c0d6773bf | 27 | |
| Innomatix | 11:b28c0d6773bf | 28 | typedef struct |
| Innomatix | 11:b28c0d6773bf | 29 | { |
| Innomatix | 11:b28c0d6773bf | 30 | char Address[ADDRESS_LENGTH]; |
| Innomatix | 11:b28c0d6773bf | 31 | int Port; |
| Innomatix | 11:b28c0d6773bf | 32 | #ifndef DO_SERIAL_NET |
| Innomatix | 11:b28c0d6773bf | 33 | UDPSocket sendSocket; |
| Innomatix | 11:b28c0d6773bf | 34 | UDPSocket receiveSocket; |
| Innomatix | 11:b28c0d6773bf | 35 | Endpoint sendEndpoint; |
| Innomatix | 11:b28c0d6773bf | 36 | Endpoint receiveEndpoint; |
| Innomatix | 11:b28c0d6773bf | 37 | #endif |
| Innomatix | 11:b28c0d6773bf | 38 | |
| Innomatix | 11:b28c0d6773bf | 39 | }TransportHandle_t, *TransportHandle_p; |
| Innomatix | 11:b28c0d6773bf | 40 | |
| Innomatix | 11:b28c0d6773bf | 41 | /** |
| Innomatix | 11:b28c0d6773bf | 42 | * Function to initialize ethernet, UDP socket sending and UDP socket receiving. |
| Innomatix | 11:b28c0d6773bf | 43 | * |
| Innomatix | 11:b28c0d6773bf | 44 | * @param h - TransportHandle that saves all of the socket information for future |
| Innomatix | 11:b28c0d6773bf | 45 | use when we need to send/recieve information. |
| Innomatix | 11:b28c0d6773bf | 46 | * @retval result - lets us know if there was a success or error. |
| Innomatix | 11:b28c0d6773bf | 47 | ***********************************************************************************/ |
| Innomatix | 11:b28c0d6773bf | 48 | int TransportInit( TransportHandle_p handle, const char *address, unsigned short port ); |
| Innomatix | 11:b28c0d6773bf | 49 | |
| Innomatix | 11:b28c0d6773bf | 50 | |
| Innomatix | 11:b28c0d6773bf | 51 | |
| Innomatix | 11:b28c0d6773bf | 52 | /***********************************************************************************/ |
| Innomatix | 11:b28c0d6773bf | 53 | void TransportClose( TransportHandle_p handle ); |
| Innomatix | 11:b28c0d6773bf | 54 | |
| Innomatix | 11:b28c0d6773bf | 55 | |
| Innomatix | 11:b28c0d6773bf | 56 | /** |
| Innomatix | 11:b28c0d6773bf | 57 | * Test if the transport is ready to use. Ensures that TransportInit() has been |
| Innomatix | 11:b28c0d6773bf | 58 | * called for the given handle. May include other conditions based on the underlying |
| Innomatix | 11:b28c0d6773bf | 59 | * interface/connection. |
| Innomatix | 11:b28c0d6773bf | 60 | * serial_net - includes testing that the DAP side of the connection is open |
| Innomatix | 11:b28c0d6773bf | 61 | * |
| Innomatix | 11:b28c0d6773bf | 62 | * NOTE: calls to TransportSend() and TransportReceive() when the transport reports |
| Innomatix | 11:b28c0d6773bf | 63 | * not Ready() may block. |
| Innomatix | 11:b28c0d6773bf | 64 | * |
| Innomatix | 11:b28c0d6773bf | 65 | * @retval result - 0 indicates not ready or not connected. 1 indicates ready to use |
| Innomatix | 11:b28c0d6773bf | 66 | ***********************************************************************************/ |
| Innomatix | 11:b28c0d6773bf | 67 | int TransportReady( TransportHandle_p handle ); |
| Innomatix | 11:b28c0d6773bf | 68 | |
| Innomatix | 11:b28c0d6773bf | 69 | |
| Innomatix | 11:b28c0d6773bf | 70 | /** |
| Innomatix | 11:b28c0d6773bf | 71 | * Function for sending a buffer via UDP with the socket we set up in Init. |
| Innomatix | 11:b28c0d6773bf | 72 | * |
| Innomatix | 11:b28c0d6773bf | 73 | * @param len - length of the buffer we want to send to the server. |
| Innomatix | 11:b28c0d6773bf | 74 | * @param buff - the buffer we would like to send to the server. |
| Innomatix | 11:b28c0d6773bf | 75 | * @retval result - Value < 0 indicates error or no remote device connected. Value >= 0 indicates number bytes sent |
| Innomatix | 11:b28c0d6773bf | 76 | ******************************************************************************************/ |
| Innomatix | 11:b28c0d6773bf | 77 | int TransportSend( TransportHandle_p handle, unsigned short len, const unsigned char *buff, int timeout); |
| Innomatix | 11:b28c0d6773bf | 78 | |
| Innomatix | 11:b28c0d6773bf | 79 | |
| Innomatix | 11:b28c0d6773bf | 80 | /** |
| Innomatix | 11:b28c0d6773bf | 81 | * Function for receving a buffer via UDP with the socket we set up in Init. |
| Innomatix | 11:b28c0d6773bf | 82 | * |
| Innomatix | 11:b28c0d6773bf | 83 | * @param maxlen - the maximum length of the buffer we want to receive from the server. |
| Innomatix | 11:b28c0d6773bf | 84 | * @param buff - the buffer we would like to receiver from the server. |
| Innomatix | 11:b28c0d6773bf | 85 | * @retval result - Value < 0 indicates error or no remote device connected. Value >= 0 indicates number bytes received |
| Innomatix | 11:b28c0d6773bf | 86 | ***********************************************************************************************/ |
| Innomatix | 11:b28c0d6773bf | 87 | int TransportReceive( TransportHandle_p handle, unsigned short maxlen, unsigned char *buff, int timeout ); |
| Innomatix | 11:b28c0d6773bf | 88 | |
| Innomatix | 11:b28c0d6773bf | 89 | |
| Innomatix | 11:b28c0d6773bf | 90 | #endif /* _MBEDTRANSPORT_H_ */ |