Integrating the ublox LISA C200 modem
Fork of SprintUSBModemHTTPClientTest by
SprintUSBModem/Socket/UDPSocket.h@5:3f93dd1d4cb3, 2013-09-26 (annotated)
- Committer:
- sam_grove
- Date:
- Thu Sep 26 00:44:20 2013 -0500
- Revision:
- 5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 5:3f93dd1d4cb3 | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
sam_grove | 5:3f93dd1d4cb3 | 2 | * |
sam_grove | 5:3f93dd1d4cb3 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
sam_grove | 5:3f93dd1d4cb3 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
sam_grove | 5:3f93dd1d4cb3 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
sam_grove | 5:3f93dd1d4cb3 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
sam_grove | 5:3f93dd1d4cb3 | 7 | * furnished to do so, subject to the following conditions: |
sam_grove | 5:3f93dd1d4cb3 | 8 | * |
sam_grove | 5:3f93dd1d4cb3 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
sam_grove | 5:3f93dd1d4cb3 | 10 | * substantial portions of the Software. |
sam_grove | 5:3f93dd1d4cb3 | 11 | * |
sam_grove | 5:3f93dd1d4cb3 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
sam_grove | 5:3f93dd1d4cb3 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
sam_grove | 5:3f93dd1d4cb3 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
sam_grove | 5:3f93dd1d4cb3 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
sam_grove | 5:3f93dd1d4cb3 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
sam_grove | 5:3f93dd1d4cb3 | 17 | */ |
sam_grove | 5:3f93dd1d4cb3 | 18 | |
sam_grove | 5:3f93dd1d4cb3 | 19 | #ifndef UDPSOCKET_H |
sam_grove | 5:3f93dd1d4cb3 | 20 | #define UDPSOCKET_H |
sam_grove | 5:3f93dd1d4cb3 | 21 | |
sam_grove | 5:3f93dd1d4cb3 | 22 | #include "Socket/Socket.h" |
sam_grove | 5:3f93dd1d4cb3 | 23 | #include "Socket/Endpoint.h" |
sam_grove | 5:3f93dd1d4cb3 | 24 | |
sam_grove | 5:3f93dd1d4cb3 | 25 | #include <cstdint> |
sam_grove | 5:3f93dd1d4cb3 | 26 | |
sam_grove | 5:3f93dd1d4cb3 | 27 | /** |
sam_grove | 5:3f93dd1d4cb3 | 28 | UDP Socket |
sam_grove | 5:3f93dd1d4cb3 | 29 | */ |
sam_grove | 5:3f93dd1d4cb3 | 30 | class UDPSocket : public Socket { |
sam_grove | 5:3f93dd1d4cb3 | 31 | |
sam_grove | 5:3f93dd1d4cb3 | 32 | public: |
sam_grove | 5:3f93dd1d4cb3 | 33 | /** Instantiate an UDP Socket. |
sam_grove | 5:3f93dd1d4cb3 | 34 | */ |
sam_grove | 5:3f93dd1d4cb3 | 35 | UDPSocket(); |
sam_grove | 5:3f93dd1d4cb3 | 36 | |
sam_grove | 5:3f93dd1d4cb3 | 37 | /** Init the UDP Client Socket without binding it to any specific port |
sam_grove | 5:3f93dd1d4cb3 | 38 | \return 0 on success, -1 on failure. |
sam_grove | 5:3f93dd1d4cb3 | 39 | */ |
sam_grove | 5:3f93dd1d4cb3 | 40 | int init(void); |
sam_grove | 5:3f93dd1d4cb3 | 41 | |
sam_grove | 5:3f93dd1d4cb3 | 42 | /** Bind a UDP Server Socket to a specific port |
sam_grove | 5:3f93dd1d4cb3 | 43 | \param port The port to listen for incoming connections on |
sam_grove | 5:3f93dd1d4cb3 | 44 | \return 0 on success, -1 on failure. |
sam_grove | 5:3f93dd1d4cb3 | 45 | */ |
sam_grove | 5:3f93dd1d4cb3 | 46 | int bind(int port); |
sam_grove | 5:3f93dd1d4cb3 | 47 | |
sam_grove | 5:3f93dd1d4cb3 | 48 | /** Send a packet to a remote endpoint |
sam_grove | 5:3f93dd1d4cb3 | 49 | \param remote The remote endpoint |
sam_grove | 5:3f93dd1d4cb3 | 50 | \param packet The packet to be sent |
sam_grove | 5:3f93dd1d4cb3 | 51 | \param length The length of the packet to be sent |
sam_grove | 5:3f93dd1d4cb3 | 52 | \return the number of written bytes on success (>=0) or -1 on failure |
sam_grove | 5:3f93dd1d4cb3 | 53 | */ |
sam_grove | 5:3f93dd1d4cb3 | 54 | int sendTo(Endpoint &remote, char *packet, int length); |
sam_grove | 5:3f93dd1d4cb3 | 55 | |
sam_grove | 5:3f93dd1d4cb3 | 56 | /** Receive a packet from a remote endpoint |
sam_grove | 5:3f93dd1d4cb3 | 57 | \param remote The remote endpoint |
sam_grove | 5:3f93dd1d4cb3 | 58 | \param buffer The buffer for storing the incoming packet data. If a packet |
sam_grove | 5:3f93dd1d4cb3 | 59 | is too long to fit in the supplied buffer, excess bytes are discarded |
sam_grove | 5:3f93dd1d4cb3 | 60 | \param length The length of the buffer |
sam_grove | 5:3f93dd1d4cb3 | 61 | \return the number of received bytes on success (>=0) or -1 on failure |
sam_grove | 5:3f93dd1d4cb3 | 62 | */ |
sam_grove | 5:3f93dd1d4cb3 | 63 | int receiveFrom(Endpoint &remote, char *buffer, int length); |
sam_grove | 5:3f93dd1d4cb3 | 64 | }; |
sam_grove | 5:3f93dd1d4cb3 | 65 | |
sam_grove | 5:3f93dd1d4cb3 | 66 | #endif |