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