Denislam Valeev / Mbed OS Nucleo_rtos_basic
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CellularBase.h Source File

CellularBase.h

00001 /* Copyright (c) 2017 ARM Limited
00002  *
00003  * Licensed under the Apache License, Version 2.0 (the "License");
00004  * you may not use this file except in compliance with the License.
00005  * You may obtain a copy of the License at
00006  *
00007  *     http://www.apache.org/licenses/LICENSE-2.0
00008  *
00009  * Unless required by applicable law or agreed to in writing, software
00010  * distributed under the License is distributed on an "AS IS" BASIS,
00011  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012  * See the License for the specific language governing permissions and
00013  * limitations under the License.
00014  */
00015 
00016 #ifndef CELLULAR_BASE_H
00017 #define CELLULAR_BASE_H
00018 
00019 #include "netsocket/NetworkInterface.h"
00020 
00021 /** CellularBase class
00022  *
00023  *  Common interface that is shared between Cellular interfaces
00024  */
00025 class CellularBase: public NetworkInterface {
00026 
00027 public:
00028 
00029     /** Set the Cellular network credentials
00030      *
00031      *  Please check documentation of connect() for default behaviour of APN settings.
00032      *
00033      *  @param apn      Access point name
00034      *  @param uname    optionally, Username
00035      *  @param pwd      optionally, password
00036      */
00037     virtual void set_credentials(const char *apn, const char *uname = 0,
00038                                  const char *pwd = 0) = 0;
00039 
00040     /** Set the pin code for SIM card
00041      *
00042      *  @param sim_pin      PIN for the SIM card
00043      */
00044     virtual void set_sim_pin(const char *sim_pin) = 0;
00045 
00046     /** Start the interface
00047      *
00048      *  Attempts to connect to a Cellular network.
00049      *
00050      *  @param sim_pin     PIN for the SIM card
00051      *  @param apn         optionally, access point name
00052      *  @param uname       optionally, Username
00053      *  @param pwd         optionally, password
00054      *  @return            NSAPI_ERROR_OK on success, or negative error code on failure
00055      */
00056     virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0,
00057                                   const char *uname = 0,
00058                                   const char *pwd = 0) = 0;
00059 
00060     /** Start the interface
00061      *
00062      *  Attempts to connect to a Cellular network.
00063      *  If the SIM requires a PIN, and it is not set/invalid, NSAPI_ERROR_AUTH_ERROR is returned.
00064      *
00065      *  @return            NSAPI_ERROR_OK on success, or negative error code on failure
00066      */
00067     virtual nsapi_error_t connect() = 0;
00068 
00069     /** Stop the interface
00070      *
00071      *  @return         0 on success, or error code on failure
00072      */
00073     virtual nsapi_error_t disconnect() = 0;
00074 
00075     /** Check if the connection is currently established or not
00076      *
00077      * @return true/false   If the cellular module have successfully acquired a carrier and is
00078      *                      connected to an external packet data network using PPP, isConnected()
00079      *                      API returns true and false otherwise.
00080      */
00081     virtual bool is_connected() = 0;
00082 
00083     /** Get the local IP address
00084      *
00085      *  @return         Null-terminated representation of the local IP address
00086      *                  or null if no IP address has been received
00087      */
00088     virtual const char *get_ip_address() = 0;
00089 
00090     /** Get the local network mask
00091      *
00092      *  @return         Null-terminated representation of the local network mask
00093      *                  or null if no network mask has been received
00094      */
00095     virtual const char *get_netmask() = 0;
00096 
00097     /** Get the local gateways
00098      *
00099      *  @return         Null-terminated representation of the local gateway
00100      *                  or null if no network mask has been received
00101      */
00102     virtual const char *get_gateway() = 0;
00103 
00104 };
00105 
00106 #endif //CELLULAR_BASE_H
00107 
00108 /** @}*/