ublox-at-cellular-interface-ext
Dependencies: ublox-at-cellular-interface
UbloxATCellularInterfaceExt.h@11:3631f62bb359, 2017-06-16 (annotated)
- Committer:
- rob.meades@u-blox.com
- Date:
- Fri Jun 16 00:55:19 2017 +0100
- Revision:
- 11:3631f62bb359
- Parent:
- 5:9fd89567f769
- Child:
- 15:6f0a1ecc8cec
Remove return code from ftpResetPar() since not all modules support all parameters and hence it's not possible to be certain which are errors and which are normal. Change order of parameters in ftpCommand() as offset is truly optional (it is not supported by Sara-G350). Make switching on of +ULOCIND URC optional (it is only informative and is not supported by Sara-G350). Update UbloxAtCellularInterface library version. Update mbed_app.json templates. Don't run the HTTP TLS test on C027 as Sara-G350 doesn't support it.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobMeades | 0:0b75e22c9231 | 1 | /* Copyright (c) 2017 ARM Limited |
RobMeades | 0:0b75e22c9231 | 2 | * |
RobMeades | 0:0b75e22c9231 | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
RobMeades | 0:0b75e22c9231 | 4 | * you may not use this file except in compliance with the License. |
RobMeades | 0:0b75e22c9231 | 5 | * You may obtain a copy of the License at |
RobMeades | 0:0b75e22c9231 | 6 | * |
RobMeades | 0:0b75e22c9231 | 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
RobMeades | 0:0b75e22c9231 | 8 | * |
RobMeades | 0:0b75e22c9231 | 9 | * Unless required by applicable law or agreed to in writing, software |
RobMeades | 0:0b75e22c9231 | 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
RobMeades | 0:0b75e22c9231 | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
RobMeades | 0:0b75e22c9231 | 12 | * See the License for the specific language governing permissions and |
RobMeades | 0:0b75e22c9231 | 13 | * limitations under the License. |
RobMeades | 0:0b75e22c9231 | 14 | */ |
RobMeades | 0:0b75e22c9231 | 15 | |
RobMeades | 0:0b75e22c9231 | 16 | #ifndef _UBLOX_AT_CELLULAR_INTERFACE_EXT_ |
RobMeades | 0:0b75e22c9231 | 17 | #define _UBLOX_AT_CELLULAR_INTERFACE_EXT_ |
RobMeades | 0:0b75e22c9231 | 18 | |
rob.meades@u-blox.com | 5:9fd89567f769 | 19 | #include "UbloxATCellularInterface.h" |
RobMeades | 0:0b75e22c9231 | 20 | #include "UbloxCellularDriverGen.h" |
RobMeades | 0:0b75e22c9231 | 21 | |
RobMeades | 0:0b75e22c9231 | 22 | /**UbloxATCellularInterfaceExt class. |
RobMeades | 0:0b75e22c9231 | 23 | * |
RobMeades | 0:0b75e22c9231 | 24 | * This interface extends the UbloxATCellularInterface to |
RobMeades | 0:0b75e22c9231 | 25 | * include other features that use the IP stack on board the |
RobMeades | 0:0b75e22c9231 | 26 | * cellular modem: HTTP, FTP and Cell Locate. |
RobMeades | 0:0b75e22c9231 | 27 | * |
RobMeades | 0:0b75e22c9231 | 28 | * Note: the UbloxCellularGeneric class is required because |
RobMeades | 0:0b75e22c9231 | 29 | * reading a large HTTP response is performed via a modem |
RobMeades | 0:0b75e22c9231 | 30 | * file system call and the UbloxCellularGeneric class is |
RobMeades | 0:0b75e22c9231 | 31 | * where modem file system support is provided. |
RobMeades | 0:0b75e22c9231 | 32 | */ |
RobMeades | 0:0b75e22c9231 | 33 | class UbloxATCellularInterfaceExt : public UbloxATCellularInterface, public UbloxCellularDriverGen { |
RobMeades | 0:0b75e22c9231 | 34 | |
RobMeades | 0:0b75e22c9231 | 35 | public: |
RobMeades | 0:0b75e22c9231 | 36 | /** Constructor. |
RobMeades | 0:0b75e22c9231 | 37 | * |
RobMeades | 0:0b75e22c9231 | 38 | * @param tx the UART TX data pin to which the modem is attached. |
RobMeades | 0:0b75e22c9231 | 39 | * @param rx the UART RX data pin to which the modem is attached. |
RobMeades | 0:0b75e22c9231 | 40 | * @param baud the UART baud rate. |
RobMeades | 0:0b75e22c9231 | 41 | * @param debugOn true to switch AT interface debug on, otherwise false. |
RobMeades | 0:0b75e22c9231 | 42 | */ |
RobMeades | 0:0b75e22c9231 | 43 | UbloxATCellularInterfaceExt(PinName tx = MDMTXD, |
RobMeades | 0:0b75e22c9231 | 44 | PinName rx = MDMRXD, |
RobMeades | 0:0b75e22c9231 | 45 | int baud = MBED_CONF_UBLOX_CELL_BAUD_RATE, |
RobMeades | 0:0b75e22c9231 | 46 | bool debugOn = false); |
RobMeades | 0:0b75e22c9231 | 47 | |
RobMeades | 0:0b75e22c9231 | 48 | /* Destructor. |
RobMeades | 0:0b75e22c9231 | 49 | */ |
RobMeades | 0:0b75e22c9231 | 50 | virtual ~UbloxATCellularInterfaceExt(); |
RobMeades | 0:0b75e22c9231 | 51 | |
RobMeades | 0:0b75e22c9231 | 52 | /********************************************************************** |
RobMeades | 0:0b75e22c9231 | 53 | * PUBLIC: General |
RobMeades | 0:0b75e22c9231 | 54 | **********************************************************************/ |
RobMeades | 0:0b75e22c9231 | 55 | |
RobMeades | 0:0b75e22c9231 | 56 | /** Infinite timeout. |
RobMeades | 0:0b75e22c9231 | 57 | */ |
RobMeades | 0:0b75e22c9231 | 58 | #define TIMEOUT_BLOCKING -1 |
RobMeades | 0:0b75e22c9231 | 59 | |
RobMeades | 0:0b75e22c9231 | 60 | /** A struct containing an HTTP or FTP error class and code |
RobMeades | 0:0b75e22c9231 | 61 | */ |
RobMeades | 0:0b75e22c9231 | 62 | typedef struct { |
RobMeades | 0:0b75e22c9231 | 63 | int eClass; |
RobMeades | 0:0b75e22c9231 | 64 | int eCode; |
RobMeades | 0:0b75e22c9231 | 65 | } Error; |
RobMeades | 0:0b75e22c9231 | 66 | |
RobMeades | 0:0b75e22c9231 | 67 | /********************************************************************** |
RobMeades | 0:0b75e22c9231 | 68 | * PUBLIC: HTTP |
RobMeades | 0:0b75e22c9231 | 69 | **********************************************************************/ |
RobMeades | 0:0b75e22c9231 | 70 | |
RobMeades | 0:0b75e22c9231 | 71 | /** HTTP profile unused marker. |
RobMeades | 0:0b75e22c9231 | 72 | */ |
RobMeades | 0:0b75e22c9231 | 73 | #define HTTP_PROF_UNUSED -1 |
RobMeades | 0:0b75e22c9231 | 74 | |
RobMeades | 0:0b75e22c9231 | 75 | /** HTTP configuration parameters (reference to HTTP control +UHTTP). |
RobMeades | 0:0b75e22c9231 | 76 | */ |
RobMeades | 0:0b75e22c9231 | 77 | typedef enum { |
RobMeades | 0:0b75e22c9231 | 78 | HTTP_IP_ADDRESS = 0, |
RobMeades | 0:0b75e22c9231 | 79 | HTTP_SERVER_NAME = 1, |
RobMeades | 0:0b75e22c9231 | 80 | HTTP_USER_NAME = 2, |
RobMeades | 0:0b75e22c9231 | 81 | HTTP_PASSWORD = 3, |
RobMeades | 0:0b75e22c9231 | 82 | HTTP_AUTH_TYPE = 4, |
RobMeades | 0:0b75e22c9231 | 83 | HTTP_SERVER_PORT = 5, |
RobMeades | 0:0b75e22c9231 | 84 | HTTP_SECURE = 6 |
RobMeades | 0:0b75e22c9231 | 85 | } HttpOpCode; |
RobMeades | 0:0b75e22c9231 | 86 | |
RobMeades | 0:0b75e22c9231 | 87 | /** Type of HTTP Command. |
RobMeades | 0:0b75e22c9231 | 88 | */ |
RobMeades | 0:0b75e22c9231 | 89 | typedef enum { |
RobMeades | 0:0b75e22c9231 | 90 | HTTP_HEAD = 0, |
RobMeades | 0:0b75e22c9231 | 91 | HTTP_GET = 1, |
RobMeades | 0:0b75e22c9231 | 92 | HTTP_DELETE = 2, |
RobMeades | 0:0b75e22c9231 | 93 | HTTP_PUT = 3, |
RobMeades | 0:0b75e22c9231 | 94 | HTTP_POST_FILE = 4, |
RobMeades | 0:0b75e22c9231 | 95 | HTTP_POST_DATA = 5 |
RobMeades | 0:0b75e22c9231 | 96 | } HttpCmd; |
RobMeades | 0:0b75e22c9231 | 97 | |
RobMeades | 0:0b75e22c9231 | 98 | /** HTTP content types. |
RobMeades | 0:0b75e22c9231 | 99 | */ |
RobMeades | 0:0b75e22c9231 | 100 | typedef enum { |
RobMeades | 0:0b75e22c9231 | 101 | HTTP_CONTENT_URLENCODED = 0, |
RobMeades | 0:0b75e22c9231 | 102 | HTTP_CONTENT_TEXT = 1, |
RobMeades | 0:0b75e22c9231 | 103 | HTTP_CONTENT_OCTET_STREAM = 2, |
RobMeades | 0:0b75e22c9231 | 104 | HTTP_CONTENT_FORM_DATA = 3, |
RobMeades | 0:0b75e22c9231 | 105 | HTTP_CONTENT_JSON = 4, |
RobMeades | 0:0b75e22c9231 | 106 | HTTP_CONTENT_XML = 5, |
RobMeades | 0:0b75e22c9231 | 107 | HTTP_CONTENT_USER_DEFINED = 6 |
RobMeades | 0:0b75e22c9231 | 108 | } HttpContentType; |
RobMeades | 0:0b75e22c9231 | 109 | |
RobMeades | 0:0b75e22c9231 | 110 | /** Find a free HTTP profile. |
RobMeades | 0:0b75e22c9231 | 111 | * |
RobMeades | 0:0b75e22c9231 | 112 | * A profile will be blocking when first allocated. |
RobMeades | 0:0b75e22c9231 | 113 | * |
RobMeades | 0:0b75e22c9231 | 114 | * @return the profile or negative if none are available. |
RobMeades | 0:0b75e22c9231 | 115 | */ |
RobMeades | 0:0b75e22c9231 | 116 | int httpAllocProfile(); |
RobMeades | 0:0b75e22c9231 | 117 | |
RobMeades | 0:0b75e22c9231 | 118 | /** Free the HTTP profile. |
RobMeades | 0:0b75e22c9231 | 119 | * |
RobMeades | 0:0b75e22c9231 | 120 | * @param profile the HTTP profile handle. |
RobMeades | 0:0b75e22c9231 | 121 | * @return true if successful, otherwise false. |
RobMeades | 0:0b75e22c9231 | 122 | */ |
RobMeades | 0:0b75e22c9231 | 123 | bool httpFreeProfile(int profile); |
RobMeades | 0:0b75e22c9231 | 124 | |
RobMeades | 0:0b75e22c9231 | 125 | /** Set the timeout for this profile. |
RobMeades | 0:0b75e22c9231 | 126 | * |
RobMeades | 0:0b75e22c9231 | 127 | * @param profile the HTTP profile handle. |
RobMeades | 0:0b75e22c9231 | 128 | * @param timeout -1 blocking, else non-blocking timeout in milliseconds. |
RobMeades | 0:0b75e22c9231 | 129 | * @return true if successful, otherwise false. |
RobMeades | 0:0b75e22c9231 | 130 | */ |
RobMeades | 0:0b75e22c9231 | 131 | bool httpSetTimeout(int profile, int timeout); |
RobMeades | 0:0b75e22c9231 | 132 | |
RobMeades | 0:0b75e22c9231 | 133 | /** Reset a HTTP profile back to defaults. |
RobMeades | 0:0b75e22c9231 | 134 | * |
RobMeades | 0:0b75e22c9231 | 135 | * This may be called if the state of a HTTP profile |
RobMeades | 0:0b75e22c9231 | 136 | * during parameter setting or exchange of HTTP commands |
RobMeades | 0:0b75e22c9231 | 137 | * has become confusing/unknown. |
RobMeades | 0:0b75e22c9231 | 138 | * |
RobMeades | 0:0b75e22c9231 | 139 | * @param httpProfile the HTTP profile to be reset. |
RobMeades | 0:0b75e22c9231 | 140 | * @return true if successful, false otherwise. |
RobMeades | 0:0b75e22c9231 | 141 | */ |
RobMeades | 0:0b75e22c9231 | 142 | bool httpResetProfile(int httpProfile); |
RobMeades | 0:0b75e22c9231 | 143 | |
RobMeades | 0:0b75e22c9231 | 144 | /** Set HTTP parameters. |
RobMeades | 0:0b75e22c9231 | 145 | * |
RobMeades | 0:0b75e22c9231 | 146 | * This should be called as many times as is necessary |
RobMeades | 0:0b75e22c9231 | 147 | * to set all the possible parameters (HttpOpCode). |
RobMeades | 0:0b75e22c9231 | 148 | * |
RobMeades | 0:0b75e22c9231 | 149 | * See section 28.1 of u-blox-ATCommands_Manual(UBX-13002752).pdf |
RobMeades | 0:0b75e22c9231 | 150 | * for full details. By example: |
RobMeades | 0:0b75e22c9231 | 151 | * |
RobMeades | 0:0b75e22c9231 | 152 | * httpOpCode httpInPar |
RobMeades | 0:0b75e22c9231 | 153 | * HTTP_IP_ADDRESS "145.33.18.10" (the target HTTP server IP address) |
RobMeades | 0:0b75e22c9231 | 154 | * HTTP_SERVER_NAME "www.myhttpserver.com" (the target HTTP server name) |
RobMeades | 0:0b75e22c9231 | 155 | * HTTP_USER_NAME "my_username" |
RobMeades | 0:0b75e22c9231 | 156 | * HTTP_PASSWORD "my_password" |
RobMeades | 0:0b75e22c9231 | 157 | * HTTP_AUTH_TYPE "0" for no authentication, "1" for username/password |
RobMeades | 0:0b75e22c9231 | 158 | * authentication (the default is 0) |
RobMeades | 0:0b75e22c9231 | 159 | * HTTP_SERVER_PORT "81" (default is port 80) |
rob.meades@u-blox.com | 11:3631f62bb359 | 160 | * HTTP_SECURE "0" for no security, "1" for TLS (the default is 0), |
rob.meades@u-blox.com | 11:3631f62bb359 | 161 | * not all modems support this parameter |
RobMeades | 0:0b75e22c9231 | 162 | * |
RobMeades | 0:0b75e22c9231 | 163 | * @param httpProfile the HTTP profile identifier. |
RobMeades | 0:0b75e22c9231 | 164 | * @param httpOpCode the HTTP operation code. |
RobMeades | 0:0b75e22c9231 | 165 | * @param httpInPar the HTTP input parameter. |
RobMeades | 0:0b75e22c9231 | 166 | * @return true if successful, false otherwise. |
RobMeades | 0:0b75e22c9231 | 167 | */ |
RobMeades | 0:0b75e22c9231 | 168 | bool httpSetPar(int httpProfile, HttpOpCode httpOpCode, const char * httpInPar); |
RobMeades | 0:0b75e22c9231 | 169 | |
RobMeades | 0:0b75e22c9231 | 170 | /** Perform a HTTP command. |
RobMeades | 0:0b75e22c9231 | 171 | * |
RobMeades | 0:0b75e22c9231 | 172 | * See section 28.3 of u-blox-ATCommands_Manual(UBX-13002752).pdf |
RobMeades | 0:0b75e22c9231 | 173 | * for full details. By example, it works like this: |
RobMeades | 0:0b75e22c9231 | 174 | * |
RobMeades | 0:0b75e22c9231 | 175 | * httpCmd httpPath rspFile sendStr httpContentType httpCustomPar |
RobMeades | 0:0b75e22c9231 | 176 | * HEAD "path/file.html" NULL NULL 0 NULL |
RobMeades | 0:0b75e22c9231 | 177 | * GET "path/file.html" NULL NULL 0 NULL |
RobMeades | 0:0b75e22c9231 | 178 | * DELETE "path/file.html" NULL NULL 0 NULL |
RobMeades | 0:0b75e22c9231 | 179 | * PUT "path/file.html" NULL "myfile.txt" 0 to 6 Note 1 |
RobMeades | 0:0b75e22c9231 | 180 | * POST_FILE "path/file.html" NULL "myfile.txt" 0 to 6 Note 1 |
RobMeades | 0:0b75e22c9231 | 181 | * POST "path/file.html" NULL "hello there!" 0 to 6 Note 1 |
RobMeades | 0:0b75e22c9231 | 182 | * |
RobMeades | 0:0b75e22c9231 | 183 | * Note 1: httpCustomPar is only applicable when httpContentType = HTTP_CONTENT_USER_DEFINED. |
RobMeades | 0:0b75e22c9231 | 184 | * |
RobMeades | 0:0b75e22c9231 | 185 | * The server to which this command is directed must have previously been |
RobMeades | 0:0b75e22c9231 | 186 | * set with a call to httpSetPar(). If the server requires TLS (i.e. "HTTPS"), |
RobMeades | 0:0b75e22c9231 | 187 | * then set that up with httpSetPar() also (HTTP_SECURE). |
RobMeades | 0:0b75e22c9231 | 188 | * |
RobMeades | 0:0b75e22c9231 | 189 | * rspFile may be left as NULL as the server response will be returned in buf. |
RobMeades | 0:0b75e22c9231 | 190 | * Alternatively, a rspFile may be given (e.g. "myresponse.txt") and this can |
RobMeades | 0:0b75e22c9231 | 191 | * later be read from the modem file system using readFile(). |
RobMeades | 0:0b75e22c9231 | 192 | * |
RobMeades | 0:0b75e22c9231 | 193 | * @param httpProfile the HTTP profile identifier. |
RobMeades | 0:0b75e22c9231 | 194 | * @param httpCmd the HTTP command. |
RobMeades | 0:0b75e22c9231 | 195 | * @param httpPath the path of resource on the HTTP server. |
RobMeades | 0:0b75e22c9231 | 196 | * @param rspFile the local modem file where the server |
RobMeades | 0:0b75e22c9231 | 197 | * response will be stored, use NULL for |
RobMeades | 0:0b75e22c9231 | 198 | * don't care. |
RobMeades | 0:0b75e22c9231 | 199 | * @param sendStr the filename or string to be sent |
RobMeades | 0:0b75e22c9231 | 200 | * to the HTTP server with the command request. |
RobMeades | 0:0b75e22c9231 | 201 | * @param httpContentType the HTTP Content-Type identifier. |
RobMeades | 0:0b75e22c9231 | 202 | * @param httpCustomPar the parameter for a user defined HTTP Content-Type. |
RobMeades | 0:0b75e22c9231 | 203 | * @param buf the buffer to read into. |
RobMeades | 0:0b75e22c9231 | 204 | * @param len the size of the buffer to read into. |
RobMeades | 0:0b75e22c9231 | 205 | * @return NULL if successful, otherwise a pointer to |
RobMeades | 0:0b75e22c9231 | 206 | * a Error struct containing the error class and error |
RobMeades | 0:0b75e22c9231 | 207 | * code, see section Appendix A.B of |
RobMeades | 0:0b75e22c9231 | 208 | * u-blox-ATCommands_Manual(UBX-13002752).pdf for details. |
RobMeades | 0:0b75e22c9231 | 209 | */ |
RobMeades | 0:0b75e22c9231 | 210 | Error * httpCommand(int httpProfile, HttpCmd httpCmd, const char* httpPath, |
RobMeades | 0:0b75e22c9231 | 211 | const char* rspFile, const char* sendStr, |
RobMeades | 0:0b75e22c9231 | 212 | int httpContentType, const char* httpCustomPar, |
RobMeades | 0:0b75e22c9231 | 213 | char* buf, int len); |
RobMeades | 0:0b75e22c9231 | 214 | |
RobMeades | 0:0b75e22c9231 | 215 | /********************************************************************** |
RobMeades | 0:0b75e22c9231 | 216 | * PUBLIC: FTP |
RobMeades | 0:0b75e22c9231 | 217 | **********************************************************************/ |
RobMeades | 0:0b75e22c9231 | 218 | |
RobMeades | 0:0b75e22c9231 | 219 | /** FTP configuration parameters (reference to FTP control +UFTP). |
RobMeades | 0:0b75e22c9231 | 220 | */ |
RobMeades | 0:0b75e22c9231 | 221 | typedef enum { |
RobMeades | 0:0b75e22c9231 | 222 | FTP_IP_ADDRESS = 0, |
RobMeades | 0:0b75e22c9231 | 223 | FTP_SERVER_NAME = 1, |
RobMeades | 0:0b75e22c9231 | 224 | FTP_USER_NAME = 2, |
RobMeades | 0:0b75e22c9231 | 225 | FTP_PASSWORD = 3, |
RobMeades | 0:0b75e22c9231 | 226 | FTP_ACCOUNT = 4, |
RobMeades | 0:0b75e22c9231 | 227 | FTP_INACTIVITY_TIMEOUT = 5, |
RobMeades | 0:0b75e22c9231 | 228 | FTP_MODE = 6, |
RobMeades | 0:0b75e22c9231 | 229 | FTP_SERVER_PORT = 7, |
RobMeades | 0:0b75e22c9231 | 230 | FTP_SECURE = 8, |
RobMeades | 0:0b75e22c9231 | 231 | NUM_FTP_OP_CODES |
RobMeades | 0:0b75e22c9231 | 232 | } FtpOpCode; |
RobMeades | 0:0b75e22c9231 | 233 | |
RobMeades | 0:0b75e22c9231 | 234 | /** Type of FTP Command. |
RobMeades | 0:0b75e22c9231 | 235 | */ |
RobMeades | 0:0b75e22c9231 | 236 | typedef enum { |
RobMeades | 0:0b75e22c9231 | 237 | FTP_LOGOUT = 0, |
RobMeades | 0:0b75e22c9231 | 238 | FTP_LOGIN = 1, |
RobMeades | 0:0b75e22c9231 | 239 | FTP_DELETE_FILE = 2, |
RobMeades | 0:0b75e22c9231 | 240 | FTP_RENAME_FILE = 3, |
RobMeades | 0:0b75e22c9231 | 241 | FTP_GET_FILE = 4, |
RobMeades | 0:0b75e22c9231 | 242 | FTP_PUT_FILE = 5, |
RobMeades | 0:0b75e22c9231 | 243 | FTP_GET_DIRECT = 6, |
RobMeades | 0:0b75e22c9231 | 244 | FTP_PUT_DIRECT = 7, |
RobMeades | 0:0b75e22c9231 | 245 | FTP_CD = 8, |
RobMeades | 0:0b75e22c9231 | 246 | FTP_MKDIR = 10, |
RobMeades | 0:0b75e22c9231 | 247 | FTP_RMDIR = 11, |
RobMeades | 0:0b75e22c9231 | 248 | FTP_FILE_INFO = 13, |
RobMeades | 0:0b75e22c9231 | 249 | FTP_LS = 14, |
RobMeades | 0:0b75e22c9231 | 250 | FTP_FOTA_FILE = 100 |
RobMeades | 0:0b75e22c9231 | 251 | } FtpCmd; |
RobMeades | 0:0b75e22c9231 | 252 | |
RobMeades | 0:0b75e22c9231 | 253 | /** Set the timeout for FTP operations. |
RobMeades | 0:0b75e22c9231 | 254 | * |
RobMeades | 0:0b75e22c9231 | 255 | * @param timeout -1 blocking, else non-blocking timeout in milliseconds. |
RobMeades | 0:0b75e22c9231 | 256 | * @return true if successful, otherwise false. |
RobMeades | 0:0b75e22c9231 | 257 | */ |
RobMeades | 0:0b75e22c9231 | 258 | bool ftpSetTimeout(int timeout); |
RobMeades | 0:0b75e22c9231 | 259 | |
RobMeades | 0:0b75e22c9231 | 260 | /** Reset the FTP configuration back to defaults. |
RobMeades | 0:0b75e22c9231 | 261 | */ |
rob.meades@u-blox.com | 11:3631f62bb359 | 262 | void ftpResetPar(); |
RobMeades | 0:0b75e22c9231 | 263 | |
RobMeades | 0:0b75e22c9231 | 264 | /** Set FTP parameters. |
RobMeades | 0:0b75e22c9231 | 265 | * |
RobMeades | 0:0b75e22c9231 | 266 | * This should be called as many times as is necessary |
RobMeades | 0:0b75e22c9231 | 267 | * to set all the possible parameters (FtpOpCode). |
RobMeades | 0:0b75e22c9231 | 268 | * |
RobMeades | 0:0b75e22c9231 | 269 | * See section 27.1 of u-blox-ATCommands_Manual(UBX-13002752).pdf |
RobMeades | 0:0b75e22c9231 | 270 | * for full details. By example: |
RobMeades | 0:0b75e22c9231 | 271 | * |
RobMeades | 0:0b75e22c9231 | 272 | * ftpOpCode ftpInPar |
RobMeades | 0:0b75e22c9231 | 273 | * FTP_IP_ADDRESS "145.33.18.10" (the target FTP server IP address) |
RobMeades | 0:0b75e22c9231 | 274 | * FTP_SERVER_NAME "www.ftpserver.com" (the target FTP server name) |
RobMeades | 0:0b75e22c9231 | 275 | * FTP_USER_NAME "my_username" |
RobMeades | 0:0b75e22c9231 | 276 | * FTP_PASSWORD "my_password" |
RobMeades | 0:0b75e22c9231 | 277 | * FTP_ACCOUNT "my_account" (not required by most FTP servers) |
RobMeades | 0:0b75e22c9231 | 278 | * FTP_INACTIVITY_TIMEOUT "60" (the default is 0, which means no timeout) |
RobMeades | 0:0b75e22c9231 | 279 | * FTP_MODE "0" for active, "1" for passive (the default is 0) |
RobMeades | 0:0b75e22c9231 | 280 | * FTP_SERVER_PORT "25" (default is port 21) |
RobMeades | 0:0b75e22c9231 | 281 | * FTP_SECURE "0" for no security, "1" for SFTP (the default is 0) |
RobMeades | 0:0b75e22c9231 | 282 | * |
RobMeades | 0:0b75e22c9231 | 283 | * @param ftpOpCode the FTP operation code. |
RobMeades | 0:0b75e22c9231 | 284 | * @param ftpInPar the FTP input parameter. |
RobMeades | 0:0b75e22c9231 | 285 | * @return true if successful, false otherwise. |
RobMeades | 0:0b75e22c9231 | 286 | */ |
RobMeades | 0:0b75e22c9231 | 287 | bool ftpSetPar(FtpOpCode ftpOpCode, const char * ftpInPar); |
RobMeades | 0:0b75e22c9231 | 288 | |
RobMeades | 0:0b75e22c9231 | 289 | /** Perform an FTP command. |
RobMeades | 0:0b75e22c9231 | 290 | * |
RobMeades | 0:0b75e22c9231 | 291 | * Connect() must have been called previously to establish a data |
RobMeades | 0:0b75e22c9231 | 292 | * connection. |
RobMeades | 0:0b75e22c9231 | 293 | * |
RobMeades | 0:0b75e22c9231 | 294 | * See section 27.2 of u-blox-ATCommands_Manual(UBX-13002752).pdf |
RobMeades | 0:0b75e22c9231 | 295 | * for full details. By example, it works like this: |
RobMeades | 0:0b75e22c9231 | 296 | * |
rob.meades@u-blox.com | 11:3631f62bb359 | 297 | * ftpCmd file1 file2 buf len offset |
rob.meades@u-blox.com | 11:3631f62bb359 | 298 | * FTP_LOGOUT N/A N/A N/A N/A N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 299 | * FTP_LOGIN N/A N/A N/A N/A N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 300 | * FTP_DELETE_FILE "the_file" N/A N/A N/A N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 301 | * FTP_RENAME_FILE "old_name" "new_name" N/A N/A N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 302 | * FTP_GET_FILE "the_file" Note 1 N/A N/A 0 - 1 (Notes 2 & 3) |
rob.meades@u-blox.com | 11:3631f62bb359 | 303 | * FTP_PUT_FILE "the_file" Note 1 N/A N/A 0 - 65535 (Notes 2 & 4 & 5) |
rob.meades@u-blox.com | 11:3631f62bb359 | 304 | * FTP_CD "dir1\dir2" N/A N/A N/A N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 305 | * FTP_MKDIR "newdir" N/A N/A N/A N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 306 | * FTP_RMDIR "dir" N/A N/A N/A N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 307 | * FTP_FILE_INFO "the_path" N/A Note 6 N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 308 | * FTP_LS "the_path" N/A Note 6 N/A |
rob.meades@u-blox.com | 11:3631f62bb359 | 309 | * FTP_FOTA_FILE "the_file" N/A Note 7 N/A |
RobMeades | 0:0b75e22c9231 | 310 | * |
RobMeades | 0:0b75e22c9231 | 311 | * Note 1: for this case, file2 is the name that the file should be |
RobMeades | 0:0b75e22c9231 | 312 | * given when it arrives (in the modem file system for a GET, at the FTP |
RobMeades | 0:0b75e22c9231 | 313 | * server for a PUT); if set to NULL then file1 is used. |
RobMeades | 0:0b75e22c9231 | 314 | * Note 2: the file will placed into the modem file system for the |
RobMeades | 0:0b75e22c9231 | 315 | * GET case (and can be read with readFile()), or must already be in the |
RobMeades | 0:0b75e22c9231 | 316 | * modem file system, (can be written using writeFile()) for the PUT case. |
rob.meades@u-blox.com | 11:3631f62bb359 | 317 | * Note 3: if offset is 1 then, where supported, the FTP GET |
rob.meades@u-blox.com | 11:3631f62bb359 | 318 | * will be continued from the point it previously stopped. |
rob.meades@u-blox.com | 11:3631f62bb359 | 319 | * Note 4: if the file already exists in the modem file system some |
rob.meades@u-blox.com | 11:3631f62bb359 | 320 | * modems will return an error. It is up to the caller to ensure that |
rob.meades@u-blox.com | 11:3631f62bb359 | 321 | * the file does not exist before the FTP PUT operation. |
rob.meades@u-blox.com | 11:3631f62bb359 | 322 | * Note 5: where supported, offset is the position in the file to continue |
rob.meades@u-blox.com | 11:3631f62bb359 | 323 | * the FTP PUT from. |
rob.meades@u-blox.com | 11:3631f62bb359 | 324 | * Note 6: buf should point to the location where the file info |
RobMeades | 0:0b75e22c9231 | 325 | * or directory listing is to be stored and len should be the maximum |
RobMeades | 0:0b75e22c9231 | 326 | * length that can be stored. |
rob.meades@u-blox.com | 11:3631f62bb359 | 327 | * Note 7: a hex string representing the MD5 sum of the FOTA file will be |
RobMeades | 0:0b75e22c9231 | 328 | * stored at buf; len must be at least 32 as an MD5 sum is 16 bytes. |
RobMeades | 0:0b75e22c9231 | 329 | * FTP_FOTA_FILE is not supported on SARA-U2. |
rob.meades@u-blox.com | 11:3631f62bb359 | 330 | * Note 8: FTP_GET_DIRECT and FTP_PUT_DIRECT are not supported by |
RobMeades | 0:0b75e22c9231 | 331 | * this driver. |
RobMeades | 0:0b75e22c9231 | 332 | * |
RobMeades | 0:0b75e22c9231 | 333 | * @param ftpCmd the FTP command. |
RobMeades | 0:0b75e22c9231 | 334 | * @param file1 the first file name if required (NULL otherwise). |
RobMeades | 0:0b75e22c9231 | 335 | * @param file2 the second file name if required (NULL otherwise). |
RobMeades | 0:0b75e22c9231 | 336 | * @param buf pointer to a buffer, required for FTP_DIRECT mode |
RobMeades | 0:0b75e22c9231 | 337 | * and FTP_LS only. |
RobMeades | 0:0b75e22c9231 | 338 | * @param len the size of buf. |
rob.meades@u-blox.com | 11:3631f62bb359 | 339 | * @param continue if true then attempt to continue a download that |
rob.meades@u-blox.com | 11:3631f62bb359 | 340 | * was previously interrupted. |
RobMeades | 0:0b75e22c9231 | 341 | * @return NULL if successful, otherwise a pointer to |
RobMeades | 0:0b75e22c9231 | 342 | * a Error struct containing the error class and error |
RobMeades | 0:0b75e22c9231 | 343 | * code, see section Appendix A.B of |
RobMeades | 0:0b75e22c9231 | 344 | * u-blox-ATCommands_Manual(UBX-13002752).pdf for details. |
RobMeades | 0:0b75e22c9231 | 345 | */ |
RobMeades | 0:0b75e22c9231 | 346 | Error *ftpCommand(FtpCmd ftpCmd, const char* file1 = NULL, const char* file2 = NULL, |
rob.meades@u-blox.com | 11:3631f62bb359 | 347 | char* buf = NULL, int len = 0, int offset = 0); |
RobMeades | 0:0b75e22c9231 | 348 | |
RobMeades | 0:0b75e22c9231 | 349 | /********************************************************************** |
RobMeades | 0:0b75e22c9231 | 350 | * PUBLIC: Cell Locate |
RobMeades | 0:0b75e22c9231 | 351 | **********************************************************************/ |
RobMeades | 0:0b75e22c9231 | 352 | |
RobMeades | 0:0b75e22c9231 | 353 | /** Which form of Cell Locate sensing to use. |
RobMeades | 0:0b75e22c9231 | 354 | */ |
RobMeades | 0:0b75e22c9231 | 355 | typedef enum { |
RobMeades | 0:0b75e22c9231 | 356 | CELL_LAST, |
RobMeades | 0:0b75e22c9231 | 357 | CELL_GNSS, |
RobMeades | 0:0b75e22c9231 | 358 | CELL_LOCATE, |
RobMeades | 0:0b75e22c9231 | 359 | CELL_HYBRID |
RobMeades | 0:0b75e22c9231 | 360 | } CellSensType; |
RobMeades | 0:0b75e22c9231 | 361 | |
RobMeades | 0:0b75e22c9231 | 362 | /** Types of Cell Locate response. |
RobMeades | 0:0b75e22c9231 | 363 | */ |
RobMeades | 0:0b75e22c9231 | 364 | typedef enum { |
RobMeades | 0:0b75e22c9231 | 365 | CELL_DETAILED = 1, |
RobMeades | 0:0b75e22c9231 | 366 | CELL_MULTIHYP = 2 |
RobMeades | 0:0b75e22c9231 | 367 | } CellRespType; |
RobMeades | 0:0b75e22c9231 | 368 | |
RobMeades | 0:0b75e22c9231 | 369 | /** Cell Locate data. |
RobMeades | 0:0b75e22c9231 | 370 | */ |
RobMeades | 0:0b75e22c9231 | 371 | typedef struct { |
RobMeades | 0:0b75e22c9231 | 372 | volatile bool validData; //!< Flag for indicating if data is valid. |
RobMeades | 0:0b75e22c9231 | 373 | volatile struct tm time; //!< GPS Timestamp. |
RobMeades | 0:0b75e22c9231 | 374 | volatile float longitude; //!< Estimated longitude, in degrees. |
RobMeades | 0:0b75e22c9231 | 375 | volatile float latitude; //!< Estimated latitude, in degrees. |
RobMeades | 0:0b75e22c9231 | 376 | volatile int altitude; //!< Estimated altitude, in meters^2. |
RobMeades | 0:0b75e22c9231 | 377 | volatile int uncertainty; //!< Maximum possible error, in meters. |
RobMeades | 0:0b75e22c9231 | 378 | volatile int speed; //!< Speed over ground m/s^2. |
RobMeades | 0:0b75e22c9231 | 379 | volatile int direction; //!< Course over ground in degrees. |
RobMeades | 0:0b75e22c9231 | 380 | volatile int verticalAcc; //!< Vertical accuracy, in meters^2. |
RobMeades | 0:0b75e22c9231 | 381 | volatile CellSensType sensor; //!< Sensor used for last calculation. |
RobMeades | 0:0b75e22c9231 | 382 | volatile int svUsed; //!< number of satellite used. |
RobMeades | 0:0b75e22c9231 | 383 | } CellLocData; |
RobMeades | 0:0b75e22c9231 | 384 | |
RobMeades | 0:0b75e22c9231 | 385 | /** Configure the Cell Locate TCP aiding server. |
RobMeades | 0:0b75e22c9231 | 386 | * |
RobMeades | 0:0b75e22c9231 | 387 | * Connect() must have been called previously to establish |
RobMeades | 0:0b75e22c9231 | 388 | * a data connection. |
RobMeades | 0:0b75e22c9231 | 389 | * |
RobMeades | 0:0b75e22c9231 | 390 | * @param server_1 host name of the primary MGA server. |
RobMeades | 0:0b75e22c9231 | 391 | * @param server_2 host name of the secondary MGA server. |
RobMeades | 0:0b75e22c9231 | 392 | * @param token authentication token for MGA server access. |
RobMeades | 0:0b75e22c9231 | 393 | * @param days the number of days into the future the off-line |
RobMeades | 0:0b75e22c9231 | 394 | * data for the u-blox 7. |
RobMeades | 0:0b75e22c9231 | 395 | * @param period the number of weeks into the future the off-line |
RobMeades | 0:0b75e22c9231 | 396 | * data for u-blox M8. |
RobMeades | 0:0b75e22c9231 | 397 | * @param resolution resolution of off-line data for u-blox M8: 1 every |
RobMeades | 0:0b75e22c9231 | 398 | * day, 0 every other day. |
RobMeades | 0:0b75e22c9231 | 399 | * @return true if the request is successful, otherwise false. |
RobMeades | 0:0b75e22c9231 | 400 | */ |
RobMeades | 0:0b75e22c9231 | 401 | bool cellLocSrvTcp(const char* token, const char* server_1 = "cell-live1.services.u-blox.com", |
RobMeades | 0:0b75e22c9231 | 402 | const char* server_2 = "cell-live2.services.u-blox.com", |
RobMeades | 0:0b75e22c9231 | 403 | int days = 14, int period = 4, int resolution = 1); |
RobMeades | 0:0b75e22c9231 | 404 | |
RobMeades | 0:0b75e22c9231 | 405 | /** Configure Cell Locate UDP aiding server. |
RobMeades | 0:0b75e22c9231 | 406 | * |
RobMeades | 0:0b75e22c9231 | 407 | * Connect() must have been called previously to establish |
RobMeades | 0:0b75e22c9231 | 408 | * a data connection. |
RobMeades | 0:0b75e22c9231 | 409 | * |
RobMeades | 0:0b75e22c9231 | 410 | * @param server_1 host name of the primary MGA server. |
RobMeades | 0:0b75e22c9231 | 411 | * @param port server port. |
RobMeades | 0:0b75e22c9231 | 412 | * @param latency expected network latency in seconds from 0 to 10000 milliseconds. |
RobMeades | 0:0b75e22c9231 | 413 | * @param mode Assist Now management, mode of operation: |
RobMeades | 0:0b75e22c9231 | 414 | * 0 data downloaded at GNSS power up, |
RobMeades | 0:0b75e22c9231 | 415 | * 1 automatically kept alive, manual download. |
RobMeades | 0:0b75e22c9231 | 416 | * @return true if the request is successful, otherwise false. |
RobMeades | 0:0b75e22c9231 | 417 | */ |
RobMeades | 0:0b75e22c9231 | 418 | bool cellLocSrvUdp(const char* server_1 = "cell-live1.services.u-blox.com", |
RobMeades | 0:0b75e22c9231 | 419 | int port = 46434, int latency = 1000, int mode = 0); |
RobMeades | 0:0b75e22c9231 | 420 | |
RobMeades | 0:0b75e22c9231 | 421 | /** Configure Cell Locate location sensor. |
RobMeades | 0:0b75e22c9231 | 422 | * |
RobMeades | 0:0b75e22c9231 | 423 | * @param scanMode network scan mode: 0 normal, 1 deep scan. |
RobMeades | 0:0b75e22c9231 | 424 | * @return true if the request is successful, otherwise false. |
RobMeades | 0:0b75e22c9231 | 425 | */ |
RobMeades | 0:0b75e22c9231 | 426 | bool cellLocConfig(int scanMode); |
RobMeades | 0:0b75e22c9231 | 427 | |
RobMeades | 0:0b75e22c9231 | 428 | /** Request a one-shot Cell Locate. |
RobMeades | 0:0b75e22c9231 | 429 | * |
RobMeades | 0:0b75e22c9231 | 430 | * This function is non-blocking, the result is retrieved using cellLocGetxxx. |
RobMeades | 0:0b75e22c9231 | 431 | * |
rob.meades@u-blox.com | 1:26a67ab07275 | 432 | * Note: none of the CellLocate methods switch on the GNSS receiver chip. |
rob.meades@u-blox.com | 1:26a67ab07275 | 433 | * That should be done by instantiating the GnssSerial or GnssI2C classes and |
rob.meades@u-blox.com | 1:26a67ab07275 | 434 | * calling the init() method. |
rob.meades@u-blox.com | 1:26a67ab07275 | 435 | * |
RobMeades | 0:0b75e22c9231 | 436 | * Note: during the location process, unsolicited result codes will be returned |
RobMeades | 0:0b75e22c9231 | 437 | * by the modem indicating progress and potentially flagging interesting errors. |
RobMeades | 0:0b75e22c9231 | 438 | * In order to see these errors, instantiate this class with debugOn set to true. |
RobMeades | 0:0b75e22c9231 | 439 | * |
RobMeades | 0:0b75e22c9231 | 440 | * @param sensor sensor selection. |
RobMeades | 0:0b75e22c9231 | 441 | * @param timeout timeout period in seconds (1 - 999). |
RobMeades | 0:0b75e22c9231 | 442 | * @param accuracy target accuracy in meters (1 - 999999). |
RobMeades | 0:0b75e22c9231 | 443 | * @param type detailed or multi-hypothesis. |
RobMeades | 0:0b75e22c9231 | 444 | * @param hypothesis maximum desired number of responses from CellLocate (up to 16), |
RobMeades | 0:0b75e22c9231 | 445 | * must be 1 if type is CELL_DETAILED. |
RobMeades | 0:0b75e22c9231 | 446 | * @return true if the request is successful, otherwise false. |
RobMeades | 0:0b75e22c9231 | 447 | */ |
RobMeades | 0:0b75e22c9231 | 448 | bool cellLocRequest(CellSensType sensor, int timeout, int accuracy, |
RobMeades | 0:0b75e22c9231 | 449 | CellRespType type = CELL_DETAILED, int hypothesis = 1); |
RobMeades | 0:0b75e22c9231 | 450 | |
RobMeades | 0:0b75e22c9231 | 451 | /** Get a position record. |
RobMeades | 0:0b75e22c9231 | 452 | * |
RobMeades | 0:0b75e22c9231 | 453 | * @param data pointer to a CellLocData structure where the location will be put. |
RobMeades | 0:0b75e22c9231 | 454 | * @param index of the position to retrieve. |
RobMeades | 0:0b75e22c9231 | 455 | * @return true if data has been retrieved and copied, false otherwise. |
RobMeades | 0:0b75e22c9231 | 456 | */ |
RobMeades | 0:0b75e22c9231 | 457 | bool cellLocGetData(CellLocData *data, int index = 0); |
RobMeades | 0:0b75e22c9231 | 458 | |
RobMeades | 0:0b75e22c9231 | 459 | /** Get the number of position records received. |
RobMeades | 0:0b75e22c9231 | 460 | * |
RobMeades | 0:0b75e22c9231 | 461 | * @return number of position records received. |
RobMeades | 0:0b75e22c9231 | 462 | */ |
RobMeades | 0:0b75e22c9231 | 463 | int cellLocGetRes(); |
RobMeades | 0:0b75e22c9231 | 464 | |
RobMeades | 0:0b75e22c9231 | 465 | /** Get the number of position records expected to be received. |
RobMeades | 0:0b75e22c9231 | 466 | * |
RobMeades | 0:0b75e22c9231 | 467 | * @return number of position records expected to be received. |
RobMeades | 0:0b75e22c9231 | 468 | */ |
RobMeades | 0:0b75e22c9231 | 469 | int cellLocGetExpRes(); |
RobMeades | 0:0b75e22c9231 | 470 | |
RobMeades | 0:0b75e22c9231 | 471 | protected: |
RobMeades | 0:0b75e22c9231 | 472 | |
RobMeades | 0:0b75e22c9231 | 473 | /********************************************************************** |
RobMeades | 0:0b75e22c9231 | 474 | * PROTECTED: HTTP |
RobMeades | 0:0b75e22c9231 | 475 | **********************************************************************/ |
RobMeades | 0:0b75e22c9231 | 476 | |
RobMeades | 0:0b75e22c9231 | 477 | /** Check for timeout. |
RobMeades | 0:0b75e22c9231 | 478 | */ |
RobMeades | 0:0b75e22c9231 | 479 | #define TIMEOUT(t, ms) ((ms != TIMEOUT_BLOCKING) && (ms < t.read_ms())) |
RobMeades | 0:0b75e22c9231 | 480 | |
RobMeades | 0:0b75e22c9231 | 481 | /** Check for a valid profile. |
RobMeades | 0:0b75e22c9231 | 482 | */ |
RobMeades | 0:0b75e22c9231 | 483 | #define IS_PROFILE(p) (((p) >= 0) && (((unsigned int) p) < (sizeof(_httpProfiles)/sizeof(_httpProfiles[0]))) \ |
RobMeades | 0:0b75e22c9231 | 484 | && (_httpProfiles[p].modemHandle != HTTP_PROF_UNUSED)) |
RobMeades | 0:0b75e22c9231 | 485 | |
RobMeades | 0:0b75e22c9231 | 486 | /** Management structure for HTTP profiles. |
RobMeades | 0:0b75e22c9231 | 487 | * |
RobMeades | 0:0b75e22c9231 | 488 | * It is possible to have up to 4 different HTTP profiles (LISA-C200, LISA-U200 and SARA-G350) having: |
RobMeades | 0:0b75e22c9231 | 489 | * |
RobMeades | 0:0b75e22c9231 | 490 | * @param handle the current HTTP profile is in handling state or not (default value is HTTP_ERROR). |
RobMeades | 0:0b75e22c9231 | 491 | * @param timeout the timeout for the current HTTP command. |
RobMeades | 0:0b75e22c9231 | 492 | * @param pending the status for the current HTTP command (in processing state or not). |
RobMeades | 0:0b75e22c9231 | 493 | * @param cmd the code for the current HTTP command. |
RobMeades | 0:0b75e22c9231 | 494 | * @param result the result for the current HTTP command once processed. |
RobMeades | 0:0b75e22c9231 | 495 | */ |
RobMeades | 0:0b75e22c9231 | 496 | typedef struct { |
RobMeades | 0:0b75e22c9231 | 497 | int modemHandle; |
RobMeades | 0:0b75e22c9231 | 498 | int timeout; |
RobMeades | 0:0b75e22c9231 | 499 | volatile bool pending; |
RobMeades | 0:0b75e22c9231 | 500 | volatile int cmd; |
RobMeades | 0:0b75e22c9231 | 501 | volatile int result; |
RobMeades | 0:0b75e22c9231 | 502 | Error httpError; |
RobMeades | 0:0b75e22c9231 | 503 | } HttpProfCtrl; |
RobMeades | 0:0b75e22c9231 | 504 | |
RobMeades | 0:0b75e22c9231 | 505 | /** The HTTP profile storage. |
RobMeades | 0:0b75e22c9231 | 506 | */ |
RobMeades | 0:0b75e22c9231 | 507 | HttpProfCtrl _httpProfiles[4]; |
RobMeades | 0:0b75e22c9231 | 508 | |
RobMeades | 0:0b75e22c9231 | 509 | /** Callback to capture the response to an HTTP command. |
RobMeades | 0:0b75e22c9231 | 510 | */ |
RobMeades | 0:0b75e22c9231 | 511 | void UUHTTPCR_URC(); |
RobMeades | 0:0b75e22c9231 | 512 | |
RobMeades | 0:0b75e22c9231 | 513 | /** Find a profile with a given handle. If no handle is given, find the next |
RobMeades | 0:0b75e22c9231 | 514 | * free profile. |
RobMeades | 0:0b75e22c9231 | 515 | * |
RobMeades | 0:0b75e22c9231 | 516 | * @param modemHandle the handle of the profile to find. |
RobMeades | 0:0b75e22c9231 | 517 | * @return the profile handle or negative if not found/created. |
RobMeades | 0:0b75e22c9231 | 518 | */ |
RobMeades | 0:0b75e22c9231 | 519 | int findProfile(int modemHandle = HTTP_PROF_UNUSED); |
RobMeades | 0:0b75e22c9231 | 520 | |
RobMeades | 0:0b75e22c9231 | 521 | /** Helper function to get a HTTP command as a text string, useful |
RobMeades | 0:0b75e22c9231 | 522 | * for debug purposes. |
RobMeades | 0:0b75e22c9231 | 523 | * |
RobMeades | 0:0b75e22c9231 | 524 | * @param httpCmdCode the HTTP command. |
RobMeades | 0:0b75e22c9231 | 525 | * @return HTTP command in string format. |
RobMeades | 0:0b75e22c9231 | 526 | */ |
RobMeades | 0:0b75e22c9231 | 527 | const char* getHttpCmd(HttpCmd httpCmd); |
RobMeades | 0:0b75e22c9231 | 528 | |
RobMeades | 0:0b75e22c9231 | 529 | /********************************************************************** |
RobMeades | 0:0b75e22c9231 | 530 | * PROTECTED: FTP |
RobMeades | 0:0b75e22c9231 | 531 | **********************************************************************/ |
RobMeades | 0:0b75e22c9231 | 532 | |
RobMeades | 0:0b75e22c9231 | 533 | /** Unused FTP op code marker. |
RobMeades | 0:0b75e22c9231 | 534 | */ |
RobMeades | 0:0b75e22c9231 | 535 | #define FTP_OP_CODE_UNUSED -1 |
RobMeades | 0:0b75e22c9231 | 536 | |
RobMeades | 0:0b75e22c9231 | 537 | /** The FTP timeout in milliseconds. |
RobMeades | 0:0b75e22c9231 | 538 | */ |
RobMeades | 0:0b75e22c9231 | 539 | int _ftpTimeout; |
RobMeades | 0:0b75e22c9231 | 540 | |
RobMeades | 0:0b75e22c9231 | 541 | /** A place to store the FTP op code for the last result. |
RobMeades | 0:0b75e22c9231 | 542 | */ |
RobMeades | 0:0b75e22c9231 | 543 | volatile int _lastFtpOpCodeResult; |
RobMeades | 0:0b75e22c9231 | 544 | |
RobMeades | 0:0b75e22c9231 | 545 | /** A place to store the last FTP result. |
RobMeades | 0:0b75e22c9231 | 546 | */ |
RobMeades | 0:0b75e22c9231 | 547 | volatile int _lastFtpResult; |
RobMeades | 0:0b75e22c9231 | 548 | |
RobMeades | 0:0b75e22c9231 | 549 | /** A place to store the last FTP op code for data response. |
RobMeades | 0:0b75e22c9231 | 550 | */ |
RobMeades | 0:0b75e22c9231 | 551 | volatile int _lastFtpOpCodeData; |
RobMeades | 0:0b75e22c9231 | 552 | |
RobMeades | 0:0b75e22c9231 | 553 | /** A place to store data returns from an FTP operation. |
RobMeades | 0:0b75e22c9231 | 554 | */ |
RobMeades | 0:0b75e22c9231 | 555 | char * _ftpBuf; |
RobMeades | 0:0b75e22c9231 | 556 | |
RobMeades | 0:0b75e22c9231 | 557 | /** The length of FTP data that can be stored (at _ftpBuf). |
RobMeades | 0:0b75e22c9231 | 558 | */ |
RobMeades | 0:0b75e22c9231 | 559 | int _ftpBufLen; |
RobMeades | 0:0b75e22c9231 | 560 | |
RobMeades | 0:0b75e22c9231 | 561 | /** storage for the last FTP error |
RobMeades | 0:0b75e22c9231 | 562 | */ |
RobMeades | 0:0b75e22c9231 | 563 | Error _ftpError; |
RobMeades | 0:0b75e22c9231 | 564 | |
RobMeades | 0:0b75e22c9231 | 565 | /** Callback to capture the result of an FTP command. |
RobMeades | 0:0b75e22c9231 | 566 | */ |
RobMeades | 0:0b75e22c9231 | 567 | void UUFTPCR_URC(); |
RobMeades | 0:0b75e22c9231 | 568 | |
RobMeades | 0:0b75e22c9231 | 569 | /** Callback to capture data returned from an FTP command. |
RobMeades | 0:0b75e22c9231 | 570 | */ |
RobMeades | 0:0b75e22c9231 | 571 | void UUFTPCD_URC(); |
RobMeades | 0:0b75e22c9231 | 572 | |
RobMeades | 0:0b75e22c9231 | 573 | /** Helper function to get an FTP command as a text string, useful |
RobMeades | 0:0b75e22c9231 | 574 | * for debug purposes. |
RobMeades | 0:0b75e22c9231 | 575 | * |
RobMeades | 0:0b75e22c9231 | 576 | * @param ftpCmdCode the FTP command. |
RobMeades | 0:0b75e22c9231 | 577 | * @return FTP command in string format. |
RobMeades | 0:0b75e22c9231 | 578 | */ |
RobMeades | 0:0b75e22c9231 | 579 | const char * getFtpCmd(FtpCmd ftpCmd); |
RobMeades | 0:0b75e22c9231 | 580 | |
RobMeades | 0:0b75e22c9231 | 581 | /********************************************************************** |
RobMeades | 0:0b75e22c9231 | 582 | * PROTECTED: Cell Locate |
RobMeades | 0:0b75e22c9231 | 583 | **********************************************************************/ |
RobMeades | 0:0b75e22c9231 | 584 | |
RobMeades | 0:0b75e22c9231 | 585 | /** The maximum number of hypotheses |
RobMeades | 0:0b75e22c9231 | 586 | */ |
RobMeades | 0:0b75e22c9231 | 587 | #define CELL_MAX_HYP (16 + 1) |
RobMeades | 0:0b75e22c9231 | 588 | |
RobMeades | 0:0b75e22c9231 | 589 | /** Received positions. |
RobMeades | 0:0b75e22c9231 | 590 | */ |
RobMeades | 0:0b75e22c9231 | 591 | volatile int _locRcvPos; |
RobMeades | 0:0b75e22c9231 | 592 | |
RobMeades | 0:0b75e22c9231 | 593 | /** Expected positions. |
RobMeades | 0:0b75e22c9231 | 594 | */ |
RobMeades | 0:0b75e22c9231 | 595 | volatile int _locExpPos; |
RobMeades | 0:0b75e22c9231 | 596 | |
RobMeades | 0:0b75e22c9231 | 597 | /** The Cell Locate data. |
RobMeades | 0:0b75e22c9231 | 598 | */ |
RobMeades | 0:0b75e22c9231 | 599 | CellLocData _loc[CELL_MAX_HYP]; |
RobMeades | 0:0b75e22c9231 | 600 | |
RobMeades | 0:0b75e22c9231 | 601 | /** Buffer for the URC to work with |
RobMeades | 0:0b75e22c9231 | 602 | */ |
RobMeades | 0:0b75e22c9231 | 603 | char urcBuf[128]; |
RobMeades | 0:0b75e22c9231 | 604 | |
RobMeades | 0:0b75e22c9231 | 605 | /** Callback to capture +UULOCIND. |
RobMeades | 0:0b75e22c9231 | 606 | */ |
RobMeades | 0:0b75e22c9231 | 607 | void UULOCIND_URC(); |
RobMeades | 0:0b75e22c9231 | 608 | |
RobMeades | 0:0b75e22c9231 | 609 | /** Callback to capture +UULOC. |
RobMeades | 0:0b75e22c9231 | 610 | */ |
RobMeades | 0:0b75e22c9231 | 611 | void UULOC_URC(); |
RobMeades | 0:0b75e22c9231 | 612 | }; |
RobMeades | 0:0b75e22c9231 | 613 | |
RobMeades | 0:0b75e22c9231 | 614 | #endif // _UBLOX_AT_CELLULAR_INTERFACE_EXT_ |
RobMeades | 0:0b75e22c9231 | 615 |