Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

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