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