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) 2010-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
sam_grove 5:3f93dd1d4cb3 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
sam_grove 5:3f93dd1d4cb3 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
sam_grove 5:3f93dd1d4cb3 7 * Software is 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 WANDONGLESERIALPORT_H
sam_grove 5:3f93dd1d4cb3 20 #define WANDONGLESERIALPORT_H
sam_grove 5:3f93dd1d4cb3 21
sam_grove 5:3f93dd1d4cb3 22 #include "USBHost.h"
sam_grove 5:3f93dd1d4cb3 23 #include "IUSBHostSerial.h"
sam_grove 5:3f93dd1d4cb3 24
sam_grove 5:3f93dd1d4cb3 25 #include "rtos.h"
sam_grove 5:3f93dd1d4cb3 26
sam_grove 5:3f93dd1d4cb3 27
sam_grove 5:3f93dd1d4cb3 28 #define WANDONGLE_MAX_OUTEP_SIZE 64
sam_grove 5:3f93dd1d4cb3 29 #define WANDONGLE_MAX_INEP_SIZE 64
sam_grove 5:3f93dd1d4cb3 30
sam_grove 5:3f93dd1d4cb3 31 /** A class to use a WAN (3G/LTE) access dongle
sam_grove 5:3f93dd1d4cb3 32 *
sam_grove 5:3f93dd1d4cb3 33 */
sam_grove 5:3f93dd1d4cb3 34 class WANDongleSerialPort : public IUSBHostSerial {
sam_grove 5:3f93dd1d4cb3 35 public:
sam_grove 5:3f93dd1d4cb3 36 /*
sam_grove 5:3f93dd1d4cb3 37 * Constructor
sam_grove 5:3f93dd1d4cb3 38 *
sam_grove 5:3f93dd1d4cb3 39 */
sam_grove 5:3f93dd1d4cb3 40 WANDongleSerialPort();
sam_grove 5:3f93dd1d4cb3 41
sam_grove 5:3f93dd1d4cb3 42 void init( USBHost* pHost );
sam_grove 5:3f93dd1d4cb3 43
sam_grove 5:3f93dd1d4cb3 44 void connect( USBDeviceConnected* pDev, USBEndpoint* pInEp, USBEndpoint* pOutEp );
sam_grove 5:3f93dd1d4cb3 45
sam_grove 5:3f93dd1d4cb3 46 void disconnect( );
sam_grove 5:3f93dd1d4cb3 47
sam_grove 5:3f93dd1d4cb3 48 /*
sam_grove 5:3f93dd1d4cb3 49 * Get a char from the dongle's serial interface
sam_grove 5:3f93dd1d4cb3 50 */
sam_grove 5:3f93dd1d4cb3 51 virtual int getc();
sam_grove 5:3f93dd1d4cb3 52
sam_grove 5:3f93dd1d4cb3 53 /*
sam_grove 5:3f93dd1d4cb3 54 * Put a char to the dongle's serial interface
sam_grove 5:3f93dd1d4cb3 55 */
sam_grove 5:3f93dd1d4cb3 56 virtual int putc(int c);
sam_grove 5:3f93dd1d4cb3 57
sam_grove 5:3f93dd1d4cb3 58 /*
sam_grove 5:3f93dd1d4cb3 59 * Read a packet from the dongle's serial interface, to be called after multiple getc() calls
sam_grove 5:3f93dd1d4cb3 60 */
sam_grove 5:3f93dd1d4cb3 61 virtual int readPacket();
sam_grove 5:3f93dd1d4cb3 62
sam_grove 5:3f93dd1d4cb3 63 /*
sam_grove 5:3f93dd1d4cb3 64 * Write a packet to the dongle's serial interface, to be called after multiple putc() calls
sam_grove 5:3f93dd1d4cb3 65 */
sam_grove 5:3f93dd1d4cb3 66 virtual int writePacket();
sam_grove 5:3f93dd1d4cb3 67
sam_grove 5:3f93dd1d4cb3 68 /**
sam_grove 5:3f93dd1d4cb3 69 * Check the number of bytes available.
sam_grove 5:3f93dd1d4cb3 70 *
sam_grove 5:3f93dd1d4cb3 71 * @returns the number of bytes available
sam_grove 5:3f93dd1d4cb3 72 */
sam_grove 5:3f93dd1d4cb3 73 virtual int readable();
sam_grove 5:3f93dd1d4cb3 74
sam_grove 5:3f93dd1d4cb3 75 /**
sam_grove 5:3f93dd1d4cb3 76 * Check the free space in output.
sam_grove 5:3f93dd1d4cb3 77 *
sam_grove 5:3f93dd1d4cb3 78 * @returns the number of bytes available
sam_grove 5:3f93dd1d4cb3 79 */
sam_grove 5:3f93dd1d4cb3 80 virtual int writeable();
sam_grove 5:3f93dd1d4cb3 81
sam_grove 5:3f93dd1d4cb3 82 /**
sam_grove 5:3f93dd1d4cb3 83 * Attach a handler to call when a packet is received / when a packet has been transmitted.
sam_grove 5:3f93dd1d4cb3 84 *
sam_grove 5:3f93dd1d4cb3 85 * @param pListener instance of the listener deriving from the IUSBHostSerialListener
sam_grove 5:3f93dd1d4cb3 86 */
sam_grove 5:3f93dd1d4cb3 87 virtual void attach(IUSBHostSerialListener* pListener);
sam_grove 5:3f93dd1d4cb3 88
sam_grove 5:3f93dd1d4cb3 89 /**
sam_grove 5:3f93dd1d4cb3 90 * Enable or disable readable/writeable callbacks
sam_grove 5:3f93dd1d4cb3 91 */
sam_grove 5:3f93dd1d4cb3 92 virtual void setupIrq(bool en, IrqType irq = RxIrq);
sam_grove 5:3f93dd1d4cb3 93
sam_grove 5:3f93dd1d4cb3 94
sam_grove 5:3f93dd1d4cb3 95 protected:
sam_grove 5:3f93dd1d4cb3 96 USBEndpoint * bulk_in;
sam_grove 5:3f93dd1d4cb3 97 USBEndpoint * bulk_out;
sam_grove 5:3f93dd1d4cb3 98 USBHost * host;
sam_grove 5:3f93dd1d4cb3 99 USBDeviceConnected * dev;
sam_grove 5:3f93dd1d4cb3 100
sam_grove 5:3f93dd1d4cb3 101 uint8_t buf_out[WANDONGLE_MAX_OUTEP_SIZE];
sam_grove 5:3f93dd1d4cb3 102 volatile uint32_t buf_out_len;
sam_grove 5:3f93dd1d4cb3 103 uint32_t max_out_size;
sam_grove 5:3f93dd1d4cb3 104 volatile bool lock_tx;
sam_grove 5:3f93dd1d4cb3 105 volatile bool cb_tx_en;
sam_grove 5:3f93dd1d4cb3 106 volatile bool cb_tx_pending;
sam_grove 5:3f93dd1d4cb3 107 Mutex tx_mtx;
sam_grove 5:3f93dd1d4cb3 108
sam_grove 5:3f93dd1d4cb3 109 uint8_t buf_in[WANDONGLE_MAX_INEP_SIZE];
sam_grove 5:3f93dd1d4cb3 110 volatile uint32_t buf_in_len;
sam_grove 5:3f93dd1d4cb3 111 volatile uint32_t buf_in_read_pos;
sam_grove 5:3f93dd1d4cb3 112 volatile bool lock_rx;
sam_grove 5:3f93dd1d4cb3 113 volatile bool cb_rx_en;
sam_grove 5:3f93dd1d4cb3 114 volatile bool cb_rx_pending;
sam_grove 5:3f93dd1d4cb3 115 Mutex rx_mtx;
sam_grove 5:3f93dd1d4cb3 116
sam_grove 5:3f93dd1d4cb3 117 IUSBHostSerialListener* listener;
sam_grove 5:3f93dd1d4cb3 118
sam_grove 5:3f93dd1d4cb3 119 void reset();
sam_grove 5:3f93dd1d4cb3 120
sam_grove 5:3f93dd1d4cb3 121 void rxHandler();
sam_grove 5:3f93dd1d4cb3 122 void txHandler();
sam_grove 5:3f93dd1d4cb3 123
sam_grove 5:3f93dd1d4cb3 124 };
sam_grove 5:3f93dd1d4cb3 125
sam_grove 5:3f93dd1d4cb3 126 #endif