Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

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?

UserRevisionLine numberNew 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 #ifndef SOCKET_H_
sam_grove 5:3f93dd1d4cb3 19 #define SOCKET_H_
sam_grove 5:3f93dd1d4cb3 20
sam_grove 5:3f93dd1d4cb3 21 #include "lwip/sockets.h"
sam_grove 5:3f93dd1d4cb3 22 #include "lwip/netdb.h"
sam_grove 5:3f93dd1d4cb3 23
sam_grove 5:3f93dd1d4cb3 24 //DNS
sam_grove 5:3f93dd1d4cb3 25 inline struct hostent *gethostbyname(const char *name) {
sam_grove 5:3f93dd1d4cb3 26 return lwip_gethostbyname(name);
sam_grove 5:3f93dd1d4cb3 27 }
sam_grove 5:3f93dd1d4cb3 28
sam_grove 5:3f93dd1d4cb3 29 inline int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) {
sam_grove 5:3f93dd1d4cb3 30 return lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop);
sam_grove 5:3f93dd1d4cb3 31 }
sam_grove 5:3f93dd1d4cb3 32
sam_grove 5:3f93dd1d4cb3 33 class TimeInterval;
sam_grove 5:3f93dd1d4cb3 34
sam_grove 5:3f93dd1d4cb3 35 /** Socket file descriptor and select wrapper
sam_grove 5:3f93dd1d4cb3 36 */
sam_grove 5:3f93dd1d4cb3 37 class Socket {
sam_grove 5:3f93dd1d4cb3 38 public:
sam_grove 5:3f93dd1d4cb3 39 /** Socket
sam_grove 5:3f93dd1d4cb3 40 */
sam_grove 5:3f93dd1d4cb3 41 Socket();
sam_grove 5:3f93dd1d4cb3 42
sam_grove 5:3f93dd1d4cb3 43 /** Set blocking or non-blocking mode of the socket and a timeout on
sam_grove 5:3f93dd1d4cb3 44 blocking socket operations
sam_grove 5:3f93dd1d4cb3 45 \param blocking true for blocking mode, false for non-blocking mode.
sam_grove 5:3f93dd1d4cb3 46 \param timeout timeout in ms [Default: (1500)ms].
sam_grove 5:3f93dd1d4cb3 47 */
sam_grove 5:3f93dd1d4cb3 48 void set_blocking(bool blocking, unsigned int timeout=1500);
sam_grove 5:3f93dd1d4cb3 49
sam_grove 5:3f93dd1d4cb3 50 /** Close the socket file descriptor
sam_grove 5:3f93dd1d4cb3 51 */
sam_grove 5:3f93dd1d4cb3 52 int close();
sam_grove 5:3f93dd1d4cb3 53
sam_grove 5:3f93dd1d4cb3 54 ~Socket();
sam_grove 5:3f93dd1d4cb3 55
sam_grove 5:3f93dd1d4cb3 56 protected:
sam_grove 5:3f93dd1d4cb3 57 int _sock_fd;
sam_grove 5:3f93dd1d4cb3 58 int init_socket(int type);
sam_grove 5:3f93dd1d4cb3 59
sam_grove 5:3f93dd1d4cb3 60 int wait_readable(TimeInterval& timeout);
sam_grove 5:3f93dd1d4cb3 61 int wait_writable(TimeInterval& timeout);
sam_grove 5:3f93dd1d4cb3 62
sam_grove 5:3f93dd1d4cb3 63 bool _blocking;
sam_grove 5:3f93dd1d4cb3 64 unsigned int _timeout;
sam_grove 5:3f93dd1d4cb3 65
sam_grove 5:3f93dd1d4cb3 66 private:
sam_grove 5:3f93dd1d4cb3 67 int select(struct timeval *timeout, bool read, bool write);
sam_grove 5:3f93dd1d4cb3 68 };
sam_grove 5:3f93dd1d4cb3 69
sam_grove 5:3f93dd1d4cb3 70 /** Time interval class used to specify timeouts
sam_grove 5:3f93dd1d4cb3 71 */
sam_grove 5:3f93dd1d4cb3 72 class TimeInterval {
sam_grove 5:3f93dd1d4cb3 73 friend class Socket;
sam_grove 5:3f93dd1d4cb3 74
sam_grove 5:3f93dd1d4cb3 75 public:
sam_grove 5:3f93dd1d4cb3 76 /** Time Interval
sam_grove 5:3f93dd1d4cb3 77 \param ms time interval expressed in milliseconds
sam_grove 5:3f93dd1d4cb3 78 */
sam_grove 5:3f93dd1d4cb3 79 TimeInterval(unsigned int ms);
sam_grove 5:3f93dd1d4cb3 80
sam_grove 5:3f93dd1d4cb3 81 private:
sam_grove 5:3f93dd1d4cb3 82 struct timeval _time;
sam_grove 5:3f93dd1d4cb3 83 };
sam_grove 5:3f93dd1d4cb3 84
sam_grove 5:3f93dd1d4cb3 85 #endif /* SOCKET_H_ */