Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UBLOX_AT_CellularContext.h Source File

UBLOX_AT_CellularContext.h

00001 /*
00002  * Copyright (c) 2018, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef UBLOX_AT_CELLULARCONTEXT_H_
00018 #define UBLOX_AT_CELLULARCONTEXT_H_
00019 
00020 #include "AT_CellularContext.h"
00021 #include "UBLOX_AT_CellularNetwork.h"
00022 
00023 namespace mbed {
00024 
00025 class UBLOX_AT_CellularContext: public AT_CellularContext {
00026 public:
00027     UBLOX_AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, bool cp_req = false, bool nonip_req = false);
00028     virtual ~UBLOX_AT_CellularContext();
00029 
00030     virtual void do_connect();
00031     virtual const char *get_gateway();
00032     virtual nsapi_error_t get_gateway(SocketAddress *addr);
00033 
00034     const char *get_apn(void);
00035     const char *get_uname(void);
00036     const char *get_pwd(void);
00037     CellularContext::AuthenticationType get_auth(void);
00038 
00039     /** Convert nsapi_security_t to the modem security numbers.
00040      *
00041      * @param nsapi_security      Security protocol.
00042      * @return                    Modem security numbers.
00043      */
00044     int nsapi_security_to_modem_security(AuthenticationType nsapi_security);
00045 
00046     /** Get the next set of credentials from the database.
00047      */
00048     void get_next_credentials(char **config);
00049 #ifdef UBX_MDM_SARA_R412M
00050     CellularNetwork::RadioAccessTechnology read_radio_technology(void);
00051 #endif
00052 protected:
00053     virtual NetworkStack *get_stack();
00054 
00055     /** Connect the on board IP stack of the modem.
00056      *
00057      * @return      True if successful, otherwise false.
00058      */
00059 #ifndef UBX_MDM_SARA_R41XM
00060     nsapi_error_t define_context();
00061 #endif
00062 
00063 private:
00064 
00065     /** Length of IMSI buffer.
00066      */
00067     static const int MAX_IMSI_LENGTH = 15;
00068 
00069     /** The type of authentication to use.
00070      */
00071     AuthenticationType _auth;
00072 
00073     /** Activate one of the on-board modem's connection profiles.
00074      *
00075      * @param apn      The APN to use.
00076      * @param username The user name to use.
00077      * @param password The password to use.
00078      * @param auth     The authentication method to use
00079      *                 (NOAUTH, PAP,
00080      *                 CHAP or AUTOMATIC).
00081      * @return         True if successful, otherwise false.
00082      */
00083 #ifndef UBX_MDM_SARA_R41XM
00084     bool activate_profile(const char *apn, const char *username, const char *password, AuthenticationType auth);
00085 #endif
00086 
00087     /** Disconnect the on board IP stack of the modem.
00088      *
00089      * @return      True if successful, otherwise false.
00090      */
00091     bool disconnect_modem_stack();
00092 
00093     /** Read IMSI of modem.
00094      */
00095     nsapi_error_t get_imsi(char *imsi);
00096 };
00097 
00098 } /* namespace mbed */
00099 
00100 #endif // UBLOX_AT_CELLULARCONTEXT_H_