mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

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