Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Tue Oct 08 00:08:22 2013 +0000
Revision:
21:3f45e53afe4f
Parent:
5:3f93dd1d4cb3
Added http client test. Return from post seems to be a bit wonky but haven't looked closely at this

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 #include "USBDeviceConnected.h"
sam_grove 5:3f93dd1d4cb3 20
sam_grove 5:3f93dd1d4cb3 21 USBDeviceConnected::USBDeviceConnected() {
sam_grove 5:3f93dd1d4cb3 22 init();
sam_grove 5:3f93dd1d4cb3 23 }
sam_grove 5:3f93dd1d4cb3 24
sam_grove 5:3f93dd1d4cb3 25 void USBDeviceConnected::init() {
sam_grove 5:3f93dd1d4cb3 26 hub = 0;
sam_grove 5:3f93dd1d4cb3 27 port = 0;
sam_grove 5:3f93dd1d4cb3 28 vid = 0;
sam_grove 5:3f93dd1d4cb3 29 pid = 0;
sam_grove 5:3f93dd1d4cb3 30 nb_interf = 0;
sam_grove 5:3f93dd1d4cb3 31 enumerated = false;
sam_grove 5:3f93dd1d4cb3 32 activeAddr = false;
sam_grove 5:3f93dd1d4cb3 33 sizeControlEndpoint = 8;
sam_grove 5:3f93dd1d4cb3 34 device_class = 0;
sam_grove 5:3f93dd1d4cb3 35 device_subclass = 0;
sam_grove 5:3f93dd1d4cb3 36 proto = 0;
sam_grove 5:3f93dd1d4cb3 37 speed = false;
sam_grove 5:3f93dd1d4cb3 38 for (int i = 0; i < MAX_INTF; i++) {
sam_grove 5:3f93dd1d4cb3 39 memset((void *)&intf[i], 0, sizeof(INTERFACE));
sam_grove 5:3f93dd1d4cb3 40 intf[i].in_use = false;
sam_grove 5:3f93dd1d4cb3 41 for (int j = 0; j < MAX_ENDPOINT_PER_INTERFACE; j++) {
sam_grove 5:3f93dd1d4cb3 42 intf[i].ep[j] = NULL;
sam_grove 5:3f93dd1d4cb3 43 }
sam_grove 5:3f93dd1d4cb3 44 }
sam_grove 5:3f93dd1d4cb3 45 }
sam_grove 5:3f93dd1d4cb3 46
sam_grove 5:3f93dd1d4cb3 47 INTERFACE * USBDeviceConnected::getInterface(uint8_t index) {
sam_grove 5:3f93dd1d4cb3 48 if (index >= MAX_INTF) {
sam_grove 5:3f93dd1d4cb3 49 return NULL;
sam_grove 5:3f93dd1d4cb3 50 }
sam_grove 5:3f93dd1d4cb3 51 return &intf[index];
sam_grove 5:3f93dd1d4cb3 52 }
sam_grove 5:3f93dd1d4cb3 53
sam_grove 5:3f93dd1d4cb3 54 bool USBDeviceConnected::addInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) {
sam_grove 5:3f93dd1d4cb3 55 if ((intf_nb >= MAX_INTF) || (intf[intf_nb].in_use)) {
sam_grove 5:3f93dd1d4cb3 56 return false;
sam_grove 5:3f93dd1d4cb3 57 }
sam_grove 5:3f93dd1d4cb3 58 intf[intf_nb].in_use = true;
sam_grove 5:3f93dd1d4cb3 59 intf[intf_nb].intf_class = intf_class;
sam_grove 5:3f93dd1d4cb3 60 intf[intf_nb].intf_subclass = intf_subclass;
sam_grove 5:3f93dd1d4cb3 61 intf[intf_nb].intf_protocol = intf_protocol;
sam_grove 5:3f93dd1d4cb3 62 intf[intf_nb].nb_endpoint = 0;
sam_grove 5:3f93dd1d4cb3 63 nb_interf++;
sam_grove 5:3f93dd1d4cb3 64 return true;
sam_grove 5:3f93dd1d4cb3 65 }
sam_grove 5:3f93dd1d4cb3 66
sam_grove 5:3f93dd1d4cb3 67 bool USBDeviceConnected::addEndpoint(uint8_t intf_nb, USBEndpoint * ept) {
sam_grove 5:3f93dd1d4cb3 68 if ((intf_nb >= MAX_INTF) || (intf[intf_nb].in_use == false) || (intf[intf_nb].nb_endpoint >= MAX_ENDPOINT_PER_INTERFACE)) {
sam_grove 5:3f93dd1d4cb3 69 return false;
sam_grove 5:3f93dd1d4cb3 70 }
sam_grove 5:3f93dd1d4cb3 71 intf[intf_nb].nb_endpoint++;
sam_grove 5:3f93dd1d4cb3 72
sam_grove 5:3f93dd1d4cb3 73 for (int i = 0; i < MAX_ENDPOINT_PER_INTERFACE; i++) {
sam_grove 5:3f93dd1d4cb3 74 if (intf[intf_nb].ep[i] == NULL) {
sam_grove 5:3f93dd1d4cb3 75 intf[intf_nb].ep[i] = ept;
sam_grove 5:3f93dd1d4cb3 76 return true;
sam_grove 5:3f93dd1d4cb3 77 }
sam_grove 5:3f93dd1d4cb3 78 }
sam_grove 5:3f93dd1d4cb3 79 return false;
sam_grove 5:3f93dd1d4cb3 80 }
sam_grove 5:3f93dd1d4cb3 81
sam_grove 5:3f93dd1d4cb3 82 void USBDeviceConnected::init(uint8_t hub, uint8_t port, bool lowSpeed) {
sam_grove 5:3f93dd1d4cb3 83 init();
sam_grove 5:3f93dd1d4cb3 84 this->hub = hub;
sam_grove 5:3f93dd1d4cb3 85 this->port = port;
sam_grove 5:3f93dd1d4cb3 86 this->speed = lowSpeed;
sam_grove 5:3f93dd1d4cb3 87 }
sam_grove 5:3f93dd1d4cb3 88
sam_grove 5:3f93dd1d4cb3 89 void USBDeviceConnected::disconnect() {
sam_grove 5:3f93dd1d4cb3 90 for(int i = 0; i < nb_interf; i++) {
sam_grove 5:3f93dd1d4cb3 91 intf[i].detach.call();
sam_grove 5:3f93dd1d4cb3 92 }
sam_grove 5:3f93dd1d4cb3 93 init();
sam_grove 5:3f93dd1d4cb3 94 }
sam_grove 5:3f93dd1d4cb3 95
sam_grove 5:3f93dd1d4cb3 96
sam_grove 5:3f93dd1d4cb3 97
sam_grove 5:3f93dd1d4cb3 98 USBEndpoint * USBDeviceConnected::getEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint8_t index) {
sam_grove 5:3f93dd1d4cb3 99 if (intf_nb >= MAX_INTF) {
sam_grove 5:3f93dd1d4cb3 100 return NULL;
sam_grove 5:3f93dd1d4cb3 101 }
sam_grove 5:3f93dd1d4cb3 102 for (int i = 0; i < MAX_ENDPOINT_PER_INTERFACE; i++) {
sam_grove 5:3f93dd1d4cb3 103 if ((intf[intf_nb].ep[i]->getType() == type) && (intf[intf_nb].ep[i]->getDir() == dir)) {
sam_grove 5:3f93dd1d4cb3 104 if(index)
sam_grove 5:3f93dd1d4cb3 105 {
sam_grove 5:3f93dd1d4cb3 106 index--;
sam_grove 5:3f93dd1d4cb3 107 }
sam_grove 5:3f93dd1d4cb3 108 else
sam_grove 5:3f93dd1d4cb3 109 {
sam_grove 5:3f93dd1d4cb3 110 return intf[intf_nb].ep[i];
sam_grove 5:3f93dd1d4cb3 111 }
sam_grove 5:3f93dd1d4cb3 112 }
sam_grove 5:3f93dd1d4cb3 113 }
sam_grove 5:3f93dd1d4cb3 114 return NULL;
sam_grove 5:3f93dd1d4cb3 115 }
sam_grove 5:3f93dd1d4cb3 116
sam_grove 5:3f93dd1d4cb3 117 USBEndpoint * USBDeviceConnected::getEndpoint(uint8_t intf_nb, uint8_t index) {
sam_grove 5:3f93dd1d4cb3 118 if ((intf_nb >= MAX_INTF) || (index >= MAX_ENDPOINT_PER_INTERFACE)) {
sam_grove 5:3f93dd1d4cb3 119 return NULL;
sam_grove 5:3f93dd1d4cb3 120 }
sam_grove 5:3f93dd1d4cb3 121 return intf[intf_nb].ep[index];
sam_grove 5:3f93dd1d4cb3 122 }