Daniel Vizcaya
/
04_RTOS_Embebidos
Entrega 3er corte - sistemas embebidos
mbed-os/features/netsocket/CellularBase.h@1:fcdb45ee95b9, 2018-05-30 (annotated)
- Committer:
- Bethory
- Date:
- Wed May 30 04:46:28 2018 +0000
- Revision:
- 1:fcdb45ee95b9
- Parent:
- 0:6ad07c9019fd
Entrega Final
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bethory | 0:6ad07c9019fd | 1 | /* Copyright (c) 2017 ARM Limited |
Bethory | 0:6ad07c9019fd | 2 | * |
Bethory | 0:6ad07c9019fd | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Bethory | 0:6ad07c9019fd | 4 | * you may not use this file except in compliance with the License. |
Bethory | 0:6ad07c9019fd | 5 | * You may obtain a copy of the License at |
Bethory | 0:6ad07c9019fd | 6 | * |
Bethory | 0:6ad07c9019fd | 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
Bethory | 0:6ad07c9019fd | 8 | * |
Bethory | 0:6ad07c9019fd | 9 | * Unless required by applicable law or agreed to in writing, software |
Bethory | 0:6ad07c9019fd | 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
Bethory | 0:6ad07c9019fd | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Bethory | 0:6ad07c9019fd | 12 | * See the License for the specific language governing permissions and |
Bethory | 0:6ad07c9019fd | 13 | * limitations under the License. |
Bethory | 0:6ad07c9019fd | 14 | */ |
Bethory | 0:6ad07c9019fd | 15 | |
Bethory | 0:6ad07c9019fd | 16 | #ifndef CELLULAR_BASE_H |
Bethory | 0:6ad07c9019fd | 17 | #define CELLULAR_BASE_H |
Bethory | 0:6ad07c9019fd | 18 | |
Bethory | 0:6ad07c9019fd | 19 | #include "netsocket/NetworkInterface.h" |
Bethory | 0:6ad07c9019fd | 20 | |
Bethory | 0:6ad07c9019fd | 21 | /** CellularBase class |
Bethory | 0:6ad07c9019fd | 22 | * |
Bethory | 0:6ad07c9019fd | 23 | * Common interface that is shared between Cellular interfaces |
Bethory | 0:6ad07c9019fd | 24 | */ |
Bethory | 0:6ad07c9019fd | 25 | class CellularBase: public NetworkInterface { |
Bethory | 0:6ad07c9019fd | 26 | |
Bethory | 0:6ad07c9019fd | 27 | public: |
Bethory | 0:6ad07c9019fd | 28 | |
Bethory | 0:6ad07c9019fd | 29 | /** Set the Cellular network credentials |
Bethory | 0:6ad07c9019fd | 30 | * |
Bethory | 0:6ad07c9019fd | 31 | * Please check documentation of connect() for default behaviour of APN settings. |
Bethory | 0:6ad07c9019fd | 32 | * |
Bethory | 0:6ad07c9019fd | 33 | * @param apn Access point name |
Bethory | 0:6ad07c9019fd | 34 | * @param uname optionally, Username |
Bethory | 0:6ad07c9019fd | 35 | * @param pwd optionally, password |
Bethory | 0:6ad07c9019fd | 36 | */ |
Bethory | 0:6ad07c9019fd | 37 | virtual void set_credentials(const char *apn, const char *uname = 0, |
Bethory | 0:6ad07c9019fd | 38 | const char *pwd = 0) = 0; |
Bethory | 0:6ad07c9019fd | 39 | |
Bethory | 0:6ad07c9019fd | 40 | /** Set the pin code for SIM card |
Bethory | 0:6ad07c9019fd | 41 | * |
Bethory | 0:6ad07c9019fd | 42 | * @param sim_pin PIN for the SIM card |
Bethory | 0:6ad07c9019fd | 43 | */ |
Bethory | 0:6ad07c9019fd | 44 | virtual void set_sim_pin(const char *sim_pin) = 0; |
Bethory | 0:6ad07c9019fd | 45 | |
Bethory | 0:6ad07c9019fd | 46 | /** Start the interface |
Bethory | 0:6ad07c9019fd | 47 | * |
Bethory | 0:6ad07c9019fd | 48 | * Attempts to connect to a Cellular network. |
Bethory | 0:6ad07c9019fd | 49 | * |
Bethory | 0:6ad07c9019fd | 50 | * @param sim_pin PIN for the SIM card |
Bethory | 0:6ad07c9019fd | 51 | * @param apn optionally, access point name |
Bethory | 0:6ad07c9019fd | 52 | * @param uname optionally, Username |
Bethory | 0:6ad07c9019fd | 53 | * @param pwd optionally, password |
Bethory | 0:6ad07c9019fd | 54 | * @return NSAPI_ERROR_OK on success, or negative error code on failure |
Bethory | 0:6ad07c9019fd | 55 | */ |
Bethory | 0:6ad07c9019fd | 56 | virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0, |
Bethory | 0:6ad07c9019fd | 57 | const char *uname = 0, |
Bethory | 0:6ad07c9019fd | 58 | const char *pwd = 0) = 0; |
Bethory | 0:6ad07c9019fd | 59 | |
Bethory | 0:6ad07c9019fd | 60 | /** Start the interface |
Bethory | 0:6ad07c9019fd | 61 | * |
Bethory | 0:6ad07c9019fd | 62 | * Attempts to connect to a Cellular network. |
Bethory | 0:6ad07c9019fd | 63 | * If the SIM requires a PIN, and it is not set/invalid, NSAPI_ERROR_AUTH_ERROR is returned. |
Bethory | 0:6ad07c9019fd | 64 | * |
Bethory | 0:6ad07c9019fd | 65 | * @return NSAPI_ERROR_OK on success, or negative error code on failure |
Bethory | 0:6ad07c9019fd | 66 | */ |
Bethory | 0:6ad07c9019fd | 67 | virtual nsapi_error_t connect() = 0; |
Bethory | 0:6ad07c9019fd | 68 | |
Bethory | 0:6ad07c9019fd | 69 | /** Stop the interface |
Bethory | 0:6ad07c9019fd | 70 | * |
Bethory | 0:6ad07c9019fd | 71 | * @return 0 on success, or error code on failure |
Bethory | 0:6ad07c9019fd | 72 | */ |
Bethory | 0:6ad07c9019fd | 73 | virtual nsapi_error_t disconnect() = 0; |
Bethory | 0:6ad07c9019fd | 74 | |
Bethory | 0:6ad07c9019fd | 75 | /** Check if the connection is currently established or not |
Bethory | 0:6ad07c9019fd | 76 | * |
Bethory | 0:6ad07c9019fd | 77 | * @return true/false If the cellular module have successfully acquired a carrier and is |
Bethory | 0:6ad07c9019fd | 78 | * connected to an external packet data network using PPP, isConnected() |
Bethory | 0:6ad07c9019fd | 79 | * API returns true and false otherwise. |
Bethory | 0:6ad07c9019fd | 80 | */ |
Bethory | 0:6ad07c9019fd | 81 | virtual bool is_connected() = 0; |
Bethory | 0:6ad07c9019fd | 82 | |
Bethory | 0:6ad07c9019fd | 83 | /** Get the local IP address |
Bethory | 0:6ad07c9019fd | 84 | * |
Bethory | 0:6ad07c9019fd | 85 | * @return Null-terminated representation of the local IP address |
Bethory | 0:6ad07c9019fd | 86 | * or null if no IP address has been received |
Bethory | 0:6ad07c9019fd | 87 | */ |
Bethory | 0:6ad07c9019fd | 88 | virtual const char *get_ip_address() = 0; |
Bethory | 0:6ad07c9019fd | 89 | |
Bethory | 0:6ad07c9019fd | 90 | /** Get the local network mask |
Bethory | 0:6ad07c9019fd | 91 | * |
Bethory | 0:6ad07c9019fd | 92 | * @return Null-terminated representation of the local network mask |
Bethory | 0:6ad07c9019fd | 93 | * or null if no network mask has been received |
Bethory | 0:6ad07c9019fd | 94 | */ |
Bethory | 0:6ad07c9019fd | 95 | virtual const char *get_netmask() = 0; |
Bethory | 0:6ad07c9019fd | 96 | |
Bethory | 0:6ad07c9019fd | 97 | /** Get the local gateways |
Bethory | 0:6ad07c9019fd | 98 | * |
Bethory | 0:6ad07c9019fd | 99 | * @return Null-terminated representation of the local gateway |
Bethory | 0:6ad07c9019fd | 100 | * or null if no network mask has been received |
Bethory | 0:6ad07c9019fd | 101 | */ |
Bethory | 0:6ad07c9019fd | 102 | virtual const char *get_gateway() = 0; |
Bethory | 0:6ad07c9019fd | 103 | |
Bethory | 0:6ad07c9019fd | 104 | }; |
Bethory | 0:6ad07c9019fd | 105 | |
Bethory | 0:6ad07c9019fd | 106 | #endif //CELLULAR_BASE_H |
Bethory | 0:6ad07c9019fd | 107 | |
Bethory | 0:6ad07c9019fd | 108 | /** @}*/ |