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 /**
sam_grove 5:3f93dd1d4cb3 2 * @file
sam_grove 5:3f93dd1d4cb3 3 * Network Interface Sequential API module
sam_grove 5:3f93dd1d4cb3 4 *
sam_grove 5:3f93dd1d4cb3 5 */
sam_grove 5:3f93dd1d4cb3 6
sam_grove 5:3f93dd1d4cb3 7 /*
sam_grove 5:3f93dd1d4cb3 8 * Redistribution and use in source and binary forms, with or without modification,
sam_grove 5:3f93dd1d4cb3 9 * are permitted provided that the following conditions are met:
sam_grove 5:3f93dd1d4cb3 10 *
sam_grove 5:3f93dd1d4cb3 11 * 1. Redistributions of source code must retain the above copyright notice,
sam_grove 5:3f93dd1d4cb3 12 * this list of conditions and the following disclaimer.
sam_grove 5:3f93dd1d4cb3 13 * 2. Redistributions in binary form must reproduce the above copyright notice,
sam_grove 5:3f93dd1d4cb3 14 * this list of conditions and the following disclaimer in the documentation
sam_grove 5:3f93dd1d4cb3 15 * and/or other materials provided with the distribution.
sam_grove 5:3f93dd1d4cb3 16 * 3. The name of the author may not be used to endorse or promote products
sam_grove 5:3f93dd1d4cb3 17 * derived from this software without specific prior written permission.
sam_grove 5:3f93dd1d4cb3 18 *
sam_grove 5:3f93dd1d4cb3 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
sam_grove 5:3f93dd1d4cb3 20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
sam_grove 5:3f93dd1d4cb3 21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
sam_grove 5:3f93dd1d4cb3 22 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
sam_grove 5:3f93dd1d4cb3 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
sam_grove 5:3f93dd1d4cb3 24 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
sam_grove 5:3f93dd1d4cb3 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
sam_grove 5:3f93dd1d4cb3 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
sam_grove 5:3f93dd1d4cb3 27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
sam_grove 5:3f93dd1d4cb3 28 * OF SUCH DAMAGE.
sam_grove 5:3f93dd1d4cb3 29 *
sam_grove 5:3f93dd1d4cb3 30 * This file is part of the lwIP TCP/IP stack.
sam_grove 5:3f93dd1d4cb3 31 *
sam_grove 5:3f93dd1d4cb3 32 */
sam_grove 5:3f93dd1d4cb3 33
sam_grove 5:3f93dd1d4cb3 34 #include "lwip/opt.h"
sam_grove 5:3f93dd1d4cb3 35
sam_grove 5:3f93dd1d4cb3 36 #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
sam_grove 5:3f93dd1d4cb3 37
sam_grove 5:3f93dd1d4cb3 38 #include "lwip/netifapi.h"
sam_grove 5:3f93dd1d4cb3 39 #include "lwip/tcpip.h"
sam_grove 5:3f93dd1d4cb3 40
sam_grove 5:3f93dd1d4cb3 41 /**
sam_grove 5:3f93dd1d4cb3 42 * Call netif_add() inside the tcpip_thread context.
sam_grove 5:3f93dd1d4cb3 43 */
sam_grove 5:3f93dd1d4cb3 44 void
sam_grove 5:3f93dd1d4cb3 45 do_netifapi_netif_add(struct netifapi_msg_msg *msg)
sam_grove 5:3f93dd1d4cb3 46 {
sam_grove 5:3f93dd1d4cb3 47 if (!netif_add( msg->netif,
sam_grove 5:3f93dd1d4cb3 48 msg->msg.add.ipaddr,
sam_grove 5:3f93dd1d4cb3 49 msg->msg.add.netmask,
sam_grove 5:3f93dd1d4cb3 50 msg->msg.add.gw,
sam_grove 5:3f93dd1d4cb3 51 msg->msg.add.state,
sam_grove 5:3f93dd1d4cb3 52 msg->msg.add.init,
sam_grove 5:3f93dd1d4cb3 53 msg->msg.add.input)) {
sam_grove 5:3f93dd1d4cb3 54 msg->err = ERR_IF;
sam_grove 5:3f93dd1d4cb3 55 } else {
sam_grove 5:3f93dd1d4cb3 56 msg->err = ERR_OK;
sam_grove 5:3f93dd1d4cb3 57 }
sam_grove 5:3f93dd1d4cb3 58 TCPIP_NETIFAPI_ACK(msg);
sam_grove 5:3f93dd1d4cb3 59 }
sam_grove 5:3f93dd1d4cb3 60
sam_grove 5:3f93dd1d4cb3 61 /**
sam_grove 5:3f93dd1d4cb3 62 * Call netif_set_addr() inside the tcpip_thread context.
sam_grove 5:3f93dd1d4cb3 63 */
sam_grove 5:3f93dd1d4cb3 64 void
sam_grove 5:3f93dd1d4cb3 65 do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg)
sam_grove 5:3f93dd1d4cb3 66 {
sam_grove 5:3f93dd1d4cb3 67 netif_set_addr( msg->netif,
sam_grove 5:3f93dd1d4cb3 68 msg->msg.add.ipaddr,
sam_grove 5:3f93dd1d4cb3 69 msg->msg.add.netmask,
sam_grove 5:3f93dd1d4cb3 70 msg->msg.add.gw);
sam_grove 5:3f93dd1d4cb3 71 msg->err = ERR_OK;
sam_grove 5:3f93dd1d4cb3 72 TCPIP_NETIFAPI_ACK(msg);
sam_grove 5:3f93dd1d4cb3 73 }
sam_grove 5:3f93dd1d4cb3 74
sam_grove 5:3f93dd1d4cb3 75 /**
sam_grove 5:3f93dd1d4cb3 76 * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the
sam_grove 5:3f93dd1d4cb3 77 * tcpip_thread context.
sam_grove 5:3f93dd1d4cb3 78 */
sam_grove 5:3f93dd1d4cb3 79 void
sam_grove 5:3f93dd1d4cb3 80 do_netifapi_netif_common(struct netifapi_msg_msg *msg)
sam_grove 5:3f93dd1d4cb3 81 {
sam_grove 5:3f93dd1d4cb3 82 if (msg->msg.common.errtfunc != NULL) {
sam_grove 5:3f93dd1d4cb3 83 msg->err = msg->msg.common.errtfunc(msg->netif);
sam_grove 5:3f93dd1d4cb3 84 } else {
sam_grove 5:3f93dd1d4cb3 85 msg->err = ERR_OK;
sam_grove 5:3f93dd1d4cb3 86 msg->msg.common.voidfunc(msg->netif);
sam_grove 5:3f93dd1d4cb3 87 }
sam_grove 5:3f93dd1d4cb3 88 TCPIP_NETIFAPI_ACK(msg);
sam_grove 5:3f93dd1d4cb3 89 }
sam_grove 5:3f93dd1d4cb3 90
sam_grove 5:3f93dd1d4cb3 91 /**
sam_grove 5:3f93dd1d4cb3 92 * Call netif_add() in a thread-safe way by running that function inside the
sam_grove 5:3f93dd1d4cb3 93 * tcpip_thread context.
sam_grove 5:3f93dd1d4cb3 94 *
sam_grove 5:3f93dd1d4cb3 95 * @note for params @see netif_add()
sam_grove 5:3f93dd1d4cb3 96 */
sam_grove 5:3f93dd1d4cb3 97 err_t
sam_grove 5:3f93dd1d4cb3 98 netifapi_netif_add(struct netif *netif,
sam_grove 5:3f93dd1d4cb3 99 ip_addr_t *ipaddr,
sam_grove 5:3f93dd1d4cb3 100 ip_addr_t *netmask,
sam_grove 5:3f93dd1d4cb3 101 ip_addr_t *gw,
sam_grove 5:3f93dd1d4cb3 102 void *state,
sam_grove 5:3f93dd1d4cb3 103 netif_init_fn init,
sam_grove 5:3f93dd1d4cb3 104 netif_input_fn input)
sam_grove 5:3f93dd1d4cb3 105 {
sam_grove 5:3f93dd1d4cb3 106 struct netifapi_msg msg;
sam_grove 5:3f93dd1d4cb3 107 msg.function = do_netifapi_netif_add;
sam_grove 5:3f93dd1d4cb3 108 msg.msg.netif = netif;
sam_grove 5:3f93dd1d4cb3 109 msg.msg.msg.add.ipaddr = ipaddr;
sam_grove 5:3f93dd1d4cb3 110 msg.msg.msg.add.netmask = netmask;
sam_grove 5:3f93dd1d4cb3 111 msg.msg.msg.add.gw = gw;
sam_grove 5:3f93dd1d4cb3 112 msg.msg.msg.add.state = state;
sam_grove 5:3f93dd1d4cb3 113 msg.msg.msg.add.init = init;
sam_grove 5:3f93dd1d4cb3 114 msg.msg.msg.add.input = input;
sam_grove 5:3f93dd1d4cb3 115 TCPIP_NETIFAPI(&msg);
sam_grove 5:3f93dd1d4cb3 116 return msg.msg.err;
sam_grove 5:3f93dd1d4cb3 117 }
sam_grove 5:3f93dd1d4cb3 118
sam_grove 5:3f93dd1d4cb3 119 /**
sam_grove 5:3f93dd1d4cb3 120 * Call netif_set_addr() in a thread-safe way by running that function inside the
sam_grove 5:3f93dd1d4cb3 121 * tcpip_thread context.
sam_grove 5:3f93dd1d4cb3 122 *
sam_grove 5:3f93dd1d4cb3 123 * @note for params @see netif_set_addr()
sam_grove 5:3f93dd1d4cb3 124 */
sam_grove 5:3f93dd1d4cb3 125 err_t
sam_grove 5:3f93dd1d4cb3 126 netifapi_netif_set_addr(struct netif *netif,
sam_grove 5:3f93dd1d4cb3 127 ip_addr_t *ipaddr,
sam_grove 5:3f93dd1d4cb3 128 ip_addr_t *netmask,
sam_grove 5:3f93dd1d4cb3 129 ip_addr_t *gw)
sam_grove 5:3f93dd1d4cb3 130 {
sam_grove 5:3f93dd1d4cb3 131 struct netifapi_msg msg;
sam_grove 5:3f93dd1d4cb3 132 msg.function = do_netifapi_netif_set_addr;
sam_grove 5:3f93dd1d4cb3 133 msg.msg.netif = netif;
sam_grove 5:3f93dd1d4cb3 134 msg.msg.msg.add.ipaddr = ipaddr;
sam_grove 5:3f93dd1d4cb3 135 msg.msg.msg.add.netmask = netmask;
sam_grove 5:3f93dd1d4cb3 136 msg.msg.msg.add.gw = gw;
sam_grove 5:3f93dd1d4cb3 137 TCPIP_NETIFAPI(&msg);
sam_grove 5:3f93dd1d4cb3 138 return msg.msg.err;
sam_grove 5:3f93dd1d4cb3 139 }
sam_grove 5:3f93dd1d4cb3 140
sam_grove 5:3f93dd1d4cb3 141 /**
sam_grove 5:3f93dd1d4cb3 142 * call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe
sam_grove 5:3f93dd1d4cb3 143 * way by running that function inside the tcpip_thread context.
sam_grove 5:3f93dd1d4cb3 144 *
sam_grove 5:3f93dd1d4cb3 145 * @note use only for functions where there is only "netif" parameter.
sam_grove 5:3f93dd1d4cb3 146 */
sam_grove 5:3f93dd1d4cb3 147 err_t
sam_grove 5:3f93dd1d4cb3 148 netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
sam_grove 5:3f93dd1d4cb3 149 netifapi_errt_fn errtfunc)
sam_grove 5:3f93dd1d4cb3 150 {
sam_grove 5:3f93dd1d4cb3 151 struct netifapi_msg msg;
sam_grove 5:3f93dd1d4cb3 152 msg.function = do_netifapi_netif_common;
sam_grove 5:3f93dd1d4cb3 153 msg.msg.netif = netif;
sam_grove 5:3f93dd1d4cb3 154 msg.msg.msg.common.voidfunc = voidfunc;
sam_grove 5:3f93dd1d4cb3 155 msg.msg.msg.common.errtfunc = errtfunc;
sam_grove 5:3f93dd1d4cb3 156 TCPIP_NETIFAPI(&msg);
sam_grove 5:3f93dd1d4cb3 157 return msg.msg.err;
sam_grove 5:3f93dd1d4cb3 158 }
sam_grove 5:3f93dd1d4cb3 159
sam_grove 5:3f93dd1d4cb3 160 #endif /* LWIP_NETIF_API */