2017-02-16 00:08:57 +00:00
|
|
|
/* Copyright (c) 2017 ARM Limited
|
2016-04-19 22:51:51 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2017-02-16 00:08:57 +00:00
|
|
|
|
2016-04-19 22:51:51 +00:00
|
|
|
#ifndef CELLULAR_INTERFACE_H
|
|
|
|
#define CELLULAR_INTERFACE_H
|
2017-02-16 00:08:57 +00:00
|
|
|
|
2016-09-30 23:32:06 +00:00
|
|
|
#include "netsocket/NetworkInterface.h"
|
2016-07-19 22:12:22 +00:00
|
|
|
|
2016-04-20 19:39:13 +00:00
|
|
|
/** CellularInterface class
|
2016-04-19 22:51:51 +00:00
|
|
|
*
|
2017-02-16 00:08:57 +00:00
|
|
|
* Common interface that is shared between Cellular interfaces
|
2016-04-19 22:51:51 +00:00
|
|
|
*/
|
2017-02-16 00:08:57 +00:00
|
|
|
class CellularInterface: public NetworkInterface {
|
2017-03-13 11:34:49 +00:00
|
|
|
|
|
|
|
public:
|
2016-09-08 18:44:11 +00:00
|
|
|
/** CellularInterface lifetime
|
|
|
|
*/
|
2017-02-16 00:08:57 +00:00
|
|
|
//virtual ~CellularInterface() {};
|
2016-09-08 18:44:11 +00:00
|
|
|
|
2017-02-16 00:08:57 +00:00
|
|
|
/** Set the Cellular network credentials
|
2016-09-08 18:44:11 +00:00
|
|
|
*
|
2017-02-16 00:08:57 +00:00
|
|
|
* Please check documentation of connect() for default behaviour of APN settings.
|
|
|
|
*
|
|
|
|
* @param apn Access point name
|
|
|
|
* @param uname optionally, Username
|
|
|
|
* @param pwd optionally, password
|
2016-09-08 18:44:11 +00:00
|
|
|
*/
|
2017-02-16 00:08:57 +00:00
|
|
|
virtual void set_credentials(const char *apn,
|
2017-03-13 11:34:49 +00:00
|
|
|
const char *uname = 0,
|
|
|
|
const char *pwd = 0) = 0;
|
2017-02-16 00:08:57 +00:00
|
|
|
|
|
|
|
/** Set the pin code for SIM card
|
|
|
|
*
|
|
|
|
* @param sim_pin PIN for the SIM card
|
|
|
|
*/
|
2017-03-13 11:34:49 +00:00
|
|
|
virtual void set_sim_pin(const char *sim_pin) = 0;
|
2016-09-08 18:44:11 +00:00
|
|
|
|
2016-04-19 22:51:51 +00:00
|
|
|
/** Start the interface
|
|
|
|
*
|
2017-02-16 00:08:57 +00:00
|
|
|
* Attempts to connect to a Cellular network.
|
|
|
|
*
|
|
|
|
* @param sim_pin PIN for the SIM card
|
|
|
|
* @param apn optionally, access point name
|
|
|
|
* @param uname optionally, Username
|
|
|
|
* @param pwd optionally, password
|
|
|
|
* @return NSAPI_ERROR_OK on success, or negative error code on failure
|
2016-04-19 22:51:51 +00:00
|
|
|
*/
|
2017-02-16 00:08:57 +00:00
|
|
|
virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0,
|
|
|
|
const char *uname = 0,
|
|
|
|
const char *pwd = 0) = 0;
|
2016-09-08 18:44:11 +00:00
|
|
|
|
|
|
|
/** Start the interface
|
|
|
|
*
|
2017-02-16 00:08:57 +00:00
|
|
|
* Attempts to connect to a Cellular network.
|
|
|
|
* If the SIM requires a PIN, and it is not set/invalid, NSAPI_ERROR_AUTH_ERROR is returned.
|
2016-09-08 18:44:11 +00:00
|
|
|
*
|
2017-02-16 00:08:57 +00:00
|
|
|
* @return NSAPI_ERROR_OK on success, or negative error code on failure
|
2016-09-08 18:44:11 +00:00
|
|
|
*/
|
2016-10-18 19:48:46 +00:00
|
|
|
virtual nsapi_error_t connect() = 0;
|
2017-02-16 00:08:57 +00:00
|
|
|
|
2016-04-19 22:51:51 +00:00
|
|
|
/** Stop the interface
|
2017-02-16 00:08:57 +00:00
|
|
|
*
|
|
|
|
* @return 0 on success, or error code on failure
|
|
|
|
*/
|
2016-10-18 19:48:46 +00:00
|
|
|
virtual nsapi_error_t disconnect() = 0;
|
2017-03-13 11:34:49 +00:00
|
|
|
|
|
|
|
/** Check if the connection is currently established or not
|
|
|
|
*
|
|
|
|
* @return true/false If the cellular module have successfully acquired a carrier and is
|
|
|
|
* connected to an external packet data network using PPP, isConnected()
|
|
|
|
* API returns true and false otherwise.
|
|
|
|
*/
|
|
|
|
virtual bool is_connected() = 0;
|
|
|
|
|
|
|
|
/** Get the local IP address
|
|
|
|
*
|
|
|
|
* @return Null-terminated representation of the local IP address
|
|
|
|
* or null if no IP address has been recieved
|
|
|
|
*/
|
|
|
|
virtual const char *get_ip_address() = 0;
|
|
|
|
|
|
|
|
/** Get the local network mask
|
|
|
|
*
|
|
|
|
* @return Null-terminated representation of the local network mask
|
|
|
|
* or null if no network mask has been recieved
|
|
|
|
*/
|
|
|
|
virtual const char *get_netmask() = 0;
|
|
|
|
|
|
|
|
/** Get the local gateways
|
|
|
|
*
|
|
|
|
* @return Null-terminated representation of the local gateway
|
|
|
|
* or null if no network mask has been recieved
|
|
|
|
*/
|
|
|
|
virtual const char *get_gateway() = 0;
|
|
|
|
|
2016-04-19 22:51:51 +00:00
|
|
|
};
|
2016-07-19 22:12:22 +00:00
|
|
|
|
2016-04-19 22:51:51 +00:00
|
|
|
#endif
|
2016-10-04 20:02:44 +00:00
|
|
|
|
|
|
|
/** @}*/
|